001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020    import com.liferay.portal.kernel.json.JSON;
021    import com.liferay.portal.kernel.util.GetterUtil;
022    import com.liferay.portal.kernel.util.ProxyUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
025    import com.liferay.portal.model.CacheModel;
026    import com.liferay.portal.model.impl.BaseModelImpl;
027    import com.liferay.portal.service.ServiceContext;
028    
029    import com.liferay.portlet.expando.model.ExpandoBridge;
030    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031    import com.liferay.portlet.softwarecatalog.model.SCLicense;
032    import com.liferay.portlet.softwarecatalog.model.SCLicenseModel;
033    import com.liferay.portlet.softwarecatalog.model.SCLicenseSoap;
034    
035    import java.io.Serializable;
036    
037    import java.sql.Types;
038    
039    import java.util.ArrayList;
040    import java.util.HashMap;
041    import java.util.List;
042    import java.util.Map;
043    
044    /**
045     * 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.
046     *
047     * <p>
048     * This implementation and its corresponding interface {@link 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}.
049     * </p>
050     *
051     * @author Brian Wing Shun Chan
052     * @see SCLicenseImpl
053     * @see SCLicense
054     * @see SCLicenseModel
055     * @generated
056     */
057    @JSON(strict = true)
058    @ProviderType
059    public class SCLicenseModelImpl extends BaseModelImpl<SCLicense>
060            implements SCLicenseModel {
061            /*
062             * NOTE FOR DEVELOPERS:
063             *
064             * Never modify or reference this class directly. All methods that expect a s c license model instance should use the {@link SCLicense} interface instead.
065             */
066            public static final String TABLE_NAME = "SCLicense";
067            public static final Object[][] TABLE_COLUMNS = {
068                            { "licenseId", Types.BIGINT },
069                            { "name", Types.VARCHAR },
070                            { "url", Types.VARCHAR },
071                            { "openSource", Types.BOOLEAN },
072                            { "active_", Types.BOOLEAN },
073                            { "recommended", Types.BOOLEAN }
074                    };
075            public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
076    
077            static {
078                    TABLE_COLUMNS_MAP.put("licenseId", Types.BIGINT);
079                    TABLE_COLUMNS_MAP.put("name", Types.VARCHAR);
080                    TABLE_COLUMNS_MAP.put("url", Types.VARCHAR);
081                    TABLE_COLUMNS_MAP.put("openSource", Types.BOOLEAN);
082                    TABLE_COLUMNS_MAP.put("active_", Types.BOOLEAN);
083                    TABLE_COLUMNS_MAP.put("recommended", Types.BOOLEAN);
084            }
085    
086            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)";
087            public static final String TABLE_SQL_DROP = "drop table SCLicense";
088            public static final String ORDER_BY_JPQL = " ORDER BY scLicense.name ASC";
089            public static final String ORDER_BY_SQL = " ORDER BY SCLicense.name ASC";
090            public static final String DATA_SOURCE = "liferayDataSource";
091            public static final String SESSION_FACTORY = "liferaySessionFactory";
092            public static final String TX_MANAGER = "liferayTransactionManager";
093            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
094                                    "value.object.entity.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCLicense"),
095                            true);
096            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
097                                    "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCLicense"),
098                            true);
099            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
100                                    "value.object.column.bitmask.enabled.com.liferay.portlet.softwarecatalog.model.SCLicense"),
101                            true);
102            public static final long ACTIVE_COLUMN_BITMASK = 1L;
103            public static final long RECOMMENDED_COLUMN_BITMASK = 2L;
104            public static final long NAME_COLUMN_BITMASK = 4L;
105    
106            /**
107             * Converts the soap model instance into a normal model instance.
108             *
109             * @param soapModel the soap model instance to convert
110             * @return the normal model instance
111             */
112            public static SCLicense toModel(SCLicenseSoap soapModel) {
113                    if (soapModel == null) {
114                            return null;
115                    }
116    
117                    SCLicense model = new SCLicenseImpl();
118    
119                    model.setLicenseId(soapModel.getLicenseId());
120                    model.setName(soapModel.getName());
121                    model.setUrl(soapModel.getUrl());
122                    model.setOpenSource(soapModel.getOpenSource());
123                    model.setActive(soapModel.getActive());
124                    model.setRecommended(soapModel.getRecommended());
125    
126                    return model;
127            }
128    
129            /**
130             * Converts the soap model instances into normal model instances.
131             *
132             * @param soapModels the soap model instances to convert
133             * @return the normal model instances
134             */
135            public static List<SCLicense> toModels(SCLicenseSoap[] soapModels) {
136                    if (soapModels == null) {
137                            return null;
138                    }
139    
140                    List<SCLicense> models = new ArrayList<SCLicense>(soapModels.length);
141    
142                    for (SCLicenseSoap soapModel : soapModels) {
143                            models.add(toModel(soapModel));
144                    }
145    
146                    return models;
147            }
148    
149            public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME = "SCLicenses_SCProductEntries";
150            public static final Object[][] MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_COLUMNS =
151                    {
152                            { "companyId", Types.BIGINT },
153                            { "licenseId", Types.BIGINT },
154                            { "productEntryId", Types.BIGINT }
155                    };
156            public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_SQL_CREATE =
157                    "create table SCLicenses_SCProductEntries (companyId LONG not null,licenseId LONG not null,productEntryId LONG not null,primary key (companyId, licenseId, productEntryId))";
158            public static final boolean FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES =
159                    GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
160                                    "value.object.finder.cache.enabled.SCLicenses_SCProductEntries"),
161                            true);
162            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
163                                    "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCLicense"));
164    
165            public SCLicenseModelImpl() {
166            }
167    
168            @Override
169            public long getPrimaryKey() {
170                    return _licenseId;
171            }
172    
173            @Override
174            public void setPrimaryKey(long primaryKey) {
175                    setLicenseId(primaryKey);
176            }
177    
178            @Override
179            public Serializable getPrimaryKeyObj() {
180                    return _licenseId;
181            }
182    
183            @Override
184            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
185                    setPrimaryKey(((Long)primaryKeyObj).longValue());
186            }
187    
188            @Override
189            public Class<?> getModelClass() {
190                    return SCLicense.class;
191            }
192    
193            @Override
194            public String getModelClassName() {
195                    return SCLicense.class.getName();
196            }
197    
198            @Override
199            public Map<String, Object> getModelAttributes() {
200                    Map<String, Object> attributes = new HashMap<String, Object>();
201    
202                    attributes.put("licenseId", getLicenseId());
203                    attributes.put("name", getName());
204                    attributes.put("url", getUrl());
205                    attributes.put("openSource", getOpenSource());
206                    attributes.put("active", getActive());
207                    attributes.put("recommended", getRecommended());
208    
209                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
210                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
211    
212                    return attributes;
213            }
214    
215            @Override
216            public void setModelAttributes(Map<String, Object> attributes) {
217                    Long licenseId = (Long)attributes.get("licenseId");
218    
219                    if (licenseId != null) {
220                            setLicenseId(licenseId);
221                    }
222    
223                    String name = (String)attributes.get("name");
224    
225                    if (name != null) {
226                            setName(name);
227                    }
228    
229                    String url = (String)attributes.get("url");
230    
231                    if (url != null) {
232                            setUrl(url);
233                    }
234    
235                    Boolean openSource = (Boolean)attributes.get("openSource");
236    
237                    if (openSource != null) {
238                            setOpenSource(openSource);
239                    }
240    
241                    Boolean active = (Boolean)attributes.get("active");
242    
243                    if (active != null) {
244                            setActive(active);
245                    }
246    
247                    Boolean recommended = (Boolean)attributes.get("recommended");
248    
249                    if (recommended != null) {
250                            setRecommended(recommended);
251                    }
252            }
253    
254            @JSON
255            @Override
256            public long getLicenseId() {
257                    return _licenseId;
258            }
259    
260            @Override
261            public void setLicenseId(long licenseId) {
262                    _licenseId = licenseId;
263            }
264    
265            @JSON
266            @Override
267            public String getName() {
268                    if (_name == null) {
269                            return StringPool.BLANK;
270                    }
271                    else {
272                            return _name;
273                    }
274            }
275    
276            @Override
277            public void setName(String name) {
278                    _columnBitmask = -1L;
279    
280                    _name = name;
281            }
282    
283            @JSON
284            @Override
285            public String getUrl() {
286                    if (_url == null) {
287                            return StringPool.BLANK;
288                    }
289                    else {
290                            return _url;
291                    }
292            }
293    
294            @Override
295            public void setUrl(String url) {
296                    _url = url;
297            }
298    
299            @JSON
300            @Override
301            public boolean getOpenSource() {
302                    return _openSource;
303            }
304    
305            @Override
306            public boolean isOpenSource() {
307                    return _openSource;
308            }
309    
310            @Override
311            public void setOpenSource(boolean openSource) {
312                    _openSource = openSource;
313            }
314    
315            @JSON
316            @Override
317            public boolean getActive() {
318                    return _active;
319            }
320    
321            @Override
322            public boolean isActive() {
323                    return _active;
324            }
325    
326            @Override
327            public void setActive(boolean active) {
328                    _columnBitmask |= ACTIVE_COLUMN_BITMASK;
329    
330                    if (!_setOriginalActive) {
331                            _setOriginalActive = true;
332    
333                            _originalActive = _active;
334                    }
335    
336                    _active = active;
337            }
338    
339            public boolean getOriginalActive() {
340                    return _originalActive;
341            }
342    
343            @JSON
344            @Override
345            public boolean getRecommended() {
346                    return _recommended;
347            }
348    
349            @Override
350            public boolean isRecommended() {
351                    return _recommended;
352            }
353    
354            @Override
355            public void setRecommended(boolean recommended) {
356                    _columnBitmask |= RECOMMENDED_COLUMN_BITMASK;
357    
358                    if (!_setOriginalRecommended) {
359                            _setOriginalRecommended = true;
360    
361                            _originalRecommended = _recommended;
362                    }
363    
364                    _recommended = recommended;
365            }
366    
367            public boolean getOriginalRecommended() {
368                    return _originalRecommended;
369            }
370    
371            public long getColumnBitmask() {
372                    return _columnBitmask;
373            }
374    
375            @Override
376            public ExpandoBridge getExpandoBridge() {
377                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
378                            SCLicense.class.getName(), getPrimaryKey());
379            }
380    
381            @Override
382            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
383                    ExpandoBridge expandoBridge = getExpandoBridge();
384    
385                    expandoBridge.setAttributes(serviceContext);
386            }
387    
388            @Override
389            public SCLicense toEscapedModel() {
390                    if (_escapedModel == null) {
391                            _escapedModel = (SCLicense)ProxyUtil.newProxyInstance(_classLoader,
392                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
393                    }
394    
395                    return _escapedModel;
396            }
397    
398            @Override
399            public Object clone() {
400                    SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
401    
402                    scLicenseImpl.setLicenseId(getLicenseId());
403                    scLicenseImpl.setName(getName());
404                    scLicenseImpl.setUrl(getUrl());
405                    scLicenseImpl.setOpenSource(getOpenSource());
406                    scLicenseImpl.setActive(getActive());
407                    scLicenseImpl.setRecommended(getRecommended());
408    
409                    scLicenseImpl.resetOriginalValues();
410    
411                    return scLicenseImpl;
412            }
413    
414            @Override
415            public int compareTo(SCLicense scLicense) {
416                    int value = 0;
417    
418                    value = getName().compareTo(scLicense.getName());
419    
420                    if (value != 0) {
421                            return value;
422                    }
423    
424                    return 0;
425            }
426    
427            @Override
428            public boolean equals(Object obj) {
429                    if (this == obj) {
430                            return true;
431                    }
432    
433                    if (!(obj instanceof SCLicense)) {
434                            return false;
435                    }
436    
437                    SCLicense scLicense = (SCLicense)obj;
438    
439                    long primaryKey = scLicense.getPrimaryKey();
440    
441                    if (getPrimaryKey() == primaryKey) {
442                            return true;
443                    }
444                    else {
445                            return false;
446                    }
447            }
448    
449            @Override
450            public int hashCode() {
451                    return (int)getPrimaryKey();
452            }
453    
454            @Override
455            public boolean isEntityCacheEnabled() {
456                    return ENTITY_CACHE_ENABLED;
457            }
458    
459            @Override
460            public boolean isFinderCacheEnabled() {
461                    return FINDER_CACHE_ENABLED;
462            }
463    
464            @Override
465            public void resetOriginalValues() {
466                    SCLicenseModelImpl scLicenseModelImpl = this;
467    
468                    scLicenseModelImpl._originalActive = scLicenseModelImpl._active;
469    
470                    scLicenseModelImpl._setOriginalActive = false;
471    
472                    scLicenseModelImpl._originalRecommended = scLicenseModelImpl._recommended;
473    
474                    scLicenseModelImpl._setOriginalRecommended = false;
475    
476                    scLicenseModelImpl._columnBitmask = 0;
477            }
478    
479            @Override
480            public CacheModel<SCLicense> toCacheModel() {
481                    SCLicenseCacheModel scLicenseCacheModel = new SCLicenseCacheModel();
482    
483                    scLicenseCacheModel.licenseId = getLicenseId();
484    
485                    scLicenseCacheModel.name = getName();
486    
487                    String name = scLicenseCacheModel.name;
488    
489                    if ((name != null) && (name.length() == 0)) {
490                            scLicenseCacheModel.name = null;
491                    }
492    
493                    scLicenseCacheModel.url = getUrl();
494    
495                    String url = scLicenseCacheModel.url;
496    
497                    if ((url != null) && (url.length() == 0)) {
498                            scLicenseCacheModel.url = null;
499                    }
500    
501                    scLicenseCacheModel.openSource = getOpenSource();
502    
503                    scLicenseCacheModel.active = getActive();
504    
505                    scLicenseCacheModel.recommended = getRecommended();
506    
507                    return scLicenseCacheModel;
508            }
509    
510            @Override
511            public String toString() {
512                    StringBundler sb = new StringBundler(13);
513    
514                    sb.append("{licenseId=");
515                    sb.append(getLicenseId());
516                    sb.append(", name=");
517                    sb.append(getName());
518                    sb.append(", url=");
519                    sb.append(getUrl());
520                    sb.append(", openSource=");
521                    sb.append(getOpenSource());
522                    sb.append(", active=");
523                    sb.append(getActive());
524                    sb.append(", recommended=");
525                    sb.append(getRecommended());
526                    sb.append("}");
527    
528                    return sb.toString();
529            }
530    
531            @Override
532            public String toXmlString() {
533                    StringBundler sb = new StringBundler(22);
534    
535                    sb.append("<model><model-name>");
536                    sb.append("com.liferay.portlet.softwarecatalog.model.SCLicense");
537                    sb.append("</model-name>");
538    
539                    sb.append(
540                            "<column><column-name>licenseId</column-name><column-value><![CDATA[");
541                    sb.append(getLicenseId());
542                    sb.append("]]></column-value></column>");
543                    sb.append(
544                            "<column><column-name>name</column-name><column-value><![CDATA[");
545                    sb.append(getName());
546                    sb.append("]]></column-value></column>");
547                    sb.append(
548                            "<column><column-name>url</column-name><column-value><![CDATA[");
549                    sb.append(getUrl());
550                    sb.append("]]></column-value></column>");
551                    sb.append(
552                            "<column><column-name>openSource</column-name><column-value><![CDATA[");
553                    sb.append(getOpenSource());
554                    sb.append("]]></column-value></column>");
555                    sb.append(
556                            "<column><column-name>active</column-name><column-value><![CDATA[");
557                    sb.append(getActive());
558                    sb.append("]]></column-value></column>");
559                    sb.append(
560                            "<column><column-name>recommended</column-name><column-value><![CDATA[");
561                    sb.append(getRecommended());
562                    sb.append("]]></column-value></column>");
563    
564                    sb.append("</model>");
565    
566                    return sb.toString();
567            }
568    
569            private static final ClassLoader _classLoader = SCLicense.class.getClassLoader();
570            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
571                            SCLicense.class
572                    };
573            private long _licenseId;
574            private String _name;
575            private String _url;
576            private boolean _openSource;
577            private boolean _active;
578            private boolean _originalActive;
579            private boolean _setOriginalActive;
580            private boolean _recommended;
581            private boolean _originalRecommended;
582            private boolean _setOriginalRecommended;
583            private long _columnBitmask;
584            private SCLicense _escapedModel;
585    }