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