1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.softwarecatalog.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.impl.BaseModelImpl;
22  
23  import com.liferay.portlet.softwarecatalog.model.SCLicense;
24  import com.liferay.portlet.softwarecatalog.model.SCLicenseSoap;
25  
26  import java.io.Serializable;
27  
28  import java.lang.reflect.Proxy;
29  
30  import java.sql.Types;
31  
32  import java.util.ArrayList;
33  import java.util.List;
34  
35  /**
36   * <a href="SCLicenseModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be
40   * overwritten the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This interface is a model that represents the SCLicense table in the
45   * database.
46   * </p>
47   *
48   * @author    Brian Wing Shun Chan
49   * @see       SCLicenseImpl
50   * @see       com.liferay.portlet.softwarecatalog.model.SCLicense
51   * @see       com.liferay.portlet.softwarecatalog.model.SCLicenseModel
52   * @generated
53   */
54  public class SCLicenseModelImpl extends BaseModelImpl<SCLicense> {
55      public static final String TABLE_NAME = "SCLicense";
56      public static final Object[][] TABLE_COLUMNS = {
57              { "licenseId", new Integer(Types.BIGINT) },
58              { "name", new Integer(Types.VARCHAR) },
59              { "url", new Integer(Types.VARCHAR) },
60              { "openSource", new Integer(Types.BOOLEAN) },
61              { "active_", new Integer(Types.BOOLEAN) },
62              { "recommended", new Integer(Types.BOOLEAN) }
63          };
64      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)";
65      public static final String TABLE_SQL_DROP = "drop table SCLicense";
66      public static final String ORDER_BY_JPQL = " ORDER BY scLicense.name ASC";
67      public static final String ORDER_BY_SQL = " ORDER BY SCLicense.name ASC";
68      public static final String DATA_SOURCE = "liferayDataSource";
69      public static final String SESSION_FACTORY = "liferaySessionFactory";
70      public static final String TX_MANAGER = "liferayTransactionManager";
71      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
72                  "value.object.entity.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCLicense"),
73              true);
74      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
75                  "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCLicense"),
76              true);
77  
78      public static SCLicense toModel(SCLicenseSoap soapModel) {
79          SCLicense model = new SCLicenseImpl();
80  
81          model.setLicenseId(soapModel.getLicenseId());
82          model.setName(soapModel.getName());
83          model.setUrl(soapModel.getUrl());
84          model.setOpenSource(soapModel.getOpenSource());
85          model.setActive(soapModel.getActive());
86          model.setRecommended(soapModel.getRecommended());
87  
88          return model;
89      }
90  
91      public static List<SCLicense> toModels(SCLicenseSoap[] soapModels) {
92          List<SCLicense> models = new ArrayList<SCLicense>(soapModels.length);
93  
94          for (SCLicenseSoap soapModel : soapModels) {
95              models.add(toModel(soapModel));
96          }
97  
98          return models;
99      }
100 
101     public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME = "SCLicenses_SCProductEntries";
102     public static final Object[][] MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_COLUMNS =
103         {
104             { "licenseId", new Integer(Types.BIGINT) },
105             { "productEntryId", new Integer(Types.BIGINT) }
106         };
107     public static final String MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_SQL_CREATE =
108         "create table SCLicenses_SCProductEntries (licenseId LONG not null,productEntryId LONG not null,primary key (licenseId, productEntryId))";
109     public static final boolean FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES =
110         GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
111                 "value.object.finder.cache.enabled.SCLicenses_SCProductEntries"),
112             true);
113     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
114                 "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCLicense"));
115 
116     public SCLicenseModelImpl() {
117     }
118 
119     public long getPrimaryKey() {
120         return _licenseId;
121     }
122 
123     public void setPrimaryKey(long pk) {
124         setLicenseId(pk);
125     }
126 
127     public Serializable getPrimaryKeyObj() {
128         return new Long(_licenseId);
129     }
130 
131     public long getLicenseId() {
132         return _licenseId;
133     }
134 
135     public void setLicenseId(long licenseId) {
136         _licenseId = licenseId;
137     }
138 
139     public String getName() {
140         return GetterUtil.getString(_name);
141     }
142 
143     public void setName(String name) {
144         _name = name;
145     }
146 
147     public String getUrl() {
148         return GetterUtil.getString(_url);
149     }
150 
151     public void setUrl(String url) {
152         _url = url;
153     }
154 
155     public boolean getOpenSource() {
156         return _openSource;
157     }
158 
159     public boolean isOpenSource() {
160         return _openSource;
161     }
162 
163     public void setOpenSource(boolean openSource) {
164         _openSource = openSource;
165     }
166 
167     public boolean getActive() {
168         return _active;
169     }
170 
171     public boolean isActive() {
172         return _active;
173     }
174 
175     public void setActive(boolean active) {
176         _active = active;
177     }
178 
179     public boolean getRecommended() {
180         return _recommended;
181     }
182 
183     public boolean isRecommended() {
184         return _recommended;
185     }
186 
187     public void setRecommended(boolean recommended) {
188         _recommended = recommended;
189     }
190 
191     public SCLicense toEscapedModel() {
192         if (isEscapedModel()) {
193             return (SCLicense)this;
194         }
195         else {
196             SCLicense model = new SCLicenseImpl();
197 
198             model.setNew(isNew());
199             model.setEscapedModel(true);
200 
201             model.setLicenseId(getLicenseId());
202             model.setName(HtmlUtil.escape(getName()));
203             model.setUrl(HtmlUtil.escape(getUrl()));
204             model.setOpenSource(getOpenSource());
205             model.setActive(getActive());
206             model.setRecommended(getRecommended());
207 
208             model = (SCLicense)Proxy.newProxyInstance(SCLicense.class.getClassLoader(),
209                     new Class[] { SCLicense.class },
210                     new ReadOnlyBeanHandler(model));
211 
212             return model;
213         }
214     }
215 
216     public Object clone() {
217         SCLicenseImpl clone = new SCLicenseImpl();
218 
219         clone.setLicenseId(getLicenseId());
220         clone.setName(getName());
221         clone.setUrl(getUrl());
222         clone.setOpenSource(getOpenSource());
223         clone.setActive(getActive());
224         clone.setRecommended(getRecommended());
225 
226         return clone;
227     }
228 
229     public int compareTo(SCLicense scLicense) {
230         int value = 0;
231 
232         value = getName().compareTo(scLicense.getName());
233 
234         if (value != 0) {
235             return value;
236         }
237 
238         return 0;
239     }
240 
241     public boolean equals(Object obj) {
242         if (obj == null) {
243             return false;
244         }
245 
246         SCLicense scLicense = null;
247 
248         try {
249             scLicense = (SCLicense)obj;
250         }
251         catch (ClassCastException cce) {
252             return false;
253         }
254 
255         long pk = scLicense.getPrimaryKey();
256 
257         if (getPrimaryKey() == pk) {
258             return true;
259         }
260         else {
261             return false;
262         }
263     }
264 
265     public int hashCode() {
266         return (int)getPrimaryKey();
267     }
268 
269     public String toString() {
270         StringBundler sb = new StringBundler(13);
271 
272         sb.append("{licenseId=");
273         sb.append(getLicenseId());
274         sb.append(", name=");
275         sb.append(getName());
276         sb.append(", url=");
277         sb.append(getUrl());
278         sb.append(", openSource=");
279         sb.append(getOpenSource());
280         sb.append(", active=");
281         sb.append(getActive());
282         sb.append(", recommended=");
283         sb.append(getRecommended());
284         sb.append("}");
285 
286         return sb.toString();
287     }
288 
289     public String toXmlString() {
290         StringBundler sb = new StringBundler(22);
291 
292         sb.append("<model><model-name>");
293         sb.append("com.liferay.portlet.softwarecatalog.model.SCLicense");
294         sb.append("</model-name>");
295 
296         sb.append(
297             "<column><column-name>licenseId</column-name><column-value><![CDATA[");
298         sb.append(getLicenseId());
299         sb.append("]]></column-value></column>");
300         sb.append(
301             "<column><column-name>name</column-name><column-value><![CDATA[");
302         sb.append(getName());
303         sb.append("]]></column-value></column>");
304         sb.append(
305             "<column><column-name>url</column-name><column-value><![CDATA[");
306         sb.append(getUrl());
307         sb.append("]]></column-value></column>");
308         sb.append(
309             "<column><column-name>openSource</column-name><column-value><![CDATA[");
310         sb.append(getOpenSource());
311         sb.append("]]></column-value></column>");
312         sb.append(
313             "<column><column-name>active</column-name><column-value><![CDATA[");
314         sb.append(getActive());
315         sb.append("]]></column-value></column>");
316         sb.append(
317             "<column><column-name>recommended</column-name><column-value><![CDATA[");
318         sb.append(getRecommended());
319         sb.append("]]></column-value></column>");
320 
321         sb.append("</model>");
322 
323         return sb.toString();
324     }
325 
326     private long _licenseId;
327     private String _name;
328     private String _url;
329     private boolean _openSource;
330     private boolean _active;
331     private boolean _recommended;
332 }