View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.api.document;
17  
18  import org.kuali.rice.core.api.CoreConstants;
19  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
20  import org.kuali.rice.core.api.mo.ModelObjectUtils;
21  import org.w3c.dom.Element;
22  
23  import javax.xml.bind.annotation.XmlAccessType;
24  import javax.xml.bind.annotation.XmlAccessorType;
25  import javax.xml.bind.annotation.XmlAnyElement;
26  import javax.xml.bind.annotation.XmlElement;
27  import javax.xml.bind.annotation.XmlElementWrapper;
28  import javax.xml.bind.annotation.XmlRootElement;
29  import javax.xml.bind.annotation.XmlType;
30  import java.util.Collection;
31  import java.util.Collections;
32  import java.util.Set;
33  
34  @XmlRootElement(name = OrchestrationConfig.Constants.ROOT_ELEMENT_NAME)
35  @XmlAccessorType(XmlAccessType.NONE)
36  @XmlType(name = OrchestrationConfig.Constants.TYPE_NAME, propOrder = {
37          OrchestrationConfig.Elements.ACTION_TAKEN_ID,
38          OrchestrationConfig.Elements.NODE_NAMES,
39          CoreConstants.CommonElements.FUTURE_ELEMENTS
40  })
41  public final class OrchestrationConfig extends AbstractDataTransferObject {
42  
43      @XmlElement(name = Elements.ACTION_TAKEN_ID, required = true)
44      private final String actionTakenId;
45  
46      @XmlElementWrapper(name = Elements.NODE_NAMES, required = false)
47      @XmlElement(name = Elements.NODE_NAME, required = false)
48      private final Set<String> nodeNames;
49  
50      @SuppressWarnings("unused")
51      @XmlAnyElement
52      private final Collection<Element> _futureElements = null;
53  
54      @SuppressWarnings("unused")
55      private OrchestrationConfig() {
56          this.actionTakenId = null;
57          this.nodeNames = null;
58      }
59  
60      private OrchestrationConfig(String actionTakenId, Set<String> nodeNames) {
61          this.actionTakenId = actionTakenId;
62          this.nodeNames = ModelObjectUtils.createImmutableCopy(nodeNames);
63      }
64  
65      public static OrchestrationConfig create(String actionTakenId, Set<String> nodeNames) {
66          return new OrchestrationConfig(actionTakenId, nodeNames);
67      }
68  
69      /**
70       * Returns the id of the {@link org.kuali.rice.kew.api.action.ActionTaken} against which any action
71       * requests that are processed by the orchestration should be associated.  This is generally the action that was
72       * submitted which triggered the orchestration process.  Should never return a null or blank value.
73       *
74       * @return the id of the action taken to link deactivated requests with during orchestration
75       */
76      public String getActionTakenId() {
77          return actionTakenId;
78      }
79  
80      /**
81       * Returns the Set of node names to which to orchestrate the document, may be an empty set in which case the
82       * document will be orchestrated from it's current position through the termination of it's entire workflow process.
83       *
84       * @return the set of node names to which to orchestrate the document, will never be null but may be empty
85       */
86      public Set<String> getNodeNames() {
87          return nodeNames;
88      }
89  
90      /**
91       * Defines some internal constants used on this class.
92       */
93      static class Constants {
94          final static String ROOT_ELEMENT_NAME = "orchestrationConfig";
95          final static String TYPE_NAME = "OrchestrationConfigType";
96      }
97  
98      /**
99       * 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 }