001    /**
002     * Copyright (c) 2000-2010 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.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 clone = new SCLicenseImpl();
241    
242                    clone.setLicenseId(getLicenseId());
243                    clone.setName(getName());
244                    clone.setUrl(getUrl());
245                    clone.setOpenSource(getOpenSource());
246                    clone.setActive(getActive());
247                    clone.setRecommended(getRecommended());
248    
249                    return clone;
250            }
251    
252            public int compareTo(SCLicense scLicense) {
253                    int value = 0;
254    
255                    value = getName().compareTo(scLicense.getName());
256    
257                    if (value != 0) {
258                            return value;
259                    }
260    
261                    return 0;
262            }
263    
264            public boolean equals(Object obj) {
265                    if (obj == null) {
266                            return false;
267                    }
268    
269                    SCLicense scLicense = null;
270    
271                    try {
272                            scLicense = (SCLicense)obj;
273                    }
274                    catch (ClassCastException cce) {
275                            return false;
276                    }
277    
278                    long pk = scLicense.getPrimaryKey();
279    
280                    if (getPrimaryKey() == pk) {
281                            return true;
282                    }
283                    else {
284                            return false;
285                    }
286            }
287    
288            public int hashCode() {
289                    return (int)getPrimaryKey();
290            }
291    
292            public String toString() {
293                    StringBundler sb = new StringBundler(13);
294    
295                    sb.append("{licenseId=");
296                    sb.append(getLicenseId());
297                    sb.append(", name=");
298                    sb.append(getName());
299                    sb.append(", url=");
300                    sb.append(getUrl());
301                    sb.append(", openSource=");
302                    sb.append(getOpenSource());
303                    sb.append(", active=");
304                    sb.append(getActive());
305                    sb.append(", recommended=");
306                    sb.append(getRecommended());
307                    sb.append("}");
308    
309                    return sb.toString();
310            }
311    
312            public String toXmlString() {
313                    StringBundler sb = new StringBundler(22);
314    
315                    sb.append("<model><model-name>");
316                    sb.append("com.liferay.portlet.softwarecatalog.model.SCLicense");
317                    sb.append("</model-name>");
318    
319                    sb.append(
320                            "<column><column-name>licenseId</column-name><column-value><![CDATA[");
321                    sb.append(getLicenseId());
322                    sb.append("]]></column-value></column>");
323                    sb.append(
324                            "<column><column-name>name</column-name><column-value><![CDATA[");
325                    sb.append(getName());
326                    sb.append("]]></column-value></column>");
327                    sb.append(
328                            "<column><column-name>url</column-name><column-value><![CDATA[");
329                    sb.append(getUrl());
330                    sb.append("]]></column-value></column>");
331                    sb.append(
332                            "<column><column-name>openSource</column-name><column-value><![CDATA[");
333                    sb.append(getOpenSource());
334                    sb.append("]]></column-value></column>");
335                    sb.append(
336                            "<column><column-name>active</column-name><column-value><![CDATA[");
337                    sb.append(getActive());
338                    sb.append("]]></column-value></column>");
339                    sb.append(
340                            "<column><column-name>recommended</column-name><column-value><![CDATA[");
341                    sb.append(getRecommended());
342                    sb.append("]]></column-value></column>");
343    
344                    sb.append("</model>");
345    
346                    return sb.toString();
347            }
348    
349            private long _licenseId;
350            private String _name;
351            private String _url;
352            private boolean _openSource;
353            private boolean _active;
354            private boolean _recommended;
355            private transient ExpandoBridge _expandoBridge;
356    }