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