1   /**
2    * Copyright (c) 2000-2008 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.portlet.tags.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.portlet.tags.model.TagsSource;
31  
32  import com.liferay.util.Html;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  /**
41   * <a href="TagsSourceModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>TagsSource</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portlet.tags.service.model.TagsSource
56   * @see com.liferay.portlet.tags.service.model.TagsSourceModel
57   * @see com.liferay.portlet.tags.service.model.impl.TagsSourceImpl
58   *
59   */
60  public class TagsSourceModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "TagsSource";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "sourceId", new Integer(Types.BIGINT) },
64              
65  
66              { "parentSourceId", new Integer(Types.BIGINT) },
67              
68  
69              { "name", new Integer(Types.VARCHAR) },
70              
71  
72              { "acronym", new Integer(Types.VARCHAR) }
73          };
74      public static final String TABLE_SQL_CREATE = "create table TagsSource (sourceId LONG not null primary key,parentSourceId LONG,name VARCHAR(75) null,acronym VARCHAR(75) null)";
75      public static final String TABLE_SQL_DROP = "drop table TagsSource";
76      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portlet.tags.model.TagsSource"),
78              true);
79      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
80                  "lock.expiration.time.com.liferay.portlet.tags.model.TagsSource"));
81  
82      public TagsSourceModelImpl() {
83      }
84  
85      public long getPrimaryKey() {
86          return _sourceId;
87      }
88  
89      public void setPrimaryKey(long pk) {
90          setSourceId(pk);
91      }
92  
93      public Serializable getPrimaryKeyObj() {
94          return new Long(_sourceId);
95      }
96  
97      public long getSourceId() {
98          return _sourceId;
99      }
100 
101     public void setSourceId(long sourceId) {
102         if (sourceId != _sourceId) {
103             _sourceId = sourceId;
104         }
105     }
106 
107     public long getParentSourceId() {
108         return _parentSourceId;
109     }
110 
111     public void setParentSourceId(long parentSourceId) {
112         if (parentSourceId != _parentSourceId) {
113             _parentSourceId = parentSourceId;
114         }
115     }
116 
117     public String getName() {
118         return GetterUtil.getString(_name);
119     }
120 
121     public void setName(String name) {
122         if (((name == null) && (_name != null)) ||
123                 ((name != null) && (_name == null)) ||
124                 ((name != null) && (_name != null) && !name.equals(_name))) {
125             _name = name;
126         }
127     }
128 
129     public String getAcronym() {
130         return GetterUtil.getString(_acronym);
131     }
132 
133     public void setAcronym(String acronym) {
134         if (((acronym == null) && (_acronym != null)) ||
135                 ((acronym != null) && (_acronym == null)) ||
136                 ((acronym != null) && (_acronym != null) &&
137                 !acronym.equals(_acronym))) {
138             _acronym = acronym;
139         }
140     }
141 
142     public TagsSource toEscapedModel() {
143         if (isEscapedModel()) {
144             return (TagsSource)this;
145         }
146         else {
147             TagsSource model = new TagsSourceImpl();
148 
149             model.setEscapedModel(true);
150 
151             model.setSourceId(getSourceId());
152             model.setParentSourceId(getParentSourceId());
153             model.setName(Html.escape(getName()));
154             model.setAcronym(Html.escape(getAcronym()));
155 
156             model = (TagsSource)Proxy.newProxyInstance(TagsSource.class.getClassLoader(),
157                     new Class[] { TagsSource.class },
158                     new ReadOnlyBeanHandler(model));
159 
160             return model;
161         }
162     }
163 
164     public Object clone() {
165         TagsSourceImpl clone = new TagsSourceImpl();
166 
167         clone.setSourceId(getSourceId());
168         clone.setParentSourceId(getParentSourceId());
169         clone.setName(getName());
170         clone.setAcronym(getAcronym());
171 
172         return clone;
173     }
174 
175     public int compareTo(Object obj) {
176         if (obj == null) {
177             return -1;
178         }
179 
180         TagsSourceImpl tagsSource = (TagsSourceImpl)obj;
181 
182         long pk = tagsSource.getPrimaryKey();
183 
184         if (getPrimaryKey() < pk) {
185             return -1;
186         }
187         else if (getPrimaryKey() > pk) {
188             return 1;
189         }
190         else {
191             return 0;
192         }
193     }
194 
195     public boolean equals(Object obj) {
196         if (obj == null) {
197             return false;
198         }
199 
200         TagsSourceImpl tagsSource = null;
201 
202         try {
203             tagsSource = (TagsSourceImpl)obj;
204         }
205         catch (ClassCastException cce) {
206             return false;
207         }
208 
209         long pk = tagsSource.getPrimaryKey();
210 
211         if (getPrimaryKey() == pk) {
212             return true;
213         }
214         else {
215             return false;
216         }
217     }
218 
219     public int hashCode() {
220         return (int)getPrimaryKey();
221     }
222 
223     private long _sourceId;
224     private long _parentSourceId;
225     private String _name;
226     private String _acronym;
227 }