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