1   /**
2    * Copyright (c) 2000-2007 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.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
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 overwritten
40   * the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class is a model that represents the <code>TagsSource</code> table in the
45   * database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portlet.tags.service.model.TagsSource
51   * @see com.liferay.portlet.tags.service.model.TagsSourceModel
52   * @see com.liferay.portlet.tags.service.model.impl.TagsSourceImpl
53   *
54   */
55  public class TagsSourceModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "TagsSource";
57      public static Object[][] TABLE_COLUMNS = {
58              { "sourceId", new Integer(Types.BIGINT) },
59              { "parentSourceId", new Integer(Types.BIGINT) },
60              { "name", new Integer(Types.VARCHAR) },
61              { "acronym", new Integer(Types.VARCHAR) }
62          };
63      public static String TABLE_SQL_CREATE = "create table TagsSource (sourceId LONG not null primary key,parentSourceId LONG,name VARCHAR(75) null,acronym VARCHAR(75) null)";
64      public static String TABLE_SQL_DROP = "drop table TagsSource";
65      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
66                  "xss.allow.com.liferay.portlet.tags.model.TagsSource"),
67              XSS_ALLOW);
68      public static boolean XSS_ALLOW_NAME = GetterUtil.getBoolean(PropsUtil.get(
69                  "xss.allow.com.liferay.portlet.tags.model.TagsSource.name"),
70              XSS_ALLOW_BY_MODEL);
71      public static boolean XSS_ALLOW_ACRONYM = GetterUtil.getBoolean(PropsUtil.get(
72                  "xss.allow.com.liferay.portlet.tags.model.TagsSource.acronym"),
73              XSS_ALLOW_BY_MODEL);
74      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
75                  "lock.expiration.time.com.liferay.portlet.tags.model.TagsSourceModel"));
76  
77      public TagsSourceModelImpl() {
78      }
79  
80      public long getPrimaryKey() {
81          return _sourceId;
82      }
83  
84      public void setPrimaryKey(long pk) {
85          setSourceId(pk);
86      }
87  
88      public Serializable getPrimaryKeyObj() {
89          return new Long(_sourceId);
90      }
91  
92      public long getSourceId() {
93          return _sourceId;
94      }
95  
96      public void setSourceId(long sourceId) {
97          if (sourceId != _sourceId) {
98              _sourceId = sourceId;
99          }
100     }
101 
102     public long getParentSourceId() {
103         return _parentSourceId;
104     }
105 
106     public void setParentSourceId(long parentSourceId) {
107         if (parentSourceId != _parentSourceId) {
108             _parentSourceId = parentSourceId;
109         }
110     }
111 
112     public String getName() {
113         return GetterUtil.getString(_name);
114     }
115 
116     public void setName(String name) {
117         if (((name == null) && (_name != null)) ||
118                 ((name != null) && (_name == null)) ||
119                 ((name != null) && (_name != null) && !name.equals(_name))) {
120             if (!XSS_ALLOW_NAME) {
121                 name = XSSUtil.strip(name);
122             }
123 
124             _name = name;
125         }
126     }
127 
128     public String getAcronym() {
129         return GetterUtil.getString(_acronym);
130     }
131 
132     public void setAcronym(String acronym) {
133         if (((acronym == null) && (_acronym != null)) ||
134                 ((acronym != null) && (_acronym == null)) ||
135                 ((acronym != null) && (_acronym != null) &&
136                 !acronym.equals(_acronym))) {
137             if (!XSS_ALLOW_ACRONYM) {
138                 acronym = XSSUtil.strip(acronym);
139             }
140 
141             _acronym = acronym;
142         }
143     }
144 
145     public Object clone() {
146         TagsSourceImpl clone = new TagsSourceImpl();
147         clone.setSourceId(getSourceId());
148         clone.setParentSourceId(getParentSourceId());
149         clone.setName(getName());
150         clone.setAcronym(getAcronym());
151 
152         return clone;
153     }
154 
155     public int compareTo(Object obj) {
156         if (obj == null) {
157             return -1;
158         }
159 
160         TagsSourceImpl tagsSource = (TagsSourceImpl)obj;
161         long pk = tagsSource.getPrimaryKey();
162 
163         if (getPrimaryKey() < pk) {
164             return -1;
165         }
166         else if (getPrimaryKey() > pk) {
167             return 1;
168         }
169         else {
170             return 0;
171         }
172     }
173 
174     public boolean equals(Object obj) {
175         if (obj == null) {
176             return false;
177         }
178 
179         TagsSourceImpl tagsSource = null;
180 
181         try {
182             tagsSource = (TagsSourceImpl)obj;
183         }
184         catch (ClassCastException cce) {
185             return false;
186         }
187 
188         long pk = tagsSource.getPrimaryKey();
189 
190         if (getPrimaryKey() == pk) {
191             return true;
192         }
193         else {
194             return false;
195         }
196     }
197 
198     public int hashCode() {
199         return (int)getPrimaryKey();
200     }
201 
202     private long _sourceId;
203     private long _parentSourceId;
204     private String _name;
205     private String _acronym;
206 }