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