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.service.model.ServiceComponent
56   * @see com.liferay.portal.service.model.ServiceComponentModel
57   * @see com.liferay.portal.service.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.setEscapedModel(true);
190 
191             model.setServiceComponentId(getServiceComponentId());
192             model.setBuildNamespace(HtmlUtil.escape(getBuildNamespace()));
193             model.setBuildNumber(getBuildNumber());
194             model.setBuildDate(getBuildDate());
195             model.setData(HtmlUtil.escape(getData()));
196 
197             model = (ServiceComponent)Proxy.newProxyInstance(ServiceComponent.class.getClassLoader(),
198                     new Class[] { ServiceComponent.class },
199                     new ReadOnlyBeanHandler(model));
200 
201             return model;
202         }
203     }
204 
205     public Object clone() {
206         ServiceComponentImpl clone = new ServiceComponentImpl();
207 
208         clone.setServiceComponentId(getServiceComponentId());
209         clone.setBuildNamespace(getBuildNamespace());
210         clone.setBuildNumber(getBuildNumber());
211         clone.setBuildDate(getBuildDate());
212         clone.setData(getData());
213 
214         return clone;
215     }
216 
217     public int compareTo(Object obj) {
218         if (obj == null) {
219             return -1;
220         }
221 
222         ServiceComponentImpl serviceComponent = (ServiceComponentImpl)obj;
223 
224         int value = 0;
225 
226         value = getBuildNamespace()
227                     .compareTo(serviceComponent.getBuildNamespace());
228 
229         value = value * -1;
230 
231         if (value != 0) {
232             return value;
233         }
234 
235         if (getBuildNumber() < serviceComponent.getBuildNumber()) {
236             value = -1;
237         }
238         else if (getBuildNumber() > serviceComponent.getBuildNumber()) {
239             value = 1;
240         }
241         else {
242             value = 0;
243         }
244 
245         value = value * -1;
246 
247         if (value != 0) {
248             return value;
249         }
250 
251         return 0;
252     }
253 
254     public boolean equals(Object obj) {
255         if (obj == null) {
256             return false;
257         }
258 
259         ServiceComponentImpl serviceComponent = null;
260 
261         try {
262             serviceComponent = (ServiceComponentImpl)obj;
263         }
264         catch (ClassCastException cce) {
265             return false;
266         }
267 
268         long pk = serviceComponent.getPrimaryKey();
269 
270         if (getPrimaryKey() == pk) {
271             return true;
272         }
273         else {
274             return false;
275         }
276     }
277 
278     public int hashCode() {
279         return (int)getPrimaryKey();
280     }
281 
282     private long _serviceComponentId;
283     private String _buildNamespace;
284     private long _buildNumber;
285     private long _buildDate;
286     private String _data;
287 }