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 public long getPrimaryKey() {
154 return _licenseId;
155 }
156
157 public void setPrimaryKey(long primaryKey) {
158 setLicenseId(primaryKey);
159 }
160
161 public Serializable getPrimaryKeyObj() {
162 return _licenseId;
163 }
164
165 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
166 setPrimaryKey(((Long)primaryKeyObj).longValue());
167 }
168
169 public Class<?> getModelClass() {
170 return SCLicense.class;
171 }
172
173 public String getModelClassName() {
174 return SCLicense.class.getName();
175 }
176
177 @Override
178 public Map<String, Object> getModelAttributes() {
179 Map<String, Object> attributes = new HashMap<String, Object>();
180
181 attributes.put("licenseId", getLicenseId());
182 attributes.put("name", getName());
183 attributes.put("url", getUrl());
184 attributes.put("openSource", getOpenSource());
185 attributes.put("active", getActive());
186 attributes.put("recommended", getRecommended());
187
188 return attributes;
189 }
190
191 @Override
192 public void setModelAttributes(Map<String, Object> attributes) {
193 Long licenseId = (Long)attributes.get("licenseId");
194
195 if (licenseId != null) {
196 setLicenseId(licenseId);
197 }
198
199 String name = (String)attributes.get("name");
200
201 if (name != null) {
202 setName(name);
203 }
204
205 String url = (String)attributes.get("url");
206
207 if (url != null) {
208 setUrl(url);
209 }
210
211 Boolean openSource = (Boolean)attributes.get("openSource");
212
213 if (openSource != null) {
214 setOpenSource(openSource);
215 }
216
217 Boolean active = (Boolean)attributes.get("active");
218
219 if (active != null) {
220 setActive(active);
221 }
222
223 Boolean recommended = (Boolean)attributes.get("recommended");
224
225 if (recommended != null) {
226 setRecommended(recommended);
227 }
228 }
229
230 @JSON
231 public long getLicenseId() {
232 return _licenseId;
233 }
234
235 public void setLicenseId(long licenseId) {
236 _licenseId = licenseId;
237 }
238
239 @JSON
240 public String getName() {
241 if (_name == null) {
242 return StringPool.BLANK;
243 }
244 else {
245 return _name;
246 }
247 }
248
249 public void setName(String name) {
250 _columnBitmask = -1L;
251
252 _name = name;
253 }
254
255 @JSON
256 public String getUrl() {
257 if (_url == null) {
258 return StringPool.BLANK;
259 }
260 else {
261 return _url;
262 }
263 }
264
265 public void setUrl(String url) {
266 _url = url;
267 }
268
269 @JSON
270 public boolean getOpenSource() {
271 return _openSource;
272 }
273
274 public boolean isOpenSource() {
275 return _openSource;
276 }
277
278 public void setOpenSource(boolean openSource) {
279 _openSource = openSource;
280 }
281
282 @JSON
283 public boolean getActive() {
284 return _active;
285 }
286
287 public boolean isActive() {
288 return _active;
289 }
290
291 public void setActive(boolean active) {
292 _columnBitmask |= ACTIVE_COLUMN_BITMASK;
293
294 if (!_setOriginalActive) {
295 _setOriginalActive = true;
296
297 _originalActive = _active;
298 }
299
300 _active = active;
301 }
302
303 public boolean getOriginalActive() {
304 return _originalActive;
305 }
306
307 @JSON
308 public boolean getRecommended() {
309 return _recommended;
310 }
311
312 public boolean isRecommended() {
313 return _recommended;
314 }
315
316 public void setRecommended(boolean recommended) {
317 _columnBitmask |= RECOMMENDED_COLUMN_BITMASK;
318
319 if (!_setOriginalRecommended) {
320 _setOriginalRecommended = true;
321
322 _originalRecommended = _recommended;
323 }
324
325 _recommended = recommended;
326 }
327
328 public boolean getOriginalRecommended() {
329 return _originalRecommended;
330 }
331
332 public long getColumnBitmask() {
333 return _columnBitmask;
334 }
335
336 @Override
337 public ExpandoBridge getExpandoBridge() {
338 return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
339 SCLicense.class.getName(), getPrimaryKey());
340 }
341
342 @Override
343 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
344 ExpandoBridge expandoBridge = getExpandoBridge();
345
346 expandoBridge.setAttributes(serviceContext);
347 }
348
349 @Override
350 public SCLicense toEscapedModel() {
351 if (_escapedModel == null) {
352 _escapedModel = (SCLicense)ProxyUtil.newProxyInstance(_classLoader,
353 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
354 }
355
356 return _escapedModel;
357 }
358
359 @Override
360 public Object clone() {
361 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
362
363 scLicenseImpl.setLicenseId(getLicenseId());
364 scLicenseImpl.setName(getName());
365 scLicenseImpl.setUrl(getUrl());
366 scLicenseImpl.setOpenSource(getOpenSource());
367 scLicenseImpl.setActive(getActive());
368 scLicenseImpl.setRecommended(getRecommended());
369
370 scLicenseImpl.resetOriginalValues();
371
372 return scLicenseImpl;
373 }
374
375 public int compareTo(SCLicense scLicense) {
376 int value = 0;
377
378 value = getName().compareTo(scLicense.getName());
379
380 if (value != 0) {
381 return value;
382 }
383
384 return 0;
385 }
386
387 @Override
388 public boolean equals(Object obj) {
389 if (obj == null) {
390 return false;
391 }
392
393 SCLicense scLicense = null;
394
395 try {
396 scLicense = (SCLicense)obj;
397 }
398 catch (ClassCastException cce) {
399 return false;
400 }
401
402 long primaryKey = scLicense.getPrimaryKey();
403
404 if (getPrimaryKey() == primaryKey) {
405 return true;
406 }
407 else {
408 return false;
409 }
410 }
411
412 @Override
413 public int hashCode() {
414 return (int)getPrimaryKey();
415 }
416
417 @Override
418 public void resetOriginalValues() {
419 SCLicenseModelImpl scLicenseModelImpl = this;
420
421 scLicenseModelImpl._originalActive = scLicenseModelImpl._active;
422
423 scLicenseModelImpl._setOriginalActive = false;
424
425 scLicenseModelImpl._originalRecommended = scLicenseModelImpl._recommended;
426
427 scLicenseModelImpl._setOriginalRecommended = false;
428
429 scLicenseModelImpl._columnBitmask = 0;
430 }
431
432 @Override
433 public CacheModel<SCLicense> toCacheModel() {
434 SCLicenseCacheModel scLicenseCacheModel = new SCLicenseCacheModel();
435
436 scLicenseCacheModel.licenseId = getLicenseId();
437
438 scLicenseCacheModel.name = getName();
439
440 String name = scLicenseCacheModel.name;
441
442 if ((name != null) && (name.length() == 0)) {
443 scLicenseCacheModel.name = null;
444 }
445
446 scLicenseCacheModel.url = getUrl();
447
448 String url = scLicenseCacheModel.url;
449
450 if ((url != null) && (url.length() == 0)) {
451 scLicenseCacheModel.url = null;
452 }
453
454 scLicenseCacheModel.openSource = getOpenSource();
455
456 scLicenseCacheModel.active = getActive();
457
458 scLicenseCacheModel.recommended = getRecommended();
459
460 return scLicenseCacheModel;
461 }
462
463 @Override
464 public String toString() {
465 StringBundler sb = new StringBundler(13);
466
467 sb.append("{licenseId=");
468 sb.append(getLicenseId());
469 sb.append(", name=");
470 sb.append(getName());
471 sb.append(", url=");
472 sb.append(getUrl());
473 sb.append(", openSource=");
474 sb.append(getOpenSource());
475 sb.append(", active=");
476 sb.append(getActive());
477 sb.append(", recommended=");
478 sb.append(getRecommended());
479 sb.append("}");
480
481 return sb.toString();
482 }
483
484 public String toXmlString() {
485 StringBundler sb = new StringBundler(22);
486
487 sb.append("<model><model-name>");
488 sb.append("com.liferay.portlet.softwarecatalog.model.SCLicense");
489 sb.append("</model-name>");
490
491 sb.append(
492 "<column><column-name>licenseId</column-name><column-value><![CDATA[");
493 sb.append(getLicenseId());
494 sb.append("]]></column-value></column>");
495 sb.append(
496 "<column><column-name>name</column-name><column-value><![CDATA[");
497 sb.append(getName());
498 sb.append("]]></column-value></column>");
499 sb.append(
500 "<column><column-name>url</column-name><column-value><![CDATA[");
501 sb.append(getUrl());
502 sb.append("]]></column-value></column>");
503 sb.append(
504 "<column><column-name>openSource</column-name><column-value><![CDATA[");
505 sb.append(getOpenSource());
506 sb.append("]]></column-value></column>");
507 sb.append(
508 "<column><column-name>active</column-name><column-value><![CDATA[");
509 sb.append(getActive());
510 sb.append("]]></column-value></column>");
511 sb.append(
512 "<column><column-name>recommended</column-name><column-value><![CDATA[");
513 sb.append(getRecommended());
514 sb.append("]]></column-value></column>");
515
516 sb.append("</model>");
517
518 return sb.toString();
519 }
520
521 private static ClassLoader _classLoader = SCLicense.class.getClassLoader();
522 private static Class<?>[] _escapedModelInterfaces = new Class[] {
523 SCLicense.class
524 };
525 private long _licenseId;
526 private String _name;
527 private String _url;
528 private boolean _openSource;
529 private boolean _active;
530 private boolean _originalActive;
531 private boolean _setOriginalActive;
532 private boolean _recommended;
533 private boolean _originalRecommended;
534 private boolean _setOriginalRecommended;
535 private long _columnBitmask;
536 private SCLicense _escapedModel;
537 }