1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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 interface is a model that represents the ServiceComponent table in the
50   * database.
51   * </p>
52   *
53   * @author    Brian Wing Shun Chan
54   * @see       ServiceComponentImpl
55   * @see       com.liferay.portal.model.ServiceComponent
56   * @see       com.liferay.portal.model.ServiceComponentModel
57   * @generated
58   */
59  public class ServiceComponentModelImpl extends BaseModelImpl<ServiceComponent> {
60      public static final String TABLE_NAME = "ServiceComponent";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "serviceComponentId", new Integer(Types.BIGINT) },
63              { "buildNamespace", new Integer(Types.VARCHAR) },
64              { "buildNumber", new Integer(Types.BIGINT) },
65              { "buildDate", new Integer(Types.BIGINT) },
66              { "data_", new Integer(Types.CLOB) }
67          };
68      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)";
69      public static final String TABLE_SQL_DROP = "drop table ServiceComponent";
70      public static final String DATA_SOURCE = "liferayDataSource";
71      public static final String SESSION_FACTORY = "liferaySessionFactory";
72      public static final String TX_MANAGER = "liferayTransactionManager";
73      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.entity.cache.enabled.com.liferay.portal.model.ServiceComponent"),
75              true);
76      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portal.model.ServiceComponent"),
78              true);
79  
80      public static ServiceComponent toModel(ServiceComponentSoap soapModel) {
81          ServiceComponent model = new ServiceComponentImpl();
82  
83          model.setServiceComponentId(soapModel.getServiceComponentId());
84          model.setBuildNamespace(soapModel.getBuildNamespace());
85          model.setBuildNumber(soapModel.getBuildNumber());
86          model.setBuildDate(soapModel.getBuildDate());
87          model.setData(soapModel.getData());
88  
89          return model;
90      }
91  
92      public static List<ServiceComponent> toModels(
93          ServiceComponentSoap[] soapModels) {
94          List<ServiceComponent> models = new ArrayList<ServiceComponent>(soapModels.length);
95  
96          for (ServiceComponentSoap soapModel : soapModels) {
97              models.add(toModel(soapModel));
98          }
99  
100         return models;
101     }
102 
103     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
104                 "lock.expiration.time.com.liferay.portal.model.ServiceComponent"));
105 
106     public ServiceComponentModelImpl() {
107     }
108 
109     public long getPrimaryKey() {
110         return _serviceComponentId;
111     }
112 
113     public void setPrimaryKey(long pk) {
114         setServiceComponentId(pk);
115     }
116 
117     public Serializable getPrimaryKeyObj() {
118         return new Long(_serviceComponentId);
119     }
120 
121     public long getServiceComponentId() {
122         return _serviceComponentId;
123     }
124 
125     public void setServiceComponentId(long serviceComponentId) {
126         _serviceComponentId = serviceComponentId;
127     }
128 
129     public String getBuildNamespace() {
130         return GetterUtil.getString(_buildNamespace);
131     }
132 
133     public void setBuildNamespace(String buildNamespace) {
134         _buildNamespace = buildNamespace;
135 
136         if (_originalBuildNamespace == null) {
137             _originalBuildNamespace = buildNamespace;
138         }
139     }
140 
141     public String getOriginalBuildNamespace() {
142         return GetterUtil.getString(_originalBuildNamespace);
143     }
144 
145     public long getBuildNumber() {
146         return _buildNumber;
147     }
148 
149     public void setBuildNumber(long buildNumber) {
150         _buildNumber = buildNumber;
151 
152         if (!_setOriginalBuildNumber) {
153             _setOriginalBuildNumber = true;
154 
155             _originalBuildNumber = buildNumber;
156         }
157     }
158 
159     public long getOriginalBuildNumber() {
160         return _originalBuildNumber;
161     }
162 
163     public long getBuildDate() {
164         return _buildDate;
165     }
166 
167     public void setBuildDate(long buildDate) {
168         _buildDate = buildDate;
169     }
170 
171     public String getData() {
172         return GetterUtil.getString(_data);
173     }
174 
175     public void setData(String data) {
176         _data = data;
177     }
178 
179     public ServiceComponent toEscapedModel() {
180         if (isEscapedModel()) {
181             return (ServiceComponent)this;
182         }
183         else {
184             ServiceComponent model = new ServiceComponentImpl();
185 
186             model.setNew(isNew());
187             model.setEscapedModel(true);
188 
189             model.setServiceComponentId(getServiceComponentId());
190             model.setBuildNamespace(HtmlUtil.escape(getBuildNamespace()));
191             model.setBuildNumber(getBuildNumber());
192             model.setBuildDate(getBuildDate());
193             model.setData(HtmlUtil.escape(getData()));
194 
195             model = (ServiceComponent)Proxy.newProxyInstance(ServiceComponent.class.getClassLoader(),
196                     new Class[] { ServiceComponent.class },
197                     new ReadOnlyBeanHandler(model));
198 
199             return model;
200         }
201     }
202 
203     public Object clone() {
204         ServiceComponentImpl clone = new ServiceComponentImpl();
205 
206         clone.setServiceComponentId(getServiceComponentId());
207         clone.setBuildNamespace(getBuildNamespace());
208         clone.setBuildNumber(getBuildNumber());
209         clone.setBuildDate(getBuildDate());
210         clone.setData(getData());
211 
212         return clone;
213     }
214 
215     public int compareTo(ServiceComponent serviceComponent) {
216         int value = 0;
217 
218         value = getBuildNamespace()
219                     .compareTo(serviceComponent.getBuildNamespace());
220 
221         value = value * -1;
222 
223         if (value != 0) {
224             return value;
225         }
226 
227         if (getBuildNumber() < serviceComponent.getBuildNumber()) {
228             value = -1;
229         }
230         else if (getBuildNumber() > serviceComponent.getBuildNumber()) {
231             value = 1;
232         }
233         else {
234             value = 0;
235         }
236 
237         value = value * -1;
238 
239         if (value != 0) {
240             return value;
241         }
242 
243         return 0;
244     }
245 
246     public boolean equals(Object obj) {
247         if (obj == null) {
248             return false;
249         }
250 
251         ServiceComponent serviceComponent = null;
252 
253         try {
254             serviceComponent = (ServiceComponent)obj;
255         }
256         catch (ClassCastException cce) {
257             return false;
258         }
259 
260         long pk = serviceComponent.getPrimaryKey();
261 
262         if (getPrimaryKey() == pk) {
263             return true;
264         }
265         else {
266             return false;
267         }
268     }
269 
270     public int hashCode() {
271         return (int)getPrimaryKey();
272     }
273 
274     public String toString() {
275         StringBuilder sb = new StringBuilder();
276 
277         sb.append("{serviceComponentId=");
278         sb.append(getServiceComponentId());
279         sb.append(", buildNamespace=");
280         sb.append(getBuildNamespace());
281         sb.append(", buildNumber=");
282         sb.append(getBuildNumber());
283         sb.append(", buildDate=");
284         sb.append(getBuildDate());
285         sb.append(", data=");
286         sb.append(getData());
287         sb.append("}");
288 
289         return sb.toString();
290     }
291 
292     public String toXmlString() {
293         StringBuilder sb = new StringBuilder();
294 
295         sb.append("<model><model-name>");
296         sb.append("com.liferay.portal.model.ServiceComponent");
297         sb.append("</model-name>");
298 
299         sb.append(
300             "<column><column-name>serviceComponentId</column-name><column-value><![CDATA[");
301         sb.append(getServiceComponentId());
302         sb.append("]]></column-value></column>");
303         sb.append(
304             "<column><column-name>buildNamespace</column-name><column-value><![CDATA[");
305         sb.append(getBuildNamespace());
306         sb.append("]]></column-value></column>");
307         sb.append(
308             "<column><column-name>buildNumber</column-name><column-value><![CDATA[");
309         sb.append(getBuildNumber());
310         sb.append("]]></column-value></column>");
311         sb.append(
312             "<column><column-name>buildDate</column-name><column-value><![CDATA[");
313         sb.append(getBuildDate());
314         sb.append("]]></column-value></column>");
315         sb.append(
316             "<column><column-name>data</column-name><column-value><![CDATA[");
317         sb.append(getData());
318         sb.append("]]></column-value></column>");
319 
320         sb.append("</model>");
321 
322         return sb.toString();
323     }
324 
325     private long _serviceComponentId;
326     private String _buildNamespace;
327     private String _originalBuildNamespace;
328     private long _buildNumber;
329     private long _originalBuildNumber;
330     private boolean _setOriginalBuildNumber;
331     private long _buildDate;
332     private String _data;
333 }