1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
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 | 151 | 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 | 402 | return children; |
84 | |
} |
85 | |
|
86 | |
public void setChildren(List<Statement> children) { |
87 | 38 | this.children = children; |
88 | 38 | } |
89 | |
|
90 | |
public List<ReqComponent> getRequiredComponents() { |
91 | 275 | return requiredComponents; |
92 | |
} |
93 | |
|
94 | |
public void setRequiredComponents(List<ReqComponent> requiredComponents) { |
95 | 47 | this.requiredComponents = requiredComponents; |
96 | 47 | } |
97 | |
|
98 | |
public StatementType getStatementType() { |
99 | 39 | return statementType; |
100 | |
} |
101 | |
|
102 | |
public void setStatementType(StatementType statementType) { |
103 | 16 | this.statementType = statementType; |
104 | 16 | } |
105 | |
|
106 | |
public StatementOperatorTypeKey getOperator() { |
107 | 241 | return operator; |
108 | |
} |
109 | |
|
110 | |
public void setOperator(StatementOperatorTypeKey operator) { |
111 | 69 | this.operator = operator; |
112 | 69 | } |
113 | |
|
114 | |
public String getName() { |
115 | 78 | return name; |
116 | |
} |
117 | |
|
118 | |
public void setName(String name) { |
119 | 8 | this.name = name; |
120 | 8 | } |
121 | |
|
122 | |
public StatementRichText getDescr() { |
123 | 39 | return descr; |
124 | |
} |
125 | |
|
126 | |
public void setDescr(StatementRichText descr) { |
127 | 8 | this.descr = descr; |
128 | 8 | } |
129 | |
|
130 | |
@Override |
131 | |
public List<StatementAttribute> getAttributes() { |
132 | 63 | return attributes; |
133 | |
} |
134 | |
|
135 | |
@Override |
136 | |
public void setAttributes(List<StatementAttribute> attributes) { |
137 | 12 | this.attributes=attributes; |
138 | 12 | } |
139 | |
|
140 | |
public String getState() { |
141 | 39 | return state; |
142 | |
} |
143 | |
|
144 | |
public void setState(String state) { |
145 | 8 | this.state = state; |
146 | 8 | } |
147 | |
|
148 | |
public List<RefStatementRelation> getRefStatementRelations() { |
149 | 1 | return refStatementRelations; |
150 | |
} |
151 | |
|
152 | |
public void setRefStatementRelations( |
153 | |
List<RefStatementRelation> refStatementRelations) { |
154 | 0 | this.refStatementRelations = refStatementRelations; |
155 | 0 | } |
156 | |
|
157 | |
@Override |
158 | |
public String toString() { |
159 | 0 | return "Statement[id=" + getId() + ", statementType=" |
160 | |
+ (statementType == null ? "null" : statementType.getId()) |
161 | |
+ ", operator=" + operator + "]"; |
162 | |
} |
163 | |
} |