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.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    /**
043     * The base model implementation for the SCLicense service. Represents a row in the "SCLicense" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portlet.softwarecatalog.model.SCLicenseModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link SCLicenseImpl}.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see SCLicenseImpl
051     * @see com.liferay.portlet.softwarecatalog.model.SCLicense
052     * @see com.liferay.portlet.softwarecatalog.model.SCLicenseModel
053     * @generated
054     */
055    @JSON(strict = true)
056    public class SCLicenseModelImpl extends BaseModelImpl<SCLicense>
057            implements SCLicenseModel {
058            /*
059             * NOTE FOR DEVELOPERS:
060             *
061             * Never modify or reference this class directly. All methods that expect a s c license model instance should use the {@link com.liferay.portlet.softwarecatalog.model.SCLicense} interface instead.
062             */
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    
091            /**
092             * Converts the soap model instance into a normal model instance.
093             *
094             * @param soapModel the soap model instance to convert
095             * @return the normal model instance
096             */
097            public static SCLicense toModel(SCLicenseSoap soapModel) {
098                    if (soapModel == null) {
099                            return null;
100                    }
101    
102                    SCLicense model = new SCLicenseImpl();
103    
104                    model.setLicenseId(soapModel.getLicenseId());
105                    model.setName(soapModel.getName());
106                    model.setUrl(soapModel.getUrl());
107                    model.setOpenSource(soapModel.getOpenSource());
108                    model.setActive(soapModel.getActive());
109                    model.setRecommended(soapModel.getRecommended());
110    
111                    return model;
112            }
113    
114            /**
115             * Converts the soap model instances into normal model instances.
116             *
117             * @param soapModels the soap model instances to convert
118             * @return the normal model instances
119             */
120            public static List<SCLicense> toModels(SCLicenseSoap[] soapModels) {
121                    if (soapModels == null) {
122                            return null;
123                    }
124    
125                    List<SCLicense> models = new ArrayList<SCLicense>(soapModels.length);
126    
127                    for (SCLicenseSoap soapModel : soapModels) {
128                            models.add(toModel(soapModel));
129                    }
130    
131                    return models;
132            }
133    
134            public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME = "SCLicenses_SCProductEntries";
135            public static final Object[][] MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_COLUMNS =
136                    {
137                            { "licenseId", Types.BIGINT },
138                            { "productEntryId", Types.BIGINT }
139                    };
140            public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_SQL_CREATE =
141                    "create table SCLicenses_SCProductEntries (licenseId LONG not null,productEntryId LONG not null,primary key (licenseId, productEntryId))";
142            public static final boolean FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES =
143                    GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
144                                    "value.object.finder.cache.enabled.SCLicenses_SCProductEntries"),
145                            true);
146            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
147                                    "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCLicense"));
148    
149            public SCLicenseModelImpl() {
150            }
151    
152            public long getPrimaryKey() {
153                    return _licenseId;
154            }
155    
156            public void setPrimaryKey(long primaryKey) {
157                    setLicenseId(primaryKey);
158            }
159    
160            public Serializable getPrimaryKeyObj() {
161                    return new Long(_licenseId);
162            }
163    
164            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
165                    setPrimaryKey(((Long)primaryKeyObj).longValue());
166            }
167    
168            public Class<?> getModelClass() {
169                    return SCLicense.class;
170            }
171    
172            public String getModelClassName() {
173                    return SCLicense.class.getName();
174            }
175    
176            @Override
177            public Map<String, Object> getModelAttributes() {
178                    Map<String, Object> attributes = new HashMap<String, Object>();
179    
180                    attributes.put("licenseId", getLicenseId());
181                    attributes.put("name", getName());
182                    attributes.put("url", getUrl());
183                    attributes.put("openSource", getOpenSource());
184                    attributes.put("active", getActive());
185                    attributes.put("recommended", getRecommended());
186    
187                    return attributes;
188            }
189    
190            @Override
191            public void setModelAttributes(Map<String, Object> attributes) {
192                    Long licenseId = (Long)attributes.get("licenseId");
193    
194                    if (licenseId != null) {
195                            setLicenseId(licenseId);
196                    }
197    
198                    String name = (String)attributes.get("name");
199    
200                    if (name != null) {
201                            setName(name);
202                    }
203    
204                    String url = (String)attributes.get("url");
205    
206                    if (url != null) {
207                            setUrl(url);
208                    }
209    
210                    Boolean openSource = (Boolean)attributes.get("openSource");
211    
212                    if (openSource != null) {
213                            setOpenSource(openSource);
214                    }
215    
216                    Boolean active = (Boolean)attributes.get("active");
217    
218                    if (active != null) {
219                            setActive(active);
220                    }
221    
222                    Boolean recommended = (Boolean)attributes.get("recommended");
223    
224                    if (recommended != null) {
225                            setRecommended(recommended);
226                    }
227            }
228    
229            @JSON
230            public long getLicenseId() {
231                    return _licenseId;
232            }
233    
234            public void setLicenseId(long licenseId) {
235                    _licenseId = licenseId;
236            }
237    
238            @JSON
239            public String getName() {
240                    if (_name == null) {
241                            return StringPool.BLANK;
242                    }
243                    else {
244                            return _name;
245                    }
246            }
247    
248            public void setName(String name) {
249                    _columnBitmask = -1L;
250    
251                    _name = name;
252            }
253    
254            @JSON
255            public String getUrl() {
256                    if (_url == null) {
257                            return StringPool.BLANK;
258                    }
259                    else {
260                            return _url;
261                    }
262            }
263    
264            public void setUrl(String url) {
265                    _url = url;
266            }
267    
268            @JSON
269            public boolean getOpenSource() {
270                    return _openSource;
271            }
272    
273            public boolean isOpenSource() {
274                    return _openSource;
275            }
276    
277            public void setOpenSource(boolean openSource) {
278                    _openSource = openSource;
279            }
280    
281            @JSON
282            public boolean getActive() {
283                    return _active;
284            }
285    
286            public boolean isActive() {
287                    return _active;
288            }
289    
290            public void setActive(boolean active) {
291                    _columnBitmask |= ACTIVE_COLUMN_BITMASK;
292    
293                    if (!_setOriginalActive) {
294                            _setOriginalActive = true;
295    
296                            _originalActive = _active;
297                    }
298    
299                    _active = active;
300            }
301    
302            public boolean getOriginalActive() {
303                    return _originalActive;
304            }
305    
306            @JSON
307            public boolean getRecommended() {
308                    return _recommended;
309            }
310    
311            public boolean isRecommended() {
312                    return _recommended;
313            }
314    
315            public void setRecommended(boolean recommended) {
316                    _columnBitmask |= RECOMMENDED_COLUMN_BITMASK;
317    
318                    if (!_setOriginalRecommended) {
319                            _setOriginalRecommended = true;
320    
321                            _originalRecommended = _recommended;
322                    }
323    
324                    _recommended = recommended;
325            }
326    
327            public boolean getOriginalRecommended() {
328                    return _originalRecommended;
329            }
330    
331            public long getColumnBitmask() {
332                    return _columnBitmask;
333            }
334    
335            @Override
336            public ExpandoBridge getExpandoBridge() {
337                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
338                            SCLicense.class.getName(), getPrimaryKey());
339            }
340    
341            @Override
342            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
343                    ExpandoBridge expandoBridge = getExpandoBridge();
344    
345                    expandoBridge.setAttributes(serviceContext);
346            }
347    
348            @Override
349            public SCLicense toEscapedModel() {
350                    if (_escapedModel == null) {
351                            _escapedModel = (SCLicense)ProxyUtil.newProxyInstance(_classLoader,
352                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
353                    }
354    
355                    return _escapedModel;
356            }
357    
358            public SCLicense toUnescapedModel() {
359                    return (SCLicense)this;
360            }
361    
362            @Override
363            public Object clone() {
364                    SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
365    
366                    scLicenseImpl.setLicenseId(getLicenseId());
367                    scLicenseImpl.setName(getName());
368                    scLicenseImpl.setUrl(getUrl());
369                    scLicenseImpl.setOpenSource(getOpenSource());
370                    scLicenseImpl.setActive(getActive());
371                    scLicenseImpl.setRecommended(getRecommended());
372    
373                    scLicenseImpl.resetOriginalValues();
374    
375                    return scLicenseImpl;
376            }
377    
378            public int compareTo(SCLicense scLicense) {
379                    int value = 0;
380    
381                    value = getName().compareTo(scLicense.getName());
382    
383                    if (value != 0) {
384                            return value;
385                    }
386    
387                    return 0;
388            }
389    
390            @Override
391            public boolean equals(Object obj) {
392                    if (this == obj) {
393                            return true;
394                    }
395    
396                    if (!(obj instanceof SCLicense)) {
397                            return false;
398                    }
399    
400                    SCLicense scLicense = (SCLicense)obj;
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    }