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.setEscapedModel(true);
174
175 model.setColumnId(getColumnId());
176 model.setTableId(getTableId());
177 model.setName(HtmlUtil.escape(getName()));
178 model.setType(getType());
179
180 model = (ExpandoColumn)Proxy.newProxyInstance(ExpandoColumn.class.getClassLoader(),
181 new Class[] { ExpandoColumn.class },
182 new ReadOnlyBeanHandler(model));
183
184 return model;
185 }
186 }
187
188 public Object clone() {
189 ExpandoColumnImpl clone = new ExpandoColumnImpl();
190
191 clone.setColumnId(getColumnId());
192 clone.setTableId(getTableId());
193 clone.setName(getName());
194 clone.setType(getType());
195
196 return clone;
197 }
198
199 public int compareTo(Object obj) {
200 if (obj == null) {
201 return -1;
202 }
203
204 ExpandoColumnImpl expandoColumn = (ExpandoColumnImpl)obj;
205
206 long pk = expandoColumn.getPrimaryKey();
207
208 if (getPrimaryKey() < pk) {
209 return -1;
210 }
211 else if (getPrimaryKey() > pk) {
212 return 1;
213 }
214 else {
215 return 0;
216 }
217 }
218
219 public boolean equals(Object obj) {
220 if (obj == null) {
221 return false;
222 }
223
224 ExpandoColumnImpl expandoColumn = null;
225
226 try {
227 expandoColumn = (ExpandoColumnImpl)obj;
228 }
229 catch (ClassCastException cce) {
230 return false;
231 }
232
233 long pk = expandoColumn.getPrimaryKey();
234
235 if (getPrimaryKey() == pk) {
236 return true;
237 }
238 else {
239 return false;
240 }
241 }
242
243 public int hashCode() {
244 return (int)getPrimaryKey();
245 }
246
247 private long _columnId;
248 private long _tableId;
249 private String _name;
250 private int _type;
251 }