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 public DDMStorageLink addStorageLink(
033 long classNameId, long classPK, long structureId,
034 ServiceContext serviceContext)
035 throws SystemException {
036
037 long storageLinkId = counterLocalService.increment();
038
039 DDMStorageLink storageLink = ddmStorageLinkPersistence.create(
040 storageLinkId);
041
042 storageLink.setClassNameId(classNameId);
043 storageLink.setClassPK(classPK);
044 storageLink.setStructureId(structureId);
045
046 ddmStorageLinkPersistence.update(storageLink, false);
047
048 return storageLink;
049 }
050
051 public void deleteClassStorageLink(long classPK)
052 throws PortalException, SystemException {
053
054 DDMStorageLink storageLink = ddmStorageLinkPersistence.findByClassPK(
055 classPK);
056
057 deleteStorageLink(storageLink);
058 }
059
060 public void deleteStorageLink(DDMStorageLink storageLink)
061 throws SystemException {
062
063 ddmStorageLinkPersistence.remove(storageLink);
064 }
065
066 public void deleteStorageLink(long storageLinkId)
067 throws PortalException, SystemException {
068
069 DDMStorageLink storageLink = ddmStorageLinkPersistence.findByPrimaryKey(
070 storageLinkId);
071
072 deleteStorageLink(storageLink);
073 }
074
075 public void deleteStructureStorageLinks(long structureId)
076 throws SystemException {
077
078 List<DDMStorageLink> storageLinks =
079 ddmStorageLinkPersistence.findByStructureId(structureId);
080
081 for (DDMStorageLink storageLink : storageLinks) {
082 deleteStorageLink(storageLink);
083 }
084 }
085
086 public DDMStorageLink getClassStorageLink(long classPK)
087 throws PortalException, SystemException {
088
089 return ddmStorageLinkPersistence.findByClassPK(classPK);
090 }
091
092 public DDMStorageLink getStorageLink(long storageLinkId)
093 throws PortalException, SystemException {
094
095 return ddmStorageLinkPersistence.findByPrimaryKey(storageLinkId);
096 }
097
098 public List<DDMStorageLink> getStructureStorageLinks(long structureId)
099 throws SystemException {
100
101 return ddmStorageLinkPersistence.findByStructureId(structureId);
102 }
103
104 public DDMStorageLink updateStorageLink(
105 long storageLinkId, long classNameId, long classPK)
106 throws PortalException, SystemException {
107
108 DDMStorageLink storageLink = ddmStorageLinkPersistence.findByPrimaryKey(
109 storageLinkId);
110
111 storageLink.setClassNameId(classNameId);
112 storageLink.setClassPK(classPK);
113
114 ddmStorageLinkPersistence.update(storageLink, false);
115
116 return storageLink;
117 }
118
119 }