1
14
15 package com.liferay.portlet.asset.service.impl;
16
17 import com.liferay.portal.kernel.exception.PortalException;
18 import com.liferay.portal.kernel.exception.SystemException;
19 import com.liferay.portal.model.User;
20 import com.liferay.portlet.asset.model.AssetLink;
21 import com.liferay.portlet.asset.service.base.AssetLinkLocalServiceBaseImpl;
22
23 import java.util.Date;
24 import java.util.List;
25
26
31 public class AssetLinkLocalServiceImpl extends AssetLinkLocalServiceBaseImpl {
32
33 public AssetLink addLink(
34 long userId, long entryId1, long entryId2, int type, int weight)
35 throws PortalException, SystemException {
36
37 User user = userLocalService.getUser(userId);
38 Date now = new Date();
39
40 long linkId = counterLocalService.increment();
41
42 AssetLink link = assetLinkPersistence.create(linkId);
43
44 link.setCompanyId(user.getCompanyId());
45 link.setUserId(user.getUserId());
46 link.setUserName(user.getFullName());
47 link.setCreateDate(now);
48 link.setEntryId1(entryId1);
49 link.setEntryId2(entryId2);
50 link.setType(type);
51 link.setWeight(weight);
52
53 assetLinkPersistence.update(link, false);
54
55 return link;
56 }
57
58 public void deleteLink(long linkId)
59 throws PortalException, SystemException {
60
61 assetLinkPersistence.remove(linkId);
62 }
63
64 public void deleteLinks(long entryId) throws SystemException {
65 assetLinkPersistence.removeByE1(entryId);
66 assetLinkPersistence.removeByE2(entryId);
67 }
68
69 public void deleteLinks(long entryId1, long entryId2)
70 throws SystemException {
71
72 assetLinkPersistence.removeByE_E(entryId1, entryId2);
73 }
74
75 public List<AssetLink> getLinks(long entryId, int typeId)
76 throws SystemException {
77
78 return assetLinkPersistence.findByE1_T(entryId, typeId);
79 }
80
81 public List<AssetLink> getReverseLinks(long entryId, int typeId)
82 throws SystemException {
83
84 return assetLinkPersistence.findByE2_T(entryId, typeId);
85 }
86
87 }