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