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 {
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90                  "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCLicense"),
91              true);
92  
93      public static SCLicense toModel(SCLicenseSoap soapModel) {
94          SCLicense model = new SCLicenseImpl();
95  
96          model.setLicenseId(soapModel.getLicenseId());
97          model.setName(soapModel.getName());
98          model.setUrl(soapModel.getUrl());
99          model.setOpenSource(soapModel.getOpenSource());
100         model.setActive(soapModel.getActive());
101         model.setRecommended(soapModel.getRecommended());
102 
103         return model;
104     }
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 boolean CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
117                 "value.object.finder.cache.enabled.SCLicenses_SCProductEntries"),
118             true);
119     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
120                 "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCLicense"));
121 
122     public SCLicenseModelImpl() {
123     }
124 
125     public long getPrimaryKey() {
126         return _licenseId;
127     }
128 
129     public void setPrimaryKey(long pk) {
130         setLicenseId(pk);
131     }
132 
133     public Serializable getPrimaryKeyObj() {
134         return new Long(_licenseId);
135     }
136 
137     public long getLicenseId() {
138         return _licenseId;
139     }
140 
141     public void setLicenseId(long licenseId) {
142         if (licenseId != _licenseId) {
143             _licenseId = licenseId;
144         }
145     }
146 
147     public String getName() {
148         return GetterUtil.getString(_name);
149     }
150 
151     public void setName(String name) {
152         if (((name == null) && (_name != null)) ||
153                 ((name != null) && (_name == null)) ||
154                 ((name != null) && (_name != null) && !name.equals(_name))) {
155             _name = name;
156         }
157     }
158 
159     public String getUrl() {
160         return GetterUtil.getString(_url);
161     }
162 
163     public void setUrl(String url) {
164         if (((url == null) && (_url != null)) ||
165                 ((url != null) && (_url == null)) ||
166                 ((url != null) && (_url != null) && !url.equals(_url))) {
167             _url = url;
168         }
169     }
170 
171     public boolean getOpenSource() {
172         return _openSource;
173     }
174 
175     public boolean isOpenSource() {
176         return _openSource;
177     }
178 
179     public void setOpenSource(boolean openSource) {
180         if (openSource != _openSource) {
181             _openSource = openSource;
182         }
183     }
184 
185     public boolean getActive() {
186         return _active;
187     }
188 
189     public boolean isActive() {
190         return _active;
191     }
192 
193     public void setActive(boolean active) {
194         if (active != _active) {
195             _active = active;
196         }
197     }
198 
199     public boolean getRecommended() {
200         return _recommended;
201     }
202 
203     public boolean isRecommended() {
204         return _recommended;
205     }
206 
207     public void setRecommended(boolean recommended) {
208         if (recommended != _recommended) {
209             _recommended = recommended;
210         }
211     }
212 
213     public SCLicense toEscapedModel() {
214         if (isEscapedModel()) {
215             return (SCLicense)this;
216         }
217         else {
218             SCLicense model = new SCLicenseImpl();
219 
220             model.setNew(isNew());
221             model.setEscapedModel(true);
222 
223             model.setLicenseId(getLicenseId());
224             model.setName(HtmlUtil.escape(getName()));
225             model.setUrl(HtmlUtil.escape(getUrl()));
226             model.setOpenSource(getOpenSource());
227             model.setActive(getActive());
228             model.setRecommended(getRecommended());
229 
230             model = (SCLicense)Proxy.newProxyInstance(SCLicense.class.getClassLoader(),
231                     new Class[] { SCLicense.class },
232                     new ReadOnlyBeanHandler(model));
233 
234             return model;
235         }
236     }
237 
238     public ExpandoBridge getExpandoBridge() {
239         if (_expandoBridge == null) {
240             _expandoBridge = new ExpandoBridgeImpl(SCLicense.class.getName(),
241                     getPrimaryKey());
242         }
243 
244         return _expandoBridge;
245     }
246 
247     public Object clone() {
248         SCLicenseImpl clone = new SCLicenseImpl();
249 
250         clone.setLicenseId(getLicenseId());
251         clone.setName(getName());
252         clone.setUrl(getUrl());
253         clone.setOpenSource(getOpenSource());
254         clone.setActive(getActive());
255         clone.setRecommended(getRecommended());
256 
257         return clone;
258     }
259 
260     public int compareTo(Object obj) {
261         if (obj == null) {
262             return -1;
263         }
264 
265         SCLicenseImpl scLicense = (SCLicenseImpl)obj;
266 
267         int value = 0;
268 
269         value = getName().compareTo(scLicense.getName());
270 
271         if (value != 0) {
272             return value;
273         }
274 
275         return 0;
276     }
277 
278     public boolean equals(Object obj) {
279         if (obj == null) {
280             return false;
281         }
282 
283         SCLicenseImpl scLicense = null;
284 
285         try {
286             scLicense = (SCLicenseImpl)obj;
287         }
288         catch (ClassCastException cce) {
289             return false;
290         }
291 
292         long pk = scLicense.getPrimaryKey();
293 
294         if (getPrimaryKey() == pk) {
295             return true;
296         }
297         else {
298             return false;
299         }
300     }
301 
302     public int hashCode() {
303         return (int)getPrimaryKey();
304     }
305 
306     private long _licenseId;
307     private String _name;
308     private String _url;
309     private boolean _openSource;
310     private boolean _active;
311     private boolean _recommended;
312     private transient ExpandoBridge _expandoBridge;
313 }