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.model.impl.BaseModelImpl;
29 import com.liferay.portal.util.PortalUtil;
30
31 import com.liferay.portlet.expando.model.ExpandoTable;
32 import com.liferay.portlet.expando.model.ExpandoTableSoap;
33
34 import java.io.Serializable;
35
36 import java.lang.reflect.Proxy;
37
38 import java.sql.Types;
39
40 import java.util.ArrayList;
41 import java.util.List;
42
43
63 public class ExpandoTableModelImpl extends BaseModelImpl {
64 public static final String TABLE_NAME = "ExpandoTable";
65 public static final Object[][] TABLE_COLUMNS = {
66 { "tableId", new Integer(Types.BIGINT) },
67
68
69 { "classNameId", new Integer(Types.BIGINT) },
70
71
72 { "name", new Integer(Types.VARCHAR) }
73 };
74 public static final String TABLE_SQL_CREATE = "create table ExpandoTable (tableId LONG not null primary key,classNameId LONG,name VARCHAR(75) null)";
75 public static final String TABLE_SQL_DROP = "drop table ExpandoTable";
76 public static final String DATA_SOURCE = "liferayDataSource";
77 public static final String SESSION_FACTORY = "liferaySessionFactory";
78 public static final String TX_MANAGER = "liferayTransactionManager";
79 public static final boolean 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.setClassNameId(soapModel.getClassNameId());
88 model.setName(soapModel.getName());
89
90 return model;
91 }
92
93 public static List<ExpandoTable> toModels(ExpandoTableSoap[] soapModels) {
94 List<ExpandoTable> models = new ArrayList<ExpandoTable>(soapModels.length);
95
96 for (ExpandoTableSoap soapModel : soapModels) {
97 models.add(toModel(soapModel));
98 }
99
100 return models;
101 }
102
103 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
104 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoTable"));
105
106 public ExpandoTableModelImpl() {
107 }
108
109 public long getPrimaryKey() {
110 return _tableId;
111 }
112
113 public void setPrimaryKey(long pk) {
114 setTableId(pk);
115 }
116
117 public Serializable getPrimaryKeyObj() {
118 return new Long(_tableId);
119 }
120
121 public long getTableId() {
122 return _tableId;
123 }
124
125 public void setTableId(long tableId) {
126 if (tableId != _tableId) {
127 _tableId = tableId;
128 }
129 }
130
131 public String getClassName() {
132 return PortalUtil.getClassName(getClassNameId());
133 }
134
135 public long getClassNameId() {
136 return _classNameId;
137 }
138
139 public void setClassNameId(long classNameId) {
140 if (classNameId != _classNameId) {
141 _classNameId = classNameId;
142 }
143 }
144
145 public String getName() {
146 return GetterUtil.getString(_name);
147 }
148
149 public void setName(String name) {
150 if (((name == null) && (_name != null)) ||
151 ((name != null) && (_name == null)) ||
152 ((name != null) && (_name != null) && !name.equals(_name))) {
153 _name = name;
154 }
155 }
156
157 public ExpandoTable toEscapedModel() {
158 if (isEscapedModel()) {
159 return (ExpandoTable)this;
160 }
161 else {
162 ExpandoTable model = new ExpandoTableImpl();
163
164 model.setEscapedModel(true);
165
166 model.setTableId(getTableId());
167 model.setClassNameId(getClassNameId());
168 model.setName(HtmlUtil.escape(getName()));
169
170 model = (ExpandoTable)Proxy.newProxyInstance(ExpandoTable.class.getClassLoader(),
171 new Class[] { ExpandoTable.class },
172 new ReadOnlyBeanHandler(model));
173
174 return model;
175 }
176 }
177
178 public Object clone() {
179 ExpandoTableImpl clone = new ExpandoTableImpl();
180
181 clone.setTableId(getTableId());
182 clone.setClassNameId(getClassNameId());
183 clone.setName(getName());
184
185 return clone;
186 }
187
188 public int compareTo(Object obj) {
189 if (obj == null) {
190 return -1;
191 }
192
193 ExpandoTableImpl expandoTable = (ExpandoTableImpl)obj;
194
195 long pk = expandoTable.getPrimaryKey();
196
197 if (getPrimaryKey() < pk) {
198 return -1;
199 }
200 else if (getPrimaryKey() > pk) {
201 return 1;
202 }
203 else {
204 return 0;
205 }
206 }
207
208 public boolean equals(Object obj) {
209 if (obj == null) {
210 return false;
211 }
212
213 ExpandoTableImpl expandoTable = null;
214
215 try {
216 expandoTable = (ExpandoTableImpl)obj;
217 }
218 catch (ClassCastException cce) {
219 return false;
220 }
221
222 long pk = expandoTable.getPrimaryKey();
223
224 if (getPrimaryKey() == pk) {
225 return true;
226 }
227 else {
228 return false;
229 }
230 }
231
232 public int hashCode() {
233 return (int)getPrimaryKey();
234 }
235
236 private long _tableId;
237 private long _classNameId;
238 private String _name;
239 }