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