1
22
23 package com.liferay.portlet.social.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.social.model.SocialRelation;
31 import com.liferay.portlet.social.model.SocialRelationSoap;
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
61 public class SocialRelationModelImpl extends BaseModelImpl<SocialRelation> {
62 public static final String TABLE_NAME = "SocialRelation";
63 public static final Object[][] TABLE_COLUMNS = {
64 { "uuid_", new Integer(Types.VARCHAR) },
65 { "relationId", new Integer(Types.BIGINT) },
66 { "companyId", new Integer(Types.BIGINT) },
67 { "createDate", new Integer(Types.BIGINT) },
68 { "userId1", new Integer(Types.BIGINT) },
69 { "userId2", new Integer(Types.BIGINT) },
70 { "type_", new Integer(Types.INTEGER) }
71 };
72 public static final String TABLE_SQL_CREATE = "create table SocialRelation (uuid_ VARCHAR(75) null,relationId LONG not null primary key,companyId LONG,createDate LONG,userId1 LONG,userId2 LONG,type_ INTEGER)";
73 public static final String TABLE_SQL_DROP = "drop table SocialRelation";
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 ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78 "value.object.entity.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
79 true);
80 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81 "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
82 true);
83
84 public static SocialRelation toModel(SocialRelationSoap soapModel) {
85 SocialRelation model = new SocialRelationImpl();
86
87 model.setUuid(soapModel.getUuid());
88 model.setRelationId(soapModel.getRelationId());
89 model.setCompanyId(soapModel.getCompanyId());
90 model.setCreateDate(soapModel.getCreateDate());
91 model.setUserId1(soapModel.getUserId1());
92 model.setUserId2(soapModel.getUserId2());
93 model.setType(soapModel.getType());
94
95 return model;
96 }
97
98 public static List<SocialRelation> toModels(SocialRelationSoap[] soapModels) {
99 List<SocialRelation> models = new ArrayList<SocialRelation>(soapModels.length);
100
101 for (SocialRelationSoap soapModel : soapModels) {
102 models.add(toModel(soapModel));
103 }
104
105 return models;
106 }
107
108 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
109 "lock.expiration.time.com.liferay.portlet.social.model.SocialRelation"));
110
111 public SocialRelationModelImpl() {
112 }
113
114 public long getPrimaryKey() {
115 return _relationId;
116 }
117
118 public void setPrimaryKey(long pk) {
119 setRelationId(pk);
120 }
121
122 public Serializable getPrimaryKeyObj() {
123 return new Long(_relationId);
124 }
125
126 public String getUuid() {
127 return GetterUtil.getString(_uuid);
128 }
129
130 public void setUuid(String uuid) {
131 _uuid = uuid;
132 }
133
134 public long getRelationId() {
135 return _relationId;
136 }
137
138 public void setRelationId(long relationId) {
139 _relationId = relationId;
140 }
141
142 public long getCompanyId() {
143 return _companyId;
144 }
145
146 public void setCompanyId(long companyId) {
147 _companyId = companyId;
148 }
149
150 public long getCreateDate() {
151 return _createDate;
152 }
153
154 public void setCreateDate(long createDate) {
155 _createDate = createDate;
156 }
157
158 public long getUserId1() {
159 return _userId1;
160 }
161
162 public void setUserId1(long userId1) {
163 _userId1 = userId1;
164
165 if (!_setOriginalUserId1) {
166 _setOriginalUserId1 = true;
167
168 _originalUserId1 = userId1;
169 }
170 }
171
172 public long getOriginalUserId1() {
173 return _originalUserId1;
174 }
175
176 public long getUserId2() {
177 return _userId2;
178 }
179
180 public void setUserId2(long userId2) {
181 _userId2 = userId2;
182
183 if (!_setOriginalUserId2) {
184 _setOriginalUserId2 = true;
185
186 _originalUserId2 = userId2;
187 }
188 }
189
190 public long getOriginalUserId2() {
191 return _originalUserId2;
192 }
193
194 public int getType() {
195 return _type;
196 }
197
198 public void setType(int type) {
199 _type = type;
200
201 if (!_setOriginalType) {
202 _setOriginalType = true;
203
204 _originalType = type;
205 }
206 }
207
208 public int getOriginalType() {
209 return _originalType;
210 }
211
212 public SocialRelation toEscapedModel() {
213 if (isEscapedModel()) {
214 return (SocialRelation)this;
215 }
216 else {
217 SocialRelation model = new SocialRelationImpl();
218
219 model.setNew(isNew());
220 model.setEscapedModel(true);
221
222 model.setUuid(HtmlUtil.escape(getUuid()));
223 model.setRelationId(getRelationId());
224 model.setCompanyId(getCompanyId());
225 model.setCreateDate(getCreateDate());
226 model.setUserId1(getUserId1());
227 model.setUserId2(getUserId2());
228 model.setType(getType());
229
230 model = (SocialRelation)Proxy.newProxyInstance(SocialRelation.class.getClassLoader(),
231 new Class[] { SocialRelation.class },
232 new ReadOnlyBeanHandler(model));
233
234 return model;
235 }
236 }
237
238 public Object clone() {
239 SocialRelationImpl clone = new SocialRelationImpl();
240
241 clone.setUuid(getUuid());
242 clone.setRelationId(getRelationId());
243 clone.setCompanyId(getCompanyId());
244 clone.setCreateDate(getCreateDate());
245 clone.setUserId1(getUserId1());
246 clone.setUserId2(getUserId2());
247 clone.setType(getType());
248
249 return clone;
250 }
251
252 public int compareTo(SocialRelation socialRelation) {
253 long pk = socialRelation.getPrimaryKey();
254
255 if (getPrimaryKey() < pk) {
256 return -1;
257 }
258 else if (getPrimaryKey() > pk) {
259 return 1;
260 }
261 else {
262 return 0;
263 }
264 }
265
266 public boolean equals(Object obj) {
267 if (obj == null) {
268 return false;
269 }
270
271 SocialRelation socialRelation = null;
272
273 try {
274 socialRelation = (SocialRelation)obj;
275 }
276 catch (ClassCastException cce) {
277 return false;
278 }
279
280 long pk = socialRelation.getPrimaryKey();
281
282 if (getPrimaryKey() == pk) {
283 return true;
284 }
285 else {
286 return false;
287 }
288 }
289
290 public int hashCode() {
291 return (int)getPrimaryKey();
292 }
293
294 public String toString() {
295 StringBuilder sb = new StringBuilder();
296
297 sb.append("{uuid=");
298 sb.append(getUuid());
299 sb.append(", relationId=");
300 sb.append(getRelationId());
301 sb.append(", companyId=");
302 sb.append(getCompanyId());
303 sb.append(", createDate=");
304 sb.append(getCreateDate());
305 sb.append(", userId1=");
306 sb.append(getUserId1());
307 sb.append(", userId2=");
308 sb.append(getUserId2());
309 sb.append(", type=");
310 sb.append(getType());
311 sb.append("}");
312
313 return sb.toString();
314 }
315
316 public String toXmlString() {
317 StringBuilder sb = new StringBuilder();
318
319 sb.append("<model><model-name>");
320 sb.append("com.liferay.portlet.social.model.SocialRelation");
321 sb.append("</model-name>");
322
323 sb.append(
324 "<column><column-name>uuid</column-name><column-value><![CDATA[");
325 sb.append(getUuid());
326 sb.append("]]></column-value></column>");
327 sb.append(
328 "<column><column-name>relationId</column-name><column-value><![CDATA[");
329 sb.append(getRelationId());
330 sb.append("]]></column-value></column>");
331 sb.append(
332 "<column><column-name>companyId</column-name><column-value><![CDATA[");
333 sb.append(getCompanyId());
334 sb.append("]]></column-value></column>");
335 sb.append(
336 "<column><column-name>createDate</column-name><column-value><![CDATA[");
337 sb.append(getCreateDate());
338 sb.append("]]></column-value></column>");
339 sb.append(
340 "<column><column-name>userId1</column-name><column-value><![CDATA[");
341 sb.append(getUserId1());
342 sb.append("]]></column-value></column>");
343 sb.append(
344 "<column><column-name>userId2</column-name><column-value><![CDATA[");
345 sb.append(getUserId2());
346 sb.append("]]></column-value></column>");
347 sb.append(
348 "<column><column-name>type</column-name><column-value><![CDATA[");
349 sb.append(getType());
350 sb.append("]]></column-value></column>");
351
352 sb.append("</model>");
353
354 return sb.toString();
355 }
356
357 private String _uuid;
358 private long _relationId;
359 private long _companyId;
360 private long _createDate;
361 private long _userId1;
362 private long _originalUserId1;
363 private boolean _setOriginalUserId1;
364 private long _userId2;
365 private long _originalUserId2;
366 private boolean _setOriginalUserId2;
367 private int _type;
368 private int _originalType;
369 private boolean _setOriginalType;
370 }