001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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.List;
039    
040    /**
041     * 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.
042     *
043     * <p>
044     * 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}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see SCLicenseImpl
049     * @see com.liferay.portlet.softwarecatalog.model.SCLicense
050     * @see com.liferay.portlet.softwarecatalog.model.SCLicenseModel
051     * @generated
052     */
053    @JSON(strict = true)
054    public class SCLicenseModelImpl extends BaseModelImpl<SCLicense>
055            implements SCLicenseModel {
056            /*
057             * NOTE FOR DEVELOPERS:
058             *
059             * 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.
060             */
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            /**
090             * Converts the soap model instance into a normal model instance.
091             *
092             * @param soapModel the soap model instance to convert
093             * @return the normal model instance
094             */
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            /**
109             * Converts the soap model instances into normal model instances.
110             *
111             * @param soapModels the soap model instances to convert
112             * @return the normal model instances
113             */
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                    _name = name;
187            }
188    
189            @JSON
190            public String getUrl() {
191                    if (_url == null) {
192                            return StringPool.BLANK;
193                    }
194                    else {
195                            return _url;
196                    }
197            }
198    
199            public void setUrl(String url) {
200                    _url = url;
201            }
202    
203            @JSON
204            public boolean getOpenSource() {
205                    return _openSource;
206            }
207    
208            public boolean isOpenSource() {
209                    return _openSource;
210            }
211    
212            public void setOpenSource(boolean openSource) {
213                    _openSource = openSource;
214            }
215    
216            @JSON
217            public boolean getActive() {
218                    return _active;
219            }
220    
221            public boolean isActive() {
222                    return _active;
223            }
224    
225            public void setActive(boolean active) {
226                    _columnBitmask |= ACTIVE_COLUMN_BITMASK;
227    
228                    if (!_setOriginalActive) {
229                            _setOriginalActive = true;
230    
231                            _originalActive = _active;
232                    }
233    
234                    _active = active;
235            }
236    
237            public boolean getOriginalActive() {
238                    return _originalActive;
239            }
240    
241            @JSON
242            public boolean getRecommended() {
243                    return _recommended;
244            }
245    
246            public boolean isRecommended() {
247                    return _recommended;
248            }
249    
250            public void setRecommended(boolean recommended) {
251                    _columnBitmask |= RECOMMENDED_COLUMN_BITMASK;
252    
253                    if (!_setOriginalRecommended) {
254                            _setOriginalRecommended = true;
255    
256                            _originalRecommended = _recommended;
257                    }
258    
259                    _recommended = recommended;
260            }
261    
262            public boolean getOriginalRecommended() {
263                    return _originalRecommended;
264            }
265    
266            public long getColumnBitmask() {
267                    return _columnBitmask;
268            }
269    
270            @Override
271            public SCLicense toEscapedModel() {
272                    if (_escapedModelProxy == null) {
273                            _escapedModelProxy = (SCLicense)ProxyUtil.newProxyInstance(_classLoader,
274                                            _escapedModelProxyInterfaces,
275                                            new AutoEscapeBeanHandler(this));
276                    }
277    
278                    return _escapedModelProxy;
279            }
280    
281            @Override
282            public ExpandoBridge getExpandoBridge() {
283                    if (_expandoBridge == null) {
284                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
285                                            SCLicense.class.getName(), getPrimaryKey());
286                    }
287    
288                    return _expandoBridge;
289            }
290    
291            @Override
292            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
293                    getExpandoBridge().setAttributes(serviceContext);
294            }
295    
296            @Override
297            public Object clone() {
298                    SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
299    
300                    scLicenseImpl.setLicenseId(getLicenseId());
301                    scLicenseImpl.setName(getName());
302                    scLicenseImpl.setUrl(getUrl());
303                    scLicenseImpl.setOpenSource(getOpenSource());
304                    scLicenseImpl.setActive(getActive());
305                    scLicenseImpl.setRecommended(getRecommended());
306    
307                    scLicenseImpl.resetOriginalValues();
308    
309                    return scLicenseImpl;
310            }
311    
312            public int compareTo(SCLicense scLicense) {
313                    int value = 0;
314    
315                    value = getName().compareTo(scLicense.getName());
316    
317                    if (value != 0) {
318                            return value;
319                    }
320    
321                    return 0;
322            }
323    
324            @Override
325            public boolean equals(Object obj) {
326                    if (obj == null) {
327                            return false;
328                    }
329    
330                    SCLicense scLicense = null;
331    
332                    try {
333                            scLicense = (SCLicense)obj;
334                    }
335                    catch (ClassCastException cce) {
336                            return false;
337                    }
338    
339                    long primaryKey = scLicense.getPrimaryKey();
340    
341                    if (getPrimaryKey() == primaryKey) {
342                            return true;
343                    }
344                    else {
345                            return false;
346                    }
347            }
348    
349            @Override
350            public int hashCode() {
351                    return (int)getPrimaryKey();
352            }
353    
354            @Override
355            public void resetOriginalValues() {
356                    SCLicenseModelImpl scLicenseModelImpl = this;
357    
358                    scLicenseModelImpl._originalActive = scLicenseModelImpl._active;
359    
360                    scLicenseModelImpl._setOriginalActive = false;
361    
362                    scLicenseModelImpl._originalRecommended = scLicenseModelImpl._recommended;
363    
364                    scLicenseModelImpl._setOriginalRecommended = false;
365    
366                    scLicenseModelImpl._columnBitmask = 0;
367            }
368    
369            @Override
370            public CacheModel<SCLicense> toCacheModel() {
371                    SCLicenseCacheModel scLicenseCacheModel = new SCLicenseCacheModel();
372    
373                    scLicenseCacheModel.licenseId = getLicenseId();
374    
375                    scLicenseCacheModel.name = getName();
376    
377                    String name = scLicenseCacheModel.name;
378    
379                    if ((name != null) && (name.length() == 0)) {
380                            scLicenseCacheModel.name = null;
381                    }
382    
383                    scLicenseCacheModel.url = getUrl();
384    
385                    String url = scLicenseCacheModel.url;
386    
387                    if ((url != null) && (url.length() == 0)) {
388                            scLicenseCacheModel.url = null;
389                    }
390    
391                    scLicenseCacheModel.openSource = getOpenSource();
392    
393                    scLicenseCacheModel.active = getActive();
394    
395                    scLicenseCacheModel.recommended = getRecommended();
396    
397                    return scLicenseCacheModel;
398            }
399    
400            @Override
401            public String toString() {
402                    StringBundler sb = new StringBundler(13);
403    
404                    sb.append("{licenseId=");
405                    sb.append(getLicenseId());
406                    sb.append(", name=");
407                    sb.append(getName());
408                    sb.append(", url=");
409                    sb.append(getUrl());
410                    sb.append(", openSource=");
411                    sb.append(getOpenSource());
412                    sb.append(", active=");
413                    sb.append(getActive());
414                    sb.append(", recommended=");
415                    sb.append(getRecommended());
416                    sb.append("}");
417    
418                    return sb.toString();
419            }
420    
421            public String toXmlString() {
422                    StringBundler sb = new StringBundler(22);
423    
424                    sb.append("<model><model-name>");
425                    sb.append("com.liferay.portlet.softwarecatalog.model.SCLicense");
426                    sb.append("</model-name>");
427    
428                    sb.append(
429                            "<column><column-name>licenseId</column-name><column-value><![CDATA[");
430                    sb.append(getLicenseId());
431                    sb.append("]]></column-value></column>");
432                    sb.append(
433                            "<column><column-name>name</column-name><column-value><![CDATA[");
434                    sb.append(getName());
435                    sb.append("]]></column-value></column>");
436                    sb.append(
437                            "<column><column-name>url</column-name><column-value><![CDATA[");
438                    sb.append(getUrl());
439                    sb.append("]]></column-value></column>");
440                    sb.append(
441                            "<column><column-name>openSource</column-name><column-value><![CDATA[");
442                    sb.append(getOpenSource());
443                    sb.append("]]></column-value></column>");
444                    sb.append(
445                            "<column><column-name>active</column-name><column-value><![CDATA[");
446                    sb.append(getActive());
447                    sb.append("]]></column-value></column>");
448                    sb.append(
449                            "<column><column-name>recommended</column-name><column-value><![CDATA[");
450                    sb.append(getRecommended());
451                    sb.append("]]></column-value></column>");
452    
453                    sb.append("</model>");
454    
455                    return sb.toString();
456            }
457    
458            private static ClassLoader _classLoader = SCLicense.class.getClassLoader();
459            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
460                            SCLicense.class
461                    };
462            private long _licenseId;
463            private String _name;
464            private String _url;
465            private boolean _openSource;
466            private boolean _active;
467            private boolean _originalActive;
468            private boolean _setOriginalActive;
469            private boolean _recommended;
470            private boolean _originalRecommended;
471            private boolean _setOriginalRecommended;
472            private transient ExpandoBridge _expandoBridge;
473            private long _columnBitmask;
474            private SCLicense _escapedModelProxy;
475    }