1
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
64 public class ExpandoTableModelImpl extends BaseModelImpl {
65 public static final String TABLE_NAME = "ExpandoTable";
66 public static final Object[][] TABLE_COLUMNS = {
67 { "tableId", new Integer(Types.BIGINT) },
68
69
70 { "companyId", new Integer(Types.BIGINT) },
71
72
73 { "classNameId", new Integer(Types.BIGINT) },
74
75
76 { "name", new Integer(Types.VARCHAR) }
77 };
78 public static final String TABLE_SQL_CREATE = "create table ExpandoTable (tableId LONG not null primary key,companyId LONG,classNameId LONG,name VARCHAR(75) null)";
79 public static final String TABLE_SQL_DROP = "drop table ExpandoTable";
80 public static final String DATA_SOURCE = "liferayDataSource";
81 public static final String SESSION_FACTORY = "liferaySessionFactory";
82 public static final String TX_MANAGER = "liferayTransactionManager";
83 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
84 "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
85 true);
86
87 public static ExpandoTable toModel(ExpandoTableSoap soapModel) {
88 ExpandoTable model = new ExpandoTableImpl();
89
90 model.setTableId(soapModel.getTableId());
91 model.setCompanyId(soapModel.getCompanyId());
92 model.setClassNameId(soapModel.getClassNameId());
93 model.setName(soapModel.getName());
94
95 return model;
96 }
97
98 public static List<ExpandoTable> toModels(ExpandoTableSoap[] soapModels) {
99 List<ExpandoTable> models = new ArrayList<ExpandoTable>(soapModels.length);
100
101 for (ExpandoTableSoap 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.expando.model.ExpandoTable"));
110
111 public ExpandoTableModelImpl() {
112 }
113
114 public long getPrimaryKey() {
115 return _tableId;
116 }
117
118 public void setPrimaryKey(long pk) {
119 setTableId(pk);
120 }
121
122 public Serializable getPrimaryKeyObj() {
123 return new Long(_tableId);
124 }
125
126 public long getTableId() {
127 return _tableId;
128 }
129
130 public void setTableId(long tableId) {
131 if (tableId != _tableId) {
132 _tableId = tableId;
133 }
134 }
135
136 public long getCompanyId() {
137 return _companyId;
138 }
139
140 public void setCompanyId(long companyId) {
141 if (companyId != _companyId) {
142 _companyId = companyId;
143 }
144 }
145
146 public String getClassName() {
147 if (getClassNameId() <= 0) {
148 return StringPool.BLANK;
149 }
150
151 return PortalUtil.getClassName(getClassNameId());
152 }
153
154 public long getClassNameId() {
155 return _classNameId;
156 }
157
158 public void setClassNameId(long classNameId) {
159 if (classNameId != _classNameId) {
160 _classNameId = classNameId;
161 }
162 }
163
164 public String getName() {
165 return GetterUtil.getString(_name);
166 }
167
168 public void setName(String name) {
169 if (((name == null) && (_name != null)) ||
170 ((name != null) && (_name == null)) ||
171 ((name != null) && (_name != null) && !name.equals(_name))) {
172 _name = name;
173 }
174 }
175
176 public ExpandoTable toEscapedModel() {
177 if (isEscapedModel()) {
178 return (ExpandoTable)this;
179 }
180 else {
181 ExpandoTable model = new ExpandoTableImpl();
182
183 model.setNew(isNew());
184 model.setEscapedModel(true);
185
186 model.setTableId(getTableId());
187 model.setCompanyId(getCompanyId());
188 model.setClassNameId(getClassNameId());
189 model.setName(HtmlUtil.escape(getName()));
190
191 model = (ExpandoTable)Proxy.newProxyInstance(ExpandoTable.class.getClassLoader(),
192 new Class[] { ExpandoTable.class },
193 new ReadOnlyBeanHandler(model));
194
195 return model;
196 }
197 }
198
199 public Object clone() {
200 ExpandoTableImpl clone = new ExpandoTableImpl();
201
202 clone.setTableId(getTableId());
203 clone.setCompanyId(getCompanyId());
204 clone.setClassNameId(getClassNameId());
205 clone.setName(getName());
206
207 return clone;
208 }
209
210 public int compareTo(Object obj) {
211 if (obj == null) {
212 return -1;
213 }
214
215 ExpandoTableImpl expandoTable = (ExpandoTableImpl)obj;
216
217 long pk = expandoTable.getPrimaryKey();
218
219 if (getPrimaryKey() < pk) {
220 return -1;
221 }
222 else if (getPrimaryKey() > pk) {
223 return 1;
224 }
225 else {
226 return 0;
227 }
228 }
229
230 public boolean equals(Object obj) {
231 if (obj == null) {
232 return false;
233 }
234
235 ExpandoTableImpl expandoTable = null;
236
237 try {
238 expandoTable = (ExpandoTableImpl)obj;
239 }
240 catch (ClassCastException cce) {
241 return false;
242 }
243
244 long pk = expandoTable.getPrimaryKey();
245
246 if (getPrimaryKey() == pk) {
247 return true;
248 }
249 else {
250 return false;
251 }
252 }
253
254 public int hashCode() {
255 return (int)getPrimaryKey();
256 }
257
258 private long _tableId;
259 private long _companyId;
260 private long _classNameId;
261 private String _name;
262 }