001/**
002 * Copyright 2005-2015 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.action;
017
018import org.kuali.rice.core.api.CoreConstants;
019import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
020import org.kuali.rice.core.api.mo.ModelBuilder;
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.XmlRootElement;
028import javax.xml.bind.annotation.XmlType;
029import java.io.Serializable;
030import java.util.Collection;
031
032
033/**
034 * A transport object representing an action a user might take
035 *
036 * @author Kuali Rice Team (rice.collab@kuali.org)
037 */
038@XmlRootElement(name = RoutingReportActionToTake.Constants.ROOT_ELEMENT_NAME)
039@XmlAccessorType(XmlAccessType.NONE)
040@XmlType(name = RoutingReportActionToTake.Constants.TYPE_NAME, propOrder = {
041    RoutingReportActionToTake.Elements.ACTION_TO_PERFORM,
042    RoutingReportActionToTake.Elements.PRINCIPAL_ID,
043    RoutingReportActionToTake.Elements.NODE_NAME,
044    CoreConstants.CommonElements.FUTURE_ELEMENTS
045})
046public final class RoutingReportActionToTake
047    extends AbstractDataTransferObject
048    implements RoutingReportActionToTakeContract
049{
050
051    @XmlElement(name = Elements.ACTION_TO_PERFORM, required = false)
052    private final String actionToPerform;
053    @XmlElement(name = Elements.PRINCIPAL_ID, required = false)
054    private final String principalId;
055    @XmlElement(name = Elements.NODE_NAME, required = false)
056    private final String nodeName;
057    @SuppressWarnings("unused")
058    @XmlAnyElement
059    private final Collection<Element> _futureElements = null;
060
061    /**
062     * Private constructor used only by JAXB.
063     * 
064     */
065    private RoutingReportActionToTake() {
066        this.actionToPerform = null;
067        this.principalId = null;
068        this.nodeName = null;
069    }
070
071    private RoutingReportActionToTake(Builder builder) {
072        this.actionToPerform = builder.getActionToPerform();
073        this.principalId = builder.getPrincipalId();
074        this.nodeName = builder.getNodeName();
075    }
076
077    @Override
078    public String getActionToPerform() {
079        return this.actionToPerform;
080    }
081
082    @Override
083    public String getPrincipalId() {
084        return this.principalId;
085    }
086
087    @Override
088    public String getNodeName() {
089        return this.nodeName;
090    }
091
092
093    /**
094     * A builder which can be used to construct {@link RoutingReportActionToTake} instances.  Enforces the constraints of the {@link RoutingReportActionToTakeContract}.
095     * 
096     */
097    public final static class Builder
098        implements Serializable, ModelBuilder, RoutingReportActionToTakeContract
099    {
100
101        private String actionToPerform;
102        private String principalId;
103        private String nodeName;
104
105        private Builder(String actionToPerform, String principalId, String nodeName) {
106            this.setActionToPerform(actionToPerform);
107            this.setPrincipalId(principalId);
108            this.setNodeName(nodeName);
109        }
110
111        public static Builder create(String actionToPerform, String principalId, String nodeName) {
112            return new Builder(actionToPerform, principalId, nodeName);
113        }
114
115        public static Builder create(RoutingReportActionToTakeContract contract) {
116            if (contract == null) {
117                throw new IllegalArgumentException("contract was null");
118            }
119            return create(contract.getActionToPerform(), contract.getPrincipalId(), contract.getNodeName());
120        }
121
122        public RoutingReportActionToTake build() {
123            return new RoutingReportActionToTake(this);
124        }
125
126        @Override
127        public String getActionToPerform() {
128            return this.actionToPerform;
129        }
130
131        @Override
132        public String getPrincipalId() {
133            return this.principalId;
134        }
135
136        @Override
137        public String getNodeName() {
138            return this.nodeName;
139        }
140
141        public void setActionToPerform(String actionToPerform) {
142            this.actionToPerform = actionToPerform;
143        }
144
145        public void setPrincipalId(String principalId) {
146            this.principalId = principalId;
147        }
148
149        public void setNodeName(String nodeName) {
150            this.nodeName = nodeName;
151        }
152
153    }
154
155
156    /**
157     * Defines some internal constants used on this class.
158     * 
159     */
160    static class Constants {
161
162        final static String ROOT_ELEMENT_NAME = "routingReportActionToTake";
163        final static String TYPE_NAME = "RoutingReportActionToTakeType";
164
165    }
166
167
168    /**
169     * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
170     * 
171     */
172    static class Elements {
173
174        final static String ACTION_TO_PERFORM = "actionToPerform";
175        final static String PRINCIPAL_ID = "principalId";
176        final static String NODE_NAME = "nodeName";
177
178    }
179
180}