001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Julien Anguenot
011 *     Florent Guillaume
012 */
013
014package org.nuxeo.ecm.core.lifecycle.extensions;
015
016import java.util.Collection;
017
018import org.apache.commons.logging.Log;
019import org.apache.commons.logging.LogFactory;
020import org.nuxeo.common.xmap.annotation.XNode;
021import org.nuxeo.common.xmap.annotation.XObject;
022import org.nuxeo.ecm.core.lifecycle.LifeCycleState;
023import org.nuxeo.ecm.core.lifecycle.LifeCycleTransition;
024import org.w3c.dom.Element;
025
026/**
027 * Descriptor for a life cycle extension.
028 *
029 * @see org.nuxeo.ecm.core.lifecycle.impl.LifeCycleServiceImpl
030 * @see org.nuxeo.ecm.core.lifecycle.LifeCycle
031 * @author Julien Anguenot
032 * @author Florent Guillaume
033 */
034@XObject(value = "lifecycle", order = { "@name" })
035public class LifeCycleDescriptor {
036
037    private static final Log log = LogFactory.getLog(LifeCycleDescriptor.class);
038
039    @XNode("@name")
040    private String name;
041
042    @XNode("@lifecyclemanager")
043    public void setLifeCycleManager(String lifeCycleManager) {
044        log.warn("Ignoring deprecated lifecyclemanager attribute '" + lifeCycleManager + "' for lifecycle '" + name
045                + "'");
046    }
047
048    @XNode("@initial")
049    private String initialStateName;
050
051    @XNode("@defaultInitial")
052    private String defaultInitialStateName;
053
054    @XNode("description")
055    private String description;
056
057    @XNode("states")
058    private Element states;
059
060    @XNode("transitions")
061    private Element transitions;
062
063    public String getDescription() {
064        return description;
065    }
066
067    public void setDescription(String description) {
068        this.description = description;
069    }
070
071    public String getName() {
072        return name;
073    }
074
075    public String getInitialStateName() {
076        return initialStateName;
077    }
078
079    public String getDefaultInitialStateName() {
080        return defaultInitialStateName;
081    }
082
083    public Collection<LifeCycleState> getStates() {
084        LifeCycleStateConfiguration conf = new LifeCycleStateConfiguration(states);
085        return conf.getStates();
086    }
087
088    public Collection<LifeCycleTransition> getTransitions() {
089        return new LifeCycleTransitionConfiguration(transitions).getTransitions();
090    }
091
092}