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 import com.liferay.portal.util.PropsUtil;
30
31 import com.liferay.portlet.social.model.SocialRelation;
32 import com.liferay.portlet.social.model.SocialRelationSoap;
33
34 import java.io.Serializable;
35
36 import java.lang.reflect.Proxy;
37
38 import java.sql.Types;
39
40 import java.util.ArrayList;
41 import java.util.Date;
42 import java.util.List;
43
44
64 public class SocialRelationModelImpl extends BaseModelImpl {
65 public static final String TABLE_NAME = "SocialRelation";
66 public static final Object[][] TABLE_COLUMNS = {
67 { "uuid_", new Integer(Types.VARCHAR) },
68
69
70 { "relationId", new Integer(Types.BIGINT) },
71
72
73 { "companyId", new Integer(Types.BIGINT) },
74
75
76 { "createDate", new Integer(Types.TIMESTAMP) },
77
78
79 { "userId1", new Integer(Types.BIGINT) },
80
81
82 { "userId2", new Integer(Types.BIGINT) },
83
84
85 { "type_", new Integer(Types.INTEGER) }
86 };
87 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)";
88 public static final String TABLE_SQL_DROP = "drop table SocialRelation";
89 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
90 "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
91 true);
92
93 public static SocialRelation toModel(SocialRelationSoap soapModel) {
94 SocialRelation model = new SocialRelationImpl();
95
96 model.setUuid(soapModel.getUuid());
97 model.setRelationId(soapModel.getRelationId());
98 model.setCompanyId(soapModel.getCompanyId());
99 model.setCreateDate(soapModel.getCreateDate());
100 model.setUserId1(soapModel.getUserId1());
101 model.setUserId2(soapModel.getUserId2());
102 model.setType(soapModel.getType());
103
104 return model;
105 }
106
107 public static List<SocialRelation> toModels(SocialRelationSoap[] soapModels) {
108 List<SocialRelation> models = new ArrayList<SocialRelation>(soapModels.length);
109
110 for (SocialRelationSoap soapModel : soapModels) {
111 models.add(toModel(soapModel));
112 }
113
114 return models;
115 }
116
117 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
118 "lock.expiration.time.com.liferay.portlet.social.model.SocialRelation"));
119
120 public SocialRelationModelImpl() {
121 }
122
123 public long getPrimaryKey() {
124 return _relationId;
125 }
126
127 public void setPrimaryKey(long pk) {
128 setRelationId(pk);
129 }
130
131 public Serializable getPrimaryKeyObj() {
132 return new Long(_relationId);
133 }
134
135 public String getUuid() {
136 return GetterUtil.getString(_uuid);
137 }
138
139 public void setUuid(String uuid) {
140 if ((uuid != null) && (uuid != _uuid)) {
141 _uuid = uuid;
142 }
143 }
144
145 public long getRelationId() {
146 return _relationId;
147 }
148
149 public void setRelationId(long relationId) {
150 if (relationId != _relationId) {
151 _relationId = relationId;
152 }
153 }
154
155 public long getCompanyId() {
156 return _companyId;
157 }
158
159 public void setCompanyId(long companyId) {
160 if (companyId != _companyId) {
161 _companyId = companyId;
162 }
163 }
164
165 public Date getCreateDate() {
166 return _createDate;
167 }
168
169 public void setCreateDate(Date createDate) {
170 if (((createDate == null) && (_createDate != null)) ||
171 ((createDate != null) && (_createDate == null)) ||
172 ((createDate != null) && (_createDate != null) &&
173 !createDate.equals(_createDate))) {
174 _createDate = createDate;
175 }
176 }
177
178 public long getUserId1() {
179 return _userId1;
180 }
181
182 public void setUserId1(long userId1) {
183 if (userId1 != _userId1) {
184 _userId1 = userId1;
185 }
186 }
187
188 public long getUserId2() {
189 return _userId2;
190 }
191
192 public void setUserId2(long userId2) {
193 if (userId2 != _userId2) {
194 _userId2 = userId2;
195 }
196 }
197
198 public int getType() {
199 return _type;
200 }
201
202 public void setType(int type) {
203 if (type != _type) {
204 _type = type;
205 }
206 }
207
208 public SocialRelation toEscapedModel() {
209 if (isEscapedModel()) {
210 return (SocialRelation)this;
211 }
212 else {
213 SocialRelation model = new SocialRelationImpl();
214
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 }