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