001
014
015 package com.liferay.portlet.dynamicdatamapping.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.service.ServiceContext;
020 import com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink;
021 import com.liferay.portlet.dynamicdatamapping.service.base.DDMStorageLinkLocalServiceBaseImpl;
022
023 import java.util.List;
024
025
029 public class DDMStorageLinkLocalServiceImpl
030 extends DDMStorageLinkLocalServiceBaseImpl {
031
032 @Override
033 public DDMStorageLink addStorageLink(
034 long classNameId, long classPK, long structureId,
035 ServiceContext serviceContext)
036 throws SystemException {
037
038 long storageLinkId = counterLocalService.increment();
039
040 DDMStorageLink storageLink = ddmStorageLinkPersistence.create(
041 storageLinkId);
042
043 storageLink.setClassNameId(classNameId);
044 storageLink.setClassPK(classPK);
045 storageLink.setStructureId(structureId);
046
047 ddmStorageLinkPersistence.update(storageLink, false);
048
049 return storageLink;
050 }
051
052 @Override
053 public void deleteClassStorageLink(long classPK)
054 throws PortalException, SystemException {
055
056 DDMStorageLink storageLink = ddmStorageLinkPersistence.findByClassPK(
057 classPK);
058
059 deleteStorageLink(storageLink);
060 }
061
062 @Override
063 public void deleteStorageLink(DDMStorageLink storageLink)
064 throws SystemException {
065
066 ddmStorageLinkPersistence.remove(storageLink);
067 }
068
069 @Override
070 public void deleteStorageLink(long storageLinkId)
071 throws PortalException, SystemException {
072
073 DDMStorageLink storageLink = ddmStorageLinkPersistence.findByPrimaryKey(
074 storageLinkId);
075
076 deleteStorageLink(storageLink);
077 }
078
079 @Override
080 public void deleteStructureStorageLinks(long structureId)
081 throws SystemException {
082
083 List<DDMStorageLink> storageLinks =
084 ddmStorageLinkPersistence.findByStructureId(structureId);
085
086 for (DDMStorageLink storageLink : storageLinks) {
087 deleteStorageLink(storageLink);
088 }
089 }
090
091 @Override
092 public DDMStorageLink getClassStorageLink(long classPK)
093 throws PortalException, SystemException {
094
095 return ddmStorageLinkPersistence.findByClassPK(classPK);
096 }
097
098 @Override
099 public DDMStorageLink getStorageLink(long storageLinkId)
100 throws PortalException, SystemException {
101
102 return ddmStorageLinkPersistence.findByPrimaryKey(storageLinkId);
103 }
104
105 @Override
106 public List<DDMStorageLink> getStructureStorageLinks(long structureId)
107 throws SystemException {
108
109 return ddmStorageLinkPersistence.findByStructureId(structureId);
110 }
111
112 @Override
113 public int getStructureStorageLinksCount(long structureId)
114 throws SystemException {
115
116 return ddmStorageLinkPersistence.countByStructureId(structureId);
117 }
118
119 @Override
120 public DDMStorageLink updateStorageLink(
121 long storageLinkId, long classNameId, long classPK)
122 throws PortalException, SystemException {
123
124 DDMStorageLink storageLink = ddmStorageLinkPersistence.findByPrimaryKey(
125 storageLinkId);
126
127 storageLink.setClassNameId(classNameId);
128 storageLink.setClassPK(classPK);
129
130 ddmStorageLinkPersistence.update(storageLink, false);
131
132 return storageLink;
133 }
134
135 }