Coverage Report - org.kuali.student.core.organization.entity.OrgOrgRelation
 
Classes in this File Line Coverage Branch Coverage Complexity
OrgOrgRelation
100%
27/27
N/A
1
 
 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.core.organization.entity;
 17  
 
 18  
 import java.util.Date;
 19  
 import java.util.List;
 20  
 
 21  
 import javax.persistence.CascadeType;
 22  
 import javax.persistence.Column;
 23  
 import javax.persistence.Entity;
 24  
 import javax.persistence.Id;
 25  
 import javax.persistence.JoinColumn;
 26  
 import javax.persistence.ManyToOne;
 27  
 import javax.persistence.NamedQueries;
 28  
 import javax.persistence.NamedQuery;
 29  
 import javax.persistence.OneToMany;
 30  
 import javax.persistence.Table;
 31  
 import javax.persistence.Temporal;
 32  
 import javax.persistence.TemporalType;
 33  
 
 34  
 import org.kuali.student.common.util.UUIDHelper;
 35  
 import org.kuali.student.core.entity.AttributeOwner;
 36  
 import org.kuali.student.core.entity.MetaEntity;
 37  
 
 38  
 @Entity
 39  
 @Table(name = "KSOR_ORG_ORG_RELTN")
 40  
 @NamedQueries( {
 41  
                 @NamedQuery(name = "OrgOrgRelation.getAllDescendants", query = "SELECT oor.relatedOrg.id FROM OrgOrgRelation oor "
 42  
                                 + " WHERE oor.org.id = :orgId "
 43  
                                 + "   AND oor.type.orgHierarchy.id = :orgHierarchy"
 44  
                                 + "   AND oor.org.effectiveDate<=CURRENT_TIMESTAMP  "
 45  
                                 + "   AND (oor.org.expirationDate IS NULL OR oor.org.expirationDate>=CURRENT_TIMESTAMP)"),
 46  
                 @NamedQuery(name = "OrgOrgRelation.getAncestors", query = "SELECT oor.org.id FROM OrgOrgRelation oor "
 47  
                                 + " WHERE oor.relatedOrg.id = :orgId "
 48  
                 + "   AND oor.type.orgHierarchy.id = :orgHierarchy"
 49  
                 + "   AND oor.relatedOrg.effectiveDate<=CURRENT_TIMESTAMP  "
 50  
                 + "   AND (oor.relatedOrg.expirationDate IS NULL OR oor.relatedOrg.expirationDate>=CURRENT_TIMESTAMP)"),
 51  
                 @NamedQuery(name = "OrgOrgRelation.getOrgOrgRelationsByIdList", query = "SELECT oor FROM OrgOrgRelation oor WHERE oor.id IN (:idList)"),
 52  
                 @NamedQuery(name = "OrgOrgRelation.OrgOrgRelation", query = "SELECT oor FROM OrgOrgRelation oor WHERE oor.org.id = :orgId"),
 53  
                 @NamedQuery(name = "OrgOrgRelation.getOrgOrgRelationsByRelatedOrg", query = "SELECT oor FROM OrgOrgRelation oor WHERE oor.relatedOrg.id = :relatedOrgId"),
 54  
                 @NamedQuery(name = "OrgOrgRelation.getOrgTreeInfo", query = "SELECT NEW org.kuali.student.core.organization.dto.OrgTreeInfo(oor.relatedOrg.id, oor.org.id, oor.relatedOrg.longName) "
 55  
                                 + "   FROM OrgOrgRelation oor "
 56  
                                 + "  WHERE oor.org.id = :orgId "
 57  
                                 + "    AND oor.type.orgHierarchy.id = :orgHierarchyId " 
 58  
                 + "   AND oor.relatedOrg.effectiveDate<=CURRENT_TIMESTAMP  "
 59  
                 + "   AND (oor.relatedOrg.expirationDate IS NULL OR oor.relatedOrg.expirationDate>=CURRENT_TIMESTAMP)"),
 60  
                 @NamedQuery(name = "OrgOrgRelation.hasOrgOrgRelation", query = "SELECT COUNT(oor) "
 61  
                                 + "  FROM OrgOrgRelation oor "
 62  
                                 + " WHERE oor.org.id = :orgId "
 63  
                                 + "   AND oor.relatedOrg.id = :comparisonOrgId "
 64  
                                 + "   AND oor.type.id = :orgOrgRelationTypeKey") })
 65  16
 public class OrgOrgRelation extends MetaEntity implements
 66  
                 AttributeOwner<OrgOrgRelationAttribute> {
 67  
         @Id
 68  
         @Column(name = "ID")
 69  
         private String id;
 70  
 
 71  
         @ManyToOne
 72  
         @JoinColumn(name = "ORG")
 73  
         private Org org;
 74  
 
 75  
         @ManyToOne
 76  
         @JoinColumn(name = "RELATED_ORG")
 77  
         private Org relatedOrg;
 78  
 
 79  
         @Temporal(TemporalType.TIMESTAMP)
 80  
         @Column(name = "EFF_DT")
 81  
         private Date effectiveDate;
 82  
 
 83  
         @Temporal(TemporalType.TIMESTAMP)
 84  
         @Column(name = "EXPIR_DT")
 85  
         private Date expirationDate;
 86  
 
 87  
         @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
 88  
         private List<OrgOrgRelationAttribute> attributes;
 89  
 
 90  
         @ManyToOne
 91  
         @JoinColumn(name = "TYPE")
 92  
         private OrgOrgRelationType type;
 93  
 
 94  
         @Column(name = "ST")
 95  
         private String state;
 96  
 
 97  
         /**
 98  
          * AutoGenerate the Id
 99  
          */
 100  
         @Override
 101  
         public void onPrePersist() {
 102  1
                 this.id = UUIDHelper.genStringUUID(this.id);
 103  1
         }
 104  
 
 105  
         public String getId() {
 106  15
                 return id;
 107  
         }
 108  
 
 109  
         public void setId(String id) {
 110  1
                 this.id = id;
 111  1
         }
 112  
 
 113  
         public Org getOrg() {
 114  15
                 return org;
 115  
         }
 116  
 
 117  
         public void setOrg(Org org) {
 118  1
                 this.org = org;
 119  1
         }
 120  
 
 121  
         public Org getRelatedOrg() {
 122  15
                 return relatedOrg;
 123  
         }
 124  
 
 125  
         public void setRelatedOrg(Org relatedOrg) {
 126  1
                 this.relatedOrg = relatedOrg;
 127  1
         }
 128  
 
 129  
         public Date getEffectiveDate() {
 130  15
                 return effectiveDate;
 131  
         }
 132  
 
 133  
         public void setEffectiveDate(Date effectiveDate) {
 134  1
                 this.effectiveDate = effectiveDate;
 135  1
         }
 136  
 
 137  
         public Date getExpirationDate() {
 138  15
                 return expirationDate;
 139  
         }
 140  
 
 141  
         public void setExpirationDate(Date expirationDate) {
 142  1
                 this.expirationDate = expirationDate;
 143  1
         }
 144  
 
 145  
         @Override
 146  
         public List<OrgOrgRelationAttribute> getAttributes() {
 147  18
                 return attributes;
 148  
         }
 149  
 
 150  
         @Override
 151  
         public void setAttributes(List<OrgOrgRelationAttribute> attributes) {
 152  2
                 this.attributes = attributes;
 153  2
         }
 154  
 
 155  
         public OrgOrgRelationType getType() {
 156  15
                 return type;
 157  
         }
 158  
 
 159  
         public void setType(OrgOrgRelationType type) {
 160  1
                 this.type = type;
 161  1
         }
 162  
 
 163  
         public String getState() {
 164  15
                 return state;
 165  
         }
 166  
 
 167  
         public void setState(String state) {
 168  1
                 this.state = state;
 169  1
         }
 170  
 
 171  
 }