Coverage Report - org.kuali.rice.kew.api.doctype.DocumentType
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentType
0%
0/59
0%
0/2
1.088
DocumentType$1
N/A
N/A
1.088
DocumentType$Builder
0%
0/82
0%
0/4
1.088
DocumentType$Cache
0%
0/1
N/A
1.088
DocumentType$Constants
0%
0/1
N/A
1.088
DocumentType$Elements
0%
0/1
N/A
1.088
 
 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.doctype;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.CoreConstants;
 20  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 21  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 22  
 import org.kuali.rice.kew.api.KewApiConstants;
 23  
 import org.w3c.dom.Element;
 24  
 
 25  
 import javax.xml.bind.annotation.XmlAccessType;
 26  
 import javax.xml.bind.annotation.XmlAccessorType;
 27  
 import javax.xml.bind.annotation.XmlAnyElement;
 28  
 import javax.xml.bind.annotation.XmlElement;
 29  
 import javax.xml.bind.annotation.XmlRootElement;
 30  
 import javax.xml.bind.annotation.XmlType;
 31  
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 32  
 import java.io.Serializable;
 33  
 import java.util.Collection;
 34  
 import java.util.Collections;
 35  
 import java.util.HashMap;
 36  
 import java.util.Map;
 37  
 
 38  
 @XmlRootElement(name = DocumentType.Constants.ROOT_ELEMENT_NAME)
 39  
 @XmlAccessorType(XmlAccessType.NONE)
 40  
 @XmlType(name = DocumentType.Constants.TYPE_NAME, propOrder = {
 41  
         DocumentType.Elements.ID,
 42  
         DocumentType.Elements.NAME,
 43  
         DocumentType.Elements.DOCUMENT_TYPE_VERSION,
 44  
         DocumentType.Elements.LABEL,
 45  
         DocumentType.Elements.DESCRIPTION,
 46  
         DocumentType.Elements.PARENT_ID,
 47  
         DocumentType.Elements.ACTIVE,
 48  
         DocumentType.Elements.DOC_HANDLER_URL,
 49  
         DocumentType.Elements.HELP_DEFINITION_URL,
 50  
         DocumentType.Elements.DOC_SEARCH_HELP_URL,
 51  
         DocumentType.Elements.POST_PROCESSOR_NAME,
 52  
         DocumentType.Elements.APPLICATION_ID,
 53  
         DocumentType.Elements.CURRENT,
 54  
         DocumentType.Elements.BLANKET_APPROVE_GROUP_ID,
 55  
         DocumentType.Elements.SUPER_USER_GROUP_ID,
 56  
         DocumentType.Elements.POLICIES,
 57  
         CoreConstants.CommonElements.VERSION_NUMBER,
 58  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 59  
 })
 60  0
 public final class DocumentType extends AbstractDataTransferObject implements DocumentTypeContract {
 61  
 
 62  
     private static final long serialVersionUID = 6866926296038814812L;
 63  
 
 64  
     @XmlElement(name = Elements.ID, required = false)
 65  
     private final String id;
 66  
 
 67  
     @XmlElement(name = Elements.NAME, required = true)
 68  
     private final String name;
 69  
 
 70  
     @XmlElement(name = Elements.DOCUMENT_TYPE_VERSION, required = false)
 71  
     private final Integer documentTypeVersion;
 72  
 
 73  
     @XmlElement(name = Elements.LABEL, required = false)
 74  
     private final String label;
 75  
 
 76  
     @XmlElement(name = Elements.DESCRIPTION, required = false)
 77  
     private final String description;
 78  
 
 79  
     @XmlElement(name = Elements.PARENT_ID, required = false)
 80  
     private final String parentId;
 81  
 
 82  
     @XmlElement(name = Elements.ACTIVE, required = true)
 83  
     private final boolean active;
 84  
 
 85  
     @XmlElement(name = Elements.DOC_HANDLER_URL, required = false)
 86  
     private final String docHandlerUrl;
 87  
 
 88  
     @XmlElement(name = Elements.HELP_DEFINITION_URL, required = false)
 89  
     private final String helpDefinitionUrl;
 90  
 
 91  
     @XmlElement(name = Elements.DOC_SEARCH_HELP_URL, required = false)
 92  
     private final String docSearchHelpUrl;
 93  
 
 94  
     @XmlElement(name = Elements.POST_PROCESSOR_NAME, required = false)
 95  
     private final String postProcessorName;
 96  
 
 97  
     @XmlElement(name = Elements.APPLICATION_ID, required = false)
 98  
     private final String applicationId;
 99  
 
 100  
     @XmlElement(name = Elements.CURRENT, required = true)
 101  
     private final boolean current;
 102  
 
 103  
     @XmlElement(name = Elements.BLANKET_APPROVE_GROUP_ID, required = false)
 104  
     private final String blanketApproveGroupId;
 105  
 
 106  
     @XmlElement(name = Elements.SUPER_USER_GROUP_ID, required = false)
 107  
     private final String superUserGroupId;
 108  
 
 109  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 110  
     private final Long versionNumber;
 111  
 
 112  
     @XmlElement(name = Elements.POLICIES, required = true)
 113  
     @XmlJavaTypeAdapter(DocumentTypePolicyMapAdapter.class)
 114  
     private final Map<DocumentTypePolicy, String> policies;
 115  
 
 116  0
     @SuppressWarnings("unused")
 117  
     @XmlAnyElement
 118  
     private final Collection<Element> _futureElements = null;
 119  
 
 120  
     /**
 121  
      * Private constructor used only by JAXB.
 122  
      */
 123  0
     private DocumentType() {
 124  0
         this.id = null;
 125  0
         this.name = null;
 126  0
         this.documentTypeVersion = null;
 127  0
         this.label = null;
 128  0
         this.description = null;
 129  0
         this.parentId = null;
 130  0
         this.active = false;
 131  0
         this.docHandlerUrl = null;
 132  0
         this.helpDefinitionUrl = null;
 133  0
         this.docSearchHelpUrl = null;
 134  0
         this.postProcessorName = null;
 135  0
         this.applicationId = null;
 136  0
         this.current = false;
 137  0
         this.blanketApproveGroupId = null;
 138  0
         this.superUserGroupId = null;
 139  0
         this.policies = null;
 140  0
         this.versionNumber = null;
 141  0
     }
 142  
 
 143  0
     private DocumentType(Builder builder) {
 144  0
         this.name = builder.getName();
 145  0
         this.id = builder.getId();
 146  0
         this.documentTypeVersion = builder.getDocumentTypeVersion();
 147  0
         this.label = builder.getLabel();
 148  0
         this.description = builder.getDescription();
 149  0
         this.parentId = builder.getParentId();
 150  0
         this.active = builder.isActive();
 151  0
         this.docHandlerUrl = builder.getDocHandlerUrl();
 152  0
         this.helpDefinitionUrl = builder.getHelpDefinitionUrl();
 153  0
         this.docSearchHelpUrl = builder.getDocSearchHelpUrl();
 154  0
         this.postProcessorName = builder.getPostProcessorName();
 155  0
         this.applicationId = builder.getApplicationId();
 156  0
         this.current = builder.isCurrent();
 157  0
         this.blanketApproveGroupId = builder.getBlanketApproveGroupId();
 158  0
         this.superUserGroupId = builder.getSuperUserGroupId();
 159  0
         if (builder.getPolicies() == null) {
 160  0
             this.policies = Collections.emptyMap();
 161  
         } else {
 162  0
             this.policies = Collections.unmodifiableMap(new HashMap<DocumentTypePolicy, String>(builder.getPolicies()));
 163  
         }
 164  0
         this.versionNumber = builder.getVersionNumber();
 165  0
     }
 166  
 
 167  
     @Override
 168  
     public String getId() {
 169  0
         return this.id;
 170  
     }
 171  
 
 172  
     @Override
 173  
     public String getName() {
 174  0
         return this.name;
 175  
     }
 176  
 
 177  
     @Override
 178  
     public Integer getDocumentTypeVersion() {
 179  0
         return this.documentTypeVersion;
 180  
     }
 181  
 
 182  
     @Override
 183  
     public String getLabel() {
 184  0
         return this.label;
 185  
     }
 186  
 
 187  
     @Override
 188  
     public String getDescription() {
 189  0
         return this.description;
 190  
     }
 191  
 
 192  
     @Override
 193  
     public String getParentId() {
 194  0
         return this.parentId;
 195  
     }
 196  
 
 197  
     @Override
 198  
     public boolean isActive() {
 199  0
         return this.active;
 200  
     }
 201  
 
 202  
     @Override
 203  
     public String getDocHandlerUrl() {
 204  0
         return this.docHandlerUrl;
 205  
     }
 206  
 
 207  
     @Override
 208  
     public String getHelpDefinitionUrl() {
 209  0
         return this.helpDefinitionUrl;
 210  
     }
 211  
 
 212  
     @Override
 213  
     public String getDocSearchHelpUrl() {
 214  0
         return this.docSearchHelpUrl;
 215  
     }
 216  
     
 217  
     @Override
 218  
     public String getPostProcessorName() {
 219  0
         return this.postProcessorName;
 220  
     }
 221  
 
 222  
     @Override
 223  
     public String getApplicationId() {
 224  0
         return this.applicationId;
 225  
     }
 226  
 
 227  
     @Override
 228  
     public boolean isCurrent() {
 229  0
         return this.current;
 230  
     }
 231  
 
 232  
     @Override
 233  
     public String getBlanketApproveGroupId() {
 234  0
         return this.blanketApproveGroupId;
 235  
     }
 236  
 
 237  
     @Override
 238  
     public String getSuperUserGroupId() {
 239  0
         return this.superUserGroupId;
 240  
     }
 241  
 
 242  
     @Override
 243  
     public Map<DocumentTypePolicy, String> getPolicies() {
 244  0
         return this.policies;
 245  
     }
 246  
 
 247  
     @Override
 248  
     public Long getVersionNumber() {
 249  0
         return this.versionNumber;
 250  
     }
 251  
 
 252  
     /**
 253  
      * A builder which can be used to construct {@link DocumentType} instances. Enforces the
 254  
      * constraints of the {@link DocumentTypeContract}.
 255  
      */
 256  0
     public final static class Builder implements Serializable, ModelBuilder, DocumentTypeContract {
 257  
 
 258  
         private static final long serialVersionUID = 1678979180435181578L;
 259  
 
 260  
         private String id;
 261  
         private String name;
 262  
         private Integer documentTypeVersion;
 263  
         private String label;
 264  
         private String description;
 265  
         private String parentId;
 266  
         private boolean active;
 267  
         private String docHandlerUrl;
 268  
         private String helpDefinitionUrl;
 269  
         private String docSearchHelpUrl;
 270  
         private String postProcessorName;
 271  
         private String applicationId;
 272  
         private boolean current;
 273  
         private String blanketApproveGroupId;
 274  
         private String superUserGroupId;
 275  
         private Map<DocumentTypePolicy, String> policies;
 276  
         private Long versionNumber;
 277  
 
 278  0
         private Builder(String name) {
 279  0
             setName(name);
 280  0
             setActive(true);
 281  0
             setCurrent(true);
 282  0
             this.policies = new HashMap<DocumentTypePolicy, String>();
 283  0
         }
 284  
 
 285  
         public static Builder create(String name) {
 286  0
             return new Builder(name);
 287  
         }
 288  
 
 289  
         public static Builder create(DocumentTypeContract contract) {
 290  0
             if (contract == null) {
 291  0
                 throw new IllegalArgumentException("contract was null");
 292  
             }
 293  0
             Builder builder = create(contract.getName());
 294  0
             builder.setId(contract.getId());
 295  0
             builder.setDocumentTypeVersion(contract.getDocumentTypeVersion());
 296  0
             builder.setLabel(contract.getLabel());
 297  0
             builder.setDescription(contract.getDescription());
 298  0
             builder.setParentId(contract.getParentId());
 299  0
             builder.setActive(contract.isActive());
 300  0
             builder.setDocHandlerUrl(contract.getDocHandlerUrl());
 301  0
             builder.setHelpDefinitionUrl(contract.getHelpDefinitionUrl());
 302  0
             builder.setDocSearchHelpUrl(contract.getDocSearchHelpUrl());
 303  0
             builder.setPostProcessorName(contract.getPostProcessorName());
 304  0
             builder.setApplicationId(contract.getApplicationId());
 305  0
             builder.setCurrent(contract.isCurrent());
 306  0
             builder.setBlanketApproveGroupId(contract.getBlanketApproveGroupId());
 307  0
             builder.setSuperUserGroupId(contract.getSuperUserGroupId());
 308  0
             builder.setPolicies(new HashMap<DocumentTypePolicy, String>(contract.getPolicies()));
 309  0
             builder.setVersionNumber(contract.getVersionNumber());
 310  0
             return builder;
 311  
         }
 312  
 
 313  
         public DocumentType build() {
 314  0
             return new DocumentType(this);
 315  
         }
 316  
 
 317  
         @Override
 318  
         public String getId() {
 319  0
             return this.id;
 320  
         }
 321  
 
 322  
         @Override
 323  
         public String getName() {
 324  0
             return this.name;
 325  
         }
 326  
 
 327  
         @Override
 328  
         public Integer getDocumentTypeVersion() {
 329  0
             return this.documentTypeVersion;
 330  
         }
 331  
 
 332  
         @Override
 333  
         public String getLabel() {
 334  0
             return this.label;
 335  
         }
 336  
 
 337  
         @Override
 338  
         public String getDescription() {
 339  0
             return this.description;
 340  
         }
 341  
 
 342  
         @Override
 343  
         public String getParentId() {
 344  0
             return this.parentId;
 345  
         }
 346  
 
 347  
         @Override
 348  
         public boolean isActive() {
 349  0
             return this.active;
 350  
         }
 351  
 
 352  
         @Override
 353  
         public String getDocHandlerUrl() {
 354  0
             return this.docHandlerUrl;
 355  
         }
 356  
         
 357  
         @Override
 358  
         public String getHelpDefinitionUrl() {
 359  0
             return this.helpDefinitionUrl;
 360  
         }
 361  
 
 362  
         @Override
 363  
         public String getDocSearchHelpUrl() {
 364  0
             return this.docSearchHelpUrl;
 365  
         }
 366  
 
 367  
         @Override
 368  
         public String getPostProcessorName() {
 369  0
             return this.postProcessorName;
 370  
         }
 371  
 
 372  
         @Override
 373  
         public String getApplicationId() {
 374  0
             return this.applicationId;
 375  
         }
 376  
 
 377  
         @Override
 378  
         public boolean isCurrent() {
 379  0
             return this.current;
 380  
         }
 381  
 
 382  
         @Override
 383  
         public String getBlanketApproveGroupId() {
 384  0
             return this.blanketApproveGroupId;
 385  
         }
 386  
 
 387  
         @Override
 388  
         public String getSuperUserGroupId() {
 389  0
             return this.superUserGroupId;
 390  
         }
 391  
 
 392  
         @Override
 393  
         public Map<DocumentTypePolicy, String> getPolicies() {
 394  0
             return this.policies;
 395  
         }
 396  
 
 397  
         @Override
 398  
         public Long getVersionNumber() {
 399  0
             return this.versionNumber;
 400  
         }
 401  
 
 402  
         public void setId(String id) {
 403  0
             this.id = id;
 404  0
         }
 405  
 
 406  
         public void setName(String name) {
 407  0
             if (StringUtils.isBlank(name)) {
 408  0
                 throw new IllegalArgumentException("name was null or blank");
 409  
             }
 410  0
             this.name = name;
 411  0
         }
 412  
 
 413  
         public void setDocumentTypeVersion(Integer documentTypeVersion) {
 414  0
             this.documentTypeVersion = documentTypeVersion;
 415  0
         }
 416  
 
 417  
         public void setLabel(String label) {
 418  0
             this.label = label;
 419  0
         }
 420  
 
 421  
         public void setDescription(String description) {
 422  0
             this.description = description;
 423  0
         }
 424  
 
 425  
         public void setParentId(String parentId) {
 426  0
             this.parentId = parentId;
 427  0
         }
 428  
 
 429  
         public void setActive(boolean active) {
 430  0
             this.active = active;
 431  0
         }
 432  
 
 433  
         public void setDocHandlerUrl(String docHandlerUrl) {
 434  0
             this.docHandlerUrl = docHandlerUrl;
 435  0
         }
 436  
 
 437  
         public void setHelpDefinitionUrl(String helpDefinitionUrl) {
 438  0
             this.helpDefinitionUrl = helpDefinitionUrl;
 439  0
         }
 440  
 
 441  
         public void setDocSearchHelpUrl(String docSearchHelpUrl) {
 442  0
             this.docSearchHelpUrl = docSearchHelpUrl;
 443  0
         }
 444  
         
 445  
         public void setPostProcessorName(String postProcessorName) {
 446  0
             this.postProcessorName = postProcessorName;
 447  0
         }
 448  
 
 449  
         public void setApplicationId(String applicationId) {
 450  0
             this.applicationId = applicationId;
 451  0
         }
 452  
 
 453  
         public void setCurrent(boolean current) {
 454  0
             this.current = current;
 455  0
         }
 456  
 
 457  
         public void setBlanketApproveGroupId(String blanketApproveGroupId) {
 458  0
             this.blanketApproveGroupId = blanketApproveGroupId;
 459  0
         }
 460  
 
 461  
         public void setSuperUserGroupId(String superUserGroupId) {
 462  0
             this.superUserGroupId = superUserGroupId;
 463  0
         }
 464  
 
 465  
         public void setPolicies(Map<DocumentTypePolicy, String> policies) {
 466  0
             this.policies = policies;
 467  0
         }
 468  
 
 469  
         public void setVersionNumber(Long versionNumber) {
 470  0
             this.versionNumber = versionNumber;
 471  0
         }
 472  
 
 473  
     }
 474  
 
 475  
     /**
 476  
      * Defines some internal constants used on this class.
 477  
      */
 478  0
     static class Constants {
 479  
         final static String ROOT_ELEMENT_NAME = "documentType";
 480  
         final static String TYPE_NAME = "DocumentTypeType";
 481  
     }
 482  
 
 483  
     /**
 484  
      * A private class which exposes constants which define the XML element names to use when this
 485  
      * object is marshalled to XML.
 486  
      */
 487  0
     static class Elements {
 488  
         final static String ID = "id";
 489  
         final static String NAME = "name";
 490  
         final static String DOCUMENT_TYPE_VERSION = "documentTypeVersion";
 491  
         final static String LABEL = "label";
 492  
         final static String DESCRIPTION = "description";
 493  
         final static String PARENT_ID = "parentId";
 494  
         final static String ACTIVE = "active";
 495  
         final static String DOC_HANDLER_URL = "docHandlerUrl";
 496  
         final static String HELP_DEFINITION_URL = "helpDefinitionUrl";
 497  
         final static String DOC_SEARCH_HELP_URL = "docSearchHelpUrl";
 498  
         final static String POST_PROCESSOR_NAME = "postProcessorName";
 499  
         final static String APPLICATION_ID = "applicationId";
 500  
         final static String CURRENT = "current";
 501  
         final static String BLANKET_APPROVE_GROUP_ID = "blanketApproveGroupId";
 502  
         final static String SUPER_USER_GROUP_ID = "superUserGroupId";
 503  
         final static String POLICIES = "policies";
 504  
     }
 505  
 
 506  0
     public static class Cache {
 507  
         public static final String NAME = KewApiConstants.Namespaces.KEW_NAMESPACE_2_0 + "/" + DocumentType.Constants.TYPE_NAME;
 508  
     }
 509  
 
 510  
 }