001
014
015 package com.liferay.portlet.softwarecatalog.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.impl.BaseModelImpl;
027 import com.liferay.portal.service.ServiceContext;
028
029 import com.liferay.portlet.expando.model.ExpandoBridge;
030 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031 import com.liferay.portlet.softwarecatalog.model.SCLicense;
032 import com.liferay.portlet.softwarecatalog.model.SCLicenseModel;
033 import com.liferay.portlet.softwarecatalog.model.SCLicenseSoap;
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 @ProviderType
059 public class SCLicenseModelImpl extends BaseModelImpl<SCLicense>
060 implements SCLicenseModel {
061
066 public static final String TABLE_NAME = "SCLicense";
067 public static final Object[][] TABLE_COLUMNS = {
068 { "licenseId", Types.BIGINT },
069 { "name", Types.VARCHAR },
070 { "url", Types.VARCHAR },
071 { "openSource", Types.BOOLEAN },
072 { "active_", Types.BOOLEAN },
073 { "recommended", Types.BOOLEAN }
074 };
075 public static final String TABLE_SQL_CREATE = "create table SCLicense (licenseId LONG not null primary key,name VARCHAR(75) null,url STRING null,openSource BOOLEAN,active_ BOOLEAN,recommended BOOLEAN)";
076 public static final String TABLE_SQL_DROP = "drop table SCLicense";
077 public static final String ORDER_BY_JPQL = " ORDER BY scLicense.name ASC";
078 public static final String ORDER_BY_SQL = " ORDER BY SCLicense.name 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.softwarecatalog.model.SCLicense"),
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.softwarecatalog.model.SCLicense"),
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.softwarecatalog.model.SCLicense"),
090 true);
091 public static final long ACTIVE_COLUMN_BITMASK = 1L;
092 public static final long RECOMMENDED_COLUMN_BITMASK = 2L;
093 public static final long NAME_COLUMN_BITMASK = 4L;
094
095
101 public static SCLicense toModel(SCLicenseSoap soapModel) {
102 if (soapModel == null) {
103 return null;
104 }
105
106 SCLicense model = new SCLicenseImpl();
107
108 model.setLicenseId(soapModel.getLicenseId());
109 model.setName(soapModel.getName());
110 model.setUrl(soapModel.getUrl());
111 model.setOpenSource(soapModel.getOpenSource());
112 model.setActive(soapModel.getActive());
113 model.setRecommended(soapModel.getRecommended());
114
115 return model;
116 }
117
118
124 public static List<SCLicense> toModels(SCLicenseSoap[] soapModels) {
125 if (soapModels == null) {
126 return null;
127 }
128
129 List<SCLicense> models = new ArrayList<SCLicense>(soapModels.length);
130
131 for (SCLicenseSoap soapModel : soapModels) {
132 models.add(toModel(soapModel));
133 }
134
135 return models;
136 }
137
138 public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME = "SCLicenses_SCProductEntries";
139 public static final Object[][] MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_COLUMNS =
140 {
141 { "licenseId", Types.BIGINT },
142 { "productEntryId", Types.BIGINT }
143 };
144 public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_SQL_CREATE =
145 "create table SCLicenses_SCProductEntries (licenseId LONG not null,productEntryId LONG not null,primary key (licenseId, productEntryId))";
146 public static final boolean FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES =
147 GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
148 "value.object.finder.cache.enabled.SCLicenses_SCProductEntries"),
149 true);
150 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
151 "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCLicense"));
152
153 public SCLicenseModelImpl() {
154 }
155
156 @Override
157 public long getPrimaryKey() {
158 return _licenseId;
159 }
160
161 @Override
162 public void setPrimaryKey(long primaryKey) {
163 setLicenseId(primaryKey);
164 }
165
166 @Override
167 public Serializable getPrimaryKeyObj() {
168 return _licenseId;
169 }
170
171 @Override
172 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
173 setPrimaryKey(((Long)primaryKeyObj).longValue());
174 }
175
176 @Override
177 public Class<?> getModelClass() {
178 return SCLicense.class;
179 }
180
181 @Override
182 public String getModelClassName() {
183 return SCLicense.class.getName();
184 }
185
186 @Override
187 public Map<String, Object> getModelAttributes() {
188 Map<String, Object> attributes = new HashMap<String, Object>();
189
190 attributes.put("licenseId", getLicenseId());
191 attributes.put("name", getName());
192 attributes.put("url", getUrl());
193 attributes.put("openSource", getOpenSource());
194 attributes.put("active", getActive());
195 attributes.put("recommended", getRecommended());
196
197 attributes.put("entityCacheEnabled", isEntityCacheEnabled());
198 attributes.put("finderCacheEnabled", isFinderCacheEnabled());
199
200 return attributes;
201 }
202
203 @Override
204 public void setModelAttributes(Map<String, Object> attributes) {
205 Long licenseId = (Long)attributes.get("licenseId");
206
207 if (licenseId != null) {
208 setLicenseId(licenseId);
209 }
210
211 String name = (String)attributes.get("name");
212
213 if (name != null) {
214 setName(name);
215 }
216
217 String url = (String)attributes.get("url");
218
219 if (url != null) {
220 setUrl(url);
221 }
222
223 Boolean openSource = (Boolean)attributes.get("openSource");
224
225 if (openSource != null) {
226 setOpenSource(openSource);
227 }
228
229 Boolean active = (Boolean)attributes.get("active");
230
231 if (active != null) {
232 setActive(active);
233 }
234
235 Boolean recommended = (Boolean)attributes.get("recommended");
236
237 if (recommended != null) {
238 setRecommended(recommended);
239 }
240 }
241
242 @JSON
243 @Override
244 public long getLicenseId() {
245 return _licenseId;
246 }
247
248 @Override
249 public void setLicenseId(long licenseId) {
250 _licenseId = licenseId;
251 }
252
253 @JSON
254 @Override
255 public String getName() {
256 if (_name == null) {
257 return StringPool.BLANK;
258 }
259 else {
260 return _name;
261 }
262 }
263
264 @Override
265 public void setName(String name) {
266 _columnBitmask = -1L;
267
268 _name = name;
269 }
270
271 @JSON
272 @Override
273 public String getUrl() {
274 if (_url == null) {
275 return StringPool.BLANK;
276 }
277 else {
278 return _url;
279 }
280 }
281
282 @Override
283 public void setUrl(String url) {
284 _url = url;
285 }
286
287 @JSON
288 @Override
289 public boolean getOpenSource() {
290 return _openSource;
291 }
292
293 @Override
294 public boolean isOpenSource() {
295 return _openSource;
296 }
297
298 @Override
299 public void setOpenSource(boolean openSource) {
300 _openSource = openSource;
301 }
302
303 @JSON
304 @Override
305 public boolean getActive() {
306 return _active;
307 }
308
309 @Override
310 public boolean isActive() {
311 return _active;
312 }
313
314 @Override
315 public void setActive(boolean active) {
316 _columnBitmask |= ACTIVE_COLUMN_BITMASK;
317
318 if (!_setOriginalActive) {
319 _setOriginalActive = true;
320
321 _originalActive = _active;
322 }
323
324 _active = active;
325 }
326
327 public boolean getOriginalActive() {
328 return _originalActive;
329 }
330
331 @JSON
332 @Override
333 public boolean getRecommended() {
334 return _recommended;
335 }
336
337 @Override
338 public boolean isRecommended() {
339 return _recommended;
340 }
341
342 @Override
343 public void setRecommended(boolean recommended) {
344 _columnBitmask |= RECOMMENDED_COLUMN_BITMASK;
345
346 if (!_setOriginalRecommended) {
347 _setOriginalRecommended = true;
348
349 _originalRecommended = _recommended;
350 }
351
352 _recommended = recommended;
353 }
354
355 public boolean getOriginalRecommended() {
356 return _originalRecommended;
357 }
358
359 public long getColumnBitmask() {
360 return _columnBitmask;
361 }
362
363 @Override
364 public ExpandoBridge getExpandoBridge() {
365 return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
366 SCLicense.class.getName(), getPrimaryKey());
367 }
368
369 @Override
370 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
371 ExpandoBridge expandoBridge = getExpandoBridge();
372
373 expandoBridge.setAttributes(serviceContext);
374 }
375
376 @Override
377 public SCLicense toEscapedModel() {
378 if (_escapedModel == null) {
379 _escapedModel = (SCLicense)ProxyUtil.newProxyInstance(_classLoader,
380 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
381 }
382
383 return _escapedModel;
384 }
385
386 @Override
387 public Object clone() {
388 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
389
390 scLicenseImpl.setLicenseId(getLicenseId());
391 scLicenseImpl.setName(getName());
392 scLicenseImpl.setUrl(getUrl());
393 scLicenseImpl.setOpenSource(getOpenSource());
394 scLicenseImpl.setActive(getActive());
395 scLicenseImpl.setRecommended(getRecommended());
396
397 scLicenseImpl.resetOriginalValues();
398
399 return scLicenseImpl;
400 }
401
402 @Override
403 public int compareTo(SCLicense scLicense) {
404 int value = 0;
405
406 value = getName().compareTo(scLicense.getName());
407
408 if (value != 0) {
409 return value;
410 }
411
412 return 0;
413 }
414
415 @Override
416 public boolean equals(Object obj) {
417 if (this == obj) {
418 return true;
419 }
420
421 if (!(obj instanceof SCLicense)) {
422 return false;
423 }
424
425 SCLicense scLicense = (SCLicense)obj;
426
427 long primaryKey = scLicense.getPrimaryKey();
428
429 if (getPrimaryKey() == primaryKey) {
430 return true;
431 }
432 else {
433 return false;
434 }
435 }
436
437 @Override
438 public int hashCode() {
439 return (int)getPrimaryKey();
440 }
441
442 @Override
443 public boolean isEntityCacheEnabled() {
444 return ENTITY_CACHE_ENABLED;
445 }
446
447 @Override
448 public boolean isFinderCacheEnabled() {
449 return FINDER_CACHE_ENABLED;
450 }
451
452 @Override
453 public void resetOriginalValues() {
454 SCLicenseModelImpl scLicenseModelImpl = this;
455
456 scLicenseModelImpl._originalActive = scLicenseModelImpl._active;
457
458 scLicenseModelImpl._setOriginalActive = false;
459
460 scLicenseModelImpl._originalRecommended = scLicenseModelImpl._recommended;
461
462 scLicenseModelImpl._setOriginalRecommended = false;
463
464 scLicenseModelImpl._columnBitmask = 0;
465 }
466
467 @Override
468 public CacheModel<SCLicense> toCacheModel() {
469 SCLicenseCacheModel scLicenseCacheModel = new SCLicenseCacheModel();
470
471 scLicenseCacheModel.licenseId = getLicenseId();
472
473 scLicenseCacheModel.name = getName();
474
475 String name = scLicenseCacheModel.name;
476
477 if ((name != null) && (name.length() == 0)) {
478 scLicenseCacheModel.name = null;
479 }
480
481 scLicenseCacheModel.url = getUrl();
482
483 String url = scLicenseCacheModel.url;
484
485 if ((url != null) && (url.length() == 0)) {
486 scLicenseCacheModel.url = null;
487 }
488
489 scLicenseCacheModel.openSource = getOpenSource();
490
491 scLicenseCacheModel.active = getActive();
492
493 scLicenseCacheModel.recommended = getRecommended();
494
495 return scLicenseCacheModel;
496 }
497
498 @Override
499 public String toString() {
500 StringBundler sb = new StringBundler(13);
501
502 sb.append("{licenseId=");
503 sb.append(getLicenseId());
504 sb.append(", name=");
505 sb.append(getName());
506 sb.append(", url=");
507 sb.append(getUrl());
508 sb.append(", openSource=");
509 sb.append(getOpenSource());
510 sb.append(", active=");
511 sb.append(getActive());
512 sb.append(", recommended=");
513 sb.append(getRecommended());
514 sb.append("}");
515
516 return sb.toString();
517 }
518
519 @Override
520 public String toXmlString() {
521 StringBundler sb = new StringBundler(22);
522
523 sb.append("<model><model-name>");
524 sb.append("com.liferay.portlet.softwarecatalog.model.SCLicense");
525 sb.append("</model-name>");
526
527 sb.append(
528 "<column><column-name>licenseId</column-name><column-value><![CDATA[");
529 sb.append(getLicenseId());
530 sb.append("]]></column-value></column>");
531 sb.append(
532 "<column><column-name>name</column-name><column-value><![CDATA[");
533 sb.append(getName());
534 sb.append("]]></column-value></column>");
535 sb.append(
536 "<column><column-name>url</column-name><column-value><![CDATA[");
537 sb.append(getUrl());
538 sb.append("]]></column-value></column>");
539 sb.append(
540 "<column><column-name>openSource</column-name><column-value><![CDATA[");
541 sb.append(getOpenSource());
542 sb.append("]]></column-value></column>");
543 sb.append(
544 "<column><column-name>active</column-name><column-value><![CDATA[");
545 sb.append(getActive());
546 sb.append("]]></column-value></column>");
547 sb.append(
548 "<column><column-name>recommended</column-name><column-value><![CDATA[");
549 sb.append(getRecommended());
550 sb.append("]]></column-value></column>");
551
552 sb.append("</model>");
553
554 return sb.toString();
555 }
556
557 private static final ClassLoader _classLoader = SCLicense.class.getClassLoader();
558 private static final Class<?>[] _escapedModelInterfaces = new Class[] {
559 SCLicense.class
560 };
561 private long _licenseId;
562 private String _name;
563 private String _url;
564 private boolean _openSource;
565 private boolean _active;
566 private boolean _originalActive;
567 private boolean _setOriginalActive;
568 private boolean _recommended;
569 private boolean _originalRecommended;
570 private boolean _setOriginalRecommended;
571 private long _columnBitmask;
572 private SCLicense _escapedModel;
573 }