Coverage Report - org.kuali.rice.kew.api.note.Note
 
Classes in this File Line Coverage Branch Coverage Complexity
Note
0%
0/24
N/A
1.25
Note$1
N/A
N/A
1.25
Note$Builder
0%
0/37
0%
0/6
1.25
Note$Constants
0%
0/1
N/A
1.25
Note$Elements
0%
0/1
N/A
1.25
 
 1  
 /*
 2  
  * Copyright 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/ecl1.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.note;
 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.apache.commons.lang.StringUtils;
 29  
 import org.joda.time.DateTime;
 30  
 import org.kuali.rice.core.api.CoreConstants;
 31  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 32  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 33  
 import org.w3c.dom.Element;
 34  
 
 35  
 @XmlRootElement(name = Note.Constants.ROOT_ELEMENT_NAME)
 36  
 @XmlAccessorType(XmlAccessType.NONE)
 37  
 @XmlType(name = Note.Constants.TYPE_NAME, propOrder = {
 38  
             Note.Elements.ID,
 39  
                 Note.Elements.DOCUMENT_ID,
 40  
                 Note.Elements.AUTHOR_PRINCIPAL_ID,
 41  
                 Note.Elements.CREATE_DATE,
 42  
                 Note.Elements.TEXT,
 43  
                 CoreConstants.CommonElements.VERSION_NUMBER,
 44  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 45  
 })
 46  0
 public final class Note extends AbstractDataTransferObject implements NoteContract {
 47  
 
 48  
         private static final long serialVersionUID = 6619061362854480922L;
 49  
 
 50  
         @XmlElement(name = Elements.ID, required = false)
 51  
     private final String id;
 52  
         
 53  
     @XmlElement(name = Elements.DOCUMENT_ID, required = true)
 54  
     private final String documentId;
 55  
     
 56  
     @XmlElement(name = Elements.AUTHOR_PRINCIPAL_ID, required = true)
 57  
     private final String authorPrincipalId;
 58  
     
 59  
     @XmlElement(name = Elements.CREATE_DATE, required = false)
 60  
     private final DateTime createDate;
 61  
     
 62  
     @XmlElement(name = Elements.TEXT, required = false)
 63  
     private final String text;
 64  
     
 65  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 66  
     private final Long versionNumber;
 67  
     
 68  0
     @SuppressWarnings("unused")
 69  
     @XmlAnyElement
 70  
     private final Collection<Element> _futureElements = null;
 71  
 
 72  
     /**
 73  
      * Private constructor used only by JAXB.
 74  
      * 
 75  
      */
 76  0
     private Note() {
 77  0
         this.id = null;
 78  0
             this.documentId = null;
 79  0
         this.authorPrincipalId = null;
 80  0
         this.createDate = null;
 81  0
         this.text = null;
 82  0
         this.versionNumber = null;
 83  0
     }
 84  
 
 85  0
     private Note(Builder builder) {
 86  0
         this.id = builder.getId();
 87  0
             this.documentId = builder.getDocumentId();
 88  0
         this.authorPrincipalId = builder.getAuthorPrincipalId();
 89  0
         this.createDate = builder.getCreateDate();
 90  0
         this.text = builder.getText();
 91  0
         this.versionNumber = builder.getVersionNumber();
 92  0
     }
 93  
 
 94  
     @Override
 95  
     public String getId() {
 96  0
         return this.id;
 97  
     }
 98  
 
 99  
     @Override
 100  
     public String getDocumentId() {
 101  0
         return this.documentId;
 102  
     }
 103  
 
 104  
     @Override
 105  
     public String getAuthorPrincipalId() {
 106  0
         return this.authorPrincipalId;
 107  
     }
 108  
 
 109  
     @Override
 110  
     public DateTime getCreateDate() {
 111  0
         return this.createDate;
 112  
     }
 113  
 
 114  
     @Override
 115  
     public String getText() {
 116  0
         return this.text;
 117  
     }
 118  
 
 119  
     @Override
 120  
     public Long getVersionNumber() {
 121  0
         return this.versionNumber;
 122  
     }
 123  
 
 124  
     /**
 125  
      * A builder which can be used to construct {@link Note} instances.  Enforces the constraints of the {@link NoteContract}.
 126  
      */
 127  0
     public final static class Builder implements Serializable, ModelBuilder, NoteContract {
 128  
 
 129  
                 private static final long serialVersionUID = 6457130539374835936L;
 130  
 
 131  
                 private String id;
 132  
         private String documentId;
 133  
         private String authorPrincipalId;
 134  
         private DateTime createDate;
 135  
         private String text;
 136  
         private Long versionNumber;
 137  
 
 138  0
         private Builder(String documentId, String authorPrincipalId) {
 139  0
             setDocumentId(documentId);
 140  0
             setAuthorPrincipalId(authorPrincipalId);
 141  0
         }
 142  
 
 143  
         public static Builder create(String documentId, String authorPrincipalId) {
 144  0
             return new Builder(documentId, authorPrincipalId);
 145  
         }
 146  
 
 147  
         public static Builder create(NoteContract contract) {
 148  0
             if (contract == null) {
 149  0
                 throw new IllegalArgumentException("contract was null");
 150  
             }
 151  
             // TODO if create() is modified to accept required parameters, this will need to be modified
 152  0
             Builder builder = create(contract.getDocumentId(), contract.getAuthorPrincipalId());
 153  0
             builder.setId(contract.getId());
 154  0
             builder.setCreateDate(contract.getCreateDate());
 155  0
             builder.setText(contract.getText());
 156  0
             builder.setVersionNumber(contract.getVersionNumber());
 157  0
             return builder;
 158  
         }
 159  
 
 160  
         public Note build() {
 161  0
             return new Note(this);
 162  
         }
 163  
         
 164  
         @Override
 165  
         public String getId() {
 166  0
             return this.id;
 167  
         }
 168  
 
 169  
         @Override
 170  
         public String getDocumentId() {
 171  0
             return this.documentId;
 172  
         }
 173  
 
 174  
         @Override
 175  
         public String getAuthorPrincipalId() {
 176  0
             return this.authorPrincipalId;
 177  
         }
 178  
 
 179  
         @Override
 180  
         public DateTime getCreateDate() {
 181  0
             return this.createDate;
 182  
         }
 183  
 
 184  
         @Override
 185  
         public String getText() {
 186  0
             return this.text;
 187  
         }
 188  
 
 189  
         @Override
 190  
         public Long getVersionNumber() {
 191  0
             return this.versionNumber;
 192  
         }
 193  
 
 194  
         public void setId(String id) {
 195  0
             this.id = id;
 196  0
         }
 197  
 
 198  
         public void setDocumentId(String documentId) {
 199  0
                 if (StringUtils.isBlank(documentId)) {
 200  0
                         throw new IllegalArgumentException("documentId was null or blank");
 201  
                 }
 202  0
             this.documentId = documentId;
 203  0
         }
 204  
 
 205  
         public void setAuthorPrincipalId(String authorPrincipalId) {
 206  0
                 if (StringUtils.isBlank(authorPrincipalId)) {
 207  0
                         throw new IllegalArgumentException("authorPrincipalId was null or blank");
 208  
                 }
 209  0
             this.authorPrincipalId = authorPrincipalId;
 210  0
         }
 211  
 
 212  
         public void setCreateDate(DateTime createDate) {
 213  0
             this.createDate = createDate;
 214  0
         }
 215  
 
 216  
         public void setText(String text) {
 217  0
             this.text = text;
 218  0
         }
 219  
         
 220  
         public void setVersionNumber(Long versionNumber) {
 221  0
             this.versionNumber = versionNumber;
 222  0
         }
 223  
 
 224  
     }
 225  
 
 226  
     /**
 227  
      * Defines some internal constants used on this class.
 228  
      */
 229  0
     static class Constants {
 230  
         final static String ROOT_ELEMENT_NAME = "note";
 231  
         final static String TYPE_NAME = "NoteType";
 232  
     }
 233  
 
 234  
     /**
 235  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 236  
      */
 237  0
     static class Elements {
 238  
         final static String DOCUMENT_ID = "documentId";
 239  
         final static String AUTHOR_PRINCIPAL_ID = "authorPrincipalId";
 240  
         final static String CREATE_DATE = "createDate";
 241  
         final static String TEXT = "text";
 242  
         final static String ID = "id";
 243  
     }
 244  
 
 245  
 }
 246