001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.softwarecatalog.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.ProxyUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.model.CacheModel;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    
025    import com.liferay.portlet.expando.model.ExpandoBridge;
026    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027    import com.liferay.portlet.softwarecatalog.model.SCProductScreenshot;
028    import com.liferay.portlet.softwarecatalog.model.SCProductScreenshotModel;
029    
030    import java.io.Serializable;
031    
032    import java.sql.Types;
033    
034    import java.util.HashMap;
035    import java.util.Map;
036    
037    /**
038     * The base model implementation for the SCProductScreenshot service. Represents a row in the "SCProductScreenshot" database table, with each column mapped to a property of this class.
039     *
040     * <p>
041     * This implementation and its corresponding interface {@link com.liferay.portlet.softwarecatalog.model.SCProductScreenshotModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link SCProductScreenshotImpl}.
042     * </p>
043     *
044     * @author Brian Wing Shun Chan
045     * @see SCProductScreenshotImpl
046     * @see com.liferay.portlet.softwarecatalog.model.SCProductScreenshot
047     * @see com.liferay.portlet.softwarecatalog.model.SCProductScreenshotModel
048     * @generated
049     */
050    public class SCProductScreenshotModelImpl extends BaseModelImpl<SCProductScreenshot>
051            implements SCProductScreenshotModel {
052            /*
053             * NOTE FOR DEVELOPERS:
054             *
055             * Never modify or reference this class directly. All methods that expect a s c product screenshot model instance should use the {@link com.liferay.portlet.softwarecatalog.model.SCProductScreenshot} interface instead.
056             */
057            public static final String TABLE_NAME = "SCProductScreenshot";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "productScreenshotId", Types.BIGINT },
060                            { "companyId", Types.BIGINT },
061                            { "groupId", Types.BIGINT },
062                            { "productEntryId", Types.BIGINT },
063                            { "thumbnailId", Types.BIGINT },
064                            { "fullImageId", Types.BIGINT },
065                            { "priority", Types.INTEGER }
066                    };
067            public static final String TABLE_SQL_CREATE = "create table SCProductScreenshot (productScreenshotId LONG not null primary key,companyId LONG,groupId LONG,productEntryId LONG,thumbnailId LONG,fullImageId LONG,priority INTEGER)";
068            public static final String TABLE_SQL_DROP = "drop table SCProductScreenshot";
069            public static final String ORDER_BY_JPQL = " ORDER BY scProductScreenshot.productEntryId ASC, scProductScreenshot.priority ASC";
070            public static final String ORDER_BY_SQL = " ORDER BY SCProductScreenshot.productEntryId ASC, SCProductScreenshot.priority ASC";
071            public static final String DATA_SOURCE = "liferayDataSource";
072            public static final String SESSION_FACTORY = "liferaySessionFactory";
073            public static final String TX_MANAGER = "liferayTransactionManager";
074            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
075                                    "value.object.entity.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCProductScreenshot"),
076                            true);
077            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078                                    "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCProductScreenshot"),
079                            true);
080            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081                                    "value.object.column.bitmask.enabled.com.liferay.portlet.softwarecatalog.model.SCProductScreenshot"),
082                            true);
083            public static long FULLIMAGEID_COLUMN_BITMASK = 1L;
084            public static long PRIORITY_COLUMN_BITMASK = 2L;
085            public static long PRODUCTENTRYID_COLUMN_BITMASK = 4L;
086            public static long THUMBNAILID_COLUMN_BITMASK = 8L;
087            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
088                                    "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCProductScreenshot"));
089    
090            public SCProductScreenshotModelImpl() {
091            }
092    
093            @Override
094            public long getPrimaryKey() {
095                    return _productScreenshotId;
096            }
097    
098            @Override
099            public void setPrimaryKey(long primaryKey) {
100                    setProductScreenshotId(primaryKey);
101            }
102    
103            @Override
104            public Serializable getPrimaryKeyObj() {
105                    return _productScreenshotId;
106            }
107    
108            @Override
109            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
110                    setPrimaryKey(((Long)primaryKeyObj).longValue());
111            }
112    
113            @Override
114            public Class<?> getModelClass() {
115                    return SCProductScreenshot.class;
116            }
117    
118            @Override
119            public String getModelClassName() {
120                    return SCProductScreenshot.class.getName();
121            }
122    
123            @Override
124            public Map<String, Object> getModelAttributes() {
125                    Map<String, Object> attributes = new HashMap<String, Object>();
126    
127                    attributes.put("productScreenshotId", getProductScreenshotId());
128                    attributes.put("companyId", getCompanyId());
129                    attributes.put("groupId", getGroupId());
130                    attributes.put("productEntryId", getProductEntryId());
131                    attributes.put("thumbnailId", getThumbnailId());
132                    attributes.put("fullImageId", getFullImageId());
133                    attributes.put("priority", getPriority());
134    
135                    return attributes;
136            }
137    
138            @Override
139            public void setModelAttributes(Map<String, Object> attributes) {
140                    Long productScreenshotId = (Long)attributes.get("productScreenshotId");
141    
142                    if (productScreenshotId != null) {
143                            setProductScreenshotId(productScreenshotId);
144                    }
145    
146                    Long companyId = (Long)attributes.get("companyId");
147    
148                    if (companyId != null) {
149                            setCompanyId(companyId);
150                    }
151    
152                    Long groupId = (Long)attributes.get("groupId");
153    
154                    if (groupId != null) {
155                            setGroupId(groupId);
156                    }
157    
158                    Long productEntryId = (Long)attributes.get("productEntryId");
159    
160                    if (productEntryId != null) {
161                            setProductEntryId(productEntryId);
162                    }
163    
164                    Long thumbnailId = (Long)attributes.get("thumbnailId");
165    
166                    if (thumbnailId != null) {
167                            setThumbnailId(thumbnailId);
168                    }
169    
170                    Long fullImageId = (Long)attributes.get("fullImageId");
171    
172                    if (fullImageId != null) {
173                            setFullImageId(fullImageId);
174                    }
175    
176                    Integer priority = (Integer)attributes.get("priority");
177    
178                    if (priority != null) {
179                            setPriority(priority);
180                    }
181            }
182    
183            @Override
184            public long getProductScreenshotId() {
185                    return _productScreenshotId;
186            }
187    
188            @Override
189            public void setProductScreenshotId(long productScreenshotId) {
190                    _productScreenshotId = productScreenshotId;
191            }
192    
193            @Override
194            public long getCompanyId() {
195                    return _companyId;
196            }
197    
198            @Override
199            public void setCompanyId(long companyId) {
200                    _companyId = companyId;
201            }
202    
203            @Override
204            public long getGroupId() {
205                    return _groupId;
206            }
207    
208            @Override
209            public void setGroupId(long groupId) {
210                    _groupId = groupId;
211            }
212    
213            @Override
214            public long getProductEntryId() {
215                    return _productEntryId;
216            }
217    
218            @Override
219            public void setProductEntryId(long productEntryId) {
220                    _columnBitmask = -1L;
221    
222                    if (!_setOriginalProductEntryId) {
223                            _setOriginalProductEntryId = true;
224    
225                            _originalProductEntryId = _productEntryId;
226                    }
227    
228                    _productEntryId = productEntryId;
229            }
230    
231            public long getOriginalProductEntryId() {
232                    return _originalProductEntryId;
233            }
234    
235            @Override
236            public long getThumbnailId() {
237                    return _thumbnailId;
238            }
239    
240            @Override
241            public void setThumbnailId(long thumbnailId) {
242                    _columnBitmask |= THUMBNAILID_COLUMN_BITMASK;
243    
244                    if (!_setOriginalThumbnailId) {
245                            _setOriginalThumbnailId = true;
246    
247                            _originalThumbnailId = _thumbnailId;
248                    }
249    
250                    _thumbnailId = thumbnailId;
251            }
252    
253            public long getOriginalThumbnailId() {
254                    return _originalThumbnailId;
255            }
256    
257            @Override
258            public long getFullImageId() {
259                    return _fullImageId;
260            }
261    
262            @Override
263            public void setFullImageId(long fullImageId) {
264                    _columnBitmask |= FULLIMAGEID_COLUMN_BITMASK;
265    
266                    if (!_setOriginalFullImageId) {
267                            _setOriginalFullImageId = true;
268    
269                            _originalFullImageId = _fullImageId;
270                    }
271    
272                    _fullImageId = fullImageId;
273            }
274    
275            public long getOriginalFullImageId() {
276                    return _originalFullImageId;
277            }
278    
279            @Override
280            public int getPriority() {
281                    return _priority;
282            }
283    
284            @Override
285            public void setPriority(int priority) {
286                    _columnBitmask = -1L;
287    
288                    if (!_setOriginalPriority) {
289                            _setOriginalPriority = true;
290    
291                            _originalPriority = _priority;
292                    }
293    
294                    _priority = priority;
295            }
296    
297            public int getOriginalPriority() {
298                    return _originalPriority;
299            }
300    
301            public long getColumnBitmask() {
302                    return _columnBitmask;
303            }
304    
305            @Override
306            public ExpandoBridge getExpandoBridge() {
307                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
308                            SCProductScreenshot.class.getName(), getPrimaryKey());
309            }
310    
311            @Override
312            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
313                    ExpandoBridge expandoBridge = getExpandoBridge();
314    
315                    expandoBridge.setAttributes(serviceContext);
316            }
317    
318            @Override
319            public SCProductScreenshot toEscapedModel() {
320                    if (_escapedModel == null) {
321                            _escapedModel = (SCProductScreenshot)ProxyUtil.newProxyInstance(_classLoader,
322                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
323                    }
324    
325                    return _escapedModel;
326            }
327    
328            @Override
329            public Object clone() {
330                    SCProductScreenshotImpl scProductScreenshotImpl = new SCProductScreenshotImpl();
331    
332                    scProductScreenshotImpl.setProductScreenshotId(getProductScreenshotId());
333                    scProductScreenshotImpl.setCompanyId(getCompanyId());
334                    scProductScreenshotImpl.setGroupId(getGroupId());
335                    scProductScreenshotImpl.setProductEntryId(getProductEntryId());
336                    scProductScreenshotImpl.setThumbnailId(getThumbnailId());
337                    scProductScreenshotImpl.setFullImageId(getFullImageId());
338                    scProductScreenshotImpl.setPriority(getPriority());
339    
340                    scProductScreenshotImpl.resetOriginalValues();
341    
342                    return scProductScreenshotImpl;
343            }
344    
345            @Override
346            public int compareTo(SCProductScreenshot scProductScreenshot) {
347                    int value = 0;
348    
349                    if (getProductEntryId() < scProductScreenshot.getProductEntryId()) {
350                            value = -1;
351                    }
352                    else if (getProductEntryId() > scProductScreenshot.getProductEntryId()) {
353                            value = 1;
354                    }
355                    else {
356                            value = 0;
357                    }
358    
359                    if (value != 0) {
360                            return value;
361                    }
362    
363                    if (getPriority() < scProductScreenshot.getPriority()) {
364                            value = -1;
365                    }
366                    else if (getPriority() > scProductScreenshot.getPriority()) {
367                            value = 1;
368                    }
369                    else {
370                            value = 0;
371                    }
372    
373                    if (value != 0) {
374                            return value;
375                    }
376    
377                    return 0;
378            }
379    
380            @Override
381            public boolean equals(Object obj) {
382                    if (this == obj) {
383                            return true;
384                    }
385    
386                    if (!(obj instanceof SCProductScreenshot)) {
387                            return false;
388                    }
389    
390                    SCProductScreenshot scProductScreenshot = (SCProductScreenshot)obj;
391    
392                    long primaryKey = scProductScreenshot.getPrimaryKey();
393    
394                    if (getPrimaryKey() == primaryKey) {
395                            return true;
396                    }
397                    else {
398                            return false;
399                    }
400            }
401    
402            @Override
403            public int hashCode() {
404                    return (int)getPrimaryKey();
405            }
406    
407            @Override
408            public void resetOriginalValues() {
409                    SCProductScreenshotModelImpl scProductScreenshotModelImpl = this;
410    
411                    scProductScreenshotModelImpl._originalProductEntryId = scProductScreenshotModelImpl._productEntryId;
412    
413                    scProductScreenshotModelImpl._setOriginalProductEntryId = false;
414    
415                    scProductScreenshotModelImpl._originalThumbnailId = scProductScreenshotModelImpl._thumbnailId;
416    
417                    scProductScreenshotModelImpl._setOriginalThumbnailId = false;
418    
419                    scProductScreenshotModelImpl._originalFullImageId = scProductScreenshotModelImpl._fullImageId;
420    
421                    scProductScreenshotModelImpl._setOriginalFullImageId = false;
422    
423                    scProductScreenshotModelImpl._originalPriority = scProductScreenshotModelImpl._priority;
424    
425                    scProductScreenshotModelImpl._setOriginalPriority = false;
426    
427                    scProductScreenshotModelImpl._columnBitmask = 0;
428            }
429    
430            @Override
431            public CacheModel<SCProductScreenshot> toCacheModel() {
432                    SCProductScreenshotCacheModel scProductScreenshotCacheModel = new SCProductScreenshotCacheModel();
433    
434                    scProductScreenshotCacheModel.productScreenshotId = getProductScreenshotId();
435    
436                    scProductScreenshotCacheModel.companyId = getCompanyId();
437    
438                    scProductScreenshotCacheModel.groupId = getGroupId();
439    
440                    scProductScreenshotCacheModel.productEntryId = getProductEntryId();
441    
442                    scProductScreenshotCacheModel.thumbnailId = getThumbnailId();
443    
444                    scProductScreenshotCacheModel.fullImageId = getFullImageId();
445    
446                    scProductScreenshotCacheModel.priority = getPriority();
447    
448                    return scProductScreenshotCacheModel;
449            }
450    
451            @Override
452            public String toString() {
453                    StringBundler sb = new StringBundler(15);
454    
455                    sb.append("{productScreenshotId=");
456                    sb.append(getProductScreenshotId());
457                    sb.append(", companyId=");
458                    sb.append(getCompanyId());
459                    sb.append(", groupId=");
460                    sb.append(getGroupId());
461                    sb.append(", productEntryId=");
462                    sb.append(getProductEntryId());
463                    sb.append(", thumbnailId=");
464                    sb.append(getThumbnailId());
465                    sb.append(", fullImageId=");
466                    sb.append(getFullImageId());
467                    sb.append(", priority=");
468                    sb.append(getPriority());
469                    sb.append("}");
470    
471                    return sb.toString();
472            }
473    
474            @Override
475            public String toXmlString() {
476                    StringBundler sb = new StringBundler(25);
477    
478                    sb.append("<model><model-name>");
479                    sb.append(
480                            "com.liferay.portlet.softwarecatalog.model.SCProductScreenshot");
481                    sb.append("</model-name>");
482    
483                    sb.append(
484                            "<column><column-name>productScreenshotId</column-name><column-value><![CDATA[");
485                    sb.append(getProductScreenshotId());
486                    sb.append("]]></column-value></column>");
487                    sb.append(
488                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
489                    sb.append(getCompanyId());
490                    sb.append("]]></column-value></column>");
491                    sb.append(
492                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
493                    sb.append(getGroupId());
494                    sb.append("]]></column-value></column>");
495                    sb.append(
496                            "<column><column-name>productEntryId</column-name><column-value><![CDATA[");
497                    sb.append(getProductEntryId());
498                    sb.append("]]></column-value></column>");
499                    sb.append(
500                            "<column><column-name>thumbnailId</column-name><column-value><![CDATA[");
501                    sb.append(getThumbnailId());
502                    sb.append("]]></column-value></column>");
503                    sb.append(
504                            "<column><column-name>fullImageId</column-name><column-value><![CDATA[");
505                    sb.append(getFullImageId());
506                    sb.append("]]></column-value></column>");
507                    sb.append(
508                            "<column><column-name>priority</column-name><column-value><![CDATA[");
509                    sb.append(getPriority());
510                    sb.append("]]></column-value></column>");
511    
512                    sb.append("</model>");
513    
514                    return sb.toString();
515            }
516    
517            private static ClassLoader _classLoader = SCProductScreenshot.class.getClassLoader();
518            private static Class<?>[] _escapedModelInterfaces = new Class[] {
519                            SCProductScreenshot.class
520                    };
521            private long _productScreenshotId;
522            private long _companyId;
523            private long _groupId;
524            private long _productEntryId;
525            private long _originalProductEntryId;
526            private boolean _setOriginalProductEntryId;
527            private long _thumbnailId;
528            private long _originalThumbnailId;
529            private boolean _setOriginalThumbnailId;
530            private long _fullImageId;
531            private long _originalFullImageId;
532            private boolean _setOriginalFullImageId;
533            private int _priority;
534            private int _originalPriority;
535            private boolean _setOriginalPriority;
536            private long _columnBitmask;
537            private SCProductScreenshot _escapedModel;
538    }