001    /**
002     * Copyright 2010 The Kuali Foundation Licensed under the
003     * Educational Community License, Version 2.0 (the "License"); you may
004     * not use this file except in compliance with the License. You may
005     * obtain a copy of the License at
006     *
007     * http://www.osedu.org/licenses/ECL-2.0
008     *
009     * Unless required by applicable law or agreed to in writing,
010     * software distributed under the License is distributed on an "AS IS"
011     * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012     * or implied. See the License for the specific language governing
013     * permissions and limitations under the License.
014     */
015    
016    package org.kuali.student.lum.lu.entity;
017    
018    import java.util.Date;
019    import java.util.List;
020    
021    import javax.persistence.CascadeType;
022    import javax.persistence.Column;
023    import javax.persistence.Entity;
024    import javax.persistence.JoinColumn;
025    import javax.persistence.ManyToOne;
026    import javax.persistence.NamedQueries;
027    import javax.persistence.NamedQuery;
028    import javax.persistence.OneToMany;
029    import javax.persistence.Table;
030    import javax.persistence.Temporal;
031    import javax.persistence.TemporalType;
032    
033    import org.kuali.student.common.entity.AttributeOwner;
034    import org.kuali.student.common.entity.MetaEntity;
035    
036    @Entity
037    @Table(name = "KSLU_CLUCLU_RELTN")
038    @NamedQueries({
039            @NamedQuery(name="CluCluRelation.getCluCluRelation", query="SELECT rel FROM CluCluRelation rel WHERE rel.clu.id = :cluId or rel.relatedClu.id = :cluId"),
040            @NamedQuery(name="CluCluRelation.getRelatedCluIdsByCluId", query="SELECT rel.relatedClu.id FROM CluCluRelation rel WHERE rel.clu.id = :cluId AND rel.luLuRelationType.id = :luLuRelationTypeId"),
041            @NamedQuery(name="CluCluRelation.getCluIdsByRelatedCluId", query = "SELECT rel.clu.id FROM CluCluRelation rel WHERE rel.relatedClu.id = :relatedCluId AND rel.luLuRelationType.id = :luLuRelationTypeId"),
042            @NamedQuery(name="CluCluRelation.getRelationTypeByCluId", query="SELECT distinct rel.luLuRelationType.id FROM CluCluRelation rel WHERE rel.clu.id = :cluId AND rel.relatedClu.id = :relatedCluId"),
043            @NamedQuery(name="CluCluRelation.getRelatedClusByCluId", query="SELECT rel.relatedClu FROM CluCluRelation rel WHERE rel.clu.id = :cluId AND rel.luLuRelationType.id = :luLuRelationTypeId"),
044            @NamedQuery(name="CluCluRelation.getClusByRelatedCluId", query="SELECT rel.clu FROM CluCluRelation rel WHERE rel.relatedClu.id = :relatedCluId AND rel.luLuRelationType.id = :luLuRelationTypeId"),
045            @NamedQuery(name="CluCluRelation.getRelatedClusByCluIdSt", query="SELECT rel.relatedClu FROM CluCluRelation rel WHERE rel.clu.id = :cluId AND rel.luLuRelationType.id = :luLuRelationTypeId AND rel.relatedClu.state in (:luStateList)"),
046            @NamedQuery(name="CluCluRelation.getClusByRelatedCluIdSt", query="SELECT rel.clu FROM CluCluRelation rel WHERE rel.relatedClu.id = :relatedCluId AND rel.luLuRelationType.id = :luLuRelationTypeId AND rel.clu.state in (:luStateList)")
047    })
048    public class CluCluRelation extends MetaEntity implements
049                    AttributeOwner<CluCluRelationAttribute> {
050            
051            @ManyToOne
052            @JoinColumn(name="CLU_ID")
053            private Clu clu;
054            
055            @ManyToOne
056            @JoinColumn(name="RELATED_CLU_ID")
057            private Clu relatedClu;
058            
059            @ManyToOne
060            @JoinColumn(name="LU_RELTN_TYPE_ID")
061            private LuLuRelationType luLuRelationType;
062            
063            @Column(name = "CLU_RELTN_REQ")
064            private boolean cluRelationRequired;
065    
066            @Temporal(TemporalType.TIMESTAMP)
067            @Column(name = "EFF_DT")
068        private Date effectiveDate;
069    
070            @Temporal(TemporalType.TIMESTAMP)
071            @Column(name = "EXPIR_DT")
072            private Date expirationDate;
073    
074            @Column(name = "ST")
075            private String state;
076    
077            @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
078            private List<CluCluRelationAttribute> attributes;
079            
080            public Clu getClu() {
081                    return clu;
082            }
083    
084            public void setClu(Clu clu) {
085                    this.clu = clu;
086            }
087    
088            public Clu getRelatedClu() {
089                    return relatedClu;
090            }
091    
092            public void setRelatedClu(Clu relatedClu) {
093                    this.relatedClu = relatedClu;
094            }
095    
096            public LuLuRelationType getLuLuRelationType() {
097                    return luLuRelationType;
098            }
099    
100            public void setLuLuRelationType(LuLuRelationType luLuRelationType) {
101                    this.luLuRelationType = luLuRelationType;
102            }
103    
104            public boolean isCluRelationRequired() {
105                    return cluRelationRequired;
106            }
107    
108            public void setCluRelationRequired(boolean cluRelationRequired) {
109                    this.cluRelationRequired = cluRelationRequired;
110            }
111    
112            public Date getEffectiveDate() {
113                    return effectiveDate;
114            }
115    
116            public void setEffectiveDate(Date effectiveDate) {
117                    this.effectiveDate = effectiveDate;
118            }
119    
120            public Date getExpirationDate() {
121                    return expirationDate;
122            }
123    
124            public void setExpirationDate(Date expirationDate) {
125                    this.expirationDate = expirationDate;
126            }
127    
128            public String getState() {
129                    return state;
130            }
131    
132            public void setState(String state) {
133                    this.state = state;
134            }
135            
136            @Override
137        public List<CluCluRelationAttribute> getAttributes() {
138                    return attributes;
139            }
140    
141            @Override
142        public void setAttributes(List<CluCluRelationAttribute> attributes) {
143                    this.attributes = attributes;
144            }
145    }