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