001
014
015 package com.liferay.portlet.trash.service.impl;
016
017 import com.liferay.portal.kernel.util.UnicodeProperties;
018 import com.liferay.portal.kernel.util.Validator;
019 import com.liferay.portlet.trash.model.TrashVersion;
020 import com.liferay.portlet.trash.service.base.TrashVersionLocalServiceBaseImpl;
021
022 import java.util.List;
023
024
027 public class TrashVersionLocalServiceImpl
028 extends TrashVersionLocalServiceBaseImpl {
029
030 @Override
031 public TrashVersion addTrashVersion(
032 long trashEntryId, String className, long classPK, int status,
033 UnicodeProperties typeSettingsProperties) {
034
035 long versionId = counterLocalService.increment();
036
037 TrashVersion trashVersion = trashVersionPersistence.create(versionId);
038
039 trashVersion.setEntryId(trashEntryId);
040 trashVersion.setClassName(className);
041 trashVersion.setClassPK(classPK);
042
043 if (typeSettingsProperties != null) {
044 trashVersion.setTypeSettingsProperties(typeSettingsProperties);
045 }
046
047 trashVersion.setStatus(status);
048
049 return trashVersionPersistence.update(trashVersion);
050 }
051
052 @Override
053 public TrashVersion deleteTrashVersion(String className, long classPK) {
054 long classNameId = classNameLocalService.getClassNameId(className);
055
056 TrashVersion trashVersion = trashVersionPersistence.fetchByC_C(
057 classNameId, classPK);
058
059 if (trashVersion != null) {
060 return deleteTrashVersion(trashVersion);
061 }
062
063 return null;
064 }
065
066
069 @Deprecated
070 @Override
071 public TrashVersion fetchVersion(
072 long entryId, String className, long classPK) {
073
074 return fetchVersion(className, classPK);
075 }
076
077 @Override
078 public TrashVersion fetchVersion(String className, long classPK) {
079 long classNameId = classNameLocalService.getClassNameId(className);
080
081 return trashVersionPersistence.fetchByC_C(classNameId, classPK);
082 }
083
084 @Override
085 public List<TrashVersion> getVersions(long entryId) {
086 return trashVersionPersistence.findByEntryId(entryId);
087 }
088
089 @Override
090 public List<TrashVersion> getVersions(long entryId, String className) {
091 if (Validator.isNull(className)) {
092 return trashVersionPersistence.findByEntryId(entryId);
093 }
094
095 long classNameId = classNameLocalService.getClassNameId(className);
096
097 return trashVersionPersistence.findByE_C(entryId, classNameId);
098 }
099
100 }