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