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