001
014
015 package com.liferay.portlet.asset.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.ProxyUtil;
021 import com.liferay.portal.kernel.util.StringBundler;
022 import com.liferay.portal.kernel.util.StringPool;
023 import com.liferay.portal.model.CacheModel;
024 import com.liferay.portal.model.impl.BaseModelImpl;
025 import com.liferay.portal.service.ServiceContext;
026 import com.liferay.portal.util.PortalUtil;
027
028 import com.liferay.portlet.asset.model.AssetLink;
029 import com.liferay.portlet.asset.model.AssetLinkModel;
030 import com.liferay.portlet.expando.model.ExpandoBridge;
031 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
032
033 import java.io.Serializable;
034
035 import java.sql.Types;
036
037 import java.util.Date;
038 import java.util.HashMap;
039 import java.util.Map;
040
041
054 public class AssetLinkModelImpl extends BaseModelImpl<AssetLink>
055 implements AssetLinkModel {
056
061 public static final String TABLE_NAME = "AssetLink";
062 public static final Object[][] TABLE_COLUMNS = {
063 { "linkId", Types.BIGINT },
064 { "companyId", Types.BIGINT },
065 { "userId", Types.BIGINT },
066 { "userName", Types.VARCHAR },
067 { "createDate", Types.TIMESTAMP },
068 { "entryId1", Types.BIGINT },
069 { "entryId2", Types.BIGINT },
070 { "type_", Types.INTEGER },
071 { "weight", Types.INTEGER }
072 };
073 public static final String TABLE_SQL_CREATE = "create table AssetLink (linkId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,entryId1 LONG,entryId2 LONG,type_ INTEGER,weight INTEGER)";
074 public static final String TABLE_SQL_DROP = "drop table AssetLink";
075 public static final String ORDER_BY_JPQL = " ORDER BY assetLink.weight ASC";
076 public static final String ORDER_BY_SQL = " ORDER BY AssetLink.weight ASC";
077 public static final String DATA_SOURCE = "liferayDataSource";
078 public static final String SESSION_FACTORY = "liferaySessionFactory";
079 public static final String TX_MANAGER = "liferayTransactionManager";
080 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081 "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetLink"),
082 true);
083 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084 "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetLink"),
085 true);
086 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087 "value.object.column.bitmask.enabled.com.liferay.portlet.asset.model.AssetLink"),
088 true);
089 public static long ENTRYID1_COLUMN_BITMASK = 1L;
090 public static long ENTRYID2_COLUMN_BITMASK = 2L;
091 public static long TYPE_COLUMN_BITMASK = 4L;
092 public static long WEIGHT_COLUMN_BITMASK = 8L;
093 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
094 "lock.expiration.time.com.liferay.portlet.asset.model.AssetLink"));
095
096 public AssetLinkModelImpl() {
097 }
098
099 public long getPrimaryKey() {
100 return _linkId;
101 }
102
103 public void setPrimaryKey(long primaryKey) {
104 setLinkId(primaryKey);
105 }
106
107 public Serializable getPrimaryKeyObj() {
108 return new Long(_linkId);
109 }
110
111 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
112 setPrimaryKey(((Long)primaryKeyObj).longValue());
113 }
114
115 public Class<?> getModelClass() {
116 return AssetLink.class;
117 }
118
119 public String getModelClassName() {
120 return AssetLink.class.getName();
121 }
122
123 @Override
124 public Map<String, Object> getModelAttributes() {
125 Map<String, Object> attributes = new HashMap<String, Object>();
126
127 attributes.put("linkId", getLinkId());
128 attributes.put("companyId", getCompanyId());
129 attributes.put("userId", getUserId());
130 attributes.put("userName", getUserName());
131 attributes.put("createDate", getCreateDate());
132 attributes.put("entryId1", getEntryId1());
133 attributes.put("entryId2", getEntryId2());
134 attributes.put("type", getType());
135 attributes.put("weight", getWeight());
136
137 return attributes;
138 }
139
140 @Override
141 public void setModelAttributes(Map<String, Object> attributes) {
142 Long linkId = (Long)attributes.get("linkId");
143
144 if (linkId != null) {
145 setLinkId(linkId);
146 }
147
148 Long companyId = (Long)attributes.get("companyId");
149
150 if (companyId != null) {
151 setCompanyId(companyId);
152 }
153
154 Long userId = (Long)attributes.get("userId");
155
156 if (userId != null) {
157 setUserId(userId);
158 }
159
160 String userName = (String)attributes.get("userName");
161
162 if (userName != null) {
163 setUserName(userName);
164 }
165
166 Date createDate = (Date)attributes.get("createDate");
167
168 if (createDate != null) {
169 setCreateDate(createDate);
170 }
171
172 Long entryId1 = (Long)attributes.get("entryId1");
173
174 if (entryId1 != null) {
175 setEntryId1(entryId1);
176 }
177
178 Long entryId2 = (Long)attributes.get("entryId2");
179
180 if (entryId2 != null) {
181 setEntryId2(entryId2);
182 }
183
184 Integer type = (Integer)attributes.get("type");
185
186 if (type != null) {
187 setType(type);
188 }
189
190 Integer weight = (Integer)attributes.get("weight");
191
192 if (weight != null) {
193 setWeight(weight);
194 }
195 }
196
197 public long getLinkId() {
198 return _linkId;
199 }
200
201 public void setLinkId(long linkId) {
202 _linkId = linkId;
203 }
204
205 public long getCompanyId() {
206 return _companyId;
207 }
208
209 public void setCompanyId(long companyId) {
210 _companyId = companyId;
211 }
212
213 public long getUserId() {
214 return _userId;
215 }
216
217 public void setUserId(long userId) {
218 _userId = userId;
219 }
220
221 public String getUserUuid() throws SystemException {
222 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
223 }
224
225 public void setUserUuid(String userUuid) {
226 _userUuid = userUuid;
227 }
228
229 public String getUserName() {
230 if (_userName == null) {
231 return StringPool.BLANK;
232 }
233 else {
234 return _userName;
235 }
236 }
237
238 public void setUserName(String userName) {
239 _userName = userName;
240 }
241
242 public Date getCreateDate() {
243 return _createDate;
244 }
245
246 public void setCreateDate(Date createDate) {
247 _createDate = createDate;
248 }
249
250 public long getEntryId1() {
251 return _entryId1;
252 }
253
254 public void setEntryId1(long entryId1) {
255 _columnBitmask |= ENTRYID1_COLUMN_BITMASK;
256
257 if (!_setOriginalEntryId1) {
258 _setOriginalEntryId1 = true;
259
260 _originalEntryId1 = _entryId1;
261 }
262
263 _entryId1 = entryId1;
264 }
265
266 public long getOriginalEntryId1() {
267 return _originalEntryId1;
268 }
269
270 public long getEntryId2() {
271 return _entryId2;
272 }
273
274 public void setEntryId2(long entryId2) {
275 _columnBitmask |= ENTRYID2_COLUMN_BITMASK;
276
277 if (!_setOriginalEntryId2) {
278 _setOriginalEntryId2 = true;
279
280 _originalEntryId2 = _entryId2;
281 }
282
283 _entryId2 = entryId2;
284 }
285
286 public long getOriginalEntryId2() {
287 return _originalEntryId2;
288 }
289
290 public int getType() {
291 return _type;
292 }
293
294 public void setType(int type) {
295 _columnBitmask |= TYPE_COLUMN_BITMASK;
296
297 if (!_setOriginalType) {
298 _setOriginalType = true;
299
300 _originalType = _type;
301 }
302
303 _type = type;
304 }
305
306 public int getOriginalType() {
307 return _originalType;
308 }
309
310 public int getWeight() {
311 return _weight;
312 }
313
314 public void setWeight(int weight) {
315 _columnBitmask = -1L;
316
317 _weight = weight;
318 }
319
320 public long getColumnBitmask() {
321 return _columnBitmask;
322 }
323
324 @Override
325 public ExpandoBridge getExpandoBridge() {
326 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
327 AssetLink.class.getName(), getPrimaryKey());
328 }
329
330 @Override
331 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
332 ExpandoBridge expandoBridge = getExpandoBridge();
333
334 expandoBridge.setAttributes(serviceContext);
335 }
336
337 @Override
338 public AssetLink toEscapedModel() {
339 if (_escapedModel == null) {
340 _escapedModel = (AssetLink)ProxyUtil.newProxyInstance(_classLoader,
341 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
342 }
343
344 return _escapedModel;
345 }
346
347 @Override
348 public Object clone() {
349 AssetLinkImpl assetLinkImpl = new AssetLinkImpl();
350
351 assetLinkImpl.setLinkId(getLinkId());
352 assetLinkImpl.setCompanyId(getCompanyId());
353 assetLinkImpl.setUserId(getUserId());
354 assetLinkImpl.setUserName(getUserName());
355 assetLinkImpl.setCreateDate(getCreateDate());
356 assetLinkImpl.setEntryId1(getEntryId1());
357 assetLinkImpl.setEntryId2(getEntryId2());
358 assetLinkImpl.setType(getType());
359 assetLinkImpl.setWeight(getWeight());
360
361 assetLinkImpl.resetOriginalValues();
362
363 return assetLinkImpl;
364 }
365
366 public int compareTo(AssetLink assetLink) {
367 int value = 0;
368
369 if (getWeight() < assetLink.getWeight()) {
370 value = -1;
371 }
372 else if (getWeight() > assetLink.getWeight()) {
373 value = 1;
374 }
375 else {
376 value = 0;
377 }
378
379 if (value != 0) {
380 return value;
381 }
382
383 return 0;
384 }
385
386 @Override
387 public boolean equals(Object obj) {
388 if (obj == null) {
389 return false;
390 }
391
392 AssetLink assetLink = null;
393
394 try {
395 assetLink = (AssetLink)obj;
396 }
397 catch (ClassCastException cce) {
398 return false;
399 }
400
401 long primaryKey = assetLink.getPrimaryKey();
402
403 if (getPrimaryKey() == primaryKey) {
404 return true;
405 }
406 else {
407 return false;
408 }
409 }
410
411 @Override
412 public int hashCode() {
413 return (int)getPrimaryKey();
414 }
415
416 @Override
417 public void resetOriginalValues() {
418 AssetLinkModelImpl assetLinkModelImpl = this;
419
420 assetLinkModelImpl._originalEntryId1 = assetLinkModelImpl._entryId1;
421
422 assetLinkModelImpl._setOriginalEntryId1 = false;
423
424 assetLinkModelImpl._originalEntryId2 = assetLinkModelImpl._entryId2;
425
426 assetLinkModelImpl._setOriginalEntryId2 = false;
427
428 assetLinkModelImpl._originalType = assetLinkModelImpl._type;
429
430 assetLinkModelImpl._setOriginalType = false;
431
432 assetLinkModelImpl._columnBitmask = 0;
433 }
434
435 @Override
436 public CacheModel<AssetLink> toCacheModel() {
437 AssetLinkCacheModel assetLinkCacheModel = new AssetLinkCacheModel();
438
439 assetLinkCacheModel.linkId = getLinkId();
440
441 assetLinkCacheModel.companyId = getCompanyId();
442
443 assetLinkCacheModel.userId = getUserId();
444
445 assetLinkCacheModel.userName = getUserName();
446
447 String userName = assetLinkCacheModel.userName;
448
449 if ((userName != null) && (userName.length() == 0)) {
450 assetLinkCacheModel.userName = null;
451 }
452
453 Date createDate = getCreateDate();
454
455 if (createDate != null) {
456 assetLinkCacheModel.createDate = createDate.getTime();
457 }
458 else {
459 assetLinkCacheModel.createDate = Long.MIN_VALUE;
460 }
461
462 assetLinkCacheModel.entryId1 = getEntryId1();
463
464 assetLinkCacheModel.entryId2 = getEntryId2();
465
466 assetLinkCacheModel.type = getType();
467
468 assetLinkCacheModel.weight = getWeight();
469
470 return assetLinkCacheModel;
471 }
472
473 @Override
474 public String toString() {
475 StringBundler sb = new StringBundler(19);
476
477 sb.append("{linkId=");
478 sb.append(getLinkId());
479 sb.append(", companyId=");
480 sb.append(getCompanyId());
481 sb.append(", userId=");
482 sb.append(getUserId());
483 sb.append(", userName=");
484 sb.append(getUserName());
485 sb.append(", createDate=");
486 sb.append(getCreateDate());
487 sb.append(", entryId1=");
488 sb.append(getEntryId1());
489 sb.append(", entryId2=");
490 sb.append(getEntryId2());
491 sb.append(", type=");
492 sb.append(getType());
493 sb.append(", weight=");
494 sb.append(getWeight());
495 sb.append("}");
496
497 return sb.toString();
498 }
499
500 public String toXmlString() {
501 StringBundler sb = new StringBundler(31);
502
503 sb.append("<model><model-name>");
504 sb.append("com.liferay.portlet.asset.model.AssetLink");
505 sb.append("</model-name>");
506
507 sb.append(
508 "<column><column-name>linkId</column-name><column-value><![CDATA[");
509 sb.append(getLinkId());
510 sb.append("]]></column-value></column>");
511 sb.append(
512 "<column><column-name>companyId</column-name><column-value><![CDATA[");
513 sb.append(getCompanyId());
514 sb.append("]]></column-value></column>");
515 sb.append(
516 "<column><column-name>userId</column-name><column-value><![CDATA[");
517 sb.append(getUserId());
518 sb.append("]]></column-value></column>");
519 sb.append(
520 "<column><column-name>userName</column-name><column-value><![CDATA[");
521 sb.append(getUserName());
522 sb.append("]]></column-value></column>");
523 sb.append(
524 "<column><column-name>createDate</column-name><column-value><![CDATA[");
525 sb.append(getCreateDate());
526 sb.append("]]></column-value></column>");
527 sb.append(
528 "<column><column-name>entryId1</column-name><column-value><![CDATA[");
529 sb.append(getEntryId1());
530 sb.append("]]></column-value></column>");
531 sb.append(
532 "<column><column-name>entryId2</column-name><column-value><![CDATA[");
533 sb.append(getEntryId2());
534 sb.append("]]></column-value></column>");
535 sb.append(
536 "<column><column-name>type</column-name><column-value><![CDATA[");
537 sb.append(getType());
538 sb.append("]]></column-value></column>");
539 sb.append(
540 "<column><column-name>weight</column-name><column-value><![CDATA[");
541 sb.append(getWeight());
542 sb.append("]]></column-value></column>");
543
544 sb.append("</model>");
545
546 return sb.toString();
547 }
548
549 private static ClassLoader _classLoader = AssetLink.class.getClassLoader();
550 private static Class<?>[] _escapedModelInterfaces = new Class[] {
551 AssetLink.class
552 };
553 private long _linkId;
554 private long _companyId;
555 private long _userId;
556 private String _userUuid;
557 private String _userName;
558 private Date _createDate;
559 private long _entryId1;
560 private long _originalEntryId1;
561 private boolean _setOriginalEntryId1;
562 private long _entryId2;
563 private long _originalEntryId2;
564 private boolean _setOriginalEntryId2;
565 private int _type;
566 private int _originalType;
567 private boolean _setOriginalType;
568 private int _weight;
569 private long _columnBitmask;
570 private AssetLink _escapedModel;
571 }