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
30 import com.liferay.portlet.expando.model.ExpandoColumn;
31 import com.liferay.portlet.expando.model.ExpandoColumnSoap;
32
33 import java.io.Serializable;
34
35 import java.lang.reflect.Proxy;
36
37 import java.sql.Types;
38
39 import java.util.ArrayList;
40 import java.util.List;
41
42
62 public class ExpandoColumnModelImpl extends BaseModelImpl {
63 public static final String TABLE_NAME = "ExpandoColumn";
64 public static final Object[][] TABLE_COLUMNS = {
65 { "columnId", new Integer(Types.BIGINT) },
66
67
68 { "companyId", new Integer(Types.BIGINT) },
69
70
71 { "tableId", new Integer(Types.BIGINT) },
72
73
74 { "name", new Integer(Types.VARCHAR) },
75
76
77 { "type_", new Integer(Types.INTEGER) },
78
79
80 { "defaultData", new Integer(Types.VARCHAR) },
81
82
83 { "typeSettings", new Integer(Types.CLOB) }
84 };
85 public static final String TABLE_SQL_CREATE = "create table ExpandoColumn (columnId LONG not null primary key,companyId LONG,tableId LONG,name VARCHAR(75) null,type_ INTEGER,defaultData STRING null,typeSettings TEXT null)";
86 public static final String TABLE_SQL_DROP = "drop table ExpandoColumn";
87 public static final String DATA_SOURCE = "liferayDataSource";
88 public static final String SESSION_FACTORY = "liferaySessionFactory";
89 public static final String TX_MANAGER = "liferayTransactionManager";
90 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
91 "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoColumn"),
92 true);
93
94 public static ExpandoColumn toModel(ExpandoColumnSoap soapModel) {
95 ExpandoColumn model = new ExpandoColumnImpl();
96
97 model.setColumnId(soapModel.getColumnId());
98 model.setCompanyId(soapModel.getCompanyId());
99 model.setTableId(soapModel.getTableId());
100 model.setName(soapModel.getName());
101 model.setType(soapModel.getType());
102 model.setDefaultData(soapModel.getDefaultData());
103 model.setTypeSettings(soapModel.getTypeSettings());
104
105 return model;
106 }
107
108 public static List<ExpandoColumn> toModels(ExpandoColumnSoap[] soapModels) {
109 List<ExpandoColumn> models = new ArrayList<ExpandoColumn>(soapModels.length);
110
111 for (ExpandoColumnSoap soapModel : soapModels) {
112 models.add(toModel(soapModel));
113 }
114
115 return models;
116 }
117
118 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
119 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoColumn"));
120
121 public ExpandoColumnModelImpl() {
122 }
123
124 public long getPrimaryKey() {
125 return _columnId;
126 }
127
128 public void setPrimaryKey(long pk) {
129 setColumnId(pk);
130 }
131
132 public Serializable getPrimaryKeyObj() {
133 return new Long(_columnId);
134 }
135
136 public long getColumnId() {
137 return _columnId;
138 }
139
140 public void setColumnId(long columnId) {
141 if (columnId != _columnId) {
142 _columnId = columnId;
143 }
144 }
145
146 public long getCompanyId() {
147 return _companyId;
148 }
149
150 public void setCompanyId(long companyId) {
151 if (companyId != _companyId) {
152 _companyId = companyId;
153 }
154 }
155
156 public long getTableId() {
157 return _tableId;
158 }
159
160 public void setTableId(long tableId) {
161 if (tableId != _tableId) {
162 _tableId = tableId;
163 }
164 }
165
166 public String getName() {
167 return GetterUtil.getString(_name);
168 }
169
170 public void setName(String name) {
171 if (((name == null) && (_name != null)) ||
172 ((name != null) && (_name == null)) ||
173 ((name != null) && (_name != null) && !name.equals(_name))) {
174 _name = name;
175 }
176 }
177
178 public int getType() {
179 return _type;
180 }
181
182 public void setType(int type) {
183 if (type != _type) {
184 _type = type;
185 }
186 }
187
188 public String getDefaultData() {
189 return GetterUtil.getString(_defaultData);
190 }
191
192 public void setDefaultData(String defaultData) {
193 if (((defaultData == null) && (_defaultData != null)) ||
194 ((defaultData != null) && (_defaultData == null)) ||
195 ((defaultData != null) && (_defaultData != null) &&
196 !defaultData.equals(_defaultData))) {
197 _defaultData = defaultData;
198 }
199 }
200
201 public String getTypeSettings() {
202 return GetterUtil.getString(_typeSettings);
203 }
204
205 public void setTypeSettings(String typeSettings) {
206 if (((typeSettings == null) && (_typeSettings != null)) ||
207 ((typeSettings != null) && (_typeSettings == null)) ||
208 ((typeSettings != null) && (_typeSettings != null) &&
209 !typeSettings.equals(_typeSettings))) {
210 _typeSettings = typeSettings;
211 }
212 }
213
214 public ExpandoColumn toEscapedModel() {
215 if (isEscapedModel()) {
216 return (ExpandoColumn)this;
217 }
218 else {
219 ExpandoColumn model = new ExpandoColumnImpl();
220
221 model.setNew(isNew());
222 model.setEscapedModel(true);
223
224 model.setColumnId(getColumnId());
225 model.setCompanyId(getCompanyId());
226 model.setTableId(getTableId());
227 model.setName(HtmlUtil.escape(getName()));
228 model.setType(getType());
229 model.setDefaultData(HtmlUtil.escape(getDefaultData()));
230 model.setTypeSettings(HtmlUtil.escape(getTypeSettings()));
231
232 model = (ExpandoColumn)Proxy.newProxyInstance(ExpandoColumn.class.getClassLoader(),
233 new Class[] { ExpandoColumn.class },
234 new ReadOnlyBeanHandler(model));
235
236 return model;
237 }
238 }
239
240 public Object clone() {
241 ExpandoColumnImpl clone = new ExpandoColumnImpl();
242
243 clone.setColumnId(getColumnId());
244 clone.setCompanyId(getCompanyId());
245 clone.setTableId(getTableId());
246 clone.setName(getName());
247 clone.setType(getType());
248 clone.setDefaultData(getDefaultData());
249 clone.setTypeSettings(getTypeSettings());
250
251 return clone;
252 }
253
254 public int compareTo(Object obj) {
255 if (obj == null) {
256 return -1;
257 }
258
259 ExpandoColumnImpl expandoColumn = (ExpandoColumnImpl)obj;
260
261 int value = 0;
262
263 value = getName().compareTo(expandoColumn.getName());
264
265 if (value != 0) {
266 return value;
267 }
268
269 return 0;
270 }
271
272 public boolean equals(Object obj) {
273 if (obj == null) {
274 return false;
275 }
276
277 ExpandoColumnImpl expandoColumn = null;
278
279 try {
280 expandoColumn = (ExpandoColumnImpl)obj;
281 }
282 catch (ClassCastException cce) {
283 return false;
284 }
285
286 long pk = expandoColumn.getPrimaryKey();
287
288 if (getPrimaryKey() == pk) {
289 return true;
290 }
291 else {
292 return false;
293 }
294 }
295
296 public int hashCode() {
297 return (int)getPrimaryKey();
298 }
299
300 private long _columnId;
301 private long _companyId;
302 private long _tableId;
303 private String _name;
304 private int _type;
305 private String _defaultData;
306 private String _typeSettings;
307 }