1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.tags.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.expando.model.ExpandoBridge;
28  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
29  import com.liferay.portlet.tags.model.TagsSource;
30  import com.liferay.portlet.tags.model.TagsSourceSoap;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="TagsSourceModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>TagsSource</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portlet.tags.model.TagsSource
57   * @see com.liferay.portlet.tags.model.TagsSourceModel
58   * @see com.liferay.portlet.tags.model.impl.TagsSourceImpl
59   *
60   */
61  public class TagsSourceModelImpl extends BaseModelImpl<TagsSource> {
62      public static final String TABLE_NAME = "TagsSource";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "sourceId", new Integer(Types.BIGINT) },
65              
66  
67              { "parentSourceId", new Integer(Types.BIGINT) },
68              
69  
70              { "name", new Integer(Types.VARCHAR) },
71              
72  
73              { "acronym", new Integer(Types.VARCHAR) }
74          };
75      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)";
76      public static final String TABLE_SQL_DROP = "drop table TagsSource";
77      public static final String DATA_SOURCE = "liferayDataSource";
78      public static final String SESSION_FACTORY = "liferaySessionFactory";
79      public static final String TX_MANAGER = "liferayTransactionManager";
80      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.entity.cache.enabled.com.liferay.portlet.tags.model.TagsSource"),
82              true);
83      public static final boolean FINDER_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         _sourceId = sourceId;
132     }
133 
134     public long getParentSourceId() {
135         return _parentSourceId;
136     }
137 
138     public void setParentSourceId(long parentSourceId) {
139         _parentSourceId = parentSourceId;
140     }
141 
142     public String getName() {
143         return GetterUtil.getString(_name);
144     }
145 
146     public void setName(String name) {
147         _name = name;
148     }
149 
150     public String getAcronym() {
151         return GetterUtil.getString(_acronym);
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             TagsSource model = new TagsSourceImpl();
164 
165             model.setNew(isNew());
166             model.setEscapedModel(true);
167 
168             model.setSourceId(getSourceId());
169             model.setParentSourceId(getParentSourceId());
170             model.setName(HtmlUtil.escape(getName()));
171             model.setAcronym(HtmlUtil.escape(getAcronym()));
172 
173             model = (TagsSource)Proxy.newProxyInstance(TagsSource.class.getClassLoader(),
174                     new Class[] { TagsSource.class },
175                     new ReadOnlyBeanHandler(model));
176 
177             return model;
178         }
179     }
180 
181     public ExpandoBridge getExpandoBridge() {
182         if (_expandoBridge == null) {
183             _expandoBridge = new ExpandoBridgeImpl(TagsSource.class.getName(),
184                     getPrimaryKey());
185         }
186 
187         return _expandoBridge;
188     }
189 
190     public Object clone() {
191         TagsSourceImpl clone = new TagsSourceImpl();
192 
193         clone.setSourceId(getSourceId());
194         clone.setParentSourceId(getParentSourceId());
195         clone.setName(getName());
196         clone.setAcronym(getAcronym());
197 
198         return clone;
199     }
200 
201     public int compareTo(TagsSource tagsSource) {
202         long pk = tagsSource.getPrimaryKey();
203 
204         if (getPrimaryKey() < pk) {
205             return -1;
206         }
207         else if (getPrimaryKey() > pk) {
208             return 1;
209         }
210         else {
211             return 0;
212         }
213     }
214 
215     public boolean equals(Object obj) {
216         if (obj == null) {
217             return false;
218         }
219 
220         TagsSource tagsSource = null;
221 
222         try {
223             tagsSource = (TagsSource)obj;
224         }
225         catch (ClassCastException cce) {
226             return false;
227         }
228 
229         long pk = tagsSource.getPrimaryKey();
230 
231         if (getPrimaryKey() == pk) {
232             return true;
233         }
234         else {
235             return false;
236         }
237     }
238 
239     public int hashCode() {
240         return (int)getPrimaryKey();
241     }
242 
243     public String toString() {
244         StringBuilder sb = new StringBuilder();
245 
246         sb.append("{sourceId=");
247         sb.append(getSourceId());
248         sb.append(", parentSourceId=");
249         sb.append(getParentSourceId());
250         sb.append(", name=");
251         sb.append(getName());
252         sb.append(", acronym=");
253         sb.append(getAcronym());
254         sb.append("}");
255 
256         return sb.toString();
257     }
258 
259     public String toXmlString() {
260         StringBuilder sb = new StringBuilder();
261 
262         sb.append("<model><model-name>");
263         sb.append("com.liferay.portlet.tags.model.TagsSource");
264         sb.append("</model-name>");
265 
266         sb.append(
267             "<column><column-name>sourceId</column-name><column-value><![CDATA[");
268         sb.append(getSourceId());
269         sb.append("]]></column-value></column>");
270         sb.append(
271             "<column><column-name>parentSourceId</column-name><column-value><![CDATA[");
272         sb.append(getParentSourceId());
273         sb.append("]]></column-value></column>");
274         sb.append(
275             "<column><column-name>name</column-name><column-value><![CDATA[");
276         sb.append(getName());
277         sb.append("]]></column-value></column>");
278         sb.append(
279             "<column><column-name>acronym</column-name><column-value><![CDATA[");
280         sb.append(getAcronym());
281         sb.append("]]></column-value></column>");
282 
283         sb.append("</model>");
284 
285         return sb.toString();
286     }
287 
288     private long _sourceId;
289     private long _parentSourceId;
290     private String _name;
291     private String _acronym;
292     private transient ExpandoBridge _expandoBridge;
293 }