001
014
015 package com.liferay.portal.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020 import com.liferay.portal.kernel.json.JSON;
021 import com.liferay.portal.kernel.util.GetterUtil;
022 import com.liferay.portal.kernel.util.ProxyUtil;
023 import com.liferay.portal.kernel.util.StringBundler;
024 import com.liferay.portal.kernel.util.StringPool;
025 import com.liferay.portal.model.CacheModel;
026 import com.liferay.portal.model.ListType;
027 import com.liferay.portal.model.ListTypeModel;
028 import com.liferay.portal.model.ListTypeSoap;
029 import com.liferay.portal.service.ServiceContext;
030
031 import com.liferay.portlet.expando.model.ExpandoBridge;
032 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033
034 import java.io.Serializable;
035
036 import java.sql.Types;
037
038 import java.util.ArrayList;
039 import java.util.HashMap;
040 import java.util.List;
041 import java.util.Map;
042
043
056 @JSON(strict = true)
057 @ProviderType
058 public class ListTypeModelImpl extends BaseModelImpl<ListType>
059 implements ListTypeModel {
060
065 public static final String TABLE_NAME = "ListType";
066 public static final Object[][] TABLE_COLUMNS = {
067 { "mvccVersion", Types.BIGINT },
068 { "listTypeId", Types.BIGINT },
069 { "name", Types.VARCHAR },
070 { "type_", Types.VARCHAR }
071 };
072 public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
073
074 static {
075 TABLE_COLUMNS_MAP.put("mvccVersion", Types.BIGINT);
076 TABLE_COLUMNS_MAP.put("listTypeId", Types.BIGINT);
077 TABLE_COLUMNS_MAP.put("name", Types.VARCHAR);
078 TABLE_COLUMNS_MAP.put("type_", Types.VARCHAR);
079 }
080
081 public static final String TABLE_SQL_CREATE = "create table ListType (mvccVersion LONG default 0,listTypeId LONG not null primary key,name VARCHAR(75) null,type_ VARCHAR(75) null)";
082 public static final String TABLE_SQL_DROP = "drop table ListType";
083 public static final String ORDER_BY_JPQL = " ORDER BY listType.name ASC";
084 public static final String ORDER_BY_SQL = " ORDER BY ListType.name ASC";
085 public static final String DATA_SOURCE = "liferayDataSource";
086 public static final String SESSION_FACTORY = "liferaySessionFactory";
087 public static final String TX_MANAGER = "liferayTransactionManager";
088 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089 "value.object.entity.cache.enabled.com.liferay.portal.model.ListType"),
090 true);
091 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
092 "value.object.finder.cache.enabled.com.liferay.portal.model.ListType"),
093 true);
094 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
095 "value.object.column.bitmask.enabled.com.liferay.portal.model.ListType"),
096 true);
097 public static final long NAME_COLUMN_BITMASK = 1L;
098 public static final long TYPE_COLUMN_BITMASK = 2L;
099
100
106 public static ListType toModel(ListTypeSoap soapModel) {
107 if (soapModel == null) {
108 return null;
109 }
110
111 ListType model = new ListTypeImpl();
112
113 model.setMvccVersion(soapModel.getMvccVersion());
114 model.setListTypeId(soapModel.getListTypeId());
115 model.setName(soapModel.getName());
116 model.setType(soapModel.getType());
117
118 return model;
119 }
120
121
127 public static List<ListType> toModels(ListTypeSoap[] soapModels) {
128 if (soapModels == null) {
129 return null;
130 }
131
132 List<ListType> models = new ArrayList<ListType>(soapModels.length);
133
134 for (ListTypeSoap soapModel : soapModels) {
135 models.add(toModel(soapModel));
136 }
137
138 return models;
139 }
140
141 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
142 "lock.expiration.time.com.liferay.portal.model.ListType"));
143
144 public ListTypeModelImpl() {
145 }
146
147 @Override
148 public long getPrimaryKey() {
149 return _listTypeId;
150 }
151
152 @Override
153 public void setPrimaryKey(long primaryKey) {
154 setListTypeId(primaryKey);
155 }
156
157 @Override
158 public Serializable getPrimaryKeyObj() {
159 return _listTypeId;
160 }
161
162 @Override
163 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
164 setPrimaryKey(((Long)primaryKeyObj).longValue());
165 }
166
167 @Override
168 public Class<?> getModelClass() {
169 return ListType.class;
170 }
171
172 @Override
173 public String getModelClassName() {
174 return ListType.class.getName();
175 }
176
177 @Override
178 public Map<String, Object> getModelAttributes() {
179 Map<String, Object> attributes = new HashMap<String, Object>();
180
181 attributes.put("mvccVersion", getMvccVersion());
182 attributes.put("listTypeId", getListTypeId());
183 attributes.put("name", getName());
184 attributes.put("type", getType());
185
186 attributes.put("entityCacheEnabled", isEntityCacheEnabled());
187 attributes.put("finderCacheEnabled", isFinderCacheEnabled());
188
189 return attributes;
190 }
191
192 @Override
193 public void setModelAttributes(Map<String, Object> attributes) {
194 Long mvccVersion = (Long)attributes.get("mvccVersion");
195
196 if (mvccVersion != null) {
197 setMvccVersion(mvccVersion);
198 }
199
200 Long listTypeId = (Long)attributes.get("listTypeId");
201
202 if (listTypeId != null) {
203 setListTypeId(listTypeId);
204 }
205
206 String name = (String)attributes.get("name");
207
208 if (name != null) {
209 setName(name);
210 }
211
212 String type = (String)attributes.get("type");
213
214 if (type != null) {
215 setType(type);
216 }
217 }
218
219 @JSON
220 @Override
221 public long getMvccVersion() {
222 return _mvccVersion;
223 }
224
225 @Override
226 public void setMvccVersion(long mvccVersion) {
227 _mvccVersion = mvccVersion;
228 }
229
230 @JSON
231 @Override
232 public long getListTypeId() {
233 return _listTypeId;
234 }
235
236 @Override
237 public void setListTypeId(long listTypeId) {
238 _listTypeId = listTypeId;
239 }
240
241 @JSON
242 @Override
243 public String getName() {
244 if (_name == null) {
245 return StringPool.BLANK;
246 }
247 else {
248 return _name;
249 }
250 }
251
252 @Override
253 public void setName(String name) {
254 _columnBitmask = -1L;
255
256 if (_originalName == null) {
257 _originalName = _name;
258 }
259
260 _name = name;
261 }
262
263 public String getOriginalName() {
264 return GetterUtil.getString(_originalName);
265 }
266
267 @JSON
268 @Override
269 public String getType() {
270 if (_type == null) {
271 return StringPool.BLANK;
272 }
273 else {
274 return _type;
275 }
276 }
277
278 @Override
279 public void setType(String type) {
280 _columnBitmask |= TYPE_COLUMN_BITMASK;
281
282 if (_originalType == null) {
283 _originalType = _type;
284 }
285
286 _type = type;
287 }
288
289 public String getOriginalType() {
290 return GetterUtil.getString(_originalType);
291 }
292
293 public long getColumnBitmask() {
294 return _columnBitmask;
295 }
296
297 @Override
298 public ExpandoBridge getExpandoBridge() {
299 return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
300 ListType.class.getName(), getPrimaryKey());
301 }
302
303 @Override
304 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
305 ExpandoBridge expandoBridge = getExpandoBridge();
306
307 expandoBridge.setAttributes(serviceContext);
308 }
309
310 @Override
311 public ListType toEscapedModel() {
312 if (_escapedModel == null) {
313 _escapedModel = (ListType)ProxyUtil.newProxyInstance(_classLoader,
314 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
315 }
316
317 return _escapedModel;
318 }
319
320 @Override
321 public Object clone() {
322 ListTypeImpl listTypeImpl = new ListTypeImpl();
323
324 listTypeImpl.setMvccVersion(getMvccVersion());
325 listTypeImpl.setListTypeId(getListTypeId());
326 listTypeImpl.setName(getName());
327 listTypeImpl.setType(getType());
328
329 listTypeImpl.resetOriginalValues();
330
331 return listTypeImpl;
332 }
333
334 @Override
335 public int compareTo(ListType listType) {
336 int value = 0;
337
338 value = getName().compareToIgnoreCase(listType.getName());
339
340 if (value != 0) {
341 return value;
342 }
343
344 return 0;
345 }
346
347 @Override
348 public boolean equals(Object obj) {
349 if (this == obj) {
350 return true;
351 }
352
353 if (!(obj instanceof ListType)) {
354 return false;
355 }
356
357 ListType listType = (ListType)obj;
358
359 long primaryKey = listType.getPrimaryKey();
360
361 if (getPrimaryKey() == primaryKey) {
362 return true;
363 }
364 else {
365 return false;
366 }
367 }
368
369 @Override
370 public int hashCode() {
371 return (int)getPrimaryKey();
372 }
373
374 @Override
375 public boolean isEntityCacheEnabled() {
376 return ENTITY_CACHE_ENABLED;
377 }
378
379 @Override
380 public boolean isFinderCacheEnabled() {
381 return FINDER_CACHE_ENABLED;
382 }
383
384 @Override
385 public void resetOriginalValues() {
386 ListTypeModelImpl listTypeModelImpl = this;
387
388 listTypeModelImpl._originalName = listTypeModelImpl._name;
389
390 listTypeModelImpl._originalType = listTypeModelImpl._type;
391
392 listTypeModelImpl._columnBitmask = 0;
393 }
394
395 @Override
396 public CacheModel<ListType> toCacheModel() {
397 ListTypeCacheModel listTypeCacheModel = new ListTypeCacheModel();
398
399 listTypeCacheModel.mvccVersion = getMvccVersion();
400
401 listTypeCacheModel.listTypeId = getListTypeId();
402
403 listTypeCacheModel.name = getName();
404
405 String name = listTypeCacheModel.name;
406
407 if ((name != null) && (name.length() == 0)) {
408 listTypeCacheModel.name = null;
409 }
410
411 listTypeCacheModel.type = getType();
412
413 String type = listTypeCacheModel.type;
414
415 if ((type != null) && (type.length() == 0)) {
416 listTypeCacheModel.type = null;
417 }
418
419 return listTypeCacheModel;
420 }
421
422 @Override
423 public String toString() {
424 StringBundler sb = new StringBundler(9);
425
426 sb.append("{mvccVersion=");
427 sb.append(getMvccVersion());
428 sb.append(", listTypeId=");
429 sb.append(getListTypeId());
430 sb.append(", name=");
431 sb.append(getName());
432 sb.append(", type=");
433 sb.append(getType());
434 sb.append("}");
435
436 return sb.toString();
437 }
438
439 @Override
440 public String toXmlString() {
441 StringBundler sb = new StringBundler(16);
442
443 sb.append("<model><model-name>");
444 sb.append("com.liferay.portal.model.ListType");
445 sb.append("</model-name>");
446
447 sb.append(
448 "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
449 sb.append(getMvccVersion());
450 sb.append("]]></column-value></column>");
451 sb.append(
452 "<column><column-name>listTypeId</column-name><column-value><![CDATA[");
453 sb.append(getListTypeId());
454 sb.append("]]></column-value></column>");
455 sb.append(
456 "<column><column-name>name</column-name><column-value><![CDATA[");
457 sb.append(getName());
458 sb.append("]]></column-value></column>");
459 sb.append(
460 "<column><column-name>type</column-name><column-value><![CDATA[");
461 sb.append(getType());
462 sb.append("]]></column-value></column>");
463
464 sb.append("</model>");
465
466 return sb.toString();
467 }
468
469 private static final ClassLoader _classLoader = ListType.class.getClassLoader();
470 private static final Class<?>[] _escapedModelInterfaces = new Class[] {
471 ListType.class
472 };
473 private long _mvccVersion;
474 private long _listTypeId;
475 private String _name;
476 private String _originalName;
477 private String _type;
478 private String _originalType;
479 private long _columnBitmask;
480 private ListType _escapedModel;
481 }