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