1
19
20 package com.liferay.portlet.social.model.impl;
21
22 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23 import com.liferay.portal.kernel.util.GetterUtil;
24 import com.liferay.portal.kernel.util.HtmlUtil;
25 import com.liferay.portal.model.impl.BaseModelImpl;
26
27 import com.liferay.portlet.social.model.SocialRelation;
28 import com.liferay.portlet.social.model.SocialRelationSoap;
29
30 import java.io.Serializable;
31
32 import java.lang.reflect.Proxy;
33
34 import java.sql.Types;
35
36 import java.util.ArrayList;
37 import java.util.Date;
38 import java.util.List;
39
40
60 public class SocialRelationModelImpl extends BaseModelImpl {
61 public static final String TABLE_NAME = "SocialRelation";
62 public static final Object[][] TABLE_COLUMNS = {
63 { "uuid_", new Integer(Types.VARCHAR) },
64
65
66 { "relationId", new Integer(Types.BIGINT) },
67
68
69 { "companyId", new Integer(Types.BIGINT) },
70
71
72 { "createDate", new Integer(Types.TIMESTAMP) },
73
74
75 { "userId1", new Integer(Types.BIGINT) },
76
77
78 { "userId2", new Integer(Types.BIGINT) },
79
80
81 { "type_", new Integer(Types.INTEGER) }
82 };
83 public static final String TABLE_SQL_CREATE = "create table SocialRelation (uuid_ VARCHAR(75) null,relationId LONG not null primary key,companyId LONG,createDate DATE null,userId1 LONG,userId2 LONG,type_ INTEGER)";
84 public static final String TABLE_SQL_DROP = "drop table SocialRelation";
85 public static final String DATA_SOURCE = "liferayDataSource";
86 public static final String SESSION_FACTORY = "liferaySessionFactory";
87 public static final String TX_MANAGER = "liferayTransactionManager";
88 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
89 "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
90 true);
91
92 public static SocialRelation toModel(SocialRelationSoap soapModel) {
93 SocialRelation model = new SocialRelationImpl();
94
95 model.setUuid(soapModel.getUuid());
96 model.setRelationId(soapModel.getRelationId());
97 model.setCompanyId(soapModel.getCompanyId());
98 model.setCreateDate(soapModel.getCreateDate());
99 model.setUserId1(soapModel.getUserId1());
100 model.setUserId2(soapModel.getUserId2());
101 model.setType(soapModel.getType());
102
103 return model;
104 }
105
106 public static List<SocialRelation> toModels(SocialRelationSoap[] soapModels) {
107 List<SocialRelation> models = new ArrayList<SocialRelation>(soapModels.length);
108
109 for (SocialRelationSoap soapModel : soapModels) {
110 models.add(toModel(soapModel));
111 }
112
113 return models;
114 }
115
116 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
117 "lock.expiration.time.com.liferay.portlet.social.model.SocialRelation"));
118
119 public SocialRelationModelImpl() {
120 }
121
122 public long getPrimaryKey() {
123 return _relationId;
124 }
125
126 public void setPrimaryKey(long pk) {
127 setRelationId(pk);
128 }
129
130 public Serializable getPrimaryKeyObj() {
131 return new Long(_relationId);
132 }
133
134 public String getUuid() {
135 return GetterUtil.getString(_uuid);
136 }
137
138 public void setUuid(String uuid) {
139 if ((uuid != null) && (uuid != _uuid)) {
140 _uuid = uuid;
141 }
142 }
143
144 public long getRelationId() {
145 return _relationId;
146 }
147
148 public void setRelationId(long relationId) {
149 if (relationId != _relationId) {
150 _relationId = relationId;
151 }
152 }
153
154 public long getCompanyId() {
155 return _companyId;
156 }
157
158 public void setCompanyId(long companyId) {
159 if (companyId != _companyId) {
160 _companyId = companyId;
161 }
162 }
163
164 public Date getCreateDate() {
165 return _createDate;
166 }
167
168 public void setCreateDate(Date createDate) {
169 if (((createDate == null) && (_createDate != null)) ||
170 ((createDate != null) && (_createDate == null)) ||
171 ((createDate != null) && (_createDate != null) &&
172 !createDate.equals(_createDate))) {
173 _createDate = createDate;
174 }
175 }
176
177 public long getUserId1() {
178 return _userId1;
179 }
180
181 public void setUserId1(long userId1) {
182 if (userId1 != _userId1) {
183 _userId1 = userId1;
184 }
185 }
186
187 public long getUserId2() {
188 return _userId2;
189 }
190
191 public void setUserId2(long userId2) {
192 if (userId2 != _userId2) {
193 _userId2 = userId2;
194 }
195 }
196
197 public int getType() {
198 return _type;
199 }
200
201 public void setType(int type) {
202 if (type != _type) {
203 _type = type;
204 }
205 }
206
207 public SocialRelation toEscapedModel() {
208 if (isEscapedModel()) {
209 return (SocialRelation)this;
210 }
211 else {
212 SocialRelation model = new SocialRelationImpl();
213
214 model.setNew(isNew());
215 model.setEscapedModel(true);
216
217 model.setUuid(HtmlUtil.escape(getUuid()));
218 model.setRelationId(getRelationId());
219 model.setCompanyId(getCompanyId());
220 model.setCreateDate(getCreateDate());
221 model.setUserId1(getUserId1());
222 model.setUserId2(getUserId2());
223 model.setType(getType());
224
225 model = (SocialRelation)Proxy.newProxyInstance(SocialRelation.class.getClassLoader(),
226 new Class[] { SocialRelation.class },
227 new ReadOnlyBeanHandler(model));
228
229 return model;
230 }
231 }
232
233 public Object clone() {
234 SocialRelationImpl clone = new SocialRelationImpl();
235
236 clone.setUuid(getUuid());
237 clone.setRelationId(getRelationId());
238 clone.setCompanyId(getCompanyId());
239 clone.setCreateDate(getCreateDate());
240 clone.setUserId1(getUserId1());
241 clone.setUserId2(getUserId2());
242 clone.setType(getType());
243
244 return clone;
245 }
246
247 public int compareTo(Object obj) {
248 if (obj == null) {
249 return -1;
250 }
251
252 SocialRelationImpl socialRelation = (SocialRelationImpl)obj;
253
254 long pk = socialRelation.getPrimaryKey();
255
256 if (getPrimaryKey() < pk) {
257 return -1;
258 }
259 else if (getPrimaryKey() > pk) {
260 return 1;
261 }
262 else {
263 return 0;
264 }
265 }
266
267 public boolean equals(Object obj) {
268 if (obj == null) {
269 return false;
270 }
271
272 SocialRelationImpl socialRelation = null;
273
274 try {
275 socialRelation = (SocialRelationImpl)obj;
276 }
277 catch (ClassCastException cce) {
278 return false;
279 }
280
281 long pk = socialRelation.getPrimaryKey();
282
283 if (getPrimaryKey() == pk) {
284 return true;
285 }
286 else {
287 return false;
288 }
289 }
290
291 public int hashCode() {
292 return (int)getPrimaryKey();
293 }
294
295 private String _uuid;
296 private long _relationId;
297 private long _companyId;
298 private Date _createDate;
299 private long _userId1;
300 private long _userId2;
301 private int _type;
302 }