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.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.portlet.tags.model.TagsSource;
32  import com.liferay.portlet.tags.model.TagsSourceSoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.List;
42  
43  /**
44   * <a href="TagsSourceModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>TagsSource</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.tags.service.model.TagsSource
59   * @see com.liferay.portlet.tags.service.model.TagsSourceModel
60   * @see com.liferay.portlet.tags.service.model.impl.TagsSourceImpl
61   *
62   */
63  public class TagsSourceModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "TagsSource";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "sourceId", new Integer(Types.BIGINT) },
67              
68  
69              { "parentSourceId", new Integer(Types.BIGINT) },
70              
71  
72              { "name", new Integer(Types.VARCHAR) },
73              
74  
75              { "acronym", new Integer(Types.VARCHAR) }
76          };
77      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)";
78      public static final String TABLE_SQL_DROP = "drop table TagsSource";
79      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
80                  "value.object.finder.cache.enabled.com.liferay.portlet.tags.model.TagsSource"),
81              true);
82  
83      public static TagsSource toModel(TagsSourceSoap soapModel) {
84          TagsSource model = new TagsSourceImpl();
85  
86          model.setSourceId(soapModel.getSourceId());
87          model.setParentSourceId(soapModel.getParentSourceId());
88          model.setName(soapModel.getName());
89          model.setAcronym(soapModel.getAcronym());
90  
91          return model;
92      }
93  
94      public static List<TagsSource> toModels(TagsSourceSoap[] soapModels) {
95          List<TagsSource> models = new ArrayList<TagsSource>(soapModels.length);
96  
97          for (TagsSourceSoap soapModel : soapModels) {
98              models.add(toModel(soapModel));
99          }
100 
101         return models;
102     }
103 
104     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
105                 "lock.expiration.time.com.liferay.portlet.tags.model.TagsSource"));
106 
107     public TagsSourceModelImpl() {
108     }
109 
110     public long getPrimaryKey() {
111         return _sourceId;
112     }
113 
114     public void setPrimaryKey(long pk) {
115         setSourceId(pk);
116     }
117 
118     public Serializable getPrimaryKeyObj() {
119         return new Long(_sourceId);
120     }
121 
122     public long getSourceId() {
123         return _sourceId;
124     }
125 
126     public void setSourceId(long sourceId) {
127         if (sourceId != _sourceId) {
128             _sourceId = sourceId;
129         }
130     }
131 
132     public long getParentSourceId() {
133         return _parentSourceId;
134     }
135 
136     public void setParentSourceId(long parentSourceId) {
137         if (parentSourceId != _parentSourceId) {
138             _parentSourceId = parentSourceId;
139         }
140     }
141 
142     public String getName() {
143         return GetterUtil.getString(_name);
144     }
145 
146     public void setName(String name) {
147         if (((name == null) && (_name != null)) ||
148                 ((name != null) && (_name == null)) ||
149                 ((name != null) && (_name != null) && !name.equals(_name))) {
150             _name = name;
151         }
152     }
153 
154     public String getAcronym() {
155         return GetterUtil.getString(_acronym);
156     }
157 
158     public void setAcronym(String acronym) {
159         if (((acronym == null) && (_acronym != null)) ||
160                 ((acronym != null) && (_acronym == null)) ||
161                 ((acronym != null) && (_acronym != null) &&
162                 !acronym.equals(_acronym))) {
163             _acronym = acronym;
164         }
165     }
166 
167     public TagsSource toEscapedModel() {
168         if (isEscapedModel()) {
169             return (TagsSource)this;
170         }
171         else {
172             TagsSource model = new TagsSourceImpl();
173 
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 }