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