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