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.proposal.entity;
17  
18  import java.util.Date;
19  import java.util.List;
20  
21  import javax.persistence.AttributeOverride;
22  import javax.persistence.CascadeType;
23  import javax.persistence.Column;
24  import javax.persistence.Entity;
25  import javax.persistence.FetchType;
26  import javax.persistence.JoinColumn;
27  import javax.persistence.JoinTable;
28  import javax.persistence.ManyToMany;
29  import javax.persistence.ManyToOne;
30  import javax.persistence.NamedQueries;
31  import javax.persistence.NamedQuery;
32  import javax.persistence.OneToMany;
33  import javax.persistence.Table;
34  import javax.persistence.Temporal;
35  import javax.persistence.TemporalType;
36  
37  import org.kuali.student.common.entity.AttributeOwner;
38  import org.kuali.student.common.entity.MetaEntity;
39  
40  /**
41   * Proposal
42   *
43   * @author Kuali Rice Team (kuali-rice@googlegroups.com)
44   *
45   */
46  @Entity
47  @Table(name = "KSPR_PROPOSAL")
48  @NamedQueries( {
49      @NamedQuery(name = "Proposal.getProposalsByIdList", query = "SELECT p FROM Proposal p WHERE p.id IN (:idList)"),
50      @NamedQuery(name = "Proposal.getProposalsByProposalType", query = "SELECT DISTINCT p FROM Proposal p WHERE p.type.id = :proposalTypeId"),
51      @NamedQuery(name = "Proposal.getProposalsByReference", query = "SELECT r.proposals FROM ProposalReference r WHERE r.objectReferenceId = :referenceId AND r.type.id = :referenceTypeId"),
52      @NamedQuery(name = "Proposal.getProposalsByState", query = "SELECT DISTINCT p FROM Proposal p WHERE p.state = :proposalState AND p.type.id = :proposalTypeId"),
53      @NamedQuery(name = "Proposal.getProposalByWorkflowId", query = "SELECT DISTINCT p FROM Proposal p WHERE p.workflowId = :workflowId"),
54      @NamedQuery(name = "Proposal.getProposalTypesForReferenceType", query = "SELECT DISTINCT p.type FROM ProposalReference r JOIN r.proposals p WHERE r.type.id = :referenceTypeId")
55  })
56  @AttributeOverride(name="id", column=@Column(name="PROPOSAL_ID"))
57  public class Proposal extends MetaEntity implements AttributeOwner<ProposalAttribute> {
58  
59  	@Column(name="WORKFLOW_ID")
60      private String workflowId;
61  
62  	@Column(name="NAME")
63      private String name;
64  
65      @OneToMany(cascade = CascadeType.ALL, mappedBy = "proposal")
66      private List<ProposalPerson> proposerPerson;
67  
68      @OneToMany(cascade = CascadeType.ALL, mappedBy = "proposal")
69      private List<ProposalOrg> proposerOrg;
70  
71      @ManyToMany(fetch=FetchType.EAGER)
72      @JoinTable(name="KSPR_PROPOSAL_JN_REFERENCE",
73              joinColumns=
74              @JoinColumn(name="PROPOSAL_ID", referencedColumnName="PROPOSAL_ID"),
75        inverseJoinColumns=
76              @JoinColumn(name="REFERENCE_ID", referencedColumnName="REFERENCE_ID")
77      )
78      private List<ProposalReference> proposalReference;
79  
80      @Column(name = "RATIONALE")
81      private String rationale;
82  
83      @Column(name = "DETAIL_DESC")
84      private String detailDesc;
85  
86      @Temporal(TemporalType.TIMESTAMP)
87      @Column(name = "EFF_DT")
88      private Date effectiveDate;
89  
90      @Temporal(TemporalType.TIMESTAMP)
91      @Column(name = "EXPIR_DT")
92      private Date expirationDate;
93  
94      @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
95      private List<ProposalAttribute> attributes;
96  
97      @ManyToOne(optional=true)
98      @JoinColumn(name = "TYPE")
99      private ProposalType type;
100 
101     @Column(name = "STATE")
102     private String state;
103 
104     public String getName() {
105         return name;
106     }
107 
108     public void setName(String name) {
109         this.name = name;
110     }
111 
112     public List<ProposalPerson> getProposerPerson() {
113         return proposerPerson;
114     }
115 
116     public void setProposerPerson(List<ProposalPerson> proposerPerson) {
117         this.proposerPerson = proposerPerson;
118     }
119 
120     public List<ProposalOrg> getProposerOrg() {
121         return proposerOrg;
122     }
123 
124     public void setProposerOrg(List<ProposalOrg> proposerOrg) {
125         this.proposerOrg = proposerOrg;
126     }
127 
128 
129     public List<ProposalReference> getProposalReference() {
130         return proposalReference;
131     }
132 
133     public void setProposalReference(List<ProposalReference> proposalReference) {
134         this.proposalReference = proposalReference;
135     }
136 
137     public String getRationale() {
138         return rationale;
139     }
140 
141     public void setRationale(String rationale) {
142         this.rationale = rationale;
143     }
144 
145     public String getDetailDesc() {
146         return detailDesc;
147     }
148 
149     public void setDetailDesc(String detailDesc) {
150         this.detailDesc = detailDesc;
151     }
152 
153     public Date getEffectiveDate() {
154         return effectiveDate;
155     }
156 
157     public void setEffectiveDate(Date effectiveDate) {
158         this.effectiveDate = effectiveDate;
159     }
160 
161     public Date getExpirationDate() {
162         return expirationDate;
163     }
164 
165     public void setExpirationDate(Date expirationDate) {
166         this.expirationDate = expirationDate;
167     }
168 
169     public ProposalType getType() {
170         return type;
171     }
172 
173     public void setType(ProposalType type) {
174         this.type = type;
175     }
176 
177     public String getState() {
178         return state;
179     }
180 
181     public void setState(String state) {
182         this.state = state;
183     }
184 
185     @Override
186     public List<ProposalAttribute> getAttributes() {
187         return attributes;
188     }
189 
190     @Override
191     public void setAttributes(List<ProposalAttribute> attributes) {
192         this.attributes = attributes;
193     }
194 
195     public String getWorkflowId() {
196 		return workflowId;
197 	}
198 
199 	public void setWorkflowId(String workflowId) {
200 		this.workflowId = workflowId;
201 	}
202 }