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.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<ServiceComponent> {
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 ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.entity.cache.enabled.com.liferay.portal.model.ServiceComponent"),
84              true);
85      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.finder.cache.enabled.com.liferay.portal.model.ServiceComponent"),
87              true);
88  
89      public static ServiceComponent toModel(ServiceComponentSoap soapModel) {
90          ServiceComponent model = new ServiceComponentImpl();
91  
92          model.setServiceComponentId(soapModel.getServiceComponentId());
93          model.setBuildNamespace(soapModel.getBuildNamespace());
94          model.setBuildNumber(soapModel.getBuildNumber());
95          model.setBuildDate(soapModel.getBuildDate());
96          model.setData(soapModel.getData());
97  
98          return model;
99      }
100 
101     public static List<ServiceComponent> toModels(
102         ServiceComponentSoap[] soapModels) {
103         List<ServiceComponent> models = new ArrayList<ServiceComponent>(soapModels.length);
104 
105         for (ServiceComponentSoap soapModel : soapModels) {
106             models.add(toModel(soapModel));
107         }
108 
109         return models;
110     }
111 
112     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
113                 "lock.expiration.time.com.liferay.portal.model.ServiceComponent"));
114 
115     public ServiceComponentModelImpl() {
116     }
117 
118     public long getPrimaryKey() {
119         return _serviceComponentId;
120     }
121 
122     public void setPrimaryKey(long pk) {
123         setServiceComponentId(pk);
124     }
125 
126     public Serializable getPrimaryKeyObj() {
127         return new Long(_serviceComponentId);
128     }
129 
130     public long getServiceComponentId() {
131         return _serviceComponentId;
132     }
133 
134     public void setServiceComponentId(long serviceComponentId) {
135         _serviceComponentId = serviceComponentId;
136     }
137 
138     public String getBuildNamespace() {
139         return GetterUtil.getString(_buildNamespace);
140     }
141 
142     public void setBuildNamespace(String buildNamespace) {
143         _buildNamespace = buildNamespace;
144 
145         if (_originalBuildNamespace == null) {
146             _originalBuildNamespace = buildNamespace;
147         }
148     }
149 
150     public String getOriginalBuildNamespace() {
151         return GetterUtil.getString(_originalBuildNamespace);
152     }
153 
154     public long getBuildNumber() {
155         return _buildNumber;
156     }
157 
158     public void setBuildNumber(long buildNumber) {
159         _buildNumber = buildNumber;
160 
161         if (!_setOriginalBuildNumber) {
162             _setOriginalBuildNumber = true;
163 
164             _originalBuildNumber = buildNumber;
165         }
166     }
167 
168     public long getOriginalBuildNumber() {
169         return _originalBuildNumber;
170     }
171 
172     public long getBuildDate() {
173         return _buildDate;
174     }
175 
176     public void setBuildDate(long buildDate) {
177         _buildDate = buildDate;
178     }
179 
180     public String getData() {
181         return GetterUtil.getString(_data);
182     }
183 
184     public void setData(String data) {
185         _data = data;
186     }
187 
188     public ServiceComponent toEscapedModel() {
189         if (isEscapedModel()) {
190             return (ServiceComponent)this;
191         }
192         else {
193             ServiceComponent model = new ServiceComponentImpl();
194 
195             model.setNew(isNew());
196             model.setEscapedModel(true);
197 
198             model.setServiceComponentId(getServiceComponentId());
199             model.setBuildNamespace(HtmlUtil.escape(getBuildNamespace()));
200             model.setBuildNumber(getBuildNumber());
201             model.setBuildDate(getBuildDate());
202             model.setData(HtmlUtil.escape(getData()));
203 
204             model = (ServiceComponent)Proxy.newProxyInstance(ServiceComponent.class.getClassLoader(),
205                     new Class[] { ServiceComponent.class },
206                     new ReadOnlyBeanHandler(model));
207 
208             return model;
209         }
210     }
211 
212     public Object clone() {
213         ServiceComponentImpl clone = new ServiceComponentImpl();
214 
215         clone.setServiceComponentId(getServiceComponentId());
216         clone.setBuildNamespace(getBuildNamespace());
217         clone.setBuildNumber(getBuildNumber());
218         clone.setBuildDate(getBuildDate());
219         clone.setData(getData());
220 
221         return clone;
222     }
223 
224     public int compareTo(ServiceComponent serviceComponent) {
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         ServiceComponent serviceComponent = null;
261 
262         try {
263             serviceComponent = (ServiceComponent)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     public String toString() {
284         StringBuilder sb = new StringBuilder();
285 
286         sb.append("{serviceComponentId=");
287         sb.append(getServiceComponentId());
288         sb.append(", buildNamespace=");
289         sb.append(getBuildNamespace());
290         sb.append(", buildNumber=");
291         sb.append(getBuildNumber());
292         sb.append(", buildDate=");
293         sb.append(getBuildDate());
294         sb.append(", data=");
295         sb.append(getData());
296         sb.append("}");
297 
298         return sb.toString();
299     }
300 
301     public String toXmlString() {
302         StringBuilder sb = new StringBuilder();
303 
304         sb.append("<model><model-name>");
305         sb.append("com.liferay.portal.model.ServiceComponent");
306         sb.append("</model-name>");
307 
308         sb.append(
309             "<column><column-name>serviceComponentId</column-name><column-value><![CDATA[");
310         sb.append(getServiceComponentId());
311         sb.append("]]></column-value></column>");
312         sb.append(
313             "<column><column-name>buildNamespace</column-name><column-value><![CDATA[");
314         sb.append(getBuildNamespace());
315         sb.append("]]></column-value></column>");
316         sb.append(
317             "<column><column-name>buildNumber</column-name><column-value><![CDATA[");
318         sb.append(getBuildNumber());
319         sb.append("]]></column-value></column>");
320         sb.append(
321             "<column><column-name>buildDate</column-name><column-value><![CDATA[");
322         sb.append(getBuildDate());
323         sb.append("]]></column-value></column>");
324         sb.append(
325             "<column><column-name>data</column-name><column-value><![CDATA[");
326         sb.append(getData());
327         sb.append("]]></column-value></column>");
328 
329         sb.append("</model>");
330 
331         return sb.toString();
332     }
333 
334     private long _serviceComponentId;
335     private String _buildNamespace;
336     private String _originalBuildNamespace;
337     private long _buildNumber;
338     private long _originalBuildNumber;
339     private boolean _setOriginalBuildNumber;
340     private long _buildDate;
341     private String _data;
342 }