1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.kernel.util.StringPool;
21  import com.liferay.portal.model.ServiceComponent;
22  import com.liferay.portal.model.ServiceComponentSoap;
23  import com.liferay.portal.service.ServiceContext;
24  
25  import com.liferay.portlet.expando.model.ExpandoBridge;
26  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="ServiceComponentModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This interface is a model that represents the ServiceComponent table in the
47   * database.
48   * </p>
49   *
50   * @author    Brian Wing Shun Chan
51   * @see       ServiceComponentImpl
52   * @see       com.liferay.portal.model.ServiceComponent
53   * @see       com.liferay.portal.model.ServiceComponentModel
54   * @generated
55   */
56  public class ServiceComponentModelImpl extends BaseModelImpl<ServiceComponent> {
57      public static final String TABLE_NAME = "ServiceComponent";
58      public static final Object[][] TABLE_COLUMNS = {
59              { "serviceComponentId", new Integer(Types.BIGINT) },
60              { "buildNamespace", new Integer(Types.VARCHAR) },
61              { "buildNumber", new Integer(Types.BIGINT) },
62              { "buildDate", new Integer(Types.BIGINT) },
63              { "data_", new Integer(Types.CLOB) }
64          };
65      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)";
66      public static final String TABLE_SQL_DROP = "drop table ServiceComponent";
67      public static final String ORDER_BY_JPQL = " ORDER BY serviceComponent.buildNamespace DESC, serviceComponent.buildNumber DESC";
68      public static final String ORDER_BY_SQL = " ORDER BY ServiceComponent.buildNamespace DESC, ServiceComponent.buildNumber DESC";
69      public static final String DATA_SOURCE = "liferayDataSource";
70      public static final String SESSION_FACTORY = "liferaySessionFactory";
71      public static final String TX_MANAGER = "liferayTransactionManager";
72      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
73                  "value.object.entity.cache.enabled.com.liferay.portal.model.ServiceComponent"),
74              true);
75      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.finder.cache.enabled.com.liferay.portal.model.ServiceComponent"),
77              true);
78  
79      public static ServiceComponent toModel(ServiceComponentSoap soapModel) {
80          ServiceComponent model = new ServiceComponentImpl();
81  
82          model.setServiceComponentId(soapModel.getServiceComponentId());
83          model.setBuildNamespace(soapModel.getBuildNamespace());
84          model.setBuildNumber(soapModel.getBuildNumber());
85          model.setBuildDate(soapModel.getBuildDate());
86          model.setData(soapModel.getData());
87  
88          return model;
89      }
90  
91      public static List<ServiceComponent> toModels(
92          ServiceComponentSoap[] soapModels) {
93          List<ServiceComponent> models = new ArrayList<ServiceComponent>(soapModels.length);
94  
95          for (ServiceComponentSoap soapModel : soapModels) {
96              models.add(toModel(soapModel));
97          }
98  
99          return models;
100     }
101 
102     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
103                 "lock.expiration.time.com.liferay.portal.model.ServiceComponent"));
104 
105     public ServiceComponentModelImpl() {
106     }
107 
108     public long getPrimaryKey() {
109         return _serviceComponentId;
110     }
111 
112     public void setPrimaryKey(long pk) {
113         setServiceComponentId(pk);
114     }
115 
116     public Serializable getPrimaryKeyObj() {
117         return new Long(_serviceComponentId);
118     }
119 
120     public long getServiceComponentId() {
121         return _serviceComponentId;
122     }
123 
124     public void setServiceComponentId(long serviceComponentId) {
125         _serviceComponentId = serviceComponentId;
126     }
127 
128     public String getBuildNamespace() {
129         if (_buildNamespace == null) {
130             return StringPool.BLANK;
131         }
132         else {
133             return _buildNamespace;
134         }
135     }
136 
137     public void setBuildNamespace(String buildNamespace) {
138         _buildNamespace = buildNamespace;
139 
140         if (_originalBuildNamespace == null) {
141             _originalBuildNamespace = buildNamespace;
142         }
143     }
144 
145     public String getOriginalBuildNamespace() {
146         return GetterUtil.getString(_originalBuildNamespace);
147     }
148 
149     public long getBuildNumber() {
150         return _buildNumber;
151     }
152 
153     public void setBuildNumber(long buildNumber) {
154         _buildNumber = buildNumber;
155 
156         if (!_setOriginalBuildNumber) {
157             _setOriginalBuildNumber = true;
158 
159             _originalBuildNumber = buildNumber;
160         }
161     }
162 
163     public long getOriginalBuildNumber() {
164         return _originalBuildNumber;
165     }
166 
167     public long getBuildDate() {
168         return _buildDate;
169     }
170 
171     public void setBuildDate(long buildDate) {
172         _buildDate = buildDate;
173     }
174 
175     public String getData() {
176         if (_data == null) {
177             return StringPool.BLANK;
178         }
179         else {
180             return _data;
181         }
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             return (ServiceComponent)Proxy.newProxyInstance(ServiceComponent.class.getClassLoader(),
194                 new Class[] { ServiceComponent.class },
195                 new AutoEscapeBeanHandler(this));
196         }
197     }
198 
199     public ExpandoBridge getExpandoBridge() {
200         if (_expandoBridge == null) {
201             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(ServiceComponent.class.getName(),
202                     getPrimaryKey());
203         }
204 
205         return _expandoBridge;
206     }
207 
208     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
209         getExpandoBridge().setAttributes(serviceContext);
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         StringBundler sb = new StringBundler(11);
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         StringBundler sb = new StringBundler(19);
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     private transient ExpandoBridge _expandoBridge;
343 }