001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.softwarecatalog.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.impl.BaseModelImpl;
022    import com.liferay.portal.service.ServiceContext;
023    
024    import com.liferay.portlet.expando.model.ExpandoBridge;
025    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
026    import com.liferay.portlet.softwarecatalog.model.SCLicense;
027    import com.liferay.portlet.softwarecatalog.model.SCLicenseModel;
028    import com.liferay.portlet.softwarecatalog.model.SCLicenseSoap;
029    
030    import java.io.Serializable;
031    
032    import java.lang.reflect.Proxy;
033    
034    import java.sql.Types;
035    
036    import java.util.ArrayList;
037    import java.util.List;
038    
039    /**
040     * 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.
041     *
042     * <p>
043     * 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}.
044     * </p>
045     *
046     * <p>
047     * 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.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see SCLicenseImpl
052     * @see com.liferay.portlet.softwarecatalog.model.SCLicense
053     * @see com.liferay.portlet.softwarecatalog.model.SCLicenseModel
054     * @generated
055     */
056    public class SCLicenseModelImpl extends BaseModelImpl<SCLicense>
057            implements SCLicenseModel {
058            public static final String TABLE_NAME = "SCLicense";
059            public static final Object[][] TABLE_COLUMNS = {
060                            { "licenseId", new Integer(Types.BIGINT) },
061                            { "name", new Integer(Types.VARCHAR) },
062                            { "url", new Integer(Types.VARCHAR) },
063                            { "openSource", new Integer(Types.BOOLEAN) },
064                            { "active_", new Integer(Types.BOOLEAN) },
065                            { "recommended", new Integer(Types.BOOLEAN) }
066                    };
067            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)";
068            public static final String TABLE_SQL_DROP = "drop table SCLicense";
069            public static final String ORDER_BY_JPQL = " ORDER BY scLicense.name ASC";
070            public static final String ORDER_BY_SQL = " ORDER BY SCLicense.name ASC";
071            public static final String DATA_SOURCE = "liferayDataSource";
072            public static final String SESSION_FACTORY = "liferaySessionFactory";
073            public static final String TX_MANAGER = "liferayTransactionManager";
074            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
075                                    "value.object.entity.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCLicense"),
076                            true);
077            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078                                    "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCLicense"),
079                            true);
080    
081            /**
082             * Converts the soap model instance into a normal model instance.
083             *
084             * @param soapModel the soap model instance to convert
085             * @return the normal model instance
086             */
087            public static SCLicense toModel(SCLicenseSoap soapModel) {
088                    SCLicense model = new SCLicenseImpl();
089    
090                    model.setLicenseId(soapModel.getLicenseId());
091                    model.setName(soapModel.getName());
092                    model.setUrl(soapModel.getUrl());
093                    model.setOpenSource(soapModel.getOpenSource());
094                    model.setActive(soapModel.getActive());
095                    model.setRecommended(soapModel.getRecommended());
096    
097                    return model;
098            }
099    
100            /**
101             * Converts the soap model instances into normal model instances.
102             *
103             * @param soapModels the soap model instances to convert
104             * @return the normal model instances
105             */
106            public static List<SCLicense> toModels(SCLicenseSoap[] soapModels) {
107                    List<SCLicense> models = new ArrayList<SCLicense>(soapModels.length);
108    
109                    for (SCLicenseSoap soapModel : soapModels) {
110                            models.add(toModel(soapModel));
111                    }
112    
113                    return models;
114            }
115    
116            public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME = "SCLicenses_SCProductEntries";
117            public static final Object[][] MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_COLUMNS =
118                    {
119                            { "licenseId", new Integer(Types.BIGINT) },
120                            { "productEntryId", new Integer(Types.BIGINT) }
121                    };
122            public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_SQL_CREATE =
123                    "create table SCLicenses_SCProductEntries (licenseId LONG not null,productEntryId LONG not null,primary key (licenseId, productEntryId))";
124            public static final boolean FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES =
125                    GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
126                                    "value.object.finder.cache.enabled.SCLicenses_SCProductEntries"),
127                            true);
128            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
129                                    "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCLicense"));
130    
131            public SCLicenseModelImpl() {
132            }
133    
134            public long getPrimaryKey() {
135                    return _licenseId;
136            }
137    
138            public void setPrimaryKey(long pk) {
139                    setLicenseId(pk);
140            }
141    
142            public Serializable getPrimaryKeyObj() {
143                    return new Long(_licenseId);
144            }
145    
146            public long getLicenseId() {
147                    return _licenseId;
148            }
149    
150            public void setLicenseId(long licenseId) {
151                    _licenseId = licenseId;
152            }
153    
154            public String getName() {
155                    if (_name == null) {
156                            return StringPool.BLANK;
157                    }
158                    else {
159                            return _name;
160                    }
161            }
162    
163            public void setName(String name) {
164                    _name = name;
165            }
166    
167            public String getUrl() {
168                    if (_url == null) {
169                            return StringPool.BLANK;
170                    }
171                    else {
172                            return _url;
173                    }
174            }
175    
176            public void setUrl(String url) {
177                    _url = url;
178            }
179    
180            public boolean getOpenSource() {
181                    return _openSource;
182            }
183    
184            public boolean isOpenSource() {
185                    return _openSource;
186            }
187    
188            public void setOpenSource(boolean openSource) {
189                    _openSource = openSource;
190            }
191    
192            public boolean getActive() {
193                    return _active;
194            }
195    
196            public boolean isActive() {
197                    return _active;
198            }
199    
200            public void setActive(boolean active) {
201                    _active = active;
202            }
203    
204            public boolean getRecommended() {
205                    return _recommended;
206            }
207    
208            public boolean isRecommended() {
209                    return _recommended;
210            }
211    
212            public void setRecommended(boolean recommended) {
213                    _recommended = recommended;
214            }
215    
216            public SCLicense toEscapedModel() {
217                    if (isEscapedModel()) {
218                            return (SCLicense)this;
219                    }
220                    else {
221                            return (SCLicense)Proxy.newProxyInstance(SCLicense.class.getClassLoader(),
222                                    new Class[] { SCLicense.class }, new AutoEscapeBeanHandler(this));
223                    }
224            }
225    
226            public ExpandoBridge getExpandoBridge() {
227                    if (_expandoBridge == null) {
228                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
229                                            SCLicense.class.getName(), getPrimaryKey());
230                    }
231    
232                    return _expandoBridge;
233            }
234    
235            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
236                    getExpandoBridge().setAttributes(serviceContext);
237            }
238    
239            public Object clone() {
240                    SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
241    
242                    scLicenseImpl.setLicenseId(getLicenseId());
243    
244                    scLicenseImpl.setName(getName());
245    
246                    scLicenseImpl.setUrl(getUrl());
247    
248                    scLicenseImpl.setOpenSource(getOpenSource());
249    
250                    scLicenseImpl.setActive(getActive());
251    
252                    scLicenseImpl.setRecommended(getRecommended());
253    
254                    return scLicenseImpl;
255            }
256    
257            public int compareTo(SCLicense scLicense) {
258                    int value = 0;
259    
260                    value = getName().compareTo(scLicense.getName());
261    
262                    if (value != 0) {
263                            return value;
264                    }
265    
266                    return 0;
267            }
268    
269            public boolean equals(Object obj) {
270                    if (obj == null) {
271                            return false;
272                    }
273    
274                    SCLicense scLicense = null;
275    
276                    try {
277                            scLicense = (SCLicense)obj;
278                    }
279                    catch (ClassCastException cce) {
280                            return false;
281                    }
282    
283                    long pk = scLicense.getPrimaryKey();
284    
285                    if (getPrimaryKey() == pk) {
286                            return true;
287                    }
288                    else {
289                            return false;
290                    }
291            }
292    
293            public int hashCode() {
294                    return (int)getPrimaryKey();
295            }
296    
297            public String toString() {
298                    StringBundler sb = new StringBundler(13);
299    
300                    sb.append("{licenseId=");
301                    sb.append(getLicenseId());
302                    sb.append(", name=");
303                    sb.append(getName());
304                    sb.append(", url=");
305                    sb.append(getUrl());
306                    sb.append(", openSource=");
307                    sb.append(getOpenSource());
308                    sb.append(", active=");
309                    sb.append(getActive());
310                    sb.append(", recommended=");
311                    sb.append(getRecommended());
312                    sb.append("}");
313    
314                    return sb.toString();
315            }
316    
317            public String toXmlString() {
318                    StringBundler sb = new StringBundler(22);
319    
320                    sb.append("<model><model-name>");
321                    sb.append("com.liferay.portlet.softwarecatalog.model.SCLicense");
322                    sb.append("</model-name>");
323    
324                    sb.append(
325                            "<column><column-name>licenseId</column-name><column-value><![CDATA[");
326                    sb.append(getLicenseId());
327                    sb.append("]]></column-value></column>");
328                    sb.append(
329                            "<column><column-name>name</column-name><column-value><![CDATA[");
330                    sb.append(getName());
331                    sb.append("]]></column-value></column>");
332                    sb.append(
333                            "<column><column-name>url</column-name><column-value><![CDATA[");
334                    sb.append(getUrl());
335                    sb.append("]]></column-value></column>");
336                    sb.append(
337                            "<column><column-name>openSource</column-name><column-value><![CDATA[");
338                    sb.append(getOpenSource());
339                    sb.append("]]></column-value></column>");
340                    sb.append(
341                            "<column><column-name>active</column-name><column-value><![CDATA[");
342                    sb.append(getActive());
343                    sb.append("]]></column-value></column>");
344                    sb.append(
345                            "<column><column-name>recommended</column-name><column-value><![CDATA[");
346                    sb.append(getRecommended());
347                    sb.append("]]></column-value></column>");
348    
349                    sb.append("</model>");
350    
351                    return sb.toString();
352            }
353    
354            private long _licenseId;
355            private String _name;
356            private String _url;
357            private boolean _openSource;
358            private boolean _active;
359            private boolean _recommended;
360            private transient ExpandoBridge _expandoBridge;
361    }