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.asset.kernel.model.AssetEntry; 020 021 import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery; 022 import com.liferay.portal.kernel.dao.orm.DynamicQuery; 023 import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery; 024 import com.liferay.portal.kernel.dao.orm.Projection; 025 import com.liferay.portal.kernel.exception.PortalException; 026 import com.liferay.portal.kernel.exception.SystemException; 027 import com.liferay.portal.kernel.messaging.async.Async; 028 import com.liferay.portal.kernel.model.PersistedModel; 029 import com.liferay.portal.kernel.search.Indexable; 030 import com.liferay.portal.kernel.search.IndexableType; 031 import com.liferay.portal.kernel.service.BaseLocalService; 032 import com.liferay.portal.kernel.service.PersistedModelLocalService; 033 import com.liferay.portal.kernel.transaction.Isolation; 034 import com.liferay.portal.kernel.transaction.Propagation; 035 import com.liferay.portal.kernel.transaction.Transactional; 036 import com.liferay.portal.kernel.util.OrderByComparator; 037 038 import com.liferay.social.kernel.model.SocialActivity; 039 040 import java.io.Serializable; 041 042 import java.util.Date; 043 import java.util.List; 044 045 /** 046 * Provides the local service interface for SocialActivity. Methods of this 047 * service will not have security checks based on the propagated JAAS 048 * credentials because this service can only be accessed from within the same 049 * VM. 050 * 051 * @author Brian Wing Shun Chan 052 * @see SocialActivityLocalServiceUtil 053 * @see com.liferay.portlet.social.service.base.SocialActivityLocalServiceBaseImpl 054 * @see com.liferay.portlet.social.service.impl.SocialActivityLocalServiceImpl 055 * @generated 056 */ 057 @ProviderType 058 @Transactional(isolation = Isolation.PORTAL, rollbackFor = { 059 PortalException.class, SystemException.class}) 060 public interface SocialActivityLocalService extends BaseLocalService, 061 PersistedModelLocalService { 062 /* 063 * NOTE FOR DEVELOPERS: 064 * 065 * Never modify or reference this interface directly. Always use {@link SocialActivityLocalServiceUtil} to access the social activity local service. Add custom service methods to {@link com.liferay.portlet.social.service.impl.SocialActivityLocalServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface. 066 */ 067 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 068 public ActionableDynamicQuery getActionableDynamicQuery(); 069 070 public DynamicQuery dynamicQuery(); 071 072 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 073 public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery(); 074 075 /** 076 * @throws PortalException 077 */ 078 @Override 079 public PersistedModel deletePersistedModel(PersistedModel persistedModel) 080 throws PortalException; 081 082 @Override 083 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 084 public PersistedModel getPersistedModel(Serializable primaryKeyObj) 085 throws PortalException; 086 087 /** 088 * Adds the social activity to the database. Also notifies the appropriate model listeners. 089 * 090 * @param socialActivity the social activity 091 * @return the social activity that was added 092 */ 093 @Indexable(type = IndexableType.REINDEX) 094 public SocialActivity addSocialActivity(SocialActivity socialActivity); 095 096 /** 097 * Creates a new social activity with the primary key. Does not add the social activity to the database. 098 * 099 * @param activityId the primary key for the new social activity 100 * @return the new social activity 101 */ 102 public SocialActivity createSocialActivity(long activityId); 103 104 /** 105 * Deletes the social activity from the database. Also notifies the appropriate model listeners. 106 * 107 * @param socialActivity the social activity 108 * @return the social activity that was removed 109 */ 110 @Indexable(type = IndexableType.DELETE) 111 public SocialActivity deleteSocialActivity(SocialActivity socialActivity); 112 113 /** 114 * Deletes the social activity with the primary key from the database. Also notifies the appropriate model listeners. 115 * 116 * @param activityId the primary key of the social activity 117 * @return the social activity that was removed 118 * @throws PortalException if a social activity with the primary key could not be found 119 */ 120 @Indexable(type = IndexableType.DELETE) 121 public SocialActivity deleteSocialActivity(long activityId) 122 throws PortalException; 123 124 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 125 public SocialActivity fetchFirstActivity(java.lang.String className, 126 long classPK, int type); 127 128 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 129 public SocialActivity fetchSocialActivity(long activityId); 130 131 /** 132 * Returns the activity identified by its primary key. 133 * 134 * @param activityId the primary key of the activity 135 * @return Returns the activity 136 */ 137 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 138 public SocialActivity getActivity(long activityId) 139 throws PortalException; 140 141 /** 142 * Returns the activity that has the mirror activity. 143 * 144 * @param mirrorActivityId the primary key of the mirror activity 145 * @return Returns the mirror activity 146 */ 147 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 148 public SocialActivity getMirrorActivity(long mirrorActivityId) 149 throws PortalException; 150 151 /** 152 * Returns the social activity with the primary key. 153 * 154 * @param activityId the primary key of the social activity 155 * @return the social activity 156 * @throws PortalException if a social activity with the primary key could not be found 157 */ 158 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 159 public SocialActivity getSocialActivity(long activityId) 160 throws PortalException; 161 162 /** 163 * Updates the social activity in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners. 164 * 165 * @param socialActivity the social activity 166 * @return the social activity that was updated 167 */ 168 @Indexable(type = IndexableType.REINDEX) 169 public SocialActivity updateSocialActivity(SocialActivity socialActivity); 170 171 /** 172 * Returns the number of activities done on assets identified by class name. 173 * 174 * @param className the target asset's class name 175 * @return the number of matching activities 176 */ 177 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 178 public int getActivitiesCount(java.lang.String className); 179 180 /** 181 * Returns the number of activities done on assets identified by the class 182 * name ID. 183 * 184 * @param classNameId the target asset's class name ID 185 * @return the number of matching activities 186 */ 187 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 188 public int getActivitiesCount(long classNameId); 189 190 /** 191 * Returns the number of activities done on the asset identified by the 192 * class name and class primary key that are mirrors of the activity 193 * identified by the mirror activity ID. 194 * 195 * @param mirrorActivityId the primary key of the mirror activity 196 * @param className the target asset's class name 197 * @param classPK the primary key of the target asset 198 * @return the number of matching activities 199 */ 200 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 201 public int getActivitiesCount(long mirrorActivityId, 202 java.lang.String className, long classPK); 203 204 /** 205 * Returns the number of activities done on the asset identified by the 206 * class name ID and class primary key that are mirrors of the activity 207 * identified by the mirror activity ID. 208 * 209 * @param mirrorActivityId the primary key of the mirror activity 210 * @param classNameId the target asset's class name ID 211 * @param classPK the primary key of the target asset 212 * @return the number of matching activities 213 */ 214 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 215 public int getActivitiesCount(long mirrorActivityId, long classNameId, 216 long classPK); 217 218 /** 219 * Returns the number of activities done in the group. 220 * 221 * <p> 222 * This method only counts activities without mirrors. 223 * </p> 224 * 225 * @param groupId the primary key of the group 226 * @return the number of matching activities 227 */ 228 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 229 public int getGroupActivitiesCount(long groupId); 230 231 /** 232 * Returns the number of activities done by users that are members of the 233 * group. 234 * 235 * <p> 236 * This method only counts activities without mirrors. 237 * </p> 238 * 239 * @param groupId the primary key of the group 240 * @return the number of matching activities 241 */ 242 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 243 public int getGroupUsersActivitiesCount(long groupId); 244 245 /** 246 * Returns the number of activities done in the organization. This method 247 * only counts activities without mirrors. 248 * 249 * @param organizationId the primary key of the organization 250 * @return the number of matching activities 251 */ 252 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 253 public int getOrganizationActivitiesCount(long organizationId); 254 255 /** 256 * Returns the number of activities done by users of the organization. This 257 * method only counts activities without mirrors. 258 * 259 * @param organizationId the primary key of the organization 260 * @return the number of matching activities 261 */ 262 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 263 public int getOrganizationUsersActivitiesCount(long organizationId); 264 265 /** 266 * Returns the number of activities done by users in a relationship with the 267 * user identified by userId. 268 * 269 * @param userId the primary key of the user 270 * @return the number of matching activities 271 */ 272 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 273 public int getRelationActivitiesCount(long userId); 274 275 /** 276 * Returns the number of activities done by users in a relationship of type 277 * <code>type</code> with the user identified by <code>userId</code>. This 278 * method only counts activities without mirrors. 279 * 280 * @param userId the primary key of the user 281 * @param type the relationship type 282 * @return the number of matching activities 283 */ 284 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 285 public int getRelationActivitiesCount(long userId, int type); 286 287 /** 288 * Returns the number of social activities. 289 * 290 * @return the number of social activities 291 */ 292 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 293 public int getSocialActivitiesCount(); 294 295 /** 296 * Returns the number of activities done by the user. 297 * 298 * @param userId the primary key of the user 299 * @return the number of matching activities 300 */ 301 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 302 public int getUserActivitiesCount(long userId); 303 304 /** 305 * Returns the number of activities done in user's groups. This method only 306 * counts activities without mirrors. 307 * 308 * @param userId the primary key of the user 309 * @return the number of matching activities 310 */ 311 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 312 public int getUserGroupsActivitiesCount(long userId); 313 314 /** 315 * Returns the number of activities done in user's groups and organizations. 316 * This method only counts activities without mirrors. 317 * 318 * @param userId the primary key of the user 319 * @return the number of matching activities 320 */ 321 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 322 public int getUserGroupsAndOrganizationsActivitiesCount(long userId); 323 324 /** 325 * Returns the number of activities done in the user's organizations. This 326 * method only counts activities without mirrors. 327 * 328 * @param userId the primary key of the user 329 * @return the number of matching activities 330 */ 331 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 332 public int getUserOrganizationsActivitiesCount(long userId); 333 334 /** 335 * Returns the OSGi service identifier. 336 * 337 * @return the OSGi service identifier 338 */ 339 public java.lang.String getOSGiServiceIdentifier(); 340 341 /** 342 * Performs a dynamic query on the database and returns the matching rows. 343 * 344 * @param dynamicQuery the dynamic query 345 * @return the matching rows 346 */ 347 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery); 348 349 /** 350 * Performs a dynamic query on the database and returns a range of the matching rows. 351 * 352 * <p> 353 * 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.SocialActivityModelImpl}. 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. 354 * </p> 355 * 356 * @param dynamicQuery the dynamic query 357 * @param start the lower bound of the range of model instances 358 * @param end the upper bound of the range of model instances (not inclusive) 359 * @return the range of matching rows 360 */ 361 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start, 362 int end); 363 364 /** 365 * Performs a dynamic query on the database and returns an ordered range of the matching rows. 366 * 367 * <p> 368 * 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.SocialActivityModelImpl}. 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. 369 * </p> 370 * 371 * @param dynamicQuery the dynamic query 372 * @param start the lower bound of the range of model instances 373 * @param end the upper bound of the range of model instances (not inclusive) 374 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) 375 * @return the ordered range of matching rows 376 */ 377 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start, 378 int end, OrderByComparator<T> orderByComparator); 379 380 /** 381 * Returns a range of all the activities done on assets identified by the 382 * class name. 383 * 384 * <p> 385 * Useful when paginating results. Returns a maximum of <code>end - 386 * start</code> instances. <code>start</code> and <code>end</code> are not 387 * primary keys, they are indexes in the result set. Thus, <code>0</code> 388 * refers to the first result in the set. Setting both <code>start</code> 389 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 390 * result set. 391 * </p> 392 * 393 * @param className the target asset's class name 394 * @param start the lower bound of the range of results 395 * @param end the upper bound of the range of results (not inclusive) 396 * @return the range of matching activities 397 */ 398 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 399 public List<SocialActivity> getActivities(java.lang.String className, 400 int start, int end); 401 402 /** 403 * Returns a range of all the activities done on assets identified by the 404 * class name ID. 405 * 406 * <p> 407 * Useful when paginating results. Returns a maximum of <code>end - 408 * start</code> instances. <code>start</code> and <code>end</code> are not 409 * primary keys, they are indexes in the result set. Thus, <code>0</code> 410 * refers to the first result in the set. Setting both <code>start</code> 411 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 412 * result set. 413 * </p> 414 * 415 * @param classNameId the target asset's class name ID 416 * @param start the lower bound of the range of results 417 * @param end the upper bound of the range of results (not inclusive) 418 * @return the range of matching activities 419 */ 420 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 421 public List<SocialActivity> getActivities(long classNameId, int start, 422 int end); 423 424 /** 425 * Returns a range of all the activities done on the asset identified by the 426 * class name and the class primary key that are mirrors of the activity 427 * identified by the mirror activity ID. 428 * 429 * <p> 430 * Useful when paginating results. Returns a maximum of <code>end - 431 * start</code> instances. <code>start</code> and <code>end</code> are not 432 * primary keys, they are indexes in the result set. Thus, <code>0</code> 433 * refers to the first result in the set. Setting both <code>start</code> 434 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 435 * result set. 436 * </p> 437 * 438 * @param mirrorActivityId the primary key of the mirror activity 439 * @param className the target asset's class name 440 * @param classPK the primary key of the target asset 441 * @param start the lower bound of the range of results 442 * @param end the upper bound of the range of results (not inclusive) 443 * @return the range of matching activities 444 */ 445 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 446 public List<SocialActivity> getActivities(long mirrorActivityId, 447 java.lang.String className, long classPK, int start, int end); 448 449 /** 450 * Returns a range of all the activities done on the asset identified by the 451 * class name ID and class primary key that are mirrors of the activity 452 * identified by the mirror activity ID. 453 * 454 * <p> 455 * Useful when paginating results. Returns a maximum of <code>end - 456 * start</code> instances. <code>start</code> and <code>end</code> are not 457 * primary keys, they are indexes in the result set. Thus, <code>0</code> 458 * refers to the first result in the set. Setting both <code>start</code> 459 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 460 * result set. 461 * </p> 462 * 463 * @param mirrorActivityId the primary key of the mirror activity 464 * @param classNameId the target asset's class name ID 465 * @param classPK the primary key of the target asset 466 * @param start the lower bound of the range of results 467 * @param end the upper bound of the range of results (not inclusive) 468 * @return the range of matching activities 469 */ 470 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 471 public List<SocialActivity> getActivities(long mirrorActivityId, 472 long classNameId, long classPK, int start, int end); 473 474 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 475 public List<SocialActivity> getActivitySetActivities(long activitySetId, 476 int start, int end); 477 478 /** 479 * Returns a range of all the activities done in the group. 480 * 481 * <p> 482 * This method only finds activities without mirrors. 483 * </p> 484 * 485 * <p> 486 * Useful when paginating results. Returns a maximum of <code>end - 487 * start</code> instances. <code>start</code> and <code>end</code> are not 488 * primary keys, they are indexes in the result set. Thus, <code>0</code> 489 * refers to the first result in the set. Setting both <code>start</code> 490 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 491 * result set. 492 * </p> 493 * 494 * @param groupId the primary key of the group 495 * @param start the lower bound of the range of results 496 * @param end the upper bound of the range of results (not inclusive) 497 * @return the range of matching activities 498 */ 499 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 500 public List<SocialActivity> getGroupActivities(long groupId, int start, 501 int end); 502 503 /** 504 * Returns a range of activities done by users that are members of the 505 * group. 506 * 507 * <p> 508 * This method only finds activities without mirrors. 509 * </p> 510 * 511 * <p> 512 * Useful when paginating results. Returns a maximum of <code>end - 513 * start</code> instances. <code>start</code> and <code>end</code> are not 514 * primary keys, they are indexes in the result set. Thus, <code>0</code> 515 * refers to the first result in the set. Setting both <code>start</code> 516 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 517 * result set. 518 * </p> 519 * 520 * @param groupId the primary key of the group 521 * @param start the lower bound of the range of results 522 * @param end the upper bound of the range of results (not inclusive) 523 * @return the range of matching activities 524 */ 525 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 526 public List<SocialActivity> getGroupUsersActivities(long groupId, 527 int start, int end); 528 529 /** 530 * Returns a range of all the activities done in the organization. This 531 * method only finds activities without mirrors. 532 * 533 * <p> 534 * Useful when paginating results. Returns a maximum of <code>end - 535 * start</code> instances. <code>start</code> and <code>end</code> are not 536 * primary keys, they are indexes in the result set. Thus, <code>0</code> 537 * refers to the first result in the set. Setting both <code>start</code> 538 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 539 * result set. 540 * </p> 541 * 542 * @param organizationId the primary key of the organization 543 * @param start the lower bound of the range of results 544 * @param end the upper bound of the range of results (not inclusive) 545 * @return the range of matching activities 546 */ 547 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 548 public List<SocialActivity> getOrganizationActivities(long organizationId, 549 int start, int end); 550 551 /** 552 * Returns a range of all the activities done by users of the organization. 553 * This method only finds activities without mirrors. 554 * 555 * <p> 556 * Useful when paginating results. Returns a maximum of <code>end - 557 * start</code> instances. <code>start</code> and <code>end</code> are not 558 * primary keys, they are indexes in the result set. Thus, <code>0</code> 559 * refers to the first result in the set. Setting both <code>start</code> 560 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 561 * result set. 562 * </p> 563 * 564 * @param organizationId the primary key of the organization 565 * @param start the lower bound of the range of results 566 * @param end the upper bound of the range of results (not inclusive) 567 * @return the range of matching activities 568 */ 569 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 570 public List<SocialActivity> getOrganizationUsersActivities( 571 long organizationId, int start, int end); 572 573 /** 574 * Returns a range of all the activities done by users in a relationship 575 * with the user identified by the user ID. 576 * 577 * <p> 578 * Useful when paginating results. Returns a maximum of <code>end - 579 * start</code> instances. <code>start</code> and <code>end</code> are not 580 * primary keys, they are indexes in the result set. Thus, <>0</code> refers 581 * to the first result in the set. Setting both <code>start</code> and 582 * <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result 583 * set. 584 * </p> 585 * 586 * @param userId the primary key of the user 587 * @param start the lower bound of the range of results 588 * @param end the upper bound of the range of results (not inclusive) 589 * @return the range of matching activities 590 */ 591 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 592 public List<SocialActivity> getRelationActivities(long userId, int start, 593 int end); 594 595 /** 596 * Returns a range of all the activities done by users in a relationship of 597 * type <code>type</code> with the user identified by <code>userId</code>. 598 * This method only finds activities without mirrors. 599 * 600 * <p> 601 * Useful when paginating results. Returns a maximum of <code>end - 602 * start</code> instances. <code>start</code> and <code>end</code> are not 603 * primary keys, they are indexes in the result set. Thus, <code>0</code> 604 * refers to the first result in the set. Setting both <code>start</code> 605 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 606 * result set. 607 * </p> 608 * 609 * @param userId the primary key of the user 610 * @param type the relationship type 611 * @param start the lower bound of the range of results 612 * @param end the upper bound of the range of results (not inclusive) 613 * @return the range of matching activities 614 */ 615 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 616 public List<SocialActivity> getRelationActivities(long userId, int type, 617 int start, int end); 618 619 /** 620 * Returns a range of all the social activities. 621 * 622 * <p> 623 * 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.SocialActivityModelImpl}. 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. 624 * </p> 625 * 626 * @param start the lower bound of the range of social activities 627 * @param end the upper bound of the range of social activities (not inclusive) 628 * @return the range of social activities 629 */ 630 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 631 public List<SocialActivity> getSocialActivities(int start, int end); 632 633 /** 634 * Returns a range of all the activities done by the user. 635 * 636 * <p> 637 * Useful when paginating results. Returns a maximum of <code>end - 638 * start</code> instances. <code>start</code> and <code>end</code> are not 639 * primary keys, they are indexes in the result set. Thus, <code>0</code> 640 * refers to the first result in the set. Setting both <code>start</code> 641 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 642 * result set. 643 * </p> 644 * 645 * @param userId the primary key of the user 646 * @param start the lower bound of the range of results 647 * @param end the upper bound of the range of results (not inclusive) 648 * @return the range of matching activities 649 */ 650 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 651 public List<SocialActivity> getUserActivities(long userId, int start, 652 int end); 653 654 /** 655 * Returns a range of all the activities done in the user's groups. This 656 * method only finds activities without mirrors. 657 * 658 * <p> 659 * Useful when paginating results. Returns a maximum of <code>end - 660 * start</code> instances. <code>start</code> and <code>end</code> are not 661 * primary keys, they are indexes in the result set. Thus, <code>0</code> 662 * refers to the first result in the set. Setting both <code>start</code> 663 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 664 * result set. 665 * </p> 666 * 667 * @param userId the primary key of the user 668 * @param start the lower bound of the range of results 669 * @param end the upper bound of the range of results (not inclusive) 670 * @return the range of matching activities 671 */ 672 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 673 public List<SocialActivity> getUserGroupsActivities(long userId, int start, 674 int end); 675 676 /** 677 * Returns a range of all the activities done in the user's groups and 678 * organizations. This method only finds activities without mirrors. 679 * 680 * <p> 681 * Useful when paginating results. Returns a maximum of <code>end - 682 * start</code> instances. <code>start</code> and <code>end</code> are not 683 * primary keys, they are indexes in the result set. Thus, <code>0</code> 684 * refers to the first result in the set. Setting both <code>start</code> 685 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 686 * result set. 687 * </p> 688 * 689 * @param userId the primary key of the user 690 * @param start the lower bound of the range of results 691 * @param end the upper bound of the range of results (not inclusive) 692 * @return the range of matching activities 693 */ 694 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 695 public List<SocialActivity> getUserGroupsAndOrganizationsActivities( 696 long userId, int start, int end); 697 698 /** 699 * Returns a range of all activities done in the user's organizations. This 700 * method only finds activities without mirrors. 701 * 702 * <p> 703 * Useful when paginating results. Returns a maximum of <code>end - 704 * start</code> instances. <code>start</code> and <code>end</code> are not 705 * primary keys, they are indexes in the result set. Thus, <code>0</code> 706 * refers to the first result in the set. Setting both <code>start</code> 707 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full 708 * result set. 709 * </p> 710 * 711 * @param userId the primary key of the user 712 * @param start the lower bound of the range of results 713 * @param end the upper bound of the range of results (not inclusive) 714 * @return the range of matching activities 715 */ 716 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 717 public List<SocialActivity> getUserOrganizationsActivities(long userId, 718 int start, int end); 719 720 /** 721 * Returns the number of rows matching the dynamic query. 722 * 723 * @param dynamicQuery the dynamic query 724 * @return the number of rows matching the dynamic query 725 */ 726 public long dynamicQueryCount(DynamicQuery dynamicQuery); 727 728 /** 729 * Returns the number of rows matching the dynamic query. 730 * 731 * @param dynamicQuery the dynamic query 732 * @param projection the projection to apply to the query 733 * @return the number of rows matching the dynamic query 734 */ 735 public long dynamicQueryCount(DynamicQuery dynamicQuery, 736 Projection projection); 737 738 @Async 739 public void addActivity(SocialActivity activity, 740 SocialActivity mirrorActivity) throws PortalException; 741 742 /** 743 * Records an activity in the database, using a time based on the current 744 * time in an attempt to make the activity's time unique. 745 * 746 * @param userId the primary key of the acting user 747 * @param groupId the primary key of the group 748 * @param className the target asset's class name 749 * @param classPK the primary key of the target asset 750 * @param type the activity's type 751 * @param extraData any extra data regarding the activity 752 * @param receiverUserId the primary key of the receiving user 753 */ 754 public void addActivity(long userId, long groupId, 755 java.lang.String className, long classPK, int type, 756 java.lang.String extraData, long receiverUserId) 757 throws PortalException; 758 759 /** 760 * Records an activity with the given time in the database. 761 * 762 * <p> 763 * This method records a social activity done on an asset, identified by its 764 * class name and class primary key, in the database. Additional information 765 * (such as the original message ID for a reply to a forum post) is passed 766 * in via the <code>extraData</code> in JSON format. For activities 767 * affecting another user, a mirror activity is generated that describes the 768 * action from the user's point of view. The target user's ID is passed in 769 * via the <code>receiverUserId</code>. 770 * </p> 771 * 772 * <p> 773 * Example for a mirrored activity:<br> When a user replies to a message 774 * boards post, the reply action is stored in the database with the 775 * <code>receiverUserId</code> being the ID of the author of the original 776 * message. The <code>extraData</code> contains the ID of the original 777 * message in JSON format. A mirror activity is generated with the values of 778 * the <code>userId</code> and the <code>receiverUserId</code> swapped. This 779 * mirror activity basically describes a "replied to" event. 780 * </p> 781 * 782 * <p> 783 * Mirror activities are most often used in relation to friend requests and 784 * activities. 785 * </p> 786 * 787 * @param userId the primary key of the acting user 788 * @param groupId the primary key of the group 789 * @param createDate the activity's date 790 * @param className the target asset's class name 791 * @param classPK the primary key of the target asset 792 * @param type the activity's type 793 * @param extraData any extra data regarding the activity 794 * @param receiverUserId the primary key of the receiving user 795 */ 796 public void addActivity(long userId, long groupId, Date createDate, 797 java.lang.String className, long classPK, int type, 798 java.lang.String extraData, long receiverUserId) 799 throws PortalException; 800 801 /** 802 * Records an activity with the current time in the database, but only if 803 * there isn't one with the same parameters. 804 * 805 * <p> 806 * For the main functionality see {@link #addActivity(long, long, Date, 807 * String, long, int, String, long)} 808 * </p> 809 * 810 * @param userId the primary key of the acting user 811 * @param groupId the primary key of the group 812 * @param className the target asset's class name 813 * @param classPK the primary key of the target asset 814 * @param type the activity's type 815 * @param extraData any extra data regarding the activity 816 * @param receiverUserId the primary key of the receiving user 817 */ 818 public void addUniqueActivity(long userId, long groupId, 819 java.lang.String className, long classPK, int type, 820 java.lang.String extraData, long receiverUserId) 821 throws PortalException; 822 823 /** 824 * Records an activity in the database, but only if there isn't already an 825 * activity with the same parameters. 826 * 827 * <p> 828 * For the main functionality see {@link #addActivity(long, long, Date, 829 * String, long, int, String, long)} 830 * </p> 831 * 832 * @param userId the primary key of the acting user 833 * @param groupId the primary key of the group 834 * @param createDate the activity's date 835 * @param className the target asset's class name 836 * @param classPK the primary key of the target asset 837 * @param type the activity's type 838 * @param extraData any extra data regarding the activity 839 * @param receiverUserId the primary key of the receiving user 840 */ 841 public void addUniqueActivity(long userId, long groupId, Date createDate, 842 java.lang.String className, long classPK, int type, 843 java.lang.String extraData, long receiverUserId) 844 throws PortalException; 845 846 /** 847 * Removes stored activities for the asset. 848 * 849 * @param assetEntry the asset from which to remove stored activities 850 */ 851 public void deleteActivities(AssetEntry assetEntry) 852 throws PortalException; 853 854 /** 855 * Removes stored activities for the asset identified by the class name and 856 * class primary key. 857 * 858 * @param className the target asset's class name 859 * @param classPK the primary key of the target asset 860 */ 861 public void deleteActivities(java.lang.String className, long classPK) 862 throws PortalException; 863 864 public void deleteActivities(long groupId); 865 866 /** 867 * Removes the stored activity and its mirror activity from the database. 868 * 869 * @param activity the activity to be removed 870 */ 871 public void deleteActivity(SocialActivity activity) 872 throws PortalException; 873 874 /** 875 * Removes the stored activity from the database. 876 * 877 * @param activityId the primary key of the stored activity 878 */ 879 public void deleteActivity(long activityId) throws PortalException; 880 881 /** 882 * Removes the user's stored activities from the database. 883 * 884 * <p> 885 * This method removes all activities where the user is either the actor or 886 * the receiver. 887 * </p> 888 * 889 * @param userId the primary key of the user 890 */ 891 public void deleteUserActivities(long userId) throws PortalException; 892 }