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