Coverage Report - org.kuali.student.r2.common.entity.TypeEntity
 
Classes in this File Line Coverage Branch Coverage Complexity
TypeEntity
0%
0/20
0%
0/2
1.2
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.r2.common.entity;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import javax.persistence.CascadeType;
 22  
 import javax.persistence.Column;
 23  
 import javax.persistence.MappedSuperclass;
 24  
 import javax.persistence.OneToMany;
 25  
 
 26  
 import org.kuali.student.r2.common.dto.AttributeInfo;
 27  
 import org.kuali.student.r2.common.dto.TypeInfo;
 28  
 
 29  
 
 30  
 @MappedSuperclass
 31  0
 public abstract class TypeEntity<T extends BaseAttributeEntity<?>> extends BaseTypeEntity implements AttributeOwner<T>  {
 32  
 
 33  
         @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
 34  
         private List<T> attributes;
 35  
 
 36  
     @Column(name = "REF_OBJECT_URI")
 37  
     private String refObjectURI;
 38  
 
 39  
         /**
 40  
          * This overridden method ...
 41  
          * 
 42  
          * @see org.kuali.student.r2.common.entity.AttributeOwner#setAttributes(java.util.List)
 43  
          */
 44  
         @Override
 45  
         public void setAttributes(List<T> attributes) { 
 46  0
                 this.attributes = attributes;
 47  0
         }
 48  
 
 49  
         /**
 50  
          * This overridden method ...
 51  
          * 
 52  
          * @see org.kuali.student.r2.common.entity.AttributeOwner#getAttributes()
 53  
          */
 54  
         @Override
 55  
         public List<T> getAttributes() {
 56  0
                 return attributes;
 57  
         }
 58  
 
 59  
     public void setRefObjectURI(String refObjectURI) {
 60  0
         this.refObjectURI = refObjectURI;
 61  0
     }
 62  
 
 63  
     public String getRefObjectURI() {
 64  0
         return refObjectURI;
 65  
     }
 66  
 
 67  
         public TypeInfo toDto() {
 68  0
                 TypeInfo typeInfo = new TypeInfo();
 69  0
                 typeInfo.setName(this.getName());
 70  0
                 typeInfo.setKey(this.getId());
 71  0
                 typeInfo.setRefObjectURI(getRefObjectURI());
 72  0
                 typeInfo.setDescr(this.getDescr());
 73  0
                 typeInfo.setEffectiveDate(this.getEffectiveDate());
 74  0
                 typeInfo.setExpirationDate(this.getExpirationDate());
 75  0
                 typeInfo.setAttributes(new ArrayList<AttributeInfo>());
 76  
 
 77  
                 // TODO - refactor this into a central place; probably Igor's Converter
 78  0
                 List<AttributeInfo> atts = new ArrayList<AttributeInfo>();
 79  0
                 for (BaseAttributeEntity<?> att : this.getAttributes()) {
 80  0
                         atts.add(att.toDto());
 81  
                 }
 82  
                 // end refactor
 83  0
                 typeInfo.setAttributes(atts);
 84  
                 
 85  0
                 return typeInfo;
 86  
         }
 87  
 }