Coverage Report - org.kuali.rice.kim.api.common.attribute.KimAttributeData
 
Classes in this File Line Coverage Branch Coverage Complexity
KimAttributeData
0%
0/31
0%
0/4
1.2
KimAttributeData$1
N/A
N/A
1.2
KimAttributeData$Builder
0%
0/43
0%
0/6
1.2
KimAttributeData$Constants
0%
0/1
N/A
1.2
KimAttributeData$Elements
0%
0/1
N/A
1.2
 
 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.kim.api.common.attribute;
 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.kim.api.type.KimType;
 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 java.io.Serializable;
 32  
 import java.util.Collection;
 33  
 
 34  
 
 35  0
 @XmlRootElement(name = KimAttributeData.Constants.ROOT_ELEMENT_NAME)
 36  
 @XmlAccessorType(XmlAccessType.NONE)
 37  
 @XmlType(name = KimAttributeData.Constants.TYPE_NAME, propOrder = {
 38  
         KimAttributeData.Elements.ID,
 39  
         KimAttributeData.Elements.ASSIGNED_TO_ID,
 40  
         KimAttributeData.Elements.KIM_TYPE_ID,
 41  
         KimAttributeData.Elements.KIM_TYPE,
 42  
         KimAttributeData.Elements.KIM_ATTRIBUTE,
 43  
         KimAttributeData.Elements.ATTRIBUTE_VALUE,
 44  
         CoreConstants.CommonElements.VERSION_NUMBER,
 45  
         CoreConstants.CommonElements.OBJECT_ID,
 46  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 47  
 })
 48  0
 public final class KimAttributeData extends AbstractDataTransferObject implements KimAttributeDataContract {
 49  
     @XmlElement(name = Elements.ID, required = false)
 50  
     private final String id;
 51  
 
 52  
     @XmlElement(name = Elements.ASSIGNED_TO_ID, required = false)
 53  
     private final String assignedToId;
 54  
 
 55  
     @XmlElement(name = Elements.KIM_TYPE_ID, required = true)
 56  
     private final String kimTypeId;
 57  
 
 58  
     @XmlElement(name = Elements.KIM_TYPE, required = false)
 59  
     private final KimType kimType;
 60  
 
 61  
     @XmlElement(name = Elements.KIM_ATTRIBUTE, required = false)
 62  
     private final KimAttribute kimAttribute;
 63  
 
 64  
     @XmlElement(name = Elements.ATTRIBUTE_VALUE, required = false)
 65  
     private final String attributeValue;
 66  
 
 67  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 68  
     private final Long versionNumber;
 69  
 
 70  
     @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
 71  
     private final String objectId;
 72  
 
 73  0
     @SuppressWarnings("unused")
 74  
     @XmlAnyElement
 75  
     private final Collection<Element> _futureElements = null;
 76  
 
 77  
     @SuppressWarnings("unused")
 78  0
     private KimAttributeData() {
 79  0
         this.id = null;
 80  0
         this.assignedToId = null;
 81  0
         this.kimTypeId = null;
 82  0
         this.kimType = null;
 83  0
         this.kimAttribute = null;
 84  0
         this.attributeValue = null;
 85  0
         this.versionNumber = null;
 86  0
         this.objectId = null;
 87  0
     }
 88  
 
 89  0
     private KimAttributeData(Builder builder) {
 90  0
         this.id = builder.getId();
 91  0
         this.assignedToId = builder.getAssignedToId();
 92  0
         this.kimTypeId = builder.getKimTypeId();
 93  0
         this.kimType =
 94  
                 builder.getKimType() != null ? builder.getKimType().build() : null;
 95  0
         this.kimAttribute =
 96  
                 builder.getKimAttribute() != null ? builder.getKimAttribute().build() : null;
 97  0
         this.attributeValue = builder.getAttributeValue();
 98  0
         this.versionNumber = builder.getVersionNumber();
 99  0
         this.objectId = builder.getObjectId();
 100  0
     }
 101  
 
 102  
     @Override
 103  
     public String getId() {
 104  0
         return id;
 105  
     }
 106  
 
 107  
     @Override
 108  
     public String getAssignedToId() {
 109  0
         return assignedToId;
 110  
     }
 111  
 
 112  
     @Override
 113  
     public String getKimTypeId() {
 114  0
         return kimTypeId;
 115  
     }
 116  
 
 117  
     @Override
 118  
     public KimType getKimType() {
 119  0
         return kimType;
 120  
     }
 121  
 
 122  
     @Override
 123  
     public KimAttribute getKimAttribute() {
 124  0
         return kimAttribute;
 125  
     }
 126  
 
 127  
     @Override
 128  
     public String getAttributeValue() {
 129  0
         return attributeValue;
 130  
     }
 131  
 
 132  
     @Override
 133  
     public Long getVersionNumber() {
 134  0
         return versionNumber;
 135  
     }
 136  
 
 137  
     @Override
 138  
     public String getObjectId() {
 139  0
         return objectId;
 140  
     }
 141  
 
 142  0
     public static final class Builder implements KimAttributeDataContract, ModelBuilder, Serializable {
 143  
         private String id;
 144  
         private String assignedToId;
 145  
         private String kimTypeId;
 146  
         private KimType.Builder kimType;
 147  
         private KimAttribute.Builder kimAttribute;
 148  
         private String attributeValue;
 149  
         private Long versionNumber;
 150  
         private String objectId;
 151  
 
 152  0
         private Builder(String kimTypeId) {
 153  0
             setKimTypeId(kimTypeId);
 154  0
         }
 155  
 
 156  
         /**
 157  
          * creates a Parameter with the required fields.
 158  
          */
 159  
         public static Builder create(String kimTypeId) {
 160  0
             return new Builder(kimTypeId);
 161  
         }
 162  
 
 163  
         /**
 164  
          * creates a KimAttributeData from an existing {@link org.kuali.rice.kim.api.common.attribute.KimAttributeContract}
 165  
          */
 166  
         public static Builder create(KimAttributeDataContract contract) {
 167  0
             Builder builder = new Builder(contract.getKimTypeId());
 168  0
             builder.setAssignedToId(contract.getAssignedToId());
 169  
 
 170  0
             builder.setId(contract.getId());
 171  0
             if (contract.getKimAttribute() != null) {
 172  0
                 builder.setKimAttribute(KimAttribute.Builder.create(contract.getKimAttribute()));
 173  
             }
 174  0
             if (contract.getKimType() != null) {
 175  0
                 builder.setKimType(KimType.Builder.create(contract.getKimType()));
 176  
             }
 177  0
             builder.setValue(contract.getAttributeValue());
 178  0
             builder.setVersionNumber(contract.getVersionNumber());
 179  0
             builder.setObjectId(contract.getObjectId());
 180  0
             return builder;
 181  
         }
 182  
 
 183  
         @Override
 184  
         public String getId() {
 185  0
             return id;
 186  
         }
 187  
 
 188  
         public void setId(final String id) {
 189  0
             if (StringUtils.isWhitespace(id)) {
 190  0
                 throw new IllegalArgumentException("id is blank");
 191  
             }
 192  0
             this.id = id;
 193  0
         }
 194  
 
 195  
         @Override
 196  
         public String getAssignedToId() {
 197  0
             return assignedToId;
 198  
         }
 199  
 
 200  
         public void setAssignedToId(final String assignedToId) {
 201  0
             this.assignedToId = assignedToId;
 202  0
         }
 203  
 
 204  
         @Override
 205  
         public String getKimTypeId(){
 206  0
             return kimTypeId;
 207  
         }
 208  
 
 209  
         public void setKimTypeId(String kimTypeId) {
 210  0
             this.kimTypeId = kimTypeId;
 211  0
         }
 212  
 
 213  
         @Override
 214  
         public KimType.Builder getKimType() {
 215  0
             return kimType;
 216  
         }
 217  
 
 218  
         public void setKimType(final KimType.Builder kimType) {
 219  0
             this.kimType = kimType;
 220  0
         }
 221  
 
 222  
         @Override
 223  
         public KimAttribute.Builder getKimAttribute() {
 224  0
             return kimAttribute;
 225  
         }
 226  
 
 227  
         public void setKimAttribute(final KimAttribute.Builder kimAttribute) {
 228  0
             this.kimAttribute = kimAttribute;
 229  0
         }
 230  
 
 231  
         @Override
 232  
         public String getAttributeValue() {
 233  0
             return attributeValue;
 234  
         }
 235  
 
 236  
         public void setValue(final String attributeValue) {
 237  0
             this.attributeValue = attributeValue;
 238  0
         }
 239  
 
 240  
         @Override
 241  
         public Long getVersionNumber() {
 242  0
             return versionNumber;
 243  
         }
 244  
 
 245  
         public void setVersionNumber(Long versionNumber) {
 246  0
             this.versionNumber = versionNumber;
 247  0
         }
 248  
 
 249  
         @Override
 250  
         public String getObjectId() {
 251  0
             return objectId;
 252  
         }
 253  
 
 254  
         public void setObjectId(final String objectId) {
 255  0
             this.objectId = objectId;
 256  0
         }
 257  
 
 258  
         @Override
 259  
         public KimAttributeData build() {
 260  0
             return new KimAttributeData(this);
 261  
         }
 262  
     }
 263  
 
 264  
     /**
 265  
      * Defines some internal constants used on this class.
 266  
      */
 267  0
     static class Constants {
 268  
         final static String ROOT_ELEMENT_NAME = "kimAttributeData";
 269  
         final static String TYPE_NAME = "KimAttributeDataType";
 270  
     }
 271  
 
 272  
     /**
 273  
      * A private class which exposes constants which define the XML element names to use
 274  
      * when this object is marshalled to XML.
 275  
      */
 276  0
     static class Elements {
 277  
         final static String ID = "id";
 278  
         final static String ASSIGNED_TO_ID = "assignedToId";
 279  
         final static String KIM_TYPE_ID = "kimTypeId";
 280  
         final static String KIM_TYPE = "kimType";
 281  
         final static String KIM_ATTRIBUTE = "kimAttribute";
 282  
         final static String ATTRIBUTE_VALUE = "attributeValue";
 283  
     }
 284  
 }