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