001
014
015 package com.liferay.portlet.announcements.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.json.JSON;
020 import com.liferay.portal.kernel.util.GetterUtil;
021 import com.liferay.portal.kernel.util.ProxyUtil;
022 import com.liferay.portal.kernel.util.StringBundler;
023 import com.liferay.portal.kernel.util.StringPool;
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.announcements.model.AnnouncementsDelivery;
030 import com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel;
031 import com.liferay.portlet.announcements.model.AnnouncementsDeliverySoap;
032 import com.liferay.portlet.expando.model.ExpandoBridge;
033 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
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 AnnouncementsDeliveryModelImpl extends BaseModelImpl<AnnouncementsDelivery>
059 implements AnnouncementsDeliveryModel {
060
065 public static final String TABLE_NAME = "AnnouncementsDelivery";
066 public static final Object[][] TABLE_COLUMNS = {
067 { "deliveryId", Types.BIGINT },
068 { "companyId", Types.BIGINT },
069 { "userId", Types.BIGINT },
070 { "type_", Types.VARCHAR },
071 { "email", Types.BOOLEAN },
072 { "sms", Types.BOOLEAN },
073 { "website", Types.BOOLEAN }
074 };
075 public static final String TABLE_SQL_CREATE = "create table AnnouncementsDelivery (deliveryId LONG not null primary key,companyId LONG,userId LONG,type_ VARCHAR(75) null,email BOOLEAN,sms BOOLEAN,website BOOLEAN)";
076 public static final String TABLE_SQL_DROP = "drop table AnnouncementsDelivery";
077 public static final String ORDER_BY_JPQL = " ORDER BY announcementsDelivery.deliveryId ASC";
078 public static final String ORDER_BY_SQL = " ORDER BY AnnouncementsDelivery.deliveryId ASC";
079 public static final String DATA_SOURCE = "liferayDataSource";
080 public static final String SESSION_FACTORY = "liferaySessionFactory";
081 public static final String TX_MANAGER = "liferayTransactionManager";
082 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083 "value.object.entity.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
084 true);
085 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086 "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
087 true);
088 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089 "value.object.column.bitmask.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
090 true);
091 public static long TYPE_COLUMN_BITMASK = 1L;
092 public static long USERID_COLUMN_BITMASK = 2L;
093 public static long DELIVERYID_COLUMN_BITMASK = 4L;
094
095
101 public static AnnouncementsDelivery toModel(
102 AnnouncementsDeliverySoap soapModel) {
103 if (soapModel == null) {
104 return null;
105 }
106
107 AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
108
109 model.setDeliveryId(soapModel.getDeliveryId());
110 model.setCompanyId(soapModel.getCompanyId());
111 model.setUserId(soapModel.getUserId());
112 model.setType(soapModel.getType());
113 model.setEmail(soapModel.getEmail());
114 model.setSms(soapModel.getSms());
115 model.setWebsite(soapModel.getWebsite());
116
117 return model;
118 }
119
120
126 public static List<AnnouncementsDelivery> toModels(
127 AnnouncementsDeliverySoap[] soapModels) {
128 if (soapModels == null) {
129 return null;
130 }
131
132 List<AnnouncementsDelivery> models = new ArrayList<AnnouncementsDelivery>(soapModels.length);
133
134 for (AnnouncementsDeliverySoap 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.portlet.announcements.model.AnnouncementsDelivery"));
143
144 public AnnouncementsDeliveryModelImpl() {
145 }
146
147 public long getPrimaryKey() {
148 return _deliveryId;
149 }
150
151 public void setPrimaryKey(long primaryKey) {
152 setDeliveryId(primaryKey);
153 }
154
155 public Serializable getPrimaryKeyObj() {
156 return _deliveryId;
157 }
158
159 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
160 setPrimaryKey(((Long)primaryKeyObj).longValue());
161 }
162
163 public Class<?> getModelClass() {
164 return AnnouncementsDelivery.class;
165 }
166
167 public String getModelClassName() {
168 return AnnouncementsDelivery.class.getName();
169 }
170
171 @Override
172 public Map<String, Object> getModelAttributes() {
173 Map<String, Object> attributes = new HashMap<String, Object>();
174
175 attributes.put("deliveryId", getDeliveryId());
176 attributes.put("companyId", getCompanyId());
177 attributes.put("userId", getUserId());
178 attributes.put("type", getType());
179 attributes.put("email", getEmail());
180 attributes.put("sms", getSms());
181 attributes.put("website", getWebsite());
182
183 return attributes;
184 }
185
186 @Override
187 public void setModelAttributes(Map<String, Object> attributes) {
188 Long deliveryId = (Long)attributes.get("deliveryId");
189
190 if (deliveryId != null) {
191 setDeliveryId(deliveryId);
192 }
193
194 Long companyId = (Long)attributes.get("companyId");
195
196 if (companyId != null) {
197 setCompanyId(companyId);
198 }
199
200 Long userId = (Long)attributes.get("userId");
201
202 if (userId != null) {
203 setUserId(userId);
204 }
205
206 String type = (String)attributes.get("type");
207
208 if (type != null) {
209 setType(type);
210 }
211
212 Boolean email = (Boolean)attributes.get("email");
213
214 if (email != null) {
215 setEmail(email);
216 }
217
218 Boolean sms = (Boolean)attributes.get("sms");
219
220 if (sms != null) {
221 setSms(sms);
222 }
223
224 Boolean website = (Boolean)attributes.get("website");
225
226 if (website != null) {
227 setWebsite(website);
228 }
229 }
230
231 @JSON
232 public long getDeliveryId() {
233 return _deliveryId;
234 }
235
236 public void setDeliveryId(long deliveryId) {
237 _deliveryId = deliveryId;
238 }
239
240 @JSON
241 public long getCompanyId() {
242 return _companyId;
243 }
244
245 public void setCompanyId(long companyId) {
246 _companyId = companyId;
247 }
248
249 @JSON
250 public long getUserId() {
251 return _userId;
252 }
253
254 public void setUserId(long userId) {
255 _columnBitmask |= USERID_COLUMN_BITMASK;
256
257 if (!_setOriginalUserId) {
258 _setOriginalUserId = true;
259
260 _originalUserId = _userId;
261 }
262
263 _userId = userId;
264 }
265
266 public String getUserUuid() throws SystemException {
267 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
268 }
269
270 public void setUserUuid(String userUuid) {
271 _userUuid = userUuid;
272 }
273
274 public long getOriginalUserId() {
275 return _originalUserId;
276 }
277
278 @JSON
279 public String getType() {
280 if (_type == null) {
281 return StringPool.BLANK;
282 }
283 else {
284 return _type;
285 }
286 }
287
288 public void setType(String type) {
289 _columnBitmask |= TYPE_COLUMN_BITMASK;
290
291 if (_originalType == null) {
292 _originalType = _type;
293 }
294
295 _type = type;
296 }
297
298 public String getOriginalType() {
299 return GetterUtil.getString(_originalType);
300 }
301
302 @JSON
303 public boolean getEmail() {
304 return _email;
305 }
306
307 public boolean isEmail() {
308 return _email;
309 }
310
311 public void setEmail(boolean email) {
312 _email = email;
313 }
314
315 @JSON
316 public boolean getSms() {
317 return _sms;
318 }
319
320 public boolean isSms() {
321 return _sms;
322 }
323
324 public void setSms(boolean sms) {
325 _sms = sms;
326 }
327
328 @JSON
329 public boolean getWebsite() {
330 return _website;
331 }
332
333 public boolean isWebsite() {
334 return _website;
335 }
336
337 public void setWebsite(boolean website) {
338 _website = website;
339 }
340
341 public long getColumnBitmask() {
342 return _columnBitmask;
343 }
344
345 @Override
346 public ExpandoBridge getExpandoBridge() {
347 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
348 AnnouncementsDelivery.class.getName(), getPrimaryKey());
349 }
350
351 @Override
352 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
353 ExpandoBridge expandoBridge = getExpandoBridge();
354
355 expandoBridge.setAttributes(serviceContext);
356 }
357
358 @Override
359 public AnnouncementsDelivery toEscapedModel() {
360 if (_escapedModel == null) {
361 _escapedModel = (AnnouncementsDelivery)ProxyUtil.newProxyInstance(_classLoader,
362 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
363 }
364
365 return _escapedModel;
366 }
367
368 @Override
369 public Object clone() {
370 AnnouncementsDeliveryImpl announcementsDeliveryImpl = new AnnouncementsDeliveryImpl();
371
372 announcementsDeliveryImpl.setDeliveryId(getDeliveryId());
373 announcementsDeliveryImpl.setCompanyId(getCompanyId());
374 announcementsDeliveryImpl.setUserId(getUserId());
375 announcementsDeliveryImpl.setType(getType());
376 announcementsDeliveryImpl.setEmail(getEmail());
377 announcementsDeliveryImpl.setSms(getSms());
378 announcementsDeliveryImpl.setWebsite(getWebsite());
379
380 announcementsDeliveryImpl.resetOriginalValues();
381
382 return announcementsDeliveryImpl;
383 }
384
385 public int compareTo(AnnouncementsDelivery announcementsDelivery) {
386 long primaryKey = announcementsDelivery.getPrimaryKey();
387
388 if (getPrimaryKey() < primaryKey) {
389 return -1;
390 }
391 else if (getPrimaryKey() > primaryKey) {
392 return 1;
393 }
394 else {
395 return 0;
396 }
397 }
398
399 @Override
400 public boolean equals(Object obj) {
401 if (obj == null) {
402 return false;
403 }
404
405 AnnouncementsDelivery announcementsDelivery = null;
406
407 try {
408 announcementsDelivery = (AnnouncementsDelivery)obj;
409 }
410 catch (ClassCastException cce) {
411 return false;
412 }
413
414 long primaryKey = announcementsDelivery.getPrimaryKey();
415
416 if (getPrimaryKey() == primaryKey) {
417 return true;
418 }
419 else {
420 return false;
421 }
422 }
423
424 @Override
425 public int hashCode() {
426 return (int)getPrimaryKey();
427 }
428
429 @Override
430 public void resetOriginalValues() {
431 AnnouncementsDeliveryModelImpl announcementsDeliveryModelImpl = this;
432
433 announcementsDeliveryModelImpl._originalUserId = announcementsDeliveryModelImpl._userId;
434
435 announcementsDeliveryModelImpl._setOriginalUserId = false;
436
437 announcementsDeliveryModelImpl._originalType = announcementsDeliveryModelImpl._type;
438
439 announcementsDeliveryModelImpl._columnBitmask = 0;
440 }
441
442 @Override
443 public CacheModel<AnnouncementsDelivery> toCacheModel() {
444 AnnouncementsDeliveryCacheModel announcementsDeliveryCacheModel = new AnnouncementsDeliveryCacheModel();
445
446 announcementsDeliveryCacheModel.deliveryId = getDeliveryId();
447
448 announcementsDeliveryCacheModel.companyId = getCompanyId();
449
450 announcementsDeliveryCacheModel.userId = getUserId();
451
452 announcementsDeliveryCacheModel.type = getType();
453
454 String type = announcementsDeliveryCacheModel.type;
455
456 if ((type != null) && (type.length() == 0)) {
457 announcementsDeliveryCacheModel.type = null;
458 }
459
460 announcementsDeliveryCacheModel.email = getEmail();
461
462 announcementsDeliveryCacheModel.sms = getSms();
463
464 announcementsDeliveryCacheModel.website = getWebsite();
465
466 return announcementsDeliveryCacheModel;
467 }
468
469 @Override
470 public String toString() {
471 StringBundler sb = new StringBundler(15);
472
473 sb.append("{deliveryId=");
474 sb.append(getDeliveryId());
475 sb.append(", companyId=");
476 sb.append(getCompanyId());
477 sb.append(", userId=");
478 sb.append(getUserId());
479 sb.append(", type=");
480 sb.append(getType());
481 sb.append(", email=");
482 sb.append(getEmail());
483 sb.append(", sms=");
484 sb.append(getSms());
485 sb.append(", website=");
486 sb.append(getWebsite());
487 sb.append("}");
488
489 return sb.toString();
490 }
491
492 public String toXmlString() {
493 StringBundler sb = new StringBundler(25);
494
495 sb.append("<model><model-name>");
496 sb.append(
497 "com.liferay.portlet.announcements.model.AnnouncementsDelivery");
498 sb.append("</model-name>");
499
500 sb.append(
501 "<column><column-name>deliveryId</column-name><column-value><![CDATA[");
502 sb.append(getDeliveryId());
503 sb.append("]]></column-value></column>");
504 sb.append(
505 "<column><column-name>companyId</column-name><column-value><![CDATA[");
506 sb.append(getCompanyId());
507 sb.append("]]></column-value></column>");
508 sb.append(
509 "<column><column-name>userId</column-name><column-value><![CDATA[");
510 sb.append(getUserId());
511 sb.append("]]></column-value></column>");
512 sb.append(
513 "<column><column-name>type</column-name><column-value><![CDATA[");
514 sb.append(getType());
515 sb.append("]]></column-value></column>");
516 sb.append(
517 "<column><column-name>email</column-name><column-value><![CDATA[");
518 sb.append(getEmail());
519 sb.append("]]></column-value></column>");
520 sb.append(
521 "<column><column-name>sms</column-name><column-value><![CDATA[");
522 sb.append(getSms());
523 sb.append("]]></column-value></column>");
524 sb.append(
525 "<column><column-name>website</column-name><column-value><![CDATA[");
526 sb.append(getWebsite());
527 sb.append("]]></column-value></column>");
528
529 sb.append("</model>");
530
531 return sb.toString();
532 }
533
534 private static ClassLoader _classLoader = AnnouncementsDelivery.class.getClassLoader();
535 private static Class<?>[] _escapedModelInterfaces = new Class[] {
536 AnnouncementsDelivery.class
537 };
538 private long _deliveryId;
539 private long _companyId;
540 private long _userId;
541 private String _userUuid;
542 private long _originalUserId;
543 private boolean _setOriginalUserId;
544 private String _type;
545 private String _originalType;
546 private boolean _email;
547 private boolean _sms;
548 private boolean _website;
549 private long _columnBitmask;
550 private AnnouncementsDelivery _escapedModel;
551 }