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