001
014
015 package com.liferay.portlet.social.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.json.JSON;
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.kernel.util.Validator;
024 import com.liferay.portal.model.CacheModel;
025 import com.liferay.portal.model.impl.BaseModelImpl;
026 import com.liferay.portal.service.ServiceContext;
027 import com.liferay.portal.util.PortalUtil;
028
029 import com.liferay.portlet.expando.model.ExpandoBridge;
030 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031 import com.liferay.portlet.social.model.SocialActivitySetting;
032 import com.liferay.portlet.social.model.SocialActivitySettingModel;
033 import com.liferay.portlet.social.model.SocialActivitySettingSoap;
034
035 import java.io.Serializable;
036
037 import java.sql.Types;
038
039 import java.util.ArrayList;
040 import java.util.HashMap;
041 import java.util.List;
042 import java.util.Map;
043
044
057 @JSON(strict = true)
058 public class SocialActivitySettingModelImpl extends BaseModelImpl<SocialActivitySetting>
059 implements SocialActivitySettingModel {
060
065 public static final String TABLE_NAME = "SocialActivitySetting";
066 public static final Object[][] TABLE_COLUMNS = {
067 { "activitySettingId", Types.BIGINT },
068 { "groupId", Types.BIGINT },
069 { "companyId", Types.BIGINT },
070 { "classNameId", Types.BIGINT },
071 { "activityType", Types.INTEGER },
072 { "name", Types.VARCHAR },
073 { "value", Types.VARCHAR }
074 };
075 public static final String TABLE_SQL_CREATE = "create table SocialActivitySetting (activitySettingId LONG not null primary key,groupId LONG,companyId LONG,classNameId LONG,activityType INTEGER,name VARCHAR(75) null,value VARCHAR(1024) null)";
076 public static final String TABLE_SQL_DROP = "drop table SocialActivitySetting";
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.social.model.SocialActivitySetting"),
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.social.model.SocialActivitySetting"),
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.social.model.SocialActivitySetting"),
088 true);
089 public static long ACTIVITYTYPE_COLUMN_BITMASK = 1L;
090 public static long CLASSNAMEID_COLUMN_BITMASK = 2L;
091 public static long GROUPID_COLUMN_BITMASK = 4L;
092 public static long NAME_COLUMN_BITMASK = 8L;
093
094
100 public static SocialActivitySetting toModel(
101 SocialActivitySettingSoap soapModel) {
102 if (soapModel == null) {
103 return null;
104 }
105
106 SocialActivitySetting model = new SocialActivitySettingImpl();
107
108 model.setActivitySettingId(soapModel.getActivitySettingId());
109 model.setGroupId(soapModel.getGroupId());
110 model.setCompanyId(soapModel.getCompanyId());
111 model.setClassNameId(soapModel.getClassNameId());
112 model.setActivityType(soapModel.getActivityType());
113 model.setName(soapModel.getName());
114 model.setValue(soapModel.getValue());
115
116 return model;
117 }
118
119
125 public static List<SocialActivitySetting> toModels(
126 SocialActivitySettingSoap[] soapModels) {
127 if (soapModels == null) {
128 return null;
129 }
130
131 List<SocialActivitySetting> models = new ArrayList<SocialActivitySetting>(soapModels.length);
132
133 for (SocialActivitySettingSoap soapModel : soapModels) {
134 models.add(toModel(soapModel));
135 }
136
137 return models;
138 }
139
140 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
141 "lock.expiration.time.com.liferay.portlet.social.model.SocialActivitySetting"));
142
143 public SocialActivitySettingModelImpl() {
144 }
145
146 public long getPrimaryKey() {
147 return _activitySettingId;
148 }
149
150 public void setPrimaryKey(long primaryKey) {
151 setActivitySettingId(primaryKey);
152 }
153
154 public Serializable getPrimaryKeyObj() {
155 return new Long(_activitySettingId);
156 }
157
158 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
159 setPrimaryKey(((Long)primaryKeyObj).longValue());
160 }
161
162 public Class<?> getModelClass() {
163 return SocialActivitySetting.class;
164 }
165
166 public String getModelClassName() {
167 return SocialActivitySetting.class.getName();
168 }
169
170 @Override
171 public Map<String, Object> getModelAttributes() {
172 Map<String, Object> attributes = new HashMap<String, Object>();
173
174 attributes.put("activitySettingId", getActivitySettingId());
175 attributes.put("groupId", getGroupId());
176 attributes.put("companyId", getCompanyId());
177 attributes.put("classNameId", getClassNameId());
178 attributes.put("activityType", getActivityType());
179 attributes.put("name", getName());
180 attributes.put("value", getValue());
181
182 return attributes;
183 }
184
185 @Override
186 public void setModelAttributes(Map<String, Object> attributes) {
187 Long activitySettingId = (Long)attributes.get("activitySettingId");
188
189 if (activitySettingId != null) {
190 setActivitySettingId(activitySettingId);
191 }
192
193 Long groupId = (Long)attributes.get("groupId");
194
195 if (groupId != null) {
196 setGroupId(groupId);
197 }
198
199 Long companyId = (Long)attributes.get("companyId");
200
201 if (companyId != null) {
202 setCompanyId(companyId);
203 }
204
205 Long classNameId = (Long)attributes.get("classNameId");
206
207 if (classNameId != null) {
208 setClassNameId(classNameId);
209 }
210
211 Integer activityType = (Integer)attributes.get("activityType");
212
213 if (activityType != null) {
214 setActivityType(activityType);
215 }
216
217 String name = (String)attributes.get("name");
218
219 if (name != null) {
220 setName(name);
221 }
222
223 String value = (String)attributes.get("value");
224
225 if (value != null) {
226 setValue(value);
227 }
228 }
229
230 @JSON
231 public long getActivitySettingId() {
232 return _activitySettingId;
233 }
234
235 public void setActivitySettingId(long activitySettingId) {
236 _activitySettingId = activitySettingId;
237 }
238
239 @JSON
240 public long getGroupId() {
241 return _groupId;
242 }
243
244 public void setGroupId(long groupId) {
245 _columnBitmask |= GROUPID_COLUMN_BITMASK;
246
247 if (!_setOriginalGroupId) {
248 _setOriginalGroupId = true;
249
250 _originalGroupId = _groupId;
251 }
252
253 _groupId = groupId;
254 }
255
256 public long getOriginalGroupId() {
257 return _originalGroupId;
258 }
259
260 @JSON
261 public long getCompanyId() {
262 return _companyId;
263 }
264
265 public void setCompanyId(long companyId) {
266 _companyId = companyId;
267 }
268
269 public String getClassName() {
270 if (getClassNameId() <= 0) {
271 return StringPool.BLANK;
272 }
273
274 return PortalUtil.getClassName(getClassNameId());
275 }
276
277 public void setClassName(String className) {
278 long classNameId = 0;
279
280 if (Validator.isNotNull(className)) {
281 classNameId = PortalUtil.getClassNameId(className);
282 }
283
284 setClassNameId(classNameId);
285 }
286
287 @JSON
288 public long getClassNameId() {
289 return _classNameId;
290 }
291
292 public void setClassNameId(long classNameId) {
293 _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
294
295 if (!_setOriginalClassNameId) {
296 _setOriginalClassNameId = true;
297
298 _originalClassNameId = _classNameId;
299 }
300
301 _classNameId = classNameId;
302 }
303
304 public long getOriginalClassNameId() {
305 return _originalClassNameId;
306 }
307
308 @JSON
309 public int getActivityType() {
310 return _activityType;
311 }
312
313 public void setActivityType(int activityType) {
314 _columnBitmask |= ACTIVITYTYPE_COLUMN_BITMASK;
315
316 if (!_setOriginalActivityType) {
317 _setOriginalActivityType = true;
318
319 _originalActivityType = _activityType;
320 }
321
322 _activityType = activityType;
323 }
324
325 public int getOriginalActivityType() {
326 return _originalActivityType;
327 }
328
329 @JSON
330 public String getName() {
331 if (_name == null) {
332 return StringPool.BLANK;
333 }
334 else {
335 return _name;
336 }
337 }
338
339 public void setName(String name) {
340 _columnBitmask |= NAME_COLUMN_BITMASK;
341
342 if (_originalName == null) {
343 _originalName = _name;
344 }
345
346 _name = name;
347 }
348
349 public String getOriginalName() {
350 return GetterUtil.getString(_originalName);
351 }
352
353 @JSON
354 public String getValue() {
355 if (_value == null) {
356 return StringPool.BLANK;
357 }
358 else {
359 return _value;
360 }
361 }
362
363 public void setValue(String value) {
364 _value = value;
365 }
366
367 public long getColumnBitmask() {
368 return _columnBitmask;
369 }
370
371 @Override
372 public ExpandoBridge getExpandoBridge() {
373 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
374 SocialActivitySetting.class.getName(), getPrimaryKey());
375 }
376
377 @Override
378 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
379 ExpandoBridge expandoBridge = getExpandoBridge();
380
381 expandoBridge.setAttributes(serviceContext);
382 }
383
384 @Override
385 public SocialActivitySetting toEscapedModel() {
386 if (_escapedModel == null) {
387 _escapedModel = (SocialActivitySetting)ProxyUtil.newProxyInstance(_classLoader,
388 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
389 }
390
391 return _escapedModel;
392 }
393
394 public SocialActivitySetting toUnescapedModel() {
395 return (SocialActivitySetting)this;
396 }
397
398 @Override
399 public Object clone() {
400 SocialActivitySettingImpl socialActivitySettingImpl = new SocialActivitySettingImpl();
401
402 socialActivitySettingImpl.setActivitySettingId(getActivitySettingId());
403 socialActivitySettingImpl.setGroupId(getGroupId());
404 socialActivitySettingImpl.setCompanyId(getCompanyId());
405 socialActivitySettingImpl.setClassNameId(getClassNameId());
406 socialActivitySettingImpl.setActivityType(getActivityType());
407 socialActivitySettingImpl.setName(getName());
408 socialActivitySettingImpl.setValue(getValue());
409
410 socialActivitySettingImpl.resetOriginalValues();
411
412 return socialActivitySettingImpl;
413 }
414
415 public int compareTo(SocialActivitySetting socialActivitySetting) {
416 long primaryKey = socialActivitySetting.getPrimaryKey();
417
418 if (getPrimaryKey() < primaryKey) {
419 return -1;
420 }
421 else if (getPrimaryKey() > primaryKey) {
422 return 1;
423 }
424 else {
425 return 0;
426 }
427 }
428
429 @Override
430 public boolean equals(Object obj) {
431 if (this == obj) {
432 return true;
433 }
434
435 if (!(obj instanceof SocialActivitySetting)) {
436 return false;
437 }
438
439 SocialActivitySetting socialActivitySetting = (SocialActivitySetting)obj;
440
441 long primaryKey = socialActivitySetting.getPrimaryKey();
442
443 if (getPrimaryKey() == primaryKey) {
444 return true;
445 }
446 else {
447 return false;
448 }
449 }
450
451 @Override
452 public int hashCode() {
453 return (int)getPrimaryKey();
454 }
455
456 @Override
457 public void resetOriginalValues() {
458 SocialActivitySettingModelImpl socialActivitySettingModelImpl = this;
459
460 socialActivitySettingModelImpl._originalGroupId = socialActivitySettingModelImpl._groupId;
461
462 socialActivitySettingModelImpl._setOriginalGroupId = false;
463
464 socialActivitySettingModelImpl._originalClassNameId = socialActivitySettingModelImpl._classNameId;
465
466 socialActivitySettingModelImpl._setOriginalClassNameId = false;
467
468 socialActivitySettingModelImpl._originalActivityType = socialActivitySettingModelImpl._activityType;
469
470 socialActivitySettingModelImpl._setOriginalActivityType = false;
471
472 socialActivitySettingModelImpl._originalName = socialActivitySettingModelImpl._name;
473
474 socialActivitySettingModelImpl._columnBitmask = 0;
475 }
476
477 @Override
478 public CacheModel<SocialActivitySetting> toCacheModel() {
479 SocialActivitySettingCacheModel socialActivitySettingCacheModel = new SocialActivitySettingCacheModel();
480
481 socialActivitySettingCacheModel.activitySettingId = getActivitySettingId();
482
483 socialActivitySettingCacheModel.groupId = getGroupId();
484
485 socialActivitySettingCacheModel.companyId = getCompanyId();
486
487 socialActivitySettingCacheModel.classNameId = getClassNameId();
488
489 socialActivitySettingCacheModel.activityType = getActivityType();
490
491 socialActivitySettingCacheModel.name = getName();
492
493 String name = socialActivitySettingCacheModel.name;
494
495 if ((name != null) && (name.length() == 0)) {
496 socialActivitySettingCacheModel.name = null;
497 }
498
499 socialActivitySettingCacheModel.value = getValue();
500
501 String value = socialActivitySettingCacheModel.value;
502
503 if ((value != null) && (value.length() == 0)) {
504 socialActivitySettingCacheModel.value = null;
505 }
506
507 return socialActivitySettingCacheModel;
508 }
509
510 @Override
511 public String toString() {
512 StringBundler sb = new StringBundler(15);
513
514 sb.append("{activitySettingId=");
515 sb.append(getActivitySettingId());
516 sb.append(", groupId=");
517 sb.append(getGroupId());
518 sb.append(", companyId=");
519 sb.append(getCompanyId());
520 sb.append(", classNameId=");
521 sb.append(getClassNameId());
522 sb.append(", activityType=");
523 sb.append(getActivityType());
524 sb.append(", name=");
525 sb.append(getName());
526 sb.append(", value=");
527 sb.append(getValue());
528 sb.append("}");
529
530 return sb.toString();
531 }
532
533 public String toXmlString() {
534 StringBundler sb = new StringBundler(25);
535
536 sb.append("<model><model-name>");
537 sb.append("com.liferay.portlet.social.model.SocialActivitySetting");
538 sb.append("</model-name>");
539
540 sb.append(
541 "<column><column-name>activitySettingId</column-name><column-value><![CDATA[");
542 sb.append(getActivitySettingId());
543 sb.append("]]></column-value></column>");
544 sb.append(
545 "<column><column-name>groupId</column-name><column-value><![CDATA[");
546 sb.append(getGroupId());
547 sb.append("]]></column-value></column>");
548 sb.append(
549 "<column><column-name>companyId</column-name><column-value><![CDATA[");
550 sb.append(getCompanyId());
551 sb.append("]]></column-value></column>");
552 sb.append(
553 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
554 sb.append(getClassNameId());
555 sb.append("]]></column-value></column>");
556 sb.append(
557 "<column><column-name>activityType</column-name><column-value><![CDATA[");
558 sb.append(getActivityType());
559 sb.append("]]></column-value></column>");
560 sb.append(
561 "<column><column-name>name</column-name><column-value><![CDATA[");
562 sb.append(getName());
563 sb.append("]]></column-value></column>");
564 sb.append(
565 "<column><column-name>value</column-name><column-value><![CDATA[");
566 sb.append(getValue());
567 sb.append("]]></column-value></column>");
568
569 sb.append("</model>");
570
571 return sb.toString();
572 }
573
574 private static ClassLoader _classLoader = SocialActivitySetting.class.getClassLoader();
575 private static Class<?>[] _escapedModelInterfaces = new Class[] {
576 SocialActivitySetting.class
577 };
578 private long _activitySettingId;
579 private long _groupId;
580 private long _originalGroupId;
581 private boolean _setOriginalGroupId;
582 private long _companyId;
583 private long _classNameId;
584 private long _originalClassNameId;
585 private boolean _setOriginalClassNameId;
586 private int _activityType;
587 private int _originalActivityType;
588 private boolean _setOriginalActivityType;
589 private String _name;
590 private String _originalName;
591 private String _value;
592 private long _columnBitmask;
593 private SocialActivitySetting _escapedModel;
594 }