001/*
002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Benjamin Jalon
016 */
017
018package org.nuxeo.ecm.platform.computedgroups;
019
020import org.nuxeo.common.xmap.annotation.XNode;
021import org.nuxeo.common.xmap.annotation.XObject;
022
023/**
024 * @since 5.7.3
025 */
026@XObject("userMetadataGroupComputer")
027public class UserMetadataGroupComputerDescriptor extends GroupComputerDescriptor {
028
029    /**
030     *
031     */
032    private static final long serialVersionUID = 1L;
033
034    @XNode("@xpath")
035    public String xpath;
036
037    @XNode("@groupPattern")
038    public String groupPattern = "%s";
039
040    @XNode("@name")
041    public String name;
042
043    @XNode("@enabled")
044    public boolean enabled = true;
045
046    @Override
047    public String getName() {
048        if (name != null) {
049            return name;
050        }
051        return computerClass.getSimpleName();
052    }
053
054    @Override
055    public boolean isEnabled() {
056        return enabled;
057    }
058
059    @Override
060    public GroupComputer getComputer() {
061        return new UserMetadataGroupComputer(xpath, groupPattern);
062    }
063
064}