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