Coverage Report - org.kuali.rice.kew.api.action.AdHocCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
AdHocCommand
0%
0/23
N/A
1.091
AdHocCommand$Builder
0%
0/25
0%
0/2
1.091
AdHocCommand$Constants
0%
0/1
N/A
1.091
AdHocCommand$Elements
0%
0/1
N/A
1.091
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.action;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Collection;
 20  
 
 21  
 import javax.xml.bind.annotation.XmlAccessType;
 22  
 import javax.xml.bind.annotation.XmlAccessorType;
 23  
 import javax.xml.bind.annotation.XmlAnyElement;
 24  
 import javax.xml.bind.annotation.XmlElement;
 25  
 import javax.xml.bind.annotation.XmlRootElement;
 26  
 import javax.xml.bind.annotation.XmlType;
 27  
 
 28  
 import org.kuali.rice.core.api.CoreConstants;
 29  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 30  
 import org.w3c.dom.Element;
 31  
 
 32  
 @XmlRootElement(name = AdHocCommand.Constants.ROOT_ELEMENT_NAME)
 33  
 @XmlAccessorType(XmlAccessType.NONE)
 34  
 @XmlType(name = AdHocCommand.Constants.TYPE_NAME, propOrder = {
 35  
                 AdHocCommand.Elements.ACTION_REQUESTED_CODE,
 36  
                 AdHocCommand.Elements.NODE_NAME,
 37  
         AdHocCommand.Elements.PRIORITY,
 38  
                 AdHocCommand.Elements.RESPONSIBILITY_DESCRIPTION,
 39  
                 AdHocCommand.Elements.FORCE_ACTION,
 40  
                 AdHocCommand.Elements.REQUEST_LABEL,
 41  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 42  
 })
 43  
 abstract class AdHocCommand extends AbstractDataTransferObject {
 44  
 
 45  
         private static final long serialVersionUID = -4181802858756667726L;
 46  
 
 47  
         @XmlElement(name = Elements.ACTION_REQUESTED_CODE, required = true)
 48  
         private final String actionRequestedCode;
 49  
         
 50  
         @XmlElement(name = Elements.NODE_NAME, required = false)
 51  
         private final String nodeName;
 52  
 
 53  
     @XmlElement(name = Elements.PRIORITY, required = false)
 54  
         private final Integer priority;
 55  
 
 56  
         @XmlElement(name = Elements.RESPONSIBILITY_DESCRIPTION, required = false)
 57  
         private final String responsibilityDescription;
 58  
         
 59  
         @XmlElement(name = Elements.FORCE_ACTION, required = true)
 60  
         private final boolean forceAction;
 61  
         
 62  
         @XmlElement(name = Elements.REQUEST_LABEL, required = false)
 63  
         private final String requestLabel;
 64  
         
 65  0
     @SuppressWarnings("unused")
 66  
     @XmlAnyElement
 67  
     private final Collection<Element> _futureElements = null;
 68  
         
 69  0
     protected AdHocCommand() {
 70  0
             this.actionRequestedCode = null;
 71  0
             this.nodeName = null;
 72  0
         this.priority = null;
 73  0
             this.responsibilityDescription = null;
 74  0
             this.forceAction = false;
 75  0
             this.requestLabel = null;
 76  0
     }
 77  
     
 78  0
     protected AdHocCommand(Builder<?> builder) {
 79  0
             this.actionRequestedCode = builder.getActionRequested().getCode();
 80  0
             this.nodeName = builder.getNodeName();
 81  0
         this.priority = builder.getPriority();
 82  0
             this.responsibilityDescription = builder.getResponsibilityDescription();
 83  0
             this.forceAction = builder.isForceAction();
 84  0
             this.requestLabel = builder.getRequestLabel();
 85  0
     }
 86  
     
 87  
     public ActionRequestType getActionRequested() {
 88  0
                 return ActionRequestType.fromCode(actionRequestedCode);
 89  
         }
 90  
 
 91  
         public String getNodeName() {
 92  0
                 return nodeName;
 93  
         }
 94  
 
 95  
     public Integer getPriority() {
 96  0
         return priority;
 97  
     }
 98  
 
 99  
     public String getResponsibilityDescription() {
 100  0
                 return responsibilityDescription;
 101  
         }
 102  
 
 103  
         public boolean isForceAction() {
 104  0
                 return forceAction;
 105  
         }
 106  
 
 107  
         public String getRequestLabel() {
 108  0
                 return requestLabel;
 109  
         }
 110  
 
 111  
         protected static abstract class Builder<T> implements Serializable {
 112  
                 
 113  
                 private static final long serialVersionUID = -3002495884401672488L;
 114  
 
 115  
                 private ActionRequestType actionRequested;
 116  
             private String nodeName;
 117  
         private Integer priority;
 118  
             private String responsibilityDescription;
 119  
             private boolean forceAction;
 120  
             private String requestLabel;
 121  
             
 122  
             public abstract T build();
 123  
             
 124  0
             protected Builder(ActionRequestType actionRequested, String nodeName) {
 125  0
                     setActionRequested(actionRequested);
 126  0
                     setNodeName(nodeName);
 127  0
                     setForceAction(true);
 128  0
             }
 129  
 
 130  
                 public ActionRequestType getActionRequested() {
 131  0
                         return actionRequested;
 132  
                 }
 133  
 
 134  
                 public String getNodeName() {
 135  0
                         return nodeName;
 136  
                 }
 137  
 
 138  
         public Integer getPriority() {
 139  0
             return priority;
 140  
         }
 141  
 
 142  
         public String getResponsibilityDescription() {
 143  0
                         return responsibilityDescription;
 144  
                 }
 145  
 
 146  
                 public boolean isForceAction() {
 147  0
                         return forceAction;
 148  
                 }
 149  
 
 150  
                 public String getRequestLabel() {
 151  0
                         return requestLabel;
 152  
                 }
 153  
 
 154  
                 public void setActionRequested(ActionRequestType actionRequested) {
 155  0
                         if (actionRequested == null) {
 156  0
                                 throw new IllegalArgumentException("actionRequested was null");
 157  
                         }
 158  0
                         this.actionRequested = actionRequested;
 159  0
                 }
 160  
 
 161  
                 public void setNodeName(String nodeName) {
 162  0
                         this.nodeName = nodeName;
 163  0
                 }
 164  
 
 165  
         public void setPriority(Integer priority) {
 166  0
             this.priority = priority;
 167  0
         }
 168  
 
 169  
         public void setResponsibilityDescription(String responsibilityDescription) {
 170  0
                         this.responsibilityDescription = responsibilityDescription;
 171  0
                 }
 172  
 
 173  
                 public void setForceAction(boolean forceAction) {
 174  0
                         this.forceAction = forceAction;
 175  0
                 }
 176  
 
 177  
                 public void setRequestLabel(String requestLabel) {
 178  0
                         this.requestLabel = requestLabel;
 179  0
                 }
 180  
             
 181  
     }
 182  
         
 183  
         /**
 184  
      * Defines some internal constants used on this class.
 185  
      */
 186  0
     static class Constants {
 187  
         final static String ROOT_ELEMENT_NAME = "adHocCommand";
 188  
         final static String TYPE_NAME = "AdHocCommandType";
 189  
     }
 190  
     
 191  
     /**
 192  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 193  
      */
 194  0
     static class Elements {
 195  
         final static String ACTION_REQUESTED_CODE = "actionRequestedCode";
 196  
         final static String NODE_NAME = "nodeName";
 197  
         final static String PRIORITY = "priority";
 198  
         final static String RESPONSIBILITY_DESCRIPTION = "responsibilityDescription";
 199  
         final static String FORCE_ACTION = "forceAction";
 200  
         final static String REQUEST_LABEL = "requestLabel";
 201  
     }
 202  
 
 203  
 }