001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 */
016package org.kuali.rice.kew.api.document;
017
018import org.kuali.rice.core.api.CoreConstants;
019import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
020import org.kuali.rice.core.api.mo.ModelObjectUtils;
021import org.w3c.dom.Element;
022
023import javax.xml.bind.annotation.XmlAccessType;
024import javax.xml.bind.annotation.XmlAccessorType;
025import javax.xml.bind.annotation.XmlAnyElement;
026import javax.xml.bind.annotation.XmlElement;
027import javax.xml.bind.annotation.XmlElementWrapper;
028import javax.xml.bind.annotation.XmlRootElement;
029import javax.xml.bind.annotation.XmlType;
030import java.util.Collection;
031import java.util.Collections;
032import java.util.Set;
033
034@XmlRootElement(name = OrchestrationConfig.Constants.ROOT_ELEMENT_NAME)
035@XmlAccessorType(XmlAccessType.NONE)
036@XmlType(name = OrchestrationConfig.Constants.TYPE_NAME, propOrder = {
037        OrchestrationConfig.Elements.ACTION_TAKEN_ID,
038        OrchestrationConfig.Elements.NODE_NAMES,
039        CoreConstants.CommonElements.FUTURE_ELEMENTS
040})
041public final class OrchestrationConfig extends AbstractDataTransferObject {
042
043    @XmlElement(name = Elements.ACTION_TAKEN_ID, required = true)
044    private final String actionTakenId;
045
046    @XmlElementWrapper(name = Elements.NODE_NAMES, required = false)
047    @XmlElement(name = Elements.NODE_NAME, required = false)
048    private final Set<String> nodeNames;
049
050    @SuppressWarnings("unused")
051    @XmlAnyElement
052    private final Collection<Element> _futureElements = null;
053
054    @SuppressWarnings("unused")
055    private OrchestrationConfig() {
056        this.actionTakenId = null;
057        this.nodeNames = null;
058    }
059
060    private OrchestrationConfig(String actionTakenId, Set<String> nodeNames) {
061        this.actionTakenId = actionTakenId;
062        this.nodeNames = ModelObjectUtils.createImmutableCopy(nodeNames);
063    }
064
065    public static OrchestrationConfig create(String actionTakenId, Set<String> nodeNames) {
066        return new OrchestrationConfig(actionTakenId, nodeNames);
067    }
068
069    /**
070     * Returns the id of the {@link org.kuali.rice.kew.api.action.ActionTaken} against which any action
071     * requests that are processed by the orchestration should be associated.  This is generally the action that was
072     * submitted which triggered the orchestration process.  Should never return a null or blank value.
073     *
074     * @return the id of the action taken to link deactivated requests with during orchestration
075     */
076    public String getActionTakenId() {
077        return actionTakenId;
078    }
079
080    /**
081     * Returns the Set of node names to which to orchestrate the document, may be an empty set in which case the
082     * document will be orchestrated from it's current position through the termination of it's entire workflow process.
083     *
084     * @return the set of node names to which to orchestrate the document, will never be null but may be empty
085     */
086    public Set<String> getNodeNames() {
087        return nodeNames;
088    }
089
090    /**
091     * Defines some internal constants used on this class.
092     */
093    static class Constants {
094        final static String ROOT_ELEMENT_NAME = "orchestrationConfig";
095        final static String TYPE_NAME = "OrchestrationConfigType";
096    }
097
098    /**
099     * A private class which exposes constants which define the XML element names to use when this object is marshalled
100     * to XML.
101     */
102    static class Elements {
103        final static String ACTION_TAKEN_ID = "actionTakenId";
104        final static String NODE_NAMES = "nodeNames";
105        final static String NODE_NAME = "nodeName";
106    }
107    
108}