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