1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.tags.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.tags.model.TagsSource;
28  import com.liferay.portlet.tags.model.TagsSourceSoap;
29  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.List;
38  
39  /**
40   * <a href="TagsSourceModelImpl.java.html"><b><i>View Source</i></b></a>
41   *
42   * <p>
43   * ServiceBuilder generated this class. Modifications in this class will be
44   * overwritten the next time is generated.
45   * </p>
46   *
47   * <p>
48   * This class is a model that represents the <code>TagsSource</code> table
49   * in the database.
50   * </p>
51   *
52   * @author Brian Wing Shun Chan
53   *
54   * @see com.liferay.portlet.tags.model.TagsSource
55   * @see com.liferay.portlet.tags.model.TagsSourceModel
56   * @see com.liferay.portlet.tags.model.impl.TagsSourceImpl
57   *
58   */
59  public class TagsSourceModelImpl extends BaseModelImpl {
60      public static final String TABLE_NAME = "TagsSource";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "sourceId", new Integer(Types.BIGINT) },
63              
64  
65              { "parentSourceId", new Integer(Types.BIGINT) },
66              
67  
68              { "name", new Integer(Types.VARCHAR) },
69              
70  
71              { "acronym", new Integer(Types.VARCHAR) }
72          };
73      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)";
74      public static final String TABLE_SQL_DROP = "drop table TagsSource";
75      public static final String DATA_SOURCE = "liferayDataSource";
76      public static final String SESSION_FACTORY = "liferaySessionFactory";
77      public static final String TX_MANAGER = "liferayTransactionManager";
78      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.finder.cache.enabled.com.liferay.portlet.tags.model.TagsSource"),
80              true);
81  
82      public static TagsSource toModel(TagsSourceSoap soapModel) {
83          TagsSource model = new TagsSourceImpl();
84  
85          model.setSourceId(soapModel.getSourceId());
86          model.setParentSourceId(soapModel.getParentSourceId());
87          model.setName(soapModel.getName());
88          model.setAcronym(soapModel.getAcronym());
89  
90          return model;
91      }
92  
93      public static List<TagsSource> toModels(TagsSourceSoap[] soapModels) {
94          List<TagsSource> models = new ArrayList<TagsSource>(soapModels.length);
95  
96          for (TagsSourceSoap soapModel : soapModels) {
97              models.add(toModel(soapModel));
98          }
99  
100         return models;
101     }
102 
103     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
104                 "lock.expiration.time.com.liferay.portlet.tags.model.TagsSource"));
105 
106     public TagsSourceModelImpl() {
107     }
108 
109     public long getPrimaryKey() {
110         return _sourceId;
111     }
112 
113     public void setPrimaryKey(long pk) {
114         setSourceId(pk);
115     }
116 
117     public Serializable getPrimaryKeyObj() {
118         return new Long(_sourceId);
119     }
120 
121     public long getSourceId() {
122         return _sourceId;
123     }
124 
125     public void setSourceId(long sourceId) {
126         if (sourceId != _sourceId) {
127             _sourceId = sourceId;
128         }
129     }
130 
131     public long getParentSourceId() {
132         return _parentSourceId;
133     }
134 
135     public void setParentSourceId(long parentSourceId) {
136         if (parentSourceId != _parentSourceId) {
137             _parentSourceId = parentSourceId;
138         }
139     }
140 
141     public String getName() {
142         return GetterUtil.getString(_name);
143     }
144 
145     public void setName(String name) {
146         if (((name == null) && (_name != null)) ||
147                 ((name != null) && (_name == null)) ||
148                 ((name != null) && (_name != null) && !name.equals(_name))) {
149             _name = name;
150         }
151     }
152 
153     public String getAcronym() {
154         return GetterUtil.getString(_acronym);
155     }
156 
157     public void setAcronym(String acronym) {
158         if (((acronym == null) && (_acronym != null)) ||
159                 ((acronym != null) && (_acronym == null)) ||
160                 ((acronym != null) && (_acronym != null) &&
161                 !acronym.equals(_acronym))) {
162             _acronym = acronym;
163         }
164     }
165 
166     public TagsSource toEscapedModel() {
167         if (isEscapedModel()) {
168             return (TagsSource)this;
169         }
170         else {
171             TagsSource model = new TagsSourceImpl();
172 
173             model.setNew(isNew());
174             model.setEscapedModel(true);
175 
176             model.setSourceId(getSourceId());
177             model.setParentSourceId(getParentSourceId());
178             model.setName(HtmlUtil.escape(getName()));
179             model.setAcronym(HtmlUtil.escape(getAcronym()));
180 
181             model = (TagsSource)Proxy.newProxyInstance(TagsSource.class.getClassLoader(),
182                     new Class[] { TagsSource.class },
183                     new ReadOnlyBeanHandler(model));
184 
185             return model;
186         }
187     }
188 
189     public Object clone() {
190         TagsSourceImpl clone = new TagsSourceImpl();
191 
192         clone.setSourceId(getSourceId());
193         clone.setParentSourceId(getParentSourceId());
194         clone.setName(getName());
195         clone.setAcronym(getAcronym());
196 
197         return clone;
198     }
199 
200     public int compareTo(Object obj) {
201         if (obj == null) {
202             return -1;
203         }
204 
205         TagsSourceImpl tagsSource = (TagsSourceImpl)obj;
206 
207         long pk = tagsSource.getPrimaryKey();
208 
209         if (getPrimaryKey() < pk) {
210             return -1;
211         }
212         else if (getPrimaryKey() > pk) {
213             return 1;
214         }
215         else {
216             return 0;
217         }
218     }
219 
220     public boolean equals(Object obj) {
221         if (obj == null) {
222             return false;
223         }
224 
225         TagsSourceImpl tagsSource = null;
226 
227         try {
228             tagsSource = (TagsSourceImpl)obj;
229         }
230         catch (ClassCastException cce) {
231             return false;
232         }
233 
234         long pk = tagsSource.getPrimaryKey();
235 
236         if (getPrimaryKey() == pk) {
237             return true;
238         }
239         else {
240             return false;
241         }
242     }
243 
244     public int hashCode() {
245         return (int)getPrimaryKey();
246     }
247 
248     private long _sourceId;
249     private long _parentSourceId;
250     private String _name;
251     private String _acronym;
252 }