1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.softwarecatalog.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.kernel.util.StringBundler;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.service.ServiceContext;
31  
32  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
34  import com.liferay.portlet.softwarecatalog.model.SCLicense;
35  import com.liferay.portlet.softwarecatalog.model.SCLicenseSoap;
36  
37  import java.io.Serializable;
38  
39  import java.lang.reflect.Proxy;
40  
41  import java.sql.Types;
42  
43  import java.util.ArrayList;
44  import java.util.List;
45  
46  /**
47   * <a href="SCLicenseModelImpl.java.html"><b><i>View Source</i></b></a>
48   *
49   * <p>
50   * ServiceBuilder generated this class. Modifications in this class will be
51   * overwritten the next time is generated.
52   * </p>
53   *
54   * <p>
55   * This interface is a model that represents the SCLicense table in the
56   * database.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       SCLicenseImpl
61   * @see       com.liferay.portlet.softwarecatalog.model.SCLicense
62   * @see       com.liferay.portlet.softwarecatalog.model.SCLicenseModel
63   * @generated
64   */
65  public class SCLicenseModelImpl extends BaseModelImpl<SCLicense> {
66      public static final String TABLE_NAME = "SCLicense";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "licenseId", new Integer(Types.BIGINT) },
69              { "name", new Integer(Types.VARCHAR) },
70              { "url", new Integer(Types.VARCHAR) },
71              { "openSource", new Integer(Types.BOOLEAN) },
72              { "active_", new Integer(Types.BOOLEAN) },
73              { "recommended", new Integer(Types.BOOLEAN) }
74          };
75      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)";
76      public static final String TABLE_SQL_DROP = "drop table SCLicense";
77      public static final String ORDER_BY_JPQL = " ORDER BY scLicense.name ASC";
78      public static final String ORDER_BY_SQL = " ORDER BY SCLicense.name ASC";
79      public static final String DATA_SOURCE = "liferayDataSource";
80      public static final String SESSION_FACTORY = "liferaySessionFactory";
81      public static final String TX_MANAGER = "liferayTransactionManager";
82      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.entity.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCLicense"),
84              true);
85      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCLicense"),
87              true);
88  
89      public static SCLicense toModel(SCLicenseSoap soapModel) {
90          SCLicense model = new SCLicenseImpl();
91  
92          model.setLicenseId(soapModel.getLicenseId());
93          model.setName(soapModel.getName());
94          model.setUrl(soapModel.getUrl());
95          model.setOpenSource(soapModel.getOpenSource());
96          model.setActive(soapModel.getActive());
97          model.setRecommended(soapModel.getRecommended());
98  
99          return model;
100     }
101 
102     public static List<SCLicense> toModels(SCLicenseSoap[] soapModels) {
103         List<SCLicense> models = new ArrayList<SCLicense>(soapModels.length);
104 
105         for (SCLicenseSoap soapModel : soapModels) {
106             models.add(toModel(soapModel));
107         }
108 
109         return models;
110     }
111 
112     public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME = "SCLicenses_SCProductEntries";
113     public static final Object[][] MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_COLUMNS =
114         {
115             { "licenseId", new Integer(Types.BIGINT) },
116             { "productEntryId", new Integer(Types.BIGINT) }
117         };
118     public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_SQL_CREATE =
119         "create table SCLicenses_SCProductEntries (licenseId LONG not null,productEntryId LONG not null,primary key (licenseId, productEntryId))";
120     public static final boolean FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES =
121         GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
122                 "value.object.finder.cache.enabled.SCLicenses_SCProductEntries"),
123             true);
124     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
125                 "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCLicense"));
126 
127     public SCLicenseModelImpl() {
128     }
129 
130     public long getPrimaryKey() {
131         return _licenseId;
132     }
133 
134     public void setPrimaryKey(long pk) {
135         setLicenseId(pk);
136     }
137 
138     public Serializable getPrimaryKeyObj() {
139         return new Long(_licenseId);
140     }
141 
142     public long getLicenseId() {
143         return _licenseId;
144     }
145 
146     public void setLicenseId(long licenseId) {
147         _licenseId = licenseId;
148     }
149 
150     public String getName() {
151         return GetterUtil.getString(_name);
152     }
153 
154     public void setName(String name) {
155         _name = name;
156     }
157 
158     public String getUrl() {
159         return GetterUtil.getString(_url);
160     }
161 
162     public void setUrl(String url) {
163         _url = url;
164     }
165 
166     public boolean getOpenSource() {
167         return _openSource;
168     }
169 
170     public boolean isOpenSource() {
171         return _openSource;
172     }
173 
174     public void setOpenSource(boolean openSource) {
175         _openSource = openSource;
176     }
177 
178     public boolean getActive() {
179         return _active;
180     }
181 
182     public boolean isActive() {
183         return _active;
184     }
185 
186     public void setActive(boolean active) {
187         _active = active;
188     }
189 
190     public boolean getRecommended() {
191         return _recommended;
192     }
193 
194     public boolean isRecommended() {
195         return _recommended;
196     }
197 
198     public void setRecommended(boolean recommended) {
199         _recommended = recommended;
200     }
201 
202     public SCLicense toEscapedModel() {
203         if (isEscapedModel()) {
204             return (SCLicense)this;
205         }
206         else {
207             SCLicense model = new SCLicenseImpl();
208 
209             model.setNew(isNew());
210             model.setEscapedModel(true);
211 
212             model.setLicenseId(getLicenseId());
213             model.setName(HtmlUtil.escape(getName()));
214             model.setUrl(HtmlUtil.escape(getUrl()));
215             model.setOpenSource(getOpenSource());
216             model.setActive(getActive());
217             model.setRecommended(getRecommended());
218 
219             model = (SCLicense)Proxy.newProxyInstance(SCLicense.class.getClassLoader(),
220                     new Class[] { SCLicense.class },
221                     new ReadOnlyBeanHandler(model));
222 
223             return model;
224         }
225     }
226 
227     public ExpandoBridge getExpandoBridge() {
228         if (_expandoBridge == null) {
229             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(SCLicense.class.getName(),
230                     getPrimaryKey());
231         }
232 
233         return _expandoBridge;
234     }
235 
236     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
237         getExpandoBridge().setAttributes(serviceContext);
238     }
239 
240     public Object clone() {
241         SCLicenseImpl clone = new SCLicenseImpl();
242 
243         clone.setLicenseId(getLicenseId());
244         clone.setName(getName());
245         clone.setUrl(getUrl());
246         clone.setOpenSource(getOpenSource());
247         clone.setActive(getActive());
248         clone.setRecommended(getRecommended());
249 
250         return clone;
251     }
252 
253     public int compareTo(SCLicense scLicense) {
254         int value = 0;
255 
256         value = getName().compareTo(scLicense.getName());
257 
258         if (value != 0) {
259             return value;
260         }
261 
262         return 0;
263     }
264 
265     public boolean equals(Object obj) {
266         if (obj == null) {
267             return false;
268         }
269 
270         SCLicense scLicense = null;
271 
272         try {
273             scLicense = (SCLicense)obj;
274         }
275         catch (ClassCastException cce) {
276             return false;
277         }
278 
279         long pk = scLicense.getPrimaryKey();
280 
281         if (getPrimaryKey() == pk) {
282             return true;
283         }
284         else {
285             return false;
286         }
287     }
288 
289     public int hashCode() {
290         return (int)getPrimaryKey();
291     }
292 
293     public String toString() {
294         StringBundler sb = new StringBundler(13);
295 
296         sb.append("{licenseId=");
297         sb.append(getLicenseId());
298         sb.append(", name=");
299         sb.append(getName());
300         sb.append(", url=");
301         sb.append(getUrl());
302         sb.append(", openSource=");
303         sb.append(getOpenSource());
304         sb.append(", active=");
305         sb.append(getActive());
306         sb.append(", recommended=");
307         sb.append(getRecommended());
308         sb.append("}");
309 
310         return sb.toString();
311     }
312 
313     public String toXmlString() {
314         StringBundler sb = new StringBundler(22);
315 
316         sb.append("<model><model-name>");
317         sb.append("com.liferay.portlet.softwarecatalog.model.SCLicense");
318         sb.append("</model-name>");
319 
320         sb.append(
321             "<column><column-name>licenseId</column-name><column-value><![CDATA[");
322         sb.append(getLicenseId());
323         sb.append("]]></column-value></column>");
324         sb.append(
325             "<column><column-name>name</column-name><column-value><![CDATA[");
326         sb.append(getName());
327         sb.append("]]></column-value></column>");
328         sb.append(
329             "<column><column-name>url</column-name><column-value><![CDATA[");
330         sb.append(getUrl());
331         sb.append("]]></column-value></column>");
332         sb.append(
333             "<column><column-name>openSource</column-name><column-value><![CDATA[");
334         sb.append(getOpenSource());
335         sb.append("]]></column-value></column>");
336         sb.append(
337             "<column><column-name>active</column-name><column-value><![CDATA[");
338         sb.append(getActive());
339         sb.append("]]></column-value></column>");
340         sb.append(
341             "<column><column-name>recommended</column-name><column-value><![CDATA[");
342         sb.append(getRecommended());
343         sb.append("]]></column-value></column>");
344 
345         sb.append("</model>");
346 
347         return sb.toString();
348     }
349 
350     private long _licenseId;
351     private String _name;
352     private String _url;
353     private boolean _openSource;
354     private boolean _active;
355     private boolean _recommended;
356     private transient ExpandoBridge _expandoBridge;
357 }