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.portlet.tags.model.impl;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.service.ServiceContext;
31  import com.liferay.portal.util.PortalUtil;
32  
33  import com.liferay.portlet.expando.model.ExpandoBridge;
34  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
35  import com.liferay.portlet.tags.model.TagsProperty;
36  import com.liferay.portlet.tags.model.TagsPropertySoap;
37  
38  import java.io.Serializable;
39  
40  import java.lang.reflect.Proxy;
41  
42  import java.sql.Types;
43  
44  import java.util.ArrayList;
45  import java.util.Date;
46  import java.util.List;
47  
48  /**
49   * <a href="TagsPropertyModelImpl.java.html"><b><i>View Source</i></b></a>
50   *
51   * <p>
52   * ServiceBuilder generated this class. Modifications in this class will be
53   * overwritten the next time is generated.
54   * </p>
55   *
56   * <p>
57   * This interface is a model that represents the TagsProperty table in the
58   * database.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       TagsPropertyImpl
63   * @see       com.liferay.portlet.tags.model.TagsProperty
64   * @see       com.liferay.portlet.tags.model.TagsPropertyModel
65   * @generated
66   */
67  public class TagsPropertyModelImpl extends BaseModelImpl<TagsProperty> {
68      public static final String TABLE_NAME = "TagsProperty";
69      public static final Object[][] TABLE_COLUMNS = {
70              { "propertyId", new Integer(Types.BIGINT) },
71              { "companyId", new Integer(Types.BIGINT) },
72              { "userId", new Integer(Types.BIGINT) },
73              { "userName", new Integer(Types.VARCHAR) },
74              { "createDate", new Integer(Types.TIMESTAMP) },
75              { "modifiedDate", new Integer(Types.TIMESTAMP) },
76              { "entryId", new Integer(Types.BIGINT) },
77              { "key_", new Integer(Types.VARCHAR) },
78              { "value", new Integer(Types.VARCHAR) }
79          };
80      public static final String TABLE_SQL_CREATE = "create table TagsProperty (propertyId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,entryId LONG,key_ VARCHAR(75) null,value VARCHAR(255) null)";
81      public static final String TABLE_SQL_DROP = "drop table TagsProperty";
82      public static final String DATA_SOURCE = "liferayDataSource";
83      public static final String SESSION_FACTORY = "liferaySessionFactory";
84      public static final String TX_MANAGER = "liferayTransactionManager";
85      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.entity.cache.enabled.com.liferay.portlet.tags.model.TagsProperty"),
87              true);
88      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
89                  "value.object.finder.cache.enabled.com.liferay.portlet.tags.model.TagsProperty"),
90              true);
91  
92      public static TagsProperty toModel(TagsPropertySoap soapModel) {
93          TagsProperty model = new TagsPropertyImpl();
94  
95          model.setPropertyId(soapModel.getPropertyId());
96          model.setCompanyId(soapModel.getCompanyId());
97          model.setUserId(soapModel.getUserId());
98          model.setUserName(soapModel.getUserName());
99          model.setCreateDate(soapModel.getCreateDate());
100         model.setModifiedDate(soapModel.getModifiedDate());
101         model.setEntryId(soapModel.getEntryId());
102         model.setKey(soapModel.getKey());
103         model.setValue(soapModel.getValue());
104 
105         return model;
106     }
107 
108     public static List<TagsProperty> toModels(TagsPropertySoap[] soapModels) {
109         List<TagsProperty> models = new ArrayList<TagsProperty>(soapModels.length);
110 
111         for (TagsPropertySoap soapModel : soapModels) {
112             models.add(toModel(soapModel));
113         }
114 
115         return models;
116     }
117 
118     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
119                 "lock.expiration.time.com.liferay.portlet.tags.model.TagsProperty"));
120 
121     public TagsPropertyModelImpl() {
122     }
123 
124     public long getPrimaryKey() {
125         return _propertyId;
126     }
127 
128     public void setPrimaryKey(long pk) {
129         setPropertyId(pk);
130     }
131 
132     public Serializable getPrimaryKeyObj() {
133         return new Long(_propertyId);
134     }
135 
136     public long getPropertyId() {
137         return _propertyId;
138     }
139 
140     public void setPropertyId(long propertyId) {
141         _propertyId = propertyId;
142     }
143 
144     public long getCompanyId() {
145         return _companyId;
146     }
147 
148     public void setCompanyId(long companyId) {
149         _companyId = companyId;
150     }
151 
152     public long getUserId() {
153         return _userId;
154     }
155 
156     public void setUserId(long userId) {
157         _userId = userId;
158     }
159 
160     public String getUserUuid() throws SystemException {
161         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
162     }
163 
164     public void setUserUuid(String userUuid) {
165         _userUuid = userUuid;
166     }
167 
168     public String getUserName() {
169         return GetterUtil.getString(_userName);
170     }
171 
172     public void setUserName(String userName) {
173         _userName = userName;
174     }
175 
176     public Date getCreateDate() {
177         return _createDate;
178     }
179 
180     public void setCreateDate(Date createDate) {
181         _createDate = createDate;
182     }
183 
184     public Date getModifiedDate() {
185         return _modifiedDate;
186     }
187 
188     public void setModifiedDate(Date modifiedDate) {
189         _modifiedDate = modifiedDate;
190     }
191 
192     public long getEntryId() {
193         return _entryId;
194     }
195 
196     public void setEntryId(long entryId) {
197         _entryId = entryId;
198 
199         if (!_setOriginalEntryId) {
200             _setOriginalEntryId = true;
201 
202             _originalEntryId = entryId;
203         }
204     }
205 
206     public long getOriginalEntryId() {
207         return _originalEntryId;
208     }
209 
210     public String getKey() {
211         return GetterUtil.getString(_key);
212     }
213 
214     public void setKey(String key) {
215         _key = key;
216 
217         if (_originalKey == null) {
218             _originalKey = key;
219         }
220     }
221 
222     public String getOriginalKey() {
223         return GetterUtil.getString(_originalKey);
224     }
225 
226     public String getValue() {
227         return GetterUtil.getString(_value);
228     }
229 
230     public void setValue(String value) {
231         _value = value;
232     }
233 
234     public TagsProperty toEscapedModel() {
235         if (isEscapedModel()) {
236             return (TagsProperty)this;
237         }
238         else {
239             TagsProperty model = new TagsPropertyImpl();
240 
241             model.setNew(isNew());
242             model.setEscapedModel(true);
243 
244             model.setPropertyId(getPropertyId());
245             model.setCompanyId(getCompanyId());
246             model.setUserId(getUserId());
247             model.setUserName(HtmlUtil.escape(getUserName()));
248             model.setCreateDate(getCreateDate());
249             model.setModifiedDate(getModifiedDate());
250             model.setEntryId(getEntryId());
251             model.setKey(HtmlUtil.escape(getKey()));
252             model.setValue(HtmlUtil.escape(getValue()));
253 
254             model = (TagsProperty)Proxy.newProxyInstance(TagsProperty.class.getClassLoader(),
255                     new Class[] { TagsProperty.class },
256                     new ReadOnlyBeanHandler(model));
257 
258             return model;
259         }
260     }
261 
262     public ExpandoBridge getExpandoBridge() {
263         if (_expandoBridge == null) {
264             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(TagsProperty.class.getName(),
265                     getPrimaryKey());
266         }
267 
268         return _expandoBridge;
269     }
270 
271     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
272         getExpandoBridge().setAttributes(serviceContext);
273     }
274 
275     public Object clone() {
276         TagsPropertyImpl clone = new TagsPropertyImpl();
277 
278         clone.setPropertyId(getPropertyId());
279         clone.setCompanyId(getCompanyId());
280         clone.setUserId(getUserId());
281         clone.setUserName(getUserName());
282         clone.setCreateDate(getCreateDate());
283         clone.setModifiedDate(getModifiedDate());
284         clone.setEntryId(getEntryId());
285         clone.setKey(getKey());
286         clone.setValue(getValue());
287 
288         return clone;
289     }
290 
291     public int compareTo(TagsProperty tagsProperty) {
292         int value = 0;
293 
294         value = getKey().compareTo(tagsProperty.getKey());
295 
296         if (value != 0) {
297             return value;
298         }
299 
300         return 0;
301     }
302 
303     public boolean equals(Object obj) {
304         if (obj == null) {
305             return false;
306         }
307 
308         TagsProperty tagsProperty = null;
309 
310         try {
311             tagsProperty = (TagsProperty)obj;
312         }
313         catch (ClassCastException cce) {
314             return false;
315         }
316 
317         long pk = tagsProperty.getPrimaryKey();
318 
319         if (getPrimaryKey() == pk) {
320             return true;
321         }
322         else {
323             return false;
324         }
325     }
326 
327     public int hashCode() {
328         return (int)getPrimaryKey();
329     }
330 
331     public String toString() {
332         StringBuilder sb = new StringBuilder();
333 
334         sb.append("{propertyId=");
335         sb.append(getPropertyId());
336         sb.append(", companyId=");
337         sb.append(getCompanyId());
338         sb.append(", userId=");
339         sb.append(getUserId());
340         sb.append(", userName=");
341         sb.append(getUserName());
342         sb.append(", createDate=");
343         sb.append(getCreateDate());
344         sb.append(", modifiedDate=");
345         sb.append(getModifiedDate());
346         sb.append(", entryId=");
347         sb.append(getEntryId());
348         sb.append(", key=");
349         sb.append(getKey());
350         sb.append(", value=");
351         sb.append(getValue());
352         sb.append("}");
353 
354         return sb.toString();
355     }
356 
357     public String toXmlString() {
358         StringBuilder sb = new StringBuilder();
359 
360         sb.append("<model><model-name>");
361         sb.append("com.liferay.portlet.tags.model.TagsProperty");
362         sb.append("</model-name>");
363 
364         sb.append(
365             "<column><column-name>propertyId</column-name><column-value><![CDATA[");
366         sb.append(getPropertyId());
367         sb.append("]]></column-value></column>");
368         sb.append(
369             "<column><column-name>companyId</column-name><column-value><![CDATA[");
370         sb.append(getCompanyId());
371         sb.append("]]></column-value></column>");
372         sb.append(
373             "<column><column-name>userId</column-name><column-value><![CDATA[");
374         sb.append(getUserId());
375         sb.append("]]></column-value></column>");
376         sb.append(
377             "<column><column-name>userName</column-name><column-value><![CDATA[");
378         sb.append(getUserName());
379         sb.append("]]></column-value></column>");
380         sb.append(
381             "<column><column-name>createDate</column-name><column-value><![CDATA[");
382         sb.append(getCreateDate());
383         sb.append("]]></column-value></column>");
384         sb.append(
385             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
386         sb.append(getModifiedDate());
387         sb.append("]]></column-value></column>");
388         sb.append(
389             "<column><column-name>entryId</column-name><column-value><![CDATA[");
390         sb.append(getEntryId());
391         sb.append("]]></column-value></column>");
392         sb.append(
393             "<column><column-name>key</column-name><column-value><![CDATA[");
394         sb.append(getKey());
395         sb.append("]]></column-value></column>");
396         sb.append(
397             "<column><column-name>value</column-name><column-value><![CDATA[");
398         sb.append(getValue());
399         sb.append("]]></column-value></column>");
400 
401         sb.append("</model>");
402 
403         return sb.toString();
404     }
405 
406     private long _propertyId;
407     private long _companyId;
408     private long _userId;
409     private String _userUuid;
410     private String _userName;
411     private Date _createDate;
412     private Date _modifiedDate;
413     private long _entryId;
414     private long _originalEntryId;
415     private boolean _setOriginalEntryId;
416     private String _key;
417     private String _originalKey;
418     private String _value;
419     private transient ExpandoBridge _expandoBridge;
420 }