001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Julien Anguenot
018 *     Florent Guillaume
019 */
020
021package org.nuxeo.ecm.core.lifecycle.extensions;
022
023import java.util.Collection;
024
025import org.apache.commons.logging.Log;
026import org.apache.commons.logging.LogFactory;
027import org.nuxeo.common.xmap.annotation.XNode;
028import org.nuxeo.common.xmap.annotation.XObject;
029import org.nuxeo.ecm.core.lifecycle.LifeCycleState;
030import org.nuxeo.ecm.core.lifecycle.LifeCycleTransition;
031import org.w3c.dom.Element;
032
033/**
034 * Descriptor for a life cycle extension.
035 *
036 * @see org.nuxeo.ecm.core.lifecycle.impl.LifeCycleServiceImpl
037 * @see org.nuxeo.ecm.core.lifecycle.LifeCycle
038 * @author Julien Anguenot
039 * @author Florent Guillaume
040 */
041@XObject(value = "lifecycle", order = { "@name" })
042public class LifeCycleDescriptor {
043
044    private static final Log log = LogFactory.getLog(LifeCycleDescriptor.class);
045
046    @XNode("@name")
047    private String name;
048
049    @XNode("@lifecyclemanager")
050    public void setLifeCycleManager(String lifeCycleManager) {
051        log.warn("Ignoring deprecated lifecyclemanager attribute '" + lifeCycleManager + "' for lifecycle '" + name
052                + "'");
053    }
054
055    @XNode("@initial")
056    private String initialStateName;
057
058    @XNode("@defaultInitial")
059    private String defaultInitialStateName;
060
061    @XNode("description")
062    private String description;
063
064    @XNode("states")
065    private Element states;
066
067    @XNode("transitions")
068    private Element transitions;
069
070    public String getDescription() {
071        return description;
072    }
073
074    public void setDescription(String description) {
075        this.description = description;
076    }
077
078    public String getName() {
079        return name;
080    }
081
082    public String getInitialStateName() {
083        return initialStateName;
084    }
085
086    public String getDefaultInitialStateName() {
087        return defaultInitialStateName;
088    }
089
090    public Collection<LifeCycleState> getStates() {
091        LifeCycleStateConfiguration conf = new LifeCycleStateConfiguration(states);
092        return conf.getStates();
093    }
094
095    public Collection<LifeCycleTransition> getTransitions() {
096        return new LifeCycleTransitionConfiguration(transitions).getTransitions();
097    }
098
099}