|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  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.apache.commons.lang.builder.EqualsBuilder;  | 
  |  30 |     | 
   import org.apache.commons.lang.builder.HashCodeBuilder;  | 
  |  31 |     | 
   import org.apache.commons.lang.builder.ToStringBuilder;  | 
  |  32 |     | 
   import org.joda.time.DateTime;  | 
  |  33 |     | 
   import org.kuali.rice.core.api.CoreConstants;  | 
  |  34 |     | 
   import org.kuali.rice.core.api.mo.ModelBuilder;  | 
  |  35 |     | 
   import org.kuali.rice.core.api.mo.ModelObjectComplete;  | 
  |  36 |     | 
   import org.w3c.dom.Element;  | 
  |  37 |     | 
     | 
  |  38 |     | 
   @XmlRootElement(name = Note.Constants.ROOT_ELEMENT_NAME)  | 
  |  39 |     | 
   @XmlAccessorType(XmlAccessType.NONE)  | 
  |  40 |     | 
   @XmlType(name = Note.Constants.TYPE_NAME, propOrder = { | 
  |  41 |     | 
               Note.Elements.ID,  | 
  |  42 |     | 
                   Note.Elements.DOCUMENT_ID,  | 
  |  43 |     | 
                   Note.Elements.AUTHOR_PRINCIPAL_ID,  | 
  |  44 |     | 
                   Note.Elements.CREATE_DATE,  | 
  |  45 |     | 
                   Note.Elements.TEXT,  | 
  |  46 |     | 
                   CoreConstants.CommonElements.VERSION_NUMBER,  | 
  |  47 |     | 
                   CoreConstants.CommonElements.FUTURE_ELEMENTS  | 
  |  48 |     | 
   })  | 
  |  49 |    0 |    public final class Note implements ModelObjectComplete, NoteContract { | 
  |  50 |     | 
     | 
  |  51 |     | 
           private static final long serialVersionUID = 6619061362854480922L;  | 
  |  52 |     | 
     | 
  |  53 |     | 
           @XmlElement(name = Elements.ID, required = false)  | 
  |  54 |     | 
       private final String id;  | 
  |  55 |     | 
             | 
  |  56 |     | 
       @XmlElement(name = Elements.DOCUMENT_ID, required = true)  | 
  |  57 |     | 
       private final String documentId;  | 
  |  58 |     | 
         | 
  |  59 |     | 
       @XmlElement(name = Elements.AUTHOR_PRINCIPAL_ID, required = true)  | 
  |  60 |     | 
       private final String authorPrincipalId;  | 
  |  61 |     | 
         | 
  |  62 |     | 
       @XmlElement(name = Elements.CREATE_DATE, required = false)  | 
  |  63 |     | 
       private final DateTime createDate;  | 
  |  64 |     | 
         | 
  |  65 |     | 
       @XmlElement(name = Elements.TEXT, required = false)  | 
  |  66 |     | 
       private final String text;  | 
  |  67 |     | 
         | 
  |  68 |     | 
       @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)  | 
  |  69 |     | 
       private final Long versionNumber;  | 
  |  70 |     | 
         | 
  |  71 |    0 |        @SuppressWarnings("unused") | 
  |  72 |     | 
       @XmlAnyElement  | 
  |  73 |     | 
       private final Collection<Element> _futureElements = null;  | 
  |  74 |     | 
     | 
  |  75 |     | 
         | 
  |  76 |     | 
     | 
  |  77 |     | 
     | 
  |  78 |     | 
     | 
  |  79 |    0 |        private Note() { | 
  |  80 |    0 |            this.id = null;  | 
  |  81 |    0 |                this.documentId = null;  | 
  |  82 |    0 |            this.authorPrincipalId = null;  | 
  |  83 |    0 |            this.createDate = null;  | 
  |  84 |    0 |            this.text = null;  | 
  |  85 |    0 |            this.versionNumber = null;  | 
  |  86 |    0 |        }  | 
  |  87 |     | 
     | 
  |  88 |    0 |        private Note(Builder builder) { | 
  |  89 |    0 |            this.id = builder.getId();  | 
  |  90 |    0 |                this.documentId = builder.getDocumentId();  | 
  |  91 |    0 |            this.authorPrincipalId = builder.getAuthorPrincipalId();  | 
  |  92 |    0 |            this.createDate = builder.getCreateDate();  | 
  |  93 |    0 |            this.text = builder.getText();  | 
  |  94 |    0 |            this.versionNumber = builder.getVersionNumber();  | 
  |  95 |    0 |        }  | 
  |  96 |     | 
     | 
  |  97 |     | 
       @Override  | 
  |  98 |     | 
       public String getId() { | 
  |  99 |    0 |            return this.id;  | 
  |  100 |     | 
       }  | 
  |  101 |     | 
     | 
  |  102 |     | 
       @Override  | 
  |  103 |     | 
       public String getDocumentId() { | 
  |  104 |    0 |            return this.documentId;  | 
  |  105 |     | 
       }  | 
  |  106 |     | 
     | 
  |  107 |     | 
       @Override  | 
  |  108 |     | 
       public String getAuthorPrincipalId() { | 
  |  109 |    0 |            return this.authorPrincipalId;  | 
  |  110 |     | 
       }  | 
  |  111 |     | 
     | 
  |  112 |     | 
       @Override  | 
  |  113 |     | 
       public DateTime getCreateDate() { | 
  |  114 |    0 |            return this.createDate;  | 
  |  115 |     | 
       }  | 
  |  116 |     | 
     | 
  |  117 |     | 
       @Override  | 
  |  118 |     | 
       public String getText() { | 
  |  119 |    0 |            return this.text;  | 
  |  120 |     | 
       }  | 
  |  121 |     | 
     | 
  |  122 |     | 
       @Override  | 
  |  123 |     | 
       public Long getVersionNumber() { | 
  |  124 |    0 |            return this.versionNumber;  | 
  |  125 |     | 
       }  | 
  |  126 |     | 
     | 
  |  127 |     | 
       @Override  | 
  |  128 |     | 
       public int hashCode() { | 
  |  129 |    0 |            return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);  | 
  |  130 |     | 
       }  | 
  |  131 |     | 
     | 
  |  132 |     | 
       @Override  | 
  |  133 |     | 
       public boolean equals(Object object) { | 
  |  134 |    0 |            return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE);  | 
  |  135 |     | 
       }  | 
  |  136 |     | 
     | 
  |  137 |     | 
       @Override  | 
  |  138 |     | 
       public String toString() { | 
  |  139 |    0 |            return ToStringBuilder.reflectionToString(this);  | 
  |  140 |     | 
       }  | 
  |  141 |     | 
     | 
  |  142 |     | 
     | 
  |  143 |     | 
         | 
  |  144 |     | 
     | 
  |  145 |     | 
     | 
  |  146 |    0 |        public final static class Builder implements Serializable, ModelBuilder, NoteContract { | 
  |  147 |     | 
     | 
  |  148 |     | 
                   private static final long serialVersionUID = 6457130539374835936L;  | 
  |  149 |     | 
     | 
  |  150 |     | 
                   private String id;  | 
  |  151 |     | 
           private String documentId;  | 
  |  152 |     | 
           private String authorPrincipalId;  | 
  |  153 |     | 
           private DateTime createDate;  | 
  |  154 |     | 
           private String text;  | 
  |  155 |     | 
           private Long versionNumber;  | 
  |  156 |     | 
     | 
  |  157 |    0 |            private Builder(String documentId, String authorPrincipalId) { | 
  |  158 |    0 |                setDocumentId(documentId);  | 
  |  159 |    0 |                setAuthorPrincipalId(authorPrincipalId);  | 
  |  160 |    0 |            }  | 
  |  161 |     | 
     | 
  |  162 |     | 
           public static Builder create(String documentId, String authorPrincipalId) { | 
  |  163 |    0 |                return new Builder(documentId, authorPrincipalId);  | 
  |  164 |     | 
           }  | 
  |  165 |     | 
     | 
  |  166 |     | 
           public static Builder create(NoteContract contract) { | 
  |  167 |    0 |                if (contract == null) { | 
  |  168 |    0 |                    throw new IllegalArgumentException("contract was null"); | 
  |  169 |     | 
               }  | 
  |  170 |     | 
                 | 
  |  171 |    0 |                Builder builder = create(contract.getDocumentId(), contract.getAuthorPrincipalId());  | 
  |  172 |    0 |                builder.setId(contract.getId());  | 
  |  173 |    0 |                builder.setCreateDate(contract.getCreateDate());  | 
  |  174 |    0 |                builder.setText(contract.getText());  | 
  |  175 |    0 |                builder.setVersionNumber(contract.getVersionNumber());  | 
  |  176 |    0 |                return builder;  | 
  |  177 |     | 
           }  | 
  |  178 |     | 
     | 
  |  179 |     | 
           public Note build() { | 
  |  180 |    0 |                return new Note(this);  | 
  |  181 |     | 
           }  | 
  |  182 |     | 
             | 
  |  183 |     | 
           @Override  | 
  |  184 |     | 
           public String getId() { | 
  |  185 |    0 |                return this.id;  | 
  |  186 |     | 
           }  | 
  |  187 |     | 
     | 
  |  188 |     | 
           @Override  | 
  |  189 |     | 
           public String getDocumentId() { | 
  |  190 |    0 |                return this.documentId;  | 
  |  191 |     | 
           }  | 
  |  192 |     | 
     | 
  |  193 |     | 
           @Override  | 
  |  194 |     | 
           public String getAuthorPrincipalId() { | 
  |  195 |    0 |                return this.authorPrincipalId;  | 
  |  196 |     | 
           }  | 
  |  197 |     | 
     | 
  |  198 |     | 
           @Override  | 
  |  199 |     | 
           public DateTime getCreateDate() { | 
  |  200 |    0 |                return this.createDate;  | 
  |  201 |     | 
           }  | 
  |  202 |     | 
     | 
  |  203 |     | 
           @Override  | 
  |  204 |     | 
           public String getText() { | 
  |  205 |    0 |                return this.text;  | 
  |  206 |     | 
           }  | 
  |  207 |     | 
     | 
  |  208 |     | 
           @Override  | 
  |  209 |     | 
           public Long getVersionNumber() { | 
  |  210 |    0 |                return this.versionNumber;  | 
  |  211 |     | 
           }  | 
  |  212 |     | 
     | 
  |  213 |     | 
           public void setId(String id) { | 
  |  214 |    0 |                this.id = id;  | 
  |  215 |    0 |            }  | 
  |  216 |     | 
     | 
  |  217 |     | 
           public void setDocumentId(String documentId) { | 
  |  218 |    0 |                    if (StringUtils.isBlank(documentId)) { | 
  |  219 |    0 |                            throw new IllegalArgumentException("documentId was null or blank"); | 
  |  220 |     | 
                   }  | 
  |  221 |    0 |                this.documentId = documentId;  | 
  |  222 |    0 |            }  | 
  |  223 |     | 
     | 
  |  224 |     | 
           public void setAuthorPrincipalId(String authorPrincipalId) { | 
  |  225 |    0 |                    if (StringUtils.isBlank(authorPrincipalId)) { | 
  |  226 |    0 |                            throw new IllegalArgumentException("authorPrincipalId was null or blank"); | 
  |  227 |     | 
                   }  | 
  |  228 |    0 |                this.authorPrincipalId = authorPrincipalId;  | 
  |  229 |    0 |            }  | 
  |  230 |     | 
     | 
  |  231 |     | 
           public void setCreateDate(DateTime createDate) { | 
  |  232 |    0 |                this.createDate = createDate;  | 
  |  233 |    0 |            }  | 
  |  234 |     | 
     | 
  |  235 |     | 
           public void setText(String text) { | 
  |  236 |    0 |                this.text = text;  | 
  |  237 |    0 |            }  | 
  |  238 |     | 
             | 
  |  239 |     | 
           public void setVersionNumber(Long versionNumber) { | 
  |  240 |    0 |                this.versionNumber = versionNumber;  | 
  |  241 |    0 |            }  | 
  |  242 |     | 
     | 
  |  243 |     | 
       }  | 
  |  244 |     | 
     | 
  |  245 |     | 
         | 
  |  246 |     | 
     | 
  |  247 |     | 
     | 
  |  248 |    0 |        static class Constants { | 
  |  249 |     | 
           final static String ROOT_ELEMENT_NAME = "note";  | 
  |  250 |     | 
           final static String TYPE_NAME = "NoteType";  | 
  |  251 |    0 |            final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS }; | 
  |  252 |     | 
       }  | 
  |  253 |     | 
     | 
  |  254 |     | 
         | 
  |  255 |     | 
     | 
  |  256 |     | 
     | 
  |  257 |    0 |        static class Elements { | 
  |  258 |     | 
           final static String DOCUMENT_ID = "documentId";  | 
  |  259 |     | 
           final static String AUTHOR_PRINCIPAL_ID = "authorPrincipalId";  | 
  |  260 |     | 
           final static String CREATE_DATE = "createDate";  | 
  |  261 |     | 
           final static String TEXT = "text";  | 
  |  262 |     | 
           final static String ID = "id";  | 
  |  263 |     | 
       }  | 
  |  264 |     | 
     | 
  |  265 |     | 
   }  | 
  |  266 |     | 
     |