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.expando.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.kernel.util.StringPool;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.expando.model.ExpandoTable;
33  import com.liferay.portlet.expando.model.ExpandoTableSoap;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.List;
43  
44  /**
45   * <a href="ExpandoTableModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This interface is a model that represents the ExpandoTable table in the
54   * database.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       ExpandoTableImpl
59   * @see       com.liferay.portlet.expando.model.ExpandoTable
60   * @see       com.liferay.portlet.expando.model.ExpandoTableModel
61   * @generated
62   */
63  public class ExpandoTableModelImpl extends BaseModelImpl<ExpandoTable> {
64      public static final String TABLE_NAME = "ExpandoTable";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "tableId", new Integer(Types.BIGINT) },
67              { "companyId", new Integer(Types.BIGINT) },
68              { "classNameId", new Integer(Types.BIGINT) },
69              { "name", new Integer(Types.VARCHAR) }
70          };
71      public static final String TABLE_SQL_CREATE = "create table ExpandoTable (tableId LONG not null primary key,companyId LONG,classNameId LONG,name VARCHAR(75) null)";
72      public static final String TABLE_SQL_DROP = "drop table ExpandoTable";
73      public static final String DATA_SOURCE = "liferayDataSource";
74      public static final String SESSION_FACTORY = "liferaySessionFactory";
75      public static final String TX_MANAGER = "liferayTransactionManager";
76      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
78              true);
79      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
81              true);
82  
83      public static ExpandoTable toModel(ExpandoTableSoap soapModel) {
84          ExpandoTable model = new ExpandoTableImpl();
85  
86          model.setTableId(soapModel.getTableId());
87          model.setCompanyId(soapModel.getCompanyId());
88          model.setClassNameId(soapModel.getClassNameId());
89          model.setName(soapModel.getName());
90  
91          return model;
92      }
93  
94      public static List<ExpandoTable> toModels(ExpandoTableSoap[] soapModels) {
95          List<ExpandoTable> models = new ArrayList<ExpandoTable>(soapModels.length);
96  
97          for (ExpandoTableSoap soapModel : soapModels) {
98              models.add(toModel(soapModel));
99          }
100 
101         return models;
102     }
103 
104     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
105                 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoTable"));
106 
107     public ExpandoTableModelImpl() {
108     }
109 
110     public long getPrimaryKey() {
111         return _tableId;
112     }
113 
114     public void setPrimaryKey(long pk) {
115         setTableId(pk);
116     }
117 
118     public Serializable getPrimaryKeyObj() {
119         return new Long(_tableId);
120     }
121 
122     public long getTableId() {
123         return _tableId;
124     }
125 
126     public void setTableId(long tableId) {
127         _tableId = tableId;
128     }
129 
130     public long getCompanyId() {
131         return _companyId;
132     }
133 
134     public void setCompanyId(long companyId) {
135         _companyId = companyId;
136 
137         if (!_setOriginalCompanyId) {
138             _setOriginalCompanyId = true;
139 
140             _originalCompanyId = companyId;
141         }
142     }
143 
144     public long getOriginalCompanyId() {
145         return _originalCompanyId;
146     }
147 
148     public String getClassName() {
149         if (getClassNameId() <= 0) {
150             return StringPool.BLANK;
151         }
152 
153         return PortalUtil.getClassName(getClassNameId());
154     }
155 
156     public long getClassNameId() {
157         return _classNameId;
158     }
159 
160     public void setClassNameId(long classNameId) {
161         _classNameId = classNameId;
162 
163         if (!_setOriginalClassNameId) {
164             _setOriginalClassNameId = true;
165 
166             _originalClassNameId = classNameId;
167         }
168     }
169 
170     public long getOriginalClassNameId() {
171         return _originalClassNameId;
172     }
173 
174     public String getName() {
175         return GetterUtil.getString(_name);
176     }
177 
178     public void setName(String name) {
179         _name = name;
180 
181         if (_originalName == null) {
182             _originalName = name;
183         }
184     }
185 
186     public String getOriginalName() {
187         return GetterUtil.getString(_originalName);
188     }
189 
190     public ExpandoTable toEscapedModel() {
191         if (isEscapedModel()) {
192             return (ExpandoTable)this;
193         }
194         else {
195             ExpandoTable model = new ExpandoTableImpl();
196 
197             model.setNew(isNew());
198             model.setEscapedModel(true);
199 
200             model.setTableId(getTableId());
201             model.setCompanyId(getCompanyId());
202             model.setClassNameId(getClassNameId());
203             model.setName(HtmlUtil.escape(getName()));
204 
205             model = (ExpandoTable)Proxy.newProxyInstance(ExpandoTable.class.getClassLoader(),
206                     new Class[] { ExpandoTable.class },
207                     new ReadOnlyBeanHandler(model));
208 
209             return model;
210         }
211     }
212 
213     public Object clone() {
214         ExpandoTableImpl clone = new ExpandoTableImpl();
215 
216         clone.setTableId(getTableId());
217         clone.setCompanyId(getCompanyId());
218         clone.setClassNameId(getClassNameId());
219         clone.setName(getName());
220 
221         return clone;
222     }
223 
224     public int compareTo(ExpandoTable expandoTable) {
225         long pk = expandoTable.getPrimaryKey();
226 
227         if (getPrimaryKey() < pk) {
228             return -1;
229         }
230         else if (getPrimaryKey() > pk) {
231             return 1;
232         }
233         else {
234             return 0;
235         }
236     }
237 
238     public boolean equals(Object obj) {
239         if (obj == null) {
240             return false;
241         }
242 
243         ExpandoTable expandoTable = null;
244 
245         try {
246             expandoTable = (ExpandoTable)obj;
247         }
248         catch (ClassCastException cce) {
249             return false;
250         }
251 
252         long pk = expandoTable.getPrimaryKey();
253 
254         if (getPrimaryKey() == pk) {
255             return true;
256         }
257         else {
258             return false;
259         }
260     }
261 
262     public int hashCode() {
263         return (int)getPrimaryKey();
264     }
265 
266     public String toString() {
267         StringBuilder sb = new StringBuilder();
268 
269         sb.append("{tableId=");
270         sb.append(getTableId());
271         sb.append(", companyId=");
272         sb.append(getCompanyId());
273         sb.append(", classNameId=");
274         sb.append(getClassNameId());
275         sb.append(", name=");
276         sb.append(getName());
277         sb.append("}");
278 
279         return sb.toString();
280     }
281 
282     public String toXmlString() {
283         StringBuilder sb = new StringBuilder();
284 
285         sb.append("<model><model-name>");
286         sb.append("com.liferay.portlet.expando.model.ExpandoTable");
287         sb.append("</model-name>");
288 
289         sb.append(
290             "<column><column-name>tableId</column-name><column-value><![CDATA[");
291         sb.append(getTableId());
292         sb.append("]]></column-value></column>");
293         sb.append(
294             "<column><column-name>companyId</column-name><column-value><![CDATA[");
295         sb.append(getCompanyId());
296         sb.append("]]></column-value></column>");
297         sb.append(
298             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
299         sb.append(getClassNameId());
300         sb.append("]]></column-value></column>");
301         sb.append(
302             "<column><column-name>name</column-name><column-value><![CDATA[");
303         sb.append(getName());
304         sb.append("]]></column-value></column>");
305 
306         sb.append("</model>");
307 
308         return sb.toString();
309     }
310 
311     private long _tableId;
312     private long _companyId;
313     private long _originalCompanyId;
314     private boolean _setOriginalCompanyId;
315     private long _classNameId;
316     private long _originalClassNameId;
317     private boolean _setOriginalClassNameId;
318     private String _name;
319     private String _originalName;
320 }