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