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.model.ServiceComponent;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.Html;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="ServiceComponentModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>ServiceComponent</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.ServiceComponent
54   * @see com.liferay.portal.service.model.ServiceComponentModel
55   * @see com.liferay.portal.service.model.impl.ServiceComponentImpl
56   *
57   */
58  public class ServiceComponentModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "ServiceComponent";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "serviceComponentId", new Integer(Types.BIGINT) },
62              
63  
64              { "buildNamespace", new Integer(Types.VARCHAR) },
65              
66  
67              { "buildNumber", new Integer(Types.BIGINT) },
68              
69  
70              { "buildDate", new Integer(Types.BIGINT) },
71              
72  
73              { "data_", new Integer(Types.CLOB) }
74          };
75      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)";
76      public static final String TABLE_SQL_DROP = "drop table ServiceComponent";
77      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
78                  "value.object.finder.cache.enabled.com.liferay.portal.model.ServiceComponent"),
79              true);
80      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
81                  "lock.expiration.time.com.liferay.portal.model.ServiceComponent"));
82  
83      public ServiceComponentModelImpl() {
84      }
85  
86      public long getPrimaryKey() {
87          return _serviceComponentId;
88      }
89  
90      public void setPrimaryKey(long pk) {
91          setServiceComponentId(pk);
92      }
93  
94      public Serializable getPrimaryKeyObj() {
95          return new Long(_serviceComponentId);
96      }
97  
98      public long getServiceComponentId() {
99          return _serviceComponentId;
100     }
101 
102     public void setServiceComponentId(long serviceComponentId) {
103         if (serviceComponentId != _serviceComponentId) {
104             _serviceComponentId = serviceComponentId;
105         }
106     }
107 
108     public String getBuildNamespace() {
109         return GetterUtil.getString(_buildNamespace);
110     }
111 
112     public void setBuildNamespace(String buildNamespace) {
113         if (((buildNamespace == null) && (_buildNamespace != null)) ||
114                 ((buildNamespace != null) && (_buildNamespace == null)) ||
115                 ((buildNamespace != null) && (_buildNamespace != null) &&
116                 !buildNamespace.equals(_buildNamespace))) {
117             _buildNamespace = buildNamespace;
118         }
119     }
120 
121     public long getBuildNumber() {
122         return _buildNumber;
123     }
124 
125     public void setBuildNumber(long buildNumber) {
126         if (buildNumber != _buildNumber) {
127             _buildNumber = buildNumber;
128         }
129     }
130 
131     public long getBuildDate() {
132         return _buildDate;
133     }
134 
135     public void setBuildDate(long buildDate) {
136         if (buildDate != _buildDate) {
137             _buildDate = buildDate;
138         }
139     }
140 
141     public String getData() {
142         return GetterUtil.getString(_data);
143     }
144 
145     public void setData(String data) {
146         if (((data == null) && (_data != null)) ||
147                 ((data != null) && (_data == null)) ||
148                 ((data != null) && (_data != null) && !data.equals(_data))) {
149             _data = data;
150         }
151     }
152 
153     public ServiceComponent toEscapedModel() {
154         if (isEscapedModel()) {
155             return (ServiceComponent)this;
156         }
157         else {
158             ServiceComponent model = new ServiceComponentImpl();
159 
160             model.setEscapedModel(true);
161 
162             model.setServiceComponentId(getServiceComponentId());
163             model.setBuildNamespace(Html.escape(getBuildNamespace()));
164             model.setBuildNumber(getBuildNumber());
165             model.setBuildDate(getBuildDate());
166             model.setData(Html.escape(getData()));
167 
168             model = (ServiceComponent)Proxy.newProxyInstance(ServiceComponent.class.getClassLoader(),
169                     new Class[] { ServiceComponent.class },
170                     new ReadOnlyBeanHandler(model));
171 
172             return model;
173         }
174     }
175 
176     public Object clone() {
177         ServiceComponentImpl clone = new ServiceComponentImpl();
178 
179         clone.setServiceComponentId(getServiceComponentId());
180         clone.setBuildNamespace(getBuildNamespace());
181         clone.setBuildNumber(getBuildNumber());
182         clone.setBuildDate(getBuildDate());
183         clone.setData(getData());
184 
185         return clone;
186     }
187 
188     public int compareTo(Object obj) {
189         if (obj == null) {
190             return -1;
191         }
192 
193         ServiceComponentImpl serviceComponent = (ServiceComponentImpl)obj;
194 
195         int value = 0;
196 
197         value = getBuildNamespace().compareTo(serviceComponent.getBuildNamespace());
198 
199         value = value * -1;
200 
201         if (value != 0) {
202             return value;
203         }
204 
205         if (getBuildNumber() < serviceComponent.getBuildNumber()) {
206             value = -1;
207         }
208         else if (getBuildNumber() > serviceComponent.getBuildNumber()) {
209             value = 1;
210         }
211         else {
212             value = 0;
213         }
214 
215         value = value * -1;
216 
217         if (value != 0) {
218             return value;
219         }
220 
221         return 0;
222     }
223 
224     public boolean equals(Object obj) {
225         if (obj == null) {
226             return false;
227         }
228 
229         ServiceComponentImpl serviceComponent = null;
230 
231         try {
232             serviceComponent = (ServiceComponentImpl)obj;
233         }
234         catch (ClassCastException cce) {
235             return false;
236         }
237 
238         long pk = serviceComponent.getPrimaryKey();
239 
240         if (getPrimaryKey() == pk) {
241             return true;
242         }
243         else {
244             return false;
245         }
246     }
247 
248     public int hashCode() {
249         return (int)getPrimaryKey();
250     }
251 
252     private long _serviceComponentId;
253     private String _buildNamespace;
254     private long _buildNumber;
255     private long _buildDate;
256     private String _data;
257 }