001
014
015 package com.liferay.portlet.asset.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.model.User;
020 import com.liferay.portlet.asset.model.AssetLink;
021 import com.liferay.portlet.asset.service.base.AssetLinkLocalServiceBaseImpl;
022
023 import java.util.Date;
024 import java.util.List;
025
026
029 public class AssetLinkLocalServiceImpl extends AssetLinkLocalServiceBaseImpl {
030
031 public AssetLink addLink(
032 long userId, long entryId1, long entryId2, int type, int weight)
033 throws PortalException, SystemException {
034
035 User user = userLocalService.getUser(userId);
036 Date now = new Date();
037
038 long linkId = counterLocalService.increment();
039
040 AssetLink link = assetLinkPersistence.create(linkId);
041
042 link.setCompanyId(user.getCompanyId());
043 link.setUserId(user.getUserId());
044 link.setUserName(user.getFullName());
045 link.setCreateDate(now);
046 link.setEntryId1(entryId1);
047 link.setEntryId2(entryId2);
048 link.setType(type);
049 link.setWeight(weight);
050
051 assetLinkPersistence.update(link, false);
052
053 return link;
054 }
055
056 public void deleteLink(long linkId)
057 throws PortalException, SystemException {
058
059 assetLinkPersistence.remove(linkId);
060 }
061
062 public void deleteLinks(long entryId) throws SystemException {
063 assetLinkPersistence.removeByE1(entryId);
064 assetLinkPersistence.removeByE2(entryId);
065 }
066
067 public void deleteLinks(long entryId1, long entryId2)
068 throws SystemException {
069
070 assetLinkPersistence.removeByE_E(entryId1, entryId2);
071 }
072
073 public List<AssetLink> getLinks(long entryId, int typeId)
074 throws SystemException {
075
076 return assetLinkPersistence.findByE1_T(entryId, typeId);
077 }
078
079 public List<AssetLink> getReverseLinks(long entryId, int typeId)
080 throws SystemException {
081
082 return assetLinkPersistence.findByE2_T(entryId, typeId);
083 }
084
085 }