View Javadoc

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.statement.entity;
17  
18  import java.util.List;
19  
20  import javax.persistence.CascadeType;
21  import javax.persistence.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.EnumType;
24  import javax.persistence.Enumerated;
25  import javax.persistence.JoinColumn;
26  import javax.persistence.JoinTable;
27  import javax.persistence.ManyToMany;
28  import javax.persistence.ManyToOne;
29  import javax.persistence.NamedQueries;
30  import javax.persistence.NamedQuery;
31  import javax.persistence.OneToMany;
32  import javax.persistence.Table;
33  
34  import org.kuali.student.common.entity.AttributeOwner;
35  import org.kuali.student.common.entity.MetaEntity;
36  import org.kuali.student.core.statement.dto.StatementOperatorTypeKey;
37  
38  @Entity
39  @Table(name = "KSST_STMT")
40  @NamedQueries( {
41      @NamedQuery(name = "Statement.getStatementsForStatementType", query = "SELECT ls FROM Statement ls WHERE ls.statementType.id = :statementTypeKey"),
42      @NamedQuery(name = "Statement.getStatements", query = "SELECT ls FROM Statement ls WHERE ls.id IN (:statementIdList)"),
43      @NamedQuery(name = "Statement.getStatementsForReqComponent", query = "SELECT ls FROM Statement ls JOIN ls.requiredComponents req WHERE req.id = :reqComponentId"),
44      @NamedQuery(name = "Statement.getParentStatement", query = "SELECT DISTINCT stmt FROM Statement stmt JOIN stmt.children children WHERE children.id = :childId"),
45      @NamedQuery(name = "Statement.getStatementsWithDependencies", query = "SELECT DISTINCT stmt, reqComp.id FROM Statement stmt, IN (stmt.requiredComponents) reqComp, IN (reqComp.reqComponentFields) field WHERE (field.type='kuali.reqComponent.field.type.course.cluSet.id' AND field.value IN(:cluSetIds)) OR (field.type='kuali.reqComponent.field.type.course.clu.id' AND field.value IN(:cluVersionIndIds))")
46  })
47  public class Statement extends MetaEntity implements AttributeOwner<StatementAttribute>{
48  
49      @Column(name="NAME")
50      private String name;
51  
52      @ManyToOne(cascade=CascadeType.ALL)
53      @JoinColumn(name = "RT_DESCR_ID")
54      private StatementRichText descr;
55  
56      @Column(name="ST")
57      private String state;
58  
59      @Column(name="OPERATOR")
60      @Enumerated(EnumType.STRING)
61      private StatementOperatorTypeKey operator;
62  
63      @OneToMany(cascade = {CascadeType.ALL})
64      @JoinTable(name = "KSST_STMT_JN_STMT", joinColumns = @JoinColumn(name = "STMT_ID"), inverseJoinColumns = @JoinColumn(name = "CHLD_STMT_ID"))
65      private List<Statement> children;
66  
67      @ManyToMany
68      @JoinTable(name = "KSST_STMT_JN_REQ_COM", joinColumns = @JoinColumn(name = "STMT_ID"), inverseJoinColumns = @JoinColumn(name = "REQ_COM_ID"))
69      private List<ReqComponent> requiredComponents;
70  
71      @ManyToOne
72      @JoinColumn(name = "STMT_TYPE_ID")
73      private StatementType statementType;
74  
75      @OneToMany(cascade = CascadeType.ALL)
76      @JoinColumn(name = "OWNER")
77      private List<StatementAttribute> attributes;
78  
79      @OneToMany(mappedBy = "statement")
80      private List<RefStatementRelation> refStatementRelations;
81  
82      public List<Statement> getChildren() {
83          return children;
84      }
85  
86      public void setChildren(List<Statement> children) {
87          this.children = children;
88      }
89  
90      public List<ReqComponent> getRequiredComponents() {
91          return requiredComponents;
92      }
93  
94      public void setRequiredComponents(List<ReqComponent> requiredComponents) {
95          this.requiredComponents = requiredComponents;
96      }
97  
98      public StatementType getStatementType() {
99          return statementType;
100     }
101 
102     public void setStatementType(StatementType statementType) {
103         this.statementType = statementType;
104     }
105 
106     public StatementOperatorTypeKey getOperator() {
107         return operator;
108     }
109 
110     public void setOperator(StatementOperatorTypeKey operator) {
111         this.operator = operator;
112     }
113 
114     public String getName() {
115         return name;
116     }
117 
118     public void setName(String name) {
119         this.name = name;
120     }
121 
122     public StatementRichText getDescr() {
123         return descr;
124     }
125 
126     public void setDescr(StatementRichText descr) {
127         this.descr = descr;
128     }
129 
130     @Override
131     public List<StatementAttribute> getAttributes() {
132         return attributes;
133     }
134 
135     @Override
136     public void setAttributes(List<StatementAttribute> attributes) {
137         this.attributes=attributes;
138     }
139 
140     public String getState() {
141         return state;
142     }
143 
144     public void setState(String state) {
145         this.state = state;
146     }
147 
148 	public List<RefStatementRelation> getRefStatementRelations() {
149 		return refStatementRelations;
150 	}
151 
152 	public void setRefStatementRelations(
153 			List<RefStatementRelation> refStatementRelations) {
154 		this.refStatementRelations = refStatementRelations;
155 	}
156 
157 	@Override
158 	public String toString() {
159 		return "Statement[id=" + getId() + ", statementType="
160 		+ (statementType == null ? "null" : statementType.getId())
161 		+ ", operator=" + operator + "]";
162 	}
163 }