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