1
22
23 package com.liferay.portal.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.kernel.util.HtmlUtil;
28 import com.liferay.portal.model.ResourceCode;
29 import com.liferay.portal.model.ResourceCodeSoap;
30
31 import java.io.Serializable;
32
33 import java.lang.reflect.Proxy;
34
35 import java.sql.Types;
36
37 import java.util.ArrayList;
38 import java.util.List;
39
40
60 public class ResourceCodeModelImpl extends BaseModelImpl {
61 public static final String TABLE_NAME = "ResourceCode";
62 public static final Object[][] TABLE_COLUMNS = {
63 { "codeId", new Integer(Types.BIGINT) },
64
65
66 { "companyId", new Integer(Types.BIGINT) },
67
68
69 { "name", new Integer(Types.VARCHAR) },
70
71
72 { "scope", new Integer(Types.INTEGER) }
73 };
74 public static final String TABLE_SQL_CREATE = "create table ResourceCode (codeId LONG not null primary key,companyId LONG,name VARCHAR(300) null,scope INTEGER)";
75 public static final String TABLE_SQL_DROP = "drop table ResourceCode";
76 public static final String DATA_SOURCE = "liferayDataSource";
77 public static final String SESSION_FACTORY = "liferaySessionFactory";
78 public static final String TX_MANAGER = "liferayTransactionManager";
79 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80 "value.object.finder.cache.enabled.com.liferay.portal.model.ResourceCode"),
81 true);
82
83 public static ResourceCode toModel(ResourceCodeSoap soapModel) {
84 ResourceCode model = new ResourceCodeImpl();
85
86 model.setCodeId(soapModel.getCodeId());
87 model.setCompanyId(soapModel.getCompanyId());
88 model.setName(soapModel.getName());
89 model.setScope(soapModel.getScope());
90
91 return model;
92 }
93
94 public static List<ResourceCode> toModels(ResourceCodeSoap[] soapModels) {
95 List<ResourceCode> models = new ArrayList<ResourceCode>(soapModels.length);
96
97 for (ResourceCodeSoap soapModel : soapModels) {
98 models.add(toModel(soapModel));
99 }
100
101 return models;
102 }
103
104 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
105 "lock.expiration.time.com.liferay.portal.model.ResourceCode"));
106
107 public ResourceCodeModelImpl() {
108 }
109
110 public long getPrimaryKey() {
111 return _codeId;
112 }
113
114 public void setPrimaryKey(long pk) {
115 setCodeId(pk);
116 }
117
118 public Serializable getPrimaryKeyObj() {
119 return new Long(_codeId);
120 }
121
122 public long getCodeId() {
123 return _codeId;
124 }
125
126 public void setCodeId(long codeId) {
127 if (codeId != _codeId) {
128 _codeId = codeId;
129 }
130 }
131
132 public long getCompanyId() {
133 return _companyId;
134 }
135
136 public void setCompanyId(long companyId) {
137 if (companyId != _companyId) {
138 _companyId = companyId;
139 }
140 }
141
142 public String getName() {
143 return GetterUtil.getString(_name);
144 }
145
146 public void setName(String name) {
147 if (((name == null) && (_name != null)) ||
148 ((name != null) && (_name == null)) ||
149 ((name != null) && (_name != null) && !name.equals(_name))) {
150 _name = name;
151 }
152 }
153
154 public int getScope() {
155 return _scope;
156 }
157
158 public void setScope(int scope) {
159 if (scope != _scope) {
160 _scope = scope;
161 }
162 }
163
164 public ResourceCode toEscapedModel() {
165 if (isEscapedModel()) {
166 return (ResourceCode)this;
167 }
168 else {
169 ResourceCode model = new ResourceCodeImpl();
170
171 model.setEscapedModel(true);
172
173 model.setCodeId(getCodeId());
174 model.setCompanyId(getCompanyId());
175 model.setName(HtmlUtil.escape(getName()));
176 model.setScope(getScope());
177
178 model = (ResourceCode)Proxy.newProxyInstance(ResourceCode.class.getClassLoader(),
179 new Class[] { ResourceCode.class },
180 new ReadOnlyBeanHandler(model));
181
182 return model;
183 }
184 }
185
186 public Object clone() {
187 ResourceCodeImpl clone = new ResourceCodeImpl();
188
189 clone.setCodeId(getCodeId());
190 clone.setCompanyId(getCompanyId());
191 clone.setName(getName());
192 clone.setScope(getScope());
193
194 return clone;
195 }
196
197 public int compareTo(Object obj) {
198 if (obj == null) {
199 return -1;
200 }
201
202 ResourceCodeImpl resourceCode = (ResourceCodeImpl)obj;
203
204 long pk = resourceCode.getPrimaryKey();
205
206 if (getPrimaryKey() < pk) {
207 return -1;
208 }
209 else if (getPrimaryKey() > pk) {
210 return 1;
211 }
212 else {
213 return 0;
214 }
215 }
216
217 public boolean equals(Object obj) {
218 if (obj == null) {
219 return false;
220 }
221
222 ResourceCodeImpl resourceCode = null;
223
224 try {
225 resourceCode = (ResourceCodeImpl)obj;
226 }
227 catch (ClassCastException cce) {
228 return false;
229 }
230
231 long pk = resourceCode.getPrimaryKey();
232
233 if (getPrimaryKey() == pk) {
234 return true;
235 }
236 else {
237 return false;
238 }
239 }
240
241 public int hashCode() {
242 return (int)getPrimaryKey();
243 }
244
245 private long _codeId;
246 private long _companyId;
247 private String _name;
248 private int _scope;
249 }