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