Coverage Report - org.kuali.rice.kew.api.action.ActionSet
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionSet
0%
0/28
0%
0/2
1.143
ActionSet$1
N/A
N/A
1.143
ActionSet$Builder
0%
0/33
0%
0/4
1.143
ActionSet$Constants
0%
0/1
N/A
1.143
ActionSet$Elements
0%
0/1
N/A
1.143
 
 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.ArrayList;
 20  
 import java.util.Collection;
 21  
 import java.util.List;
 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.XmlRootElement;
 28  
 import javax.xml.bind.annotation.XmlType;
 29  
 
 30  
 import org.kuali.rice.core.api.CoreConstants;
 31  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 32  
 import org.kuali.rice.kew.api.KewApiConstants;
 33  
 import org.kuali.rice.kew.api.actionlist.DisplayParameters;
 34  
 import org.w3c.dom.Element;
 35  
 
 36  
 
 37  
 /**
 38  
  * Specifies a set of Action codes.
 39  
  * 
 40  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 41  
  */
 42  
 @XmlRootElement(name = ActionSet.Constants.ROOT_ELEMENT_NAME)
 43  
 @XmlAccessorType(XmlAccessType.NONE)
 44  
 @XmlType(name = ActionSet.Constants.TYPE_NAME, propOrder = {
 45  
     ActionSet.Elements.ACTION_SET_LIST,
 46  
     CoreConstants.CommonElements.FUTURE_ELEMENTS
 47  
 })
 48  0
 public final class ActionSet implements Serializable, ActionSetContract {
 49  
 
 50  
         private static final long serialVersionUID = 7857749268529671300L;
 51  
         
 52  
         @XmlElement(name = Elements.ACTION_SET_LIST, required = false)
 53  
         private List<String> actionSetList;
 54  
         
 55  0
         @SuppressWarnings("unused")
 56  
     @XmlAnyElement
 57  
     private final Collection<Element> _futureElements = null;
 58  
         
 59  
         /**
 60  
      * Private constructor used only by JAXB.
 61  
      * 
 62  
      */
 63  0
         private ActionSet() {
 64  0
             this.actionSetList = null;
 65  0
         }
 66  
         
 67  
         /**
 68  
      * Constructs an ActionSet from the given builder.  This constructor is private and should only
 69  
      * ever be invoked from the builder.
 70  
      * 
 71  
      * @param builder the Builder from which to construct the ActionSet
 72  
      */
 73  0
         private ActionSet(Builder builder) {
 74  0
             this.actionSetList = builder.getActionSet();
 75  0
         }
 76  
         
 77  
         @Override
 78  
         public boolean hasAction(String actionCode) {
 79  0
                 return actionSetList.contains(actionCode);
 80  
         }
 81  
         
 82  
         @Override
 83  
         public boolean addAction(String actionCode) {
 84  0
                 if (!actionSetList.contains(actionCode)) {
 85  0
                         actionSetList.add(actionCode);
 86  0
                         return true;
 87  
                 }
 88  0
                 return false;
 89  
         }
 90  
         
 91  
         @Override
 92  
         public boolean removeAction(String actionCode) {
 93  0
                 return actionSetList.remove(actionCode);
 94  
         }
 95  
         
 96  
         // some convienance methods for common actions
 97  
         @Override
 98  
         public boolean hasApprove() {
 99  0
                 return hasAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
 100  
         }
 101  
         
 102  
         @Override
 103  
         public boolean hasComplete() {
 104  0
                 return hasAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
 105  
         }
 106  
         
 107  
         @Override
 108  
         public boolean hasAcknowledge() {
 109  0
                 return hasAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
 110  
         }
 111  
         
 112  
         @Override
 113  
         public boolean hasFyi() {
 114  0
                 return hasAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
 115  
         }
 116  
         
 117  
         @Override
 118  
         public boolean hasDisapprove() {
 119  0
                 return hasAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
 120  
         }
 121  
         
 122  
         @Override
 123  
         public boolean hasCancel() {
 124  0
                 return hasAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
 125  
         }
 126  
 
 127  
         @Override
 128  
     public boolean hasRouted() {
 129  0
         return hasAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
 130  
     }
 131  
 
 132  
         @Override
 133  
         public boolean addApprove() {
 134  0
                 return addAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
 135  
         }
 136  
         
 137  
         @Override
 138  
         public boolean addComplete() {
 139  0
                 return addAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
 140  
         }
 141  
         
 142  
         @Override
 143  
         public boolean addAcknowledge() {
 144  0
                 return addAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
 145  
         }
 146  
         
 147  
         @Override
 148  
         public boolean addFyi() {
 149  0
                 return addAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
 150  
         }
 151  
         
 152  
         @Override
 153  
         public boolean addDisapprove() {
 154  0
                 return addAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
 155  
         }
 156  
         
 157  
         @Override
 158  
         public boolean addCancel() {
 159  0
                 return addAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
 160  
         }
 161  
 
 162  
         @Override
 163  
     public boolean addRouted() {
 164  0
         return addAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
 165  
     }
 166  
     
 167  
         /**
 168  
      * A builder which can be used to construct {@link DisplayParameters} instances.  Enforces the constraints of the {@link DocumentContentContract}.
 169  
      */
 170  0
         public final static class Builder implements Serializable, ModelBuilder, ActionSetContract {
 171  
             
 172  
             private List<String> actionSet;
 173  
             
 174  
             /**
 175  
          * Private constructor for creating a builder with all of it's required attributes.
 176  
          */
 177  0
             private Builder(List<String> actionSet) {
 178  0
                 setActionSetList(actionSet);
 179  0
             }
 180  
             
 181  
             public static Builder create() {
 182  0
                 return new Builder(new ArrayList<String>());
 183  
             }
 184  
             
 185  
             /**
 186  
          * Creates a builder by populating it with data from the given {@linkActionSet}.
 187  
          * 
 188  
          * @param contract the contract from which to populate this builder
 189  
          * @return an instance of the builder populated with data from the contract
 190  
          */
 191  
             public static Builder create(ActionSetContract contract) {
 192  0
                 if (contract == null) {
 193  0
                 throw new IllegalArgumentException("contract was null");
 194  
             }
 195  0
             Builder builder = create();
 196  0
             return builder;
 197  
             }
 198  
            
 199  
             public ActionSet build() {
 200  0
                 return new ActionSet(this);
 201  
             }
 202  
             public List<String> getActionSet() {
 203  0
                 return this.actionSet;
 204  
             }
 205  
             public void setActionSetList(List<String> actionSet) {
 206  0
                 this.actionSet = actionSet;
 207  0
             }
 208  
 
 209  
         @Override
 210  
         public boolean hasAction(String actionCode) {
 211  0
             return actionSet.contains(actionCode);
 212  
         }
 213  
 
 214  
         @Override
 215  
         public boolean addAction(String actionCode) {
 216  0
             if (!actionSet.contains(actionCode)) {
 217  0
                 actionSet.add(actionCode);
 218  0
                 return true;
 219  
             }
 220  0
             return false;
 221  
         }
 222  
 
 223  
         @Override
 224  
         public boolean removeAction(String actionCode) {
 225  0
             return actionSet.remove(actionCode);
 226  
         }
 227  
 
 228  
         @Override
 229  
         public boolean hasApprove() {
 230  0
             return hasAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
 231  
         }
 232  
 
 233  
         @Override
 234  
         public boolean hasComplete() {
 235  0
             return hasAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
 236  
         }
 237  
 
 238  
         @Override
 239  
         public boolean hasAcknowledge() {
 240  0
             return hasAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
 241  
         }
 242  
 
 243  
         @Override
 244  
         public boolean hasFyi() {
 245  0
             return hasAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
 246  
         }
 247  
 
 248  
         @Override
 249  
         public boolean hasDisapprove() {
 250  0
             return hasAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
 251  
         }
 252  
 
 253  
         @Override
 254  
         public boolean hasCancel() {
 255  0
             return hasAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
 256  
         }
 257  
 
 258  
         @Override
 259  
         public boolean hasRouted() {
 260  0
             return hasAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
 261  
         }
 262  
 
 263  
         @Override
 264  
         public boolean addApprove() {
 265  0
             return addAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
 266  
         }
 267  
 
 268  
         @Override
 269  
         public boolean addComplete() {
 270  0
             return addAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
 271  
         }
 272  
 
 273  
         /**
 274  
          * This overridden method ...
 275  
          * 
 276  
          * @see org.kuali.rice.kew.api.action.ActionSetContract#addAcknowledge()
 277  
          */
 278  
         @Override
 279  
         public boolean addAcknowledge() {
 280  0
             return addAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
 281  
         }
 282  
 
 283  
         @Override
 284  
         public boolean addFyi() {
 285  0
             return addAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
 286  
         }
 287  
 
 288  
         @Override
 289  
         public boolean addDisapprove() {
 290  0
             return addAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
 291  
         }
 292  
 
 293  
         @Override
 294  
         public boolean addCancel() {
 295  0
             return addAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
 296  
         }
 297  
 
 298  
         @Override
 299  
         public boolean addRouted() {
 300  0
             return addAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
 301  
         }                
 302  
         }
 303  
         
 304  
     /**
 305  
      * Defines some internal constants used on this class.
 306  
      * 
 307  
      */
 308  0
     static class Constants {
 309  
 
 310  
         final static String ROOT_ELEMENT_NAME = "actionSet";
 311  
         final static String TYPE_NAME = "ActionSetType";
 312  
     }
 313  
 
 314  
     /**
 315  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 316  
      * 
 317  
      */
 318  0
     static class Elements {
 319  
 
 320  
         final static String ACTION_SET_LIST = "actionSetList";
 321  
     }
 322  
 }