@Test public void testActivityHierarchy() throws Exception { AssetEntry parentAssetEntry = SocialActivityTestUtil.addAssetEntry(creatorUser, group); SocialActivityHierarchyEntryThreadLocal.push( parentAssetEntry.getClassNameId(), parentAssetEntry.getClassPK()); SocialActivityTestUtil.addActivity(creatorUser, group, assetEntry, 1); List<SocialActivity> activities = SocialActivityLocalServiceUtil.getGroupActivities( group.getGroupId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); Assert.assertEquals(1, activities.size()); SocialActivity activity = activities.get(0); Assert.assertEquals(parentAssetEntry.getClassNameId(), activity.getParentClassNameId()); Assert.assertEquals(parentAssetEntry.getClassPK(), activity.getParentClassPK()); SocialActivityTestUtil.addActivity( creatorUser, group, assetEntry, SocialActivityConstants.TYPE_DELETE); Assert.assertEquals( 1, SocialActivityLocalServiceUtil.getGroupActivitiesCount(group.getGroupId())); }
protected boolean isLogActivity(SocialActivity activity) { if (activity.getType() == SocialActivityConstants.TYPE_DELETE) { if (activity.getParentClassPK() == 0) { return true; } return false; } SocialActivityDefinition activityDefinition = socialActivitySettingLocalService.getActivityDefinition( activity.getGroupId(), activity.getClassName(), activity.getType()); if (activityDefinition != null) { return activityDefinition.isLogActivity(); } if (activity.getType() < SocialActivityConstants.TYPE_VIEW) { return true; } return false; }