1   /**
2    * Copyright (c) 2000-2008 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.portal.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.ServiceComponent;
29  import com.liferay.portal.model.ServiceComponentSoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.List;
39  
40  /**
41   * <a href="ServiceComponentModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>ServiceComponent</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portal.model.ServiceComponent
56   * @see com.liferay.portal.model.ServiceComponentModel
57   * @see com.liferay.portal.model.impl.ServiceComponentImpl
58   *
59   */
60  public class ServiceComponentModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "ServiceComponent";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "serviceComponentId", new Integer(Types.BIGINT) },
64              
65  
66              { "buildNamespace", new Integer(Types.VARCHAR) },
67              
68  
69              { "buildNumber", new Integer(Types.BIGINT) },
70              
71  
72              { "buildDate", new Integer(Types.BIGINT) },
73              
74  
75              { "data_", new Integer(Types.CLOB) }
76          };
77      public static final String TABLE_SQL_CREATE = "create table ServiceComponent (serviceComponentId LONG not null primary key,buildNamespace VARCHAR(75) null,buildNumber LONG,buildDate LONG,data_ TEXT null)";
78      public static final String TABLE_SQL_DROP = "drop table ServiceComponent";
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.finder.cache.enabled.com.liferay.portal.model.ServiceComponent"),
84              true);
85  
86      public static ServiceComponent toModel(ServiceComponentSoap soapModel) {
87          ServiceComponent model = new ServiceComponentImpl();
88  
89          model.setServiceComponentId(soapModel.getServiceComponentId());
90          model.setBuildNamespace(soapModel.getBuildNamespace());
91          model.setBuildNumber(soapModel.getBuildNumber());
92          model.setBuildDate(soapModel.getBuildDate());
93          model.setData(soapModel.getData());
94  
95          return model;
96      }
97  
98      public static List<ServiceComponent> toModels(
99          ServiceComponentSoap[] soapModels) {
100         List<ServiceComponent> models = new ArrayList<ServiceComponent>(soapModels.length);
101 
102         for (ServiceComponentSoap soapModel : soapModels) {
103             models.add(toModel(soapModel));
104         }
105 
106         return models;
107     }
108 
109     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
110                 "lock.expiration.time.com.liferay.portal.model.ServiceComponent"));
111 
112     public ServiceComponentModelImpl() {
113     }
114 
115     public long getPrimaryKey() {
116         return _serviceComponentId;
117     }
118 
119     public void setPrimaryKey(long pk) {
120         setServiceComponentId(pk);
121     }
122 
123     public Serializable getPrimaryKeyObj() {
124         return new Long(_serviceComponentId);
125     }
126 
127     public long getServiceComponentId() {
128         return _serviceComponentId;
129     }
130 
131     public void setServiceComponentId(long serviceComponentId) {
132         if (serviceComponentId != _serviceComponentId) {
133             _serviceComponentId = serviceComponentId;
134         }
135     }
136 
137     public String getBuildNamespace() {
138         return GetterUtil.getString(_buildNamespace);
139     }
140 
141     public void setBuildNamespace(String buildNamespace) {
142         if (((buildNamespace == null) && (_buildNamespace != null)) ||
143                 ((buildNamespace != null) && (_buildNamespace == null)) ||
144                 ((buildNamespace != null) && (_buildNamespace != null) &&
145                 !buildNamespace.equals(_buildNamespace))) {
146             _buildNamespace = buildNamespace;
147         }
148     }
149 
150     public long getBuildNumber() {
151         return _buildNumber;
152     }
153 
154     public void setBuildNumber(long buildNumber) {
155         if (buildNumber != _buildNumber) {
156             _buildNumber = buildNumber;
157         }
158     }
159 
160     public long getBuildDate() {
161         return _buildDate;
162     }
163 
164     public void setBuildDate(long buildDate) {
165         if (buildDate != _buildDate) {
166             _buildDate = buildDate;
167         }
168     }
169 
170     public String getData() {
171         return GetterUtil.getString(_data);
172     }
173 
174     public void setData(String data) {
175         if (((data == null) && (_data != null)) ||
176                 ((data != null) && (_data == null)) ||
177                 ((data != null) && (_data != null) && !data.equals(_data))) {
178             _data = data;
179         }
180     }
181 
182     public ServiceComponent toEscapedModel() {
183         if (isEscapedModel()) {
184             return (ServiceComponent)this;
185         }
186         else {
187             ServiceComponent model = new ServiceComponentImpl();
188 
189             model.setNew(isNew());
190             model.setEscapedModel(true);
191 
192             model.setServiceComponentId(getServiceComponentId());
193             model.setBuildNamespace(HtmlUtil.escape(getBuildNamespace()));
194             model.setBuildNumber(getBuildNumber());
195             model.setBuildDate(getBuildDate());
196             model.setData(HtmlUtil.escape(getData()));
197 
198             model = (ServiceComponent)Proxy.newProxyInstance(ServiceComponent.class.getClassLoader(),
199                     new Class[] { ServiceComponent.class },
200                     new ReadOnlyBeanHandler(model));
201 
202             return model;
203         }
204     }
205 
206     public Object clone() {
207         ServiceComponentImpl clone = new ServiceComponentImpl();
208 
209         clone.setServiceComponentId(getServiceComponentId());
210         clone.setBuildNamespace(getBuildNamespace());
211         clone.setBuildNumber(getBuildNumber());
212         clone.setBuildDate(getBuildDate());
213         clone.setData(getData());
214 
215         return clone;
216     }
217 
218     public int compareTo(Object obj) {
219         if (obj == null) {
220             return -1;
221         }
222 
223         ServiceComponentImpl serviceComponent = (ServiceComponentImpl)obj;
224 
225         int value = 0;
226 
227         value = getBuildNamespace()
228                     .compareTo(serviceComponent.getBuildNamespace());
229 
230         value = value * -1;
231 
232         if (value != 0) {
233             return value;
234         }
235 
236         if (getBuildNumber() < serviceComponent.getBuildNumber()) {
237             value = -1;
238         }
239         else if (getBuildNumber() > serviceComponent.getBuildNumber()) {
240             value = 1;
241         }
242         else {
243             value = 0;
244         }
245 
246         value = value * -1;
247 
248         if (value != 0) {
249             return value;
250         }
251 
252         return 0;
253     }
254 
255     public boolean equals(Object obj) {
256         if (obj == null) {
257             return false;
258         }
259 
260         ServiceComponentImpl serviceComponent = null;
261 
262         try {
263             serviceComponent = (ServiceComponentImpl)obj;
264         }
265         catch (ClassCastException cce) {
266             return false;
267         }
268 
269         long pk = serviceComponent.getPrimaryKey();
270 
271         if (getPrimaryKey() == pk) {
272             return true;
273         }
274         else {
275             return false;
276         }
277     }
278 
279     public int hashCode() {
280         return (int)getPrimaryKey();
281     }
282 
283     private long _serviceComponentId;
284     private String _buildNamespace;
285     private long _buildNumber;
286     private long _buildDate;
287     private String _data;
288 }