View Javadoc

1   /**
2    * Copyright 2011-2013 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.mobility.security.authz.entity;
17  
18  import java.io.Serializable;
19  
20  import javax.persistence.Column;
21  import javax.persistence.Entity;
22  import javax.persistence.GeneratedValue;
23  import javax.persistence.GenerationType;
24  import javax.persistence.Id;
25  import javax.persistence.Table;
26  import javax.persistence.Transient;
27  import javax.persistence.Version;
28  import javax.xml.bind.annotation.XmlRootElement;
29  import javax.xml.bind.annotation.XmlTransient;
30  
31  import org.kuali.mobility.security.authz.expression.Expression;
32  import org.kuali.mobility.security.authz.util.XstreamUtility;
33  
34  @Entity(name = "AclExpression")
35  @Table(name = "KME_ACL_EXP_T")
36  @XmlRootElement(name="aclExpression")
37  public class AclExpression implements Serializable {
38  
39  	private static final long serialVersionUID = -6549847275619160154L;
40  
41      @Id
42      @GeneratedValue(strategy = GenerationType.TABLE)
43      @Column(name = "ID")
44  	private Long id;
45  
46      @Column(name = "HM_SCRN_ID")
47      private Long homeScreenId;
48  
49      @Column(name = "TOOL_ID")
50  	private Long toolId;
51  
52  	@Column(name = "PRMSSN_MODE")
53  	private String permissionMode;
54  
55  	@Column(name = "PRMSSN_TYP")
56  	private String permissionType;
57  
58  	@Column(name = "ACL_EXP")
59  	private String expression;
60  
61      @Version
62      @Column(name="VER_NBR")
63      protected Long versionNumber;
64  
65  	@Transient
66  	@XmlTransient
67  	Expression parsedExpression;
68  
69  	public AclExpression copy(boolean includeIds) {
70  		AclExpression copy = new AclExpression();
71  
72  		if (includeIds) {
73  			if (id != null) {
74  				copy.setId(new Long(id));
75  			}
76  			if (versionNumber != null) {
77  				copy.setVersionNumber(new Long(versionNumber));
78  			}
79  		}
80          if (homeScreenId != null) {
81              copy.setHomeScreenId(new Long(homeScreenId));
82          }
83  		if (toolId != null) {
84  			copy.setToolId(new Long(toolId));
85  		}
86  		if (permissionMode != null) {
87  			copy.setPermissionMode(new String(permissionMode));
88  		}
89  		if (permissionType != null) {
90  			copy.setPermissionType(new String(permissionType));
91  		}
92  		if (expression != null) {
93  			copy.setExpression(new String(expression));
94  		}
95  		return copy;
96  	}
97  
98  	public Long getId() {
99  		return id;
100 	}
101 
102 	public void setId(Long id) {
103 		this.id = id;
104 	}
105 
106 	public Long getHomeScreenId() {
107         return homeScreenId;
108     }
109 
110     public void setHomeScreenId(Long homeScreenId) {
111         this.homeScreenId = homeScreenId;
112     }
113 
114     public Long getToolId() {
115 		return toolId;
116 	}
117 
118 	public void setToolId(Long toolId) {
119 		this.toolId = toolId;
120 	}
121 
122 	public String getPermissionMode() {
123 		return permissionMode;
124 	}
125 
126 	public void setPermissionMode(String permissionMode) {
127 		this.permissionMode = permissionMode;
128 	}
129 
130 	public String getPermissionType() {
131 		return permissionType;
132 	}
133 
134 	public void setPermissionType(String permissionType) {
135 		this.permissionType = permissionType;
136 	}
137 
138 	public String getExpression() {
139 		return expression;
140 	}
141 
142 	public void setExpression(String expression) {
143 		this.expression = expression;
144 	}
145 
146     public Long getVersionNumber() {
147         return versionNumber;
148     }
149     public void setVersionNumber(Long versionNumber) {
150         this.versionNumber = versionNumber;
151     }
152 
153 	@XmlTransient
154 	public Expression getParsedExpression() {
155 		if (parsedExpression != null) {
156 		    return parsedExpression;
157 		}
158 
159 		if (expression != null) {
160 		    parsedExpression = XstreamUtility.xmlToExpression(expression);
161 		}
162 
163 		return parsedExpression;
164 	}
165 
166 	public void setParsedExpression(Expression parsedExpression) {
167 		this.parsedExpression = parsedExpression;
168 	}
169 
170 }