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