001
014
015 package com.liferay.portlet.expando.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.json.JSON;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.ProxyUtil;
021 import com.liferay.portal.kernel.util.StringBundler;
022 import com.liferay.portal.kernel.util.StringPool;
023 import com.liferay.portal.kernel.util.Validator;
024 import com.liferay.portal.model.CacheModel;
025 import com.liferay.portal.model.impl.BaseModelImpl;
026 import com.liferay.portal.util.PortalUtil;
027
028 import com.liferay.portlet.expando.model.ExpandoTable;
029 import com.liferay.portlet.expando.model.ExpandoTableModel;
030
031 import java.io.Serializable;
032
033 import java.sql.Types;
034
035 import java.util.HashMap;
036 import java.util.Map;
037
038
051 @JSON(strict = true)
052 public class ExpandoTableModelImpl extends BaseModelImpl<ExpandoTable>
053 implements ExpandoTableModel {
054
059 public static final String TABLE_NAME = "ExpandoTable";
060 public static final Object[][] TABLE_COLUMNS = {
061 { "tableId", Types.BIGINT },
062 { "companyId", Types.BIGINT },
063 { "classNameId", Types.BIGINT },
064 { "name", Types.VARCHAR }
065 };
066 public static final String TABLE_SQL_CREATE = "create table ExpandoTable (tableId LONG not null primary key,companyId LONG,classNameId LONG,name VARCHAR(75) null)";
067 public static final String TABLE_SQL_DROP = "drop table ExpandoTable";
068 public static final String DATA_SOURCE = "liferayDataSource";
069 public static final String SESSION_FACTORY = "liferaySessionFactory";
070 public static final String TX_MANAGER = "liferayTransactionManager";
071 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
072 "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
073 true);
074 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
075 "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
076 true);
077 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078 "value.object.column.bitmask.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
079 true);
080 public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
081 public static long COMPANYID_COLUMN_BITMASK = 2L;
082 public static long NAME_COLUMN_BITMASK = 4L;
083 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
084 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoTable"));
085
086 public ExpandoTableModelImpl() {
087 }
088
089 public long getPrimaryKey() {
090 return _tableId;
091 }
092
093 public void setPrimaryKey(long primaryKey) {
094 setTableId(primaryKey);
095 }
096
097 public Serializable getPrimaryKeyObj() {
098 return new Long(_tableId);
099 }
100
101 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
102 setPrimaryKey(((Long)primaryKeyObj).longValue());
103 }
104
105 public Class<?> getModelClass() {
106 return ExpandoTable.class;
107 }
108
109 public String getModelClassName() {
110 return ExpandoTable.class.getName();
111 }
112
113 @Override
114 public Map<String, Object> getModelAttributes() {
115 Map<String, Object> attributes = new HashMap<String, Object>();
116
117 attributes.put("tableId", getTableId());
118 attributes.put("companyId", getCompanyId());
119 attributes.put("classNameId", getClassNameId());
120 attributes.put("name", getName());
121
122 return attributes;
123 }
124
125 @Override
126 public void setModelAttributes(Map<String, Object> attributes) {
127 Long tableId = (Long)attributes.get("tableId");
128
129 if (tableId != null) {
130 setTableId(tableId);
131 }
132
133 Long companyId = (Long)attributes.get("companyId");
134
135 if (companyId != null) {
136 setCompanyId(companyId);
137 }
138
139 Long classNameId = (Long)attributes.get("classNameId");
140
141 if (classNameId != null) {
142 setClassNameId(classNameId);
143 }
144
145 String name = (String)attributes.get("name");
146
147 if (name != null) {
148 setName(name);
149 }
150 }
151
152 @JSON
153 public long getTableId() {
154 return _tableId;
155 }
156
157 public void setTableId(long tableId) {
158 _tableId = tableId;
159 }
160
161 @JSON
162 public long getCompanyId() {
163 return _companyId;
164 }
165
166 public void setCompanyId(long companyId) {
167 _columnBitmask |= COMPANYID_COLUMN_BITMASK;
168
169 if (!_setOriginalCompanyId) {
170 _setOriginalCompanyId = true;
171
172 _originalCompanyId = _companyId;
173 }
174
175 _companyId = companyId;
176 }
177
178 public long getOriginalCompanyId() {
179 return _originalCompanyId;
180 }
181
182 public String getClassName() {
183 if (getClassNameId() <= 0) {
184 return StringPool.BLANK;
185 }
186
187 return PortalUtil.getClassName(getClassNameId());
188 }
189
190 public void setClassName(String className) {
191 long classNameId = 0;
192
193 if (Validator.isNotNull(className)) {
194 classNameId = PortalUtil.getClassNameId(className);
195 }
196
197 setClassNameId(classNameId);
198 }
199
200 @JSON
201 public long getClassNameId() {
202 return _classNameId;
203 }
204
205 public void setClassNameId(long classNameId) {
206 _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
207
208 if (!_setOriginalClassNameId) {
209 _setOriginalClassNameId = true;
210
211 _originalClassNameId = _classNameId;
212 }
213
214 _classNameId = classNameId;
215 }
216
217 public long getOriginalClassNameId() {
218 return _originalClassNameId;
219 }
220
221 @JSON
222 public String getName() {
223 if (_name == null) {
224 return StringPool.BLANK;
225 }
226 else {
227 return _name;
228 }
229 }
230
231 public void setName(String name) {
232 _columnBitmask |= NAME_COLUMN_BITMASK;
233
234 if (_originalName == null) {
235 _originalName = _name;
236 }
237
238 _name = name;
239 }
240
241 public String getOriginalName() {
242 return GetterUtil.getString(_originalName);
243 }
244
245 public long getColumnBitmask() {
246 return _columnBitmask;
247 }
248
249 @Override
250 public ExpandoTable toEscapedModel() {
251 if (_escapedModel == null) {
252 _escapedModel = (ExpandoTable)ProxyUtil.newProxyInstance(_classLoader,
253 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
254 }
255
256 return _escapedModel;
257 }
258
259 public ExpandoTable toUnescapedModel() {
260 return (ExpandoTable)this;
261 }
262
263 @Override
264 public Object clone() {
265 ExpandoTableImpl expandoTableImpl = new ExpandoTableImpl();
266
267 expandoTableImpl.setTableId(getTableId());
268 expandoTableImpl.setCompanyId(getCompanyId());
269 expandoTableImpl.setClassNameId(getClassNameId());
270 expandoTableImpl.setName(getName());
271
272 expandoTableImpl.resetOriginalValues();
273
274 return expandoTableImpl;
275 }
276
277 public int compareTo(ExpandoTable expandoTable) {
278 long primaryKey = expandoTable.getPrimaryKey();
279
280 if (getPrimaryKey() < primaryKey) {
281 return -1;
282 }
283 else if (getPrimaryKey() > primaryKey) {
284 return 1;
285 }
286 else {
287 return 0;
288 }
289 }
290
291 @Override
292 public boolean equals(Object obj) {
293 if (this == obj) {
294 return true;
295 }
296
297 if (!(obj instanceof ExpandoTable)) {
298 return false;
299 }
300
301 ExpandoTable expandoTable = (ExpandoTable)obj;
302
303 long primaryKey = expandoTable.getPrimaryKey();
304
305 if (getPrimaryKey() == primaryKey) {
306 return true;
307 }
308 else {
309 return false;
310 }
311 }
312
313 @Override
314 public int hashCode() {
315 return (int)getPrimaryKey();
316 }
317
318 @Override
319 public void resetOriginalValues() {
320 ExpandoTableModelImpl expandoTableModelImpl = this;
321
322 expandoTableModelImpl._originalCompanyId = expandoTableModelImpl._companyId;
323
324 expandoTableModelImpl._setOriginalCompanyId = false;
325
326 expandoTableModelImpl._originalClassNameId = expandoTableModelImpl._classNameId;
327
328 expandoTableModelImpl._setOriginalClassNameId = false;
329
330 expandoTableModelImpl._originalName = expandoTableModelImpl._name;
331
332 expandoTableModelImpl._columnBitmask = 0;
333 }
334
335 @Override
336 public CacheModel<ExpandoTable> toCacheModel() {
337 ExpandoTableCacheModel expandoTableCacheModel = new ExpandoTableCacheModel();
338
339 expandoTableCacheModel.tableId = getTableId();
340
341 expandoTableCacheModel.companyId = getCompanyId();
342
343 expandoTableCacheModel.classNameId = getClassNameId();
344
345 expandoTableCacheModel.name = getName();
346
347 String name = expandoTableCacheModel.name;
348
349 if ((name != null) && (name.length() == 0)) {
350 expandoTableCacheModel.name = null;
351 }
352
353 return expandoTableCacheModel;
354 }
355
356 @Override
357 public String toString() {
358 StringBundler sb = new StringBundler(9);
359
360 sb.append("{tableId=");
361 sb.append(getTableId());
362 sb.append(", companyId=");
363 sb.append(getCompanyId());
364 sb.append(", classNameId=");
365 sb.append(getClassNameId());
366 sb.append(", name=");
367 sb.append(getName());
368 sb.append("}");
369
370 return sb.toString();
371 }
372
373 public String toXmlString() {
374 StringBundler sb = new StringBundler(16);
375
376 sb.append("<model><model-name>");
377 sb.append("com.liferay.portlet.expando.model.ExpandoTable");
378 sb.append("</model-name>");
379
380 sb.append(
381 "<column><column-name>tableId</column-name><column-value><![CDATA[");
382 sb.append(getTableId());
383 sb.append("]]></column-value></column>");
384 sb.append(
385 "<column><column-name>companyId</column-name><column-value><![CDATA[");
386 sb.append(getCompanyId());
387 sb.append("]]></column-value></column>");
388 sb.append(
389 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
390 sb.append(getClassNameId());
391 sb.append("]]></column-value></column>");
392 sb.append(
393 "<column><column-name>name</column-name><column-value><![CDATA[");
394 sb.append(getName());
395 sb.append("]]></column-value></column>");
396
397 sb.append("</model>");
398
399 return sb.toString();
400 }
401
402 private static ClassLoader _classLoader = ExpandoTable.class.getClassLoader();
403 private static Class<?>[] _escapedModelInterfaces = new Class[] {
404 ExpandoTable.class
405 };
406 private long _tableId;
407 private long _companyId;
408 private long _originalCompanyId;
409 private boolean _setOriginalCompanyId;
410 private long _classNameId;
411 private long _originalClassNameId;
412 private boolean _setOriginalClassNameId;
413 private String _name;
414 private String _originalName;
415 private long _columnBitmask;
416 private ExpandoTable _escapedModel;
417 }