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.setNew(isNew());
172 model.setEscapedModel(true);
173
174 model.setCodeId(getCodeId());
175 model.setCompanyId(getCompanyId());
176 model.setName(HtmlUtil.escape(getName()));
177 model.setScope(getScope());
178
179 model = (ResourceCode)Proxy.newProxyInstance(ResourceCode.class.getClassLoader(),
180 new Class[] { ResourceCode.class },
181 new ReadOnlyBeanHandler(model));
182
183 return model;
184 }
185 }
186
187 public Object clone() {
188 ResourceCodeImpl clone = new ResourceCodeImpl();
189
190 clone.setCodeId(getCodeId());
191 clone.setCompanyId(getCompanyId());
192 clone.setName(getName());
193 clone.setScope(getScope());
194
195 return clone;
196 }
197
198 public int compareTo(Object obj) {
199 if (obj == null) {
200 return -1;
201 }
202
203 ResourceCodeImpl resourceCode = (ResourceCodeImpl)obj;
204
205 long pk = resourceCode.getPrimaryKey();
206
207 if (getPrimaryKey() < pk) {
208 return -1;
209 }
210 else if (getPrimaryKey() > pk) {
211 return 1;
212 }
213 else {
214 return 0;
215 }
216 }
217
218 public boolean equals(Object obj) {
219 if (obj == null) {
220 return false;
221 }
222
223 ResourceCodeImpl resourceCode = null;
224
225 try {
226 resourceCode = (ResourceCodeImpl)obj;
227 }
228 catch (ClassCastException cce) {
229 return false;
230 }
231
232 long pk = resourceCode.getPrimaryKey();
233
234 if (getPrimaryKey() == pk) {
235 return true;
236 }
237 else {
238 return false;
239 }
240 }
241
242 public int hashCode() {
243 return (int)getPrimaryKey();
244 }
245
246 private long _codeId;
247 private long _companyId;
248 private String _name;
249 private int _scope;
250 }