001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.ade.publish.shared;
029
030import java.util.Collections;
031import java.util.List;
032
033import com.google.gwt.user.client.rpc.IsSerializable;
034
035/**
036 * A bean which represents a possible workflow, containing an identifier, a user-readable name
037 * and a list of workflow actions.<p>
038 */
039public class CmsWorkflow implements IsSerializable {
040
041    /** The list of actions which are possible in this workflow. */
042    private List<CmsWorkflowAction> m_actions;
043
044    /** An identifier for the workflow type. */
045    private String m_id;
046
047    /** A user-readable nice name for the workflow. */
048    private String m_niceName;
049
050    /**
051     * Creates a new workflow bean instance.<p>
052     *
053     * @param id the identifier for the workflow type
054     * @param niceName the nice name for the workflow which is displayed to the user
055     * @param actions the actions which are possible in this workflow
056     */
057    public CmsWorkflow(String id, String niceName, List<CmsWorkflowAction> actions) {
058
059        m_id = id;
060        m_niceName = niceName;
061        m_actions = actions;
062    }
063
064    /**
065     * Constructor. For serialization only.<p>
066     */
067    protected CmsWorkflow() {
068
069        // nothing to do
070    }
071
072    /**
073     * @see java.lang.Object#equals(java.lang.Object)
074     */
075    @Override
076    public boolean equals(Object obj) {
077
078        if (obj instanceof CmsWorkflow) {
079            return getId().equals(((CmsWorkflow)obj).getId());
080        }
081        return false;
082    }
083
084    /**
085     * Returns the list of actions which are possible in this workflow.<p>
086     *
087     * @return the actions possible in this workflow
088     */
089    public List<CmsWorkflowAction> getActions() {
090
091        return Collections.unmodifiableList(m_actions);
092    }
093
094    /**
095     * Gets the workflow identifier.<p>
096     *
097     * @return the workflow identifier
098     */
099    public String getId() {
100
101        return m_id;
102    }
103
104    /**
105     * Gets the user-readable nice name for the workflow.<p>
106     *
107     * @return the nice name for the workflow
108     */
109    public String getNiceName() {
110
111        return m_niceName;
112    }
113
114    /**
115     * @see java.lang.Object#hashCode()
116     */
117    @Override
118    public int hashCode() {
119
120        return getId().hashCode();
121    }
122
123}