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.common.ui.server.applicationstate.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.Id;
24  import javax.persistence.JoinTable;
25  import javax.persistence.NamedQueries;
26  import javax.persistence.NamedQuery;
27  import javax.persistence.OneToMany;
28  import javax.persistence.PrePersist;
29  import javax.persistence.Table;
30  import javax.persistence.UniqueConstraint;
31  
32  import org.kuali.student.common.util.UUIDHelper;
33  
34  @Entity
35  @Table(name = "KSAP_APP_STATE_T", 
36         uniqueConstraints={@UniqueConstraint(columnNames={"APPLICATION_ID", "REFERENCE_KEY", "REFERENCE_TYPE", "USER_ID"})})
37  @NamedQueries( {
38          @NamedQuery(name = "ApplicationState.getApplicationStateByAppRefUserId", query = "SELECT appState FROM ApplicationState appState WHERE appState.applicationId =:applicationId AND appState.referenceKey =:referenceKey AND appState.referenceType =:referenceType AND appState.userId =:userId")
39  } )
40  public class ApplicationState {
41  
42  	@Id
43      @Column(name = "ID")
44  	private String id;
45  	
46  	@Column(name = "APPLICATION_ID", nullable=false)
47  	private String applicationId;
48  
49  	@Column(name = "REFERENCE_KEY", nullable=false)
50  	private String referenceKey;
51  
52  	@Column(name = "REFERENCE_TYPE", nullable=false)
53  	private String referenceType;
54  
55  	@Column(name = "USER_ID", nullable=false)
56  	private String userId;
57  
58  	@OneToMany(cascade = CascadeType.ALL)
59  	@JoinTable(name="KS_APP_ST_JN_KEY_VALUE")	
60  	private List<KeyValuePair> keyValueList;
61  
62  	/**
63  	 * AutoGenerate the Id
64  	 */
65  	@PrePersist
66  	public void prePersist() {
67  		this.id = UUIDHelper.genStringUUID(this.id);
68  	}
69  
70  	public String getId() {
71  		return id;
72  	}
73  
74  	public void setId(String id) {
75  		this.id = id;
76  	}
77  
78  	public String getApplicationId() {
79  		return applicationId;
80  	}
81  
82  	public void setApplicationId(String applicationId) {
83  		this.applicationId = applicationId;
84  	}
85  	
86  	public String getReferenceKey() {
87  		return referenceKey;
88  	}
89  	
90  	public void setReferenceKey(String referenceKey) {
91  		this.referenceKey = referenceKey;
92  	}
93  	
94  	public String getReferenceType() {
95  		return referenceType;
96  	}
97  	
98  	public void setReferenceType(String referenceType) {
99  		this.referenceType = referenceType;
100 	}
101 	
102 	public String getUserId() {
103 		return userId;
104 	}
105 	
106 	public void setUserId(String userId) {
107 		this.userId = userId;
108 	}
109 
110 	public List<KeyValuePair> getKeyValueList() {
111 		return keyValueList;
112 	}
113 
114 	public void setKeyValueList(List<KeyValuePair> keyValueList) {
115 		this.keyValueList = keyValueList;
116 	}
117 
118 	@Override
119 	public String toString() {
120 		return "ApplicationState[id=" + id + ", applicationId=" + applicationId 
121 				+ ", referenceKey=" + referenceKey + ", referenceType="
122 				+ referenceType + ", userId=" + userId + "]";
123 	}
124 }