001
014
015 package com.liferay.portlet.imagegallery.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.impl.BaseModelImpl;
023 import com.liferay.portal.service.ServiceContext;
024 import com.liferay.portal.util.PortalUtil;
025
026 import com.liferay.portlet.expando.model.ExpandoBridge;
027 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028 import com.liferay.portlet.imagegallery.model.IGFolder;
029 import com.liferay.portlet.imagegallery.model.IGFolderModel;
030 import com.liferay.portlet.imagegallery.model.IGFolderSoap;
031
032 import java.io.Serializable;
033
034 import java.lang.reflect.Proxy;
035
036 import java.sql.Types;
037
038 import java.util.ArrayList;
039 import java.util.Date;
040 import java.util.List;
041
042
059 public class IGFolderModelImpl extends BaseModelImpl<IGFolder>
060 implements IGFolderModel {
061 public static final String TABLE_NAME = "IGFolder";
062 public static final Object[][] TABLE_COLUMNS = {
063 { "uuid_", new Integer(Types.VARCHAR) },
064 { "folderId", new Integer(Types.BIGINT) },
065 { "groupId", new Integer(Types.BIGINT) },
066 { "companyId", new Integer(Types.BIGINT) },
067 { "userId", new Integer(Types.BIGINT) },
068 { "createDate", new Integer(Types.TIMESTAMP) },
069 { "modifiedDate", new Integer(Types.TIMESTAMP) },
070 { "parentFolderId", new Integer(Types.BIGINT) },
071 { "name", new Integer(Types.VARCHAR) },
072 { "description", new Integer(Types.VARCHAR) }
073 };
074 public static final String TABLE_SQL_CREATE = "create table IGFolder (uuid_ VARCHAR(75) null,folderId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,createDate DATE null,modifiedDate DATE null,parentFolderId LONG,name VARCHAR(75) null,description STRING null)";
075 public static final String TABLE_SQL_DROP = "drop table IGFolder";
076 public static final String ORDER_BY_JPQL = " ORDER BY igFolder.folderId ASC, igFolder.name ASC";
077 public static final String ORDER_BY_SQL = " ORDER BY IGFolder.folderId ASC, IGFolder.name ASC";
078 public static final String DATA_SOURCE = "liferayDataSource";
079 public static final String SESSION_FACTORY = "liferaySessionFactory";
080 public static final String TX_MANAGER = "liferayTransactionManager";
081 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082 "value.object.entity.cache.enabled.com.liferay.portlet.imagegallery.model.IGFolder"),
083 true);
084 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085 "value.object.finder.cache.enabled.com.liferay.portlet.imagegallery.model.IGFolder"),
086 true);
087
088
094 public static IGFolder toModel(IGFolderSoap soapModel) {
095 IGFolder model = new IGFolderImpl();
096
097 model.setUuid(soapModel.getUuid());
098 model.setFolderId(soapModel.getFolderId());
099 model.setGroupId(soapModel.getGroupId());
100 model.setCompanyId(soapModel.getCompanyId());
101 model.setUserId(soapModel.getUserId());
102 model.setCreateDate(soapModel.getCreateDate());
103 model.setModifiedDate(soapModel.getModifiedDate());
104 model.setParentFolderId(soapModel.getParentFolderId());
105 model.setName(soapModel.getName());
106 model.setDescription(soapModel.getDescription());
107
108 return model;
109 }
110
111
117 public static List<IGFolder> toModels(IGFolderSoap[] soapModels) {
118 List<IGFolder> models = new ArrayList<IGFolder>(soapModels.length);
119
120 for (IGFolderSoap soapModel : soapModels) {
121 models.add(toModel(soapModel));
122 }
123
124 return models;
125 }
126
127 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
128 "lock.expiration.time.com.liferay.portlet.imagegallery.model.IGFolder"));
129
130 public IGFolderModelImpl() {
131 }
132
133 public long getPrimaryKey() {
134 return _folderId;
135 }
136
137 public void setPrimaryKey(long pk) {
138 setFolderId(pk);
139 }
140
141 public Serializable getPrimaryKeyObj() {
142 return new Long(_folderId);
143 }
144
145 public String getUuid() {
146 if (_uuid == null) {
147 return StringPool.BLANK;
148 }
149 else {
150 return _uuid;
151 }
152 }
153
154 public void setUuid(String uuid) {
155 _uuid = uuid;
156
157 if (_originalUuid == null) {
158 _originalUuid = uuid;
159 }
160 }
161
162 public String getOriginalUuid() {
163 return GetterUtil.getString(_originalUuid);
164 }
165
166 public long getFolderId() {
167 return _folderId;
168 }
169
170 public void setFolderId(long folderId) {
171 _folderId = folderId;
172 }
173
174 public long getGroupId() {
175 return _groupId;
176 }
177
178 public void setGroupId(long groupId) {
179 _groupId = groupId;
180
181 if (!_setOriginalGroupId) {
182 _setOriginalGroupId = true;
183
184 _originalGroupId = groupId;
185 }
186 }
187
188 public long getOriginalGroupId() {
189 return _originalGroupId;
190 }
191
192 public long getCompanyId() {
193 return _companyId;
194 }
195
196 public void setCompanyId(long companyId) {
197 _companyId = companyId;
198 }
199
200 public long getUserId() {
201 return _userId;
202 }
203
204 public void setUserId(long userId) {
205 _userId = userId;
206 }
207
208 public String getUserUuid() throws SystemException {
209 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
210 }
211
212 public void setUserUuid(String userUuid) {
213 _userUuid = userUuid;
214 }
215
216 public Date getCreateDate() {
217 return _createDate;
218 }
219
220 public void setCreateDate(Date createDate) {
221 _createDate = createDate;
222 }
223
224 public Date getModifiedDate() {
225 return _modifiedDate;
226 }
227
228 public void setModifiedDate(Date modifiedDate) {
229 _modifiedDate = modifiedDate;
230 }
231
232 public long getParentFolderId() {
233 return _parentFolderId;
234 }
235
236 public void setParentFolderId(long parentFolderId) {
237 _parentFolderId = parentFolderId;
238
239 if (!_setOriginalParentFolderId) {
240 _setOriginalParentFolderId = true;
241
242 _originalParentFolderId = parentFolderId;
243 }
244 }
245
246 public long getOriginalParentFolderId() {
247 return _originalParentFolderId;
248 }
249
250 public String getName() {
251 if (_name == null) {
252 return StringPool.BLANK;
253 }
254 else {
255 return _name;
256 }
257 }
258
259 public void setName(String name) {
260 _name = name;
261
262 if (_originalName == null) {
263 _originalName = name;
264 }
265 }
266
267 public String getOriginalName() {
268 return GetterUtil.getString(_originalName);
269 }
270
271 public String getDescription() {
272 if (_description == null) {
273 return StringPool.BLANK;
274 }
275 else {
276 return _description;
277 }
278 }
279
280 public void setDescription(String description) {
281 _description = description;
282 }
283
284 public IGFolder toEscapedModel() {
285 if (isEscapedModel()) {
286 return (IGFolder)this;
287 }
288 else {
289 return (IGFolder)Proxy.newProxyInstance(IGFolder.class.getClassLoader(),
290 new Class[] { IGFolder.class }, new AutoEscapeBeanHandler(this));
291 }
292 }
293
294 public ExpandoBridge getExpandoBridge() {
295 if (_expandoBridge == null) {
296 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
297 IGFolder.class.getName(), getPrimaryKey());
298 }
299
300 return _expandoBridge;
301 }
302
303 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
304 getExpandoBridge().setAttributes(serviceContext);
305 }
306
307 public Object clone() {
308 IGFolderImpl clone = new IGFolderImpl();
309
310 clone.setUuid(getUuid());
311 clone.setFolderId(getFolderId());
312 clone.setGroupId(getGroupId());
313 clone.setCompanyId(getCompanyId());
314 clone.setUserId(getUserId());
315 clone.setCreateDate(getCreateDate());
316 clone.setModifiedDate(getModifiedDate());
317 clone.setParentFolderId(getParentFolderId());
318 clone.setName(getName());
319 clone.setDescription(getDescription());
320
321 return clone;
322 }
323
324 public int compareTo(IGFolder igFolder) {
325 int value = 0;
326
327 if (getFolderId() < igFolder.getFolderId()) {
328 value = -1;
329 }
330 else if (getFolderId() > igFolder.getFolderId()) {
331 value = 1;
332 }
333 else {
334 value = 0;
335 }
336
337 if (value != 0) {
338 return value;
339 }
340
341 value = getName().toLowerCase()
342 .compareTo(igFolder.getName().toLowerCase());
343
344 if (value != 0) {
345 return value;
346 }
347
348 return 0;
349 }
350
351 public boolean equals(Object obj) {
352 if (obj == null) {
353 return false;
354 }
355
356 IGFolder igFolder = null;
357
358 try {
359 igFolder = (IGFolder)obj;
360 }
361 catch (ClassCastException cce) {
362 return false;
363 }
364
365 long pk = igFolder.getPrimaryKey();
366
367 if (getPrimaryKey() == pk) {
368 return true;
369 }
370 else {
371 return false;
372 }
373 }
374
375 public int hashCode() {
376 return (int)getPrimaryKey();
377 }
378
379 public String toString() {
380 StringBundler sb = new StringBundler(21);
381
382 sb.append("{uuid=");
383 sb.append(getUuid());
384 sb.append(", folderId=");
385 sb.append(getFolderId());
386 sb.append(", groupId=");
387 sb.append(getGroupId());
388 sb.append(", companyId=");
389 sb.append(getCompanyId());
390 sb.append(", userId=");
391 sb.append(getUserId());
392 sb.append(", createDate=");
393 sb.append(getCreateDate());
394 sb.append(", modifiedDate=");
395 sb.append(getModifiedDate());
396 sb.append(", parentFolderId=");
397 sb.append(getParentFolderId());
398 sb.append(", name=");
399 sb.append(getName());
400 sb.append(", description=");
401 sb.append(getDescription());
402 sb.append("}");
403
404 return sb.toString();
405 }
406
407 public String toXmlString() {
408 StringBundler sb = new StringBundler(34);
409
410 sb.append("<model><model-name>");
411 sb.append("com.liferay.portlet.imagegallery.model.IGFolder");
412 sb.append("</model-name>");
413
414 sb.append(
415 "<column><column-name>uuid</column-name><column-value><![CDATA[");
416 sb.append(getUuid());
417 sb.append("]]></column-value></column>");
418 sb.append(
419 "<column><column-name>folderId</column-name><column-value><![CDATA[");
420 sb.append(getFolderId());
421 sb.append("]]></column-value></column>");
422 sb.append(
423 "<column><column-name>groupId</column-name><column-value><![CDATA[");
424 sb.append(getGroupId());
425 sb.append("]]></column-value></column>");
426 sb.append(
427 "<column><column-name>companyId</column-name><column-value><![CDATA[");
428 sb.append(getCompanyId());
429 sb.append("]]></column-value></column>");
430 sb.append(
431 "<column><column-name>userId</column-name><column-value><![CDATA[");
432 sb.append(getUserId());
433 sb.append("]]></column-value></column>");
434 sb.append(
435 "<column><column-name>createDate</column-name><column-value><![CDATA[");
436 sb.append(getCreateDate());
437 sb.append("]]></column-value></column>");
438 sb.append(
439 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
440 sb.append(getModifiedDate());
441 sb.append("]]></column-value></column>");
442 sb.append(
443 "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
444 sb.append(getParentFolderId());
445 sb.append("]]></column-value></column>");
446 sb.append(
447 "<column><column-name>name</column-name><column-value><![CDATA[");
448 sb.append(getName());
449 sb.append("]]></column-value></column>");
450 sb.append(
451 "<column><column-name>description</column-name><column-value><![CDATA[");
452 sb.append(getDescription());
453 sb.append("]]></column-value></column>");
454
455 sb.append("</model>");
456
457 return sb.toString();
458 }
459
460 private String _uuid;
461 private String _originalUuid;
462 private long _folderId;
463 private long _groupId;
464 private long _originalGroupId;
465 private boolean _setOriginalGroupId;
466 private long _companyId;
467 private long _userId;
468 private String _userUuid;
469 private Date _createDate;
470 private Date _modifiedDate;
471 private long _parentFolderId;
472 private long _originalParentFolderId;
473 private boolean _setOriginalParentFolderId;
474 private String _name;
475 private String _originalName;
476 private String _description;
477 private transient ExpandoBridge _expandoBridge;
478 }