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