001 /** 002 * Copyright (c) 2000-present Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portlet.asset.service; 016 017 import aQute.bnd.annotation.ProviderType; 018 019 import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery; 020 import com.liferay.portal.kernel.dao.orm.DynamicQuery; 021 import com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery; 022 import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery; 023 import com.liferay.portal.kernel.dao.orm.Projection; 024 import com.liferay.portal.kernel.exception.PortalException; 025 import com.liferay.portal.kernel.exception.SystemException; 026 import com.liferay.portal.kernel.search.Indexable; 027 import com.liferay.portal.kernel.search.IndexableType; 028 import com.liferay.portal.kernel.transaction.Isolation; 029 import com.liferay.portal.kernel.transaction.Propagation; 030 import com.liferay.portal.kernel.transaction.Transactional; 031 import com.liferay.portal.kernel.util.OrderByComparator; 032 import com.liferay.portal.model.PersistedModel; 033 import com.liferay.portal.service.BaseLocalService; 034 import com.liferay.portal.service.PersistedModelLocalService; 035 036 import com.liferay.portlet.asset.model.AssetLink; 037 import com.liferay.portlet.exportimport.lar.PortletDataContext; 038 039 import java.io.Serializable; 040 041 import java.util.List; 042 043 /** 044 * Provides the local service interface for AssetLink. Methods of this 045 * service will not have security checks based on the propagated JAAS 046 * credentials because this service can only be accessed from within the same 047 * VM. 048 * 049 * @author Brian Wing Shun Chan 050 * @see AssetLinkLocalServiceUtil 051 * @see com.liferay.portlet.asset.service.base.AssetLinkLocalServiceBaseImpl 052 * @see com.liferay.portlet.asset.service.impl.AssetLinkLocalServiceImpl 053 * @generated 054 */ 055 @ProviderType 056 @Transactional(isolation = Isolation.PORTAL, rollbackFor = { 057 PortalException.class, SystemException.class}) 058 public interface AssetLinkLocalService extends BaseLocalService, 059 PersistedModelLocalService { 060 /* 061 * NOTE FOR DEVELOPERS: 062 * 063 * Never modify or reference this interface directly. Always use {@link AssetLinkLocalServiceUtil} to access the asset link local service. Add custom service methods to {@link com.liferay.portlet.asset.service.impl.AssetLinkLocalServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface. 064 */ 065 066 /** 067 * Adds the asset link to the database. Also notifies the appropriate model listeners. 068 * 069 * @param assetLink the asset link 070 * @return the asset link that was added 071 */ 072 @Indexable(type = IndexableType.REINDEX) 073 public AssetLink addAssetLink(AssetLink assetLink); 074 075 /** 076 * Adds a new asset link. 077 * 078 * @param userId the primary key of the link's creator 079 * @param entryId1 the primary key of the first asset entry 080 * @param entryId2 the primary key of the second asset entry 081 * @param type the link type. Acceptable values include {@link 082 AssetLinkConstants#TYPE_RELATED} which is a bidirectional 083 relationship and {@link AssetLinkConstants#TYPE_CHILD} which is a 084 unidirectional relationship. For more information see {@link 085 AssetLinkConstants} 086 * @param weight the weight of the relationship, allowing precedence 087 ordering of links 088 * @return the asset link 089 */ 090 public AssetLink addLink(long userId, long entryId1, long entryId2, 091 int type, int weight) throws PortalException; 092 093 /** 094 * Creates a new asset link with the primary key. Does not add the asset link to the database. 095 * 096 * @param linkId the primary key for the new asset link 097 * @return the new asset link 098 */ 099 public AssetLink createAssetLink(long linkId); 100 101 /** 102 * Deletes the asset link from the database. Also notifies the appropriate model listeners. 103 * 104 * @param assetLink the asset link 105 * @return the asset link that was removed 106 */ 107 @Indexable(type = IndexableType.DELETE) 108 public AssetLink deleteAssetLink(AssetLink assetLink); 109 110 /** 111 * Deletes the asset link with the primary key from the database. Also notifies the appropriate model listeners. 112 * 113 * @param linkId the primary key of the asset link 114 * @return the asset link that was removed 115 * @throws PortalException if a asset link with the primary key could not be found 116 */ 117 @Indexable(type = IndexableType.DELETE) 118 public AssetLink deleteAssetLink(long linkId) throws PortalException; 119 120 public void deleteGroupLinks(long groupId); 121 122 /** 123 * Deletes the asset link. 124 * 125 * @param link the asset link 126 */ 127 public void deleteLink(AssetLink link); 128 129 /** 130 * Deletes the asset link. 131 * 132 * @param linkId the primary key of the asset link 133 */ 134 public void deleteLink(long linkId) throws PortalException; 135 136 /** 137 * Deletes all links associated with the asset entry. 138 * 139 * @param entryId the primary key of the asset entry 140 */ 141 public void deleteLinks(long entryId); 142 143 /** 144 * Delete all links that associate the two asset entries. 145 * 146 * @param entryId1 the primary key of the first asset entry 147 * @param entryId2 the primary key of the second asset entry 148 */ 149 public void deleteLinks(long entryId1, long entryId2); 150 151 /** 152 * @throws PortalException 153 */ 154 @Override 155 public PersistedModel deletePersistedModel(PersistedModel persistedModel) 156 throws PortalException; 157 158 public DynamicQuery dynamicQuery(); 159 160 /** 161 * Performs a dynamic query on the database and returns the matching rows. 162 * 163 * @param dynamicQuery the dynamic query 164 * @return the matching rows 165 */ 166 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery); 167 168 /** 169 * Performs a dynamic query on the database and returns a range of the matching rows. 170 * 171 * <p> 172 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetLinkModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 173 * </p> 174 * 175 * @param dynamicQuery the dynamic query 176 * @param start the lower bound of the range of model instances 177 * @param end the upper bound of the range of model instances (not inclusive) 178 * @return the range of matching rows 179 */ 180 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start, 181 int end); 182 183 /** 184 * Performs a dynamic query on the database and returns an ordered range of the matching rows. 185 * 186 * <p> 187 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetLinkModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 188 * </p> 189 * 190 * @param dynamicQuery the dynamic query 191 * @param start the lower bound of the range of model instances 192 * @param end the upper bound of the range of model instances (not inclusive) 193 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) 194 * @return the ordered range of matching rows 195 */ 196 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start, 197 int end, OrderByComparator<T> orderByComparator); 198 199 /** 200 * Returns the number of rows matching the dynamic query. 201 * 202 * @param dynamicQuery the dynamic query 203 * @return the number of rows matching the dynamic query 204 */ 205 public long dynamicQueryCount(DynamicQuery dynamicQuery); 206 207 /** 208 * Returns the number of rows matching the dynamic query. 209 * 210 * @param dynamicQuery the dynamic query 211 * @param projection the projection to apply to the query 212 * @return the number of rows matching the dynamic query 213 */ 214 public long dynamicQueryCount(DynamicQuery dynamicQuery, 215 Projection projection); 216 217 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 218 public AssetLink fetchAssetLink(long linkId); 219 220 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 221 public ActionableDynamicQuery getActionableDynamicQuery(); 222 223 /** 224 * Returns the asset link with the primary key. 225 * 226 * @param linkId the primary key of the asset link 227 * @return the asset link 228 * @throws PortalException if a asset link with the primary key could not be found 229 */ 230 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 231 public AssetLink getAssetLink(long linkId) throws PortalException; 232 233 /** 234 * Returns a range of all the asset links. 235 * 236 * <p> 237 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetLinkModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 238 * </p> 239 * 240 * @param start the lower bound of the range of asset links 241 * @param end the upper bound of the range of asset links (not inclusive) 242 * @return the range of asset links 243 */ 244 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 245 public List<AssetLink> getAssetLinks(int start, int end); 246 247 /** 248 * Returns the number of asset links. 249 * 250 * @return the number of asset links 251 */ 252 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 253 public int getAssetLinksCount(); 254 255 /** 256 * Returns all the asset links whose first entry ID is the given entry ID. 257 * 258 * @param entryId the primary key of the asset entry 259 * @return the asset links whose first entry ID is the given entry ID 260 */ 261 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 262 public List<AssetLink> getDirectLinks(long entryId); 263 264 /** 265 * Returns all the asset links of the given link type whose first entry ID 266 * is the given entry ID. 267 * 268 * @param entryId the primary key of the asset entry 269 * @param typeId the link type. Acceptable values include {@link 270 AssetLinkConstants#TYPE_RELATED} which is a bidirectional 271 relationship and {@link AssetLinkConstants#TYPE_CHILD} which is a 272 unidirectional relationship. For more information see {@link 273 AssetLinkConstants} 274 * @return the asset links of the given link type whose first entry ID is 275 the given entry ID 276 */ 277 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 278 public List<AssetLink> getDirectLinks(long entryId, int typeId); 279 280 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 281 public ExportActionableDynamicQuery getExportActionbleDynamicQuery( 282 PortletDataContext portletDataContext); 283 284 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 285 public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery(); 286 287 /** 288 * Returns all the asset links whose first or second entry ID is the given 289 * entry ID. 290 * 291 * @param entryId the primary key of the asset entry 292 * @return the asset links whose first or second entry ID is the given entry 293 ID 294 */ 295 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 296 public List<AssetLink> getLinks(long entryId); 297 298 /** 299 * Returns all the asset links of the given link type whose first or second 300 * entry ID is the given entry ID. 301 * 302 * @param entryId the primary key of the asset entry 303 * @param typeId the link type. Acceptable values include {@link 304 AssetLinkConstants#TYPE_RELATED} which is a bidirectional 305 relationship and {@link AssetLinkConstants#TYPE_CHILD} which is a 306 unidirectional relationship. For more information see {@link 307 AssetLinkConstants} 308 * @return the asset links of the given link type whose first or second 309 entry ID is the given entry ID 310 */ 311 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 312 public List<AssetLink> getLinks(long entryId, int typeId); 313 314 /** 315 * Returns the OSGi service identifier. 316 * 317 * @return the OSGi service identifier 318 */ 319 public java.lang.String getOSGiServiceIdentifier(); 320 321 @Override 322 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 323 public PersistedModel getPersistedModel(Serializable primaryKeyObj) 324 throws PortalException; 325 326 /** 327 * Returns all the asset links of the given link type whose second entry ID 328 * is the given entry ID. 329 * 330 * @param entryId the primary key of the asset entry 331 * @param typeId the link type. Acceptable values include {@link 332 AssetLinkConstants#TYPE_RELATED} which is a bidirectional 333 relationship and {@link AssetLinkConstants#TYPE_CHILD} which is a 334 unidirectional relationship. For more information see {@link 335 AssetLinkConstants} 336 * @return the asset links of the given link type whose second entry ID is 337 the given entry ID 338 */ 339 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 340 public List<AssetLink> getReverseLinks(long entryId, int typeId); 341 342 /** 343 * Updates the asset link in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners. 344 * 345 * @param assetLink the asset link 346 * @return the asset link that was updated 347 */ 348 @Indexable(type = IndexableType.REINDEX) 349 public AssetLink updateAssetLink(AssetLink assetLink); 350 351 public AssetLink updateLink(long userId, long entryId1, long entryId2, 352 int typeId, int weight) throws PortalException; 353 354 /** 355 * Updates all links of the asset entry, replacing them with links 356 * associating the asset entry with the asset entries of the given link 357 * entry IDs. 358 * 359 * <p> 360 * If no link exists with a given link entry ID, a new link is created 361 * associating the current asset entry with the asset entry of that link 362 * entry ID. An existing link is deleted if either of its entry IDs is not 363 * contained in the given link entry IDs. 364 * </p> 365 * 366 * @param userId the primary key of the user updating the links 367 * @param entryId the primary key of the asset entry to be managed 368 * @param linkEntryIds the primary keys of the asset entries to be linked 369 with the asset entry to be managed 370 * @param typeId the type of the asset links to be created. Acceptable 371 values include {@link AssetLinkConstants#TYPE_RELATED} which is a 372 bidirectional relationship and {@link 373 AssetLinkConstants#TYPE_CHILD} which is a unidirectional 374 relationship. For more information see {@link AssetLinkConstants} 375 */ 376 public void updateLinks(long userId, long entryId, long[] linkEntryIds, 377 int typeId) throws PortalException; 378 }