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.social.kernel.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.IndexableActionableDynamicQuery; 022 import com.liferay.portal.kernel.dao.orm.Projection; 023 import com.liferay.portal.kernel.exception.PortalException; 024 import com.liferay.portal.kernel.exception.SystemException; 025 import com.liferay.portal.kernel.model.PersistedModel; 026 import com.liferay.portal.kernel.search.Indexable; 027 import com.liferay.portal.kernel.search.IndexableType; 028 import com.liferay.portal.kernel.service.BaseLocalService; 029 import com.liferay.portal.kernel.service.PersistedModelLocalService; 030 import com.liferay.portal.kernel.transaction.Isolation; 031 import com.liferay.portal.kernel.transaction.Propagation; 032 import com.liferay.portal.kernel.transaction.Transactional; 033 import com.liferay.portal.kernel.util.OrderByComparator; 034 035 import com.liferay.social.kernel.model.SocialRelation; 036 037 import java.io.Serializable; 038 039 import java.util.List; 040 041 /** 042 * Provides the local service interface for SocialRelation. Methods of this 043 * service will not have security checks based on the propagated JAAS 044 * credentials because this service can only be accessed from within the same 045 * VM. 046 * 047 * @author Brian Wing Shun Chan 048 * @see SocialRelationLocalServiceUtil 049 * @see com.liferay.portlet.social.service.base.SocialRelationLocalServiceBaseImpl 050 * @see com.liferay.portlet.social.service.impl.SocialRelationLocalServiceImpl 051 * @generated 052 */ 053 @ProviderType 054 @Transactional(isolation = Isolation.PORTAL, rollbackFor = { 055 PortalException.class, SystemException.class}) 056 public interface SocialRelationLocalService extends BaseLocalService, 057 PersistedModelLocalService { 058 /* 059 * NOTE FOR DEVELOPERS: 060 * 061 * Never modify or reference this interface directly. Always use {@link SocialRelationLocalServiceUtil} to access the social relation local service. Add custom service methods to {@link com.liferay.portlet.social.service.impl.SocialRelationLocalServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface. 062 */ 063 064 /** 065 * Returns <code>true</code> if a relation of the given type exists where 066 * the user with primary key <code>userId1</code> is User1 of the relation 067 * and the user with the primary key <code>userId2</code> is User2 of the 068 * relation. 069 * 070 * @param userId1 the user that is the subject of the relation 071 * @param userId2 the user at the other end of the relation 072 * @param type the relation's type 073 * @return <code>true</code> if the relation exists; <code>false</code> 074 otherwise 075 */ 076 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 077 public boolean hasRelation(long userId1, long userId2, int type); 078 079 /** 080 * Returns <code>true</code> if the users can be in a relation of the given 081 * type where the user with primary key <code>userId1</code> is User1 of the 082 * relation and the user with the primary key <code>userId2</code> is User2 083 * of the relation. 084 * 085 * <p> 086 * This method returns <code>false</code> if User1 and User2 are the same, 087 * if either user is the default user, or if a matching relation already 088 * exists. 089 * </p> 090 * 091 * @param userId1 the user that is the subject of the relation 092 * @param userId2 the user at the other end of the relation 093 * @param type the relation's type 094 * @return <code>true</code> if the two users can be in a new relation of 095 the given type; <code>false</code> otherwise 096 */ 097 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 098 public boolean isRelatable(long userId1, long userId2, int type); 099 100 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 101 public ActionableDynamicQuery getActionableDynamicQuery(); 102 103 public DynamicQuery dynamicQuery(); 104 105 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 106 public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery(); 107 108 /** 109 * @throws PortalException 110 */ 111 @Override 112 public PersistedModel deletePersistedModel(PersistedModel persistedModel) 113 throws PortalException; 114 115 @Override 116 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 117 public PersistedModel getPersistedModel(Serializable primaryKeyObj) 118 throws PortalException; 119 120 /** 121 * Adds a social relation between the two users to the database. 122 * 123 * @param userId1 the user that is the subject of the relation 124 * @param userId2 the user at the other end of the relation 125 * @param type the type of the relation 126 * @return the social relation 127 */ 128 public SocialRelation addRelation(long userId1, long userId2, int type) 129 throws PortalException; 130 131 /** 132 * Adds the social relation to the database. Also notifies the appropriate model listeners. 133 * 134 * @param socialRelation the social relation 135 * @return the social relation that was added 136 */ 137 @Indexable(type = IndexableType.REINDEX) 138 public SocialRelation addSocialRelation(SocialRelation socialRelation); 139 140 /** 141 * Creates a new social relation with the primary key. Does not add the social relation to the database. 142 * 143 * @param relationId the primary key for the new social relation 144 * @return the new social relation 145 */ 146 public SocialRelation createSocialRelation(long relationId); 147 148 /** 149 * Deletes the social relation from the database. Also notifies the appropriate model listeners. 150 * 151 * @param socialRelation the social relation 152 * @return the social relation that was removed 153 */ 154 @Indexable(type = IndexableType.DELETE) 155 public SocialRelation deleteSocialRelation(SocialRelation socialRelation); 156 157 /** 158 * Deletes the social relation with the primary key from the database. Also notifies the appropriate model listeners. 159 * 160 * @param relationId the primary key of the social relation 161 * @return the social relation that was removed 162 * @throws PortalException if a social relation with the primary key could not be found 163 */ 164 @Indexable(type = IndexableType.DELETE) 165 public SocialRelation deleteSocialRelation(long relationId) 166 throws PortalException; 167 168 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 169 public SocialRelation fetchSocialRelation(long relationId); 170 171 /** 172 * Returns the social relation with the matching UUID and company. 173 * 174 * @param uuid the social relation's UUID 175 * @param companyId the primary key of the company 176 * @return the matching social relation, or <code>null</code> if a matching social relation could not be found 177 */ 178 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 179 public SocialRelation fetchSocialRelationByUuidAndCompanyId( 180 java.lang.String uuid, long companyId); 181 182 /** 183 * Returns the relation identified by its primary key. 184 * 185 * @param relationId the primary key of the relation 186 * @return Returns the relation 187 */ 188 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 189 public SocialRelation getRelation(long relationId) 190 throws PortalException; 191 192 /** 193 * Returns the relation of the given type between User1 and User2. 194 * 195 * @param userId1 the user that is the subject of the relation 196 * @param userId2 the user at the other end of the relation 197 * @param type the relation's type 198 * @return Returns the relation 199 */ 200 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 201 public SocialRelation getRelation(long userId1, long userId2, int type) 202 throws PortalException; 203 204 /** 205 * Returns the social relation with the primary key. 206 * 207 * @param relationId the primary key of the social relation 208 * @return the social relation 209 * @throws PortalException if a social relation with the primary key could not be found 210 */ 211 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 212 public SocialRelation getSocialRelation(long relationId) 213 throws PortalException; 214 215 /** 216 * Returns the social relation with the matching UUID and company. 217 * 218 * @param uuid the social relation's UUID 219 * @param companyId the primary key of the company 220 * @return the matching social relation 221 * @throws PortalException if a matching social relation could not be found 222 */ 223 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 224 public SocialRelation getSocialRelationByUuidAndCompanyId( 225 java.lang.String uuid, long companyId) throws PortalException; 226 227 /** 228 * Updates the social relation in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners. 229 * 230 * @param socialRelation the social relation 231 * @return the social relation that was updated 232 */ 233 @Indexable(type = IndexableType.REINDEX) 234 public SocialRelation updateSocialRelation(SocialRelation socialRelation); 235 236 /** 237 * Returns the number of inverse relations of the given type for which the 238 * user is User2 of the relation. 239 * 240 * @param userId the primary key of the user 241 * @param type the relation's type 242 * @return the number of matching relations 243 */ 244 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 245 public int getInverseRelationsCount(long userId, int type); 246 247 /** 248 * Returns the number of relations of the given type where the user is the 249 * subject of the relation. 250 * 251 * @param userId the primary key of the user 252 * @param type the relation's type 253 * @return the number of relations 254 */ 255 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 256 public int getRelationsCount(long userId, int type); 257 258 /** 259 * Returns the number of relations between User1 and User2. 260 * 261 * @param userId1 the user that is the subject of the relation 262 * @param userId2 the user at the other end of the relation 263 * @return the number of relations 264 */ 265 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 266 public int getRelationsCount(long userId1, long userId2); 267 268 /** 269 * Returns the number of social relations. 270 * 271 * @return the number of social relations 272 */ 273 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 274 public int getSocialRelationsCount(); 275 276 /** 277 * Returns the OSGi service identifier. 278 * 279 * @return the OSGi service identifier 280 */ 281 public java.lang.String getOSGiServiceIdentifier(); 282 283 /** 284 * Performs a dynamic query on the database and returns the matching rows. 285 * 286 * @param dynamicQuery the dynamic query 287 * @return the matching rows 288 */ 289 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery); 290 291 /** 292 * Performs a dynamic query on the database and returns a range of the matching rows. 293 * 294 * <p> 295 * 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.social.model.impl.SocialRelationModelImpl}. 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. 296 * </p> 297 * 298 * @param dynamicQuery the dynamic query 299 * @param start the lower bound of the range of model instances 300 * @param end the upper bound of the range of model instances (not inclusive) 301 * @return the range of matching rows 302 */ 303 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start, 304 int end); 305 306 /** 307 * Performs a dynamic query on the database and returns an ordered range of the matching rows. 308 * 309 * <p> 310 * 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.social.model.impl.SocialRelationModelImpl}. 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. 311 * </p> 312 * 313 * @param dynamicQuery the dynamic query 314 * @param start the lower bound of the range of model instances 315 * @param end the upper bound of the range of model instances (not inclusive) 316 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) 317 * @return the ordered range of matching rows 318 */ 319 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start, 320 int end, OrderByComparator<T> orderByComparator); 321 322 /** 323 * Returns a range of all the inverse relations of the given type for which 324 * the user is User2 of the relation. 325 * 326 * <p> 327 * Useful when paginating results. Returns a maximum of <code>end - 328 * start</code> instances. <code>start</code> and <code>end</code> are not 329 * primary keys, they are indexes in the result set. Thus, <code>0</code> 330 * refers to the first result in the set. Setting both <code>start</code> 331 * and <code>end</code> to {@link 332 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full 333 * result set. 334 * </p> 335 * 336 * @param userId the primary key of the user 337 * @param type the relation's type 338 * @param start the lower bound of the range of results 339 * @param end the upper bound of the range of results (not inclusive) 340 * @return the range of matching relations 341 */ 342 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 343 public List<SocialRelation> getInverseRelations(long userId, int type, 344 int start, int end); 345 346 /** 347 * Returns a range of all the relations of the given type where the user is 348 * the subject of the relation. 349 * 350 * <p> 351 * Useful when paginating results. Returns a maximum of <code>end - 352 * start</code> instances. <code>start</code> and <code>end</code> are not 353 * primary keys, they are indexes in the result set. Thus, <code>0</code> 354 * refers to the first result in the set. Setting both <code>start</code> 355 * and <code>end</code> to {@link 356 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full 357 * result set. 358 * </p> 359 * 360 * @param userId the primary key of the user 361 * @param type the relation's type 362 * @param start the lower bound of the range of results 363 * @param end the upper bound of the range of results (not inclusive) 364 * @return the range of relations 365 */ 366 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 367 public List<SocialRelation> getRelations(long userId, int type, int start, 368 int end); 369 370 /** 371 * Returns a range of all the relations between User1 and User2. 372 * 373 * <p> 374 * Useful when paginating results. Returns a maximum of <code>end - 375 * start</code> instances. <code>start</code> and <code>end</code> are not 376 * primary keys, they are indexes in the result set. Thus, <code>0</code> 377 * refers to the first result in the set. Setting both <code>start</code> 378 * and <code>end</code> to {@link 379 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full 380 * result set. 381 * </p> 382 * 383 * @param userId1 the user that is the subject of the relation 384 * @param userId2 the user at the other end of the relation 385 * @param start the lower bound of the range of results 386 * @param end the upper bound of the range of results (not inclusive) 387 * @return the range of relations 388 */ 389 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 390 public List<SocialRelation> getRelations(long userId1, long userId2, 391 int start, int end); 392 393 /** 394 * Returns a range of all the social relations. 395 * 396 * <p> 397 * 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.social.model.impl.SocialRelationModelImpl}. 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. 398 * </p> 399 * 400 * @param start the lower bound of the range of social relations 401 * @param end the upper bound of the range of social relations (not inclusive) 402 * @return the range of social relations 403 */ 404 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 405 public List<SocialRelation> getSocialRelations(int start, int end); 406 407 /** 408 * Returns the number of rows matching the dynamic query. 409 * 410 * @param dynamicQuery the dynamic query 411 * @return the number of rows matching the dynamic query 412 */ 413 public long dynamicQueryCount(DynamicQuery dynamicQuery); 414 415 /** 416 * Returns the number of rows matching the dynamic query. 417 * 418 * @param dynamicQuery the dynamic query 419 * @param projection the projection to apply to the query 420 * @return the number of rows matching the dynamic query 421 */ 422 public long dynamicQueryCount(DynamicQuery dynamicQuery, 423 Projection projection); 424 425 /** 426 * Removes the relation (and its inverse in case of a bidirectional 427 * relation) from the database. 428 * 429 * @param relation the relation to be removed 430 */ 431 public void deleteRelation(SocialRelation relation) 432 throws PortalException; 433 434 /** 435 * Removes the relation (and its inverse in case of a bidirectional 436 * relation) from the database. 437 * 438 * @param relationId the primary key of the relation 439 */ 440 public void deleteRelation(long relationId) throws PortalException; 441 442 /** 443 * Removes the matching relation (and its inverse in case of a bidirectional 444 * relation) from the database. 445 * 446 * @param userId1 the user that is the subject of the relation 447 * @param userId2 the user at the other end of the relation 448 * @param type the relation's type 449 */ 450 public void deleteRelation(long userId1, long userId2, int type) 451 throws PortalException; 452 453 /** 454 * Removes all relations involving the user from the database. 455 * 456 * @param userId the primary key of the user 457 */ 458 public void deleteRelations(long userId); 459 460 /** 461 * Removes all relations between User1 and User2. 462 * 463 * @param userId1 the user that is the subject of the relation 464 * @param userId2 the user at the other end of the relation 465 */ 466 public void deleteRelations(long userId1, long userId2) 467 throws PortalException; 468 }