use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class DiscussionAddedEventAdapter method toSocial.
@Override
public SocialActivitiesEvent toSocial(Object object) {
CommentAddedEvent event = (CommentAddedEvent) object;
SocialUser socialUser = socialUserRepositoryAPI.findSocialUser(event.getUserName());
String additionalInfo = "commented";
return new SocialActivitiesEvent(socialUser, DiscussionEventTypes.COMMENT_ADDED.name(), new Date(event.getTimestamp())).withLink(event.getPath().getFileName(), event.getPath().toURI()).withAdicionalInfo(additionalInfo);
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class SocialTimelineRulesQuery method getAllCached.
@Override
public List<SocialActivitiesEvent> getAllCached() {
List<SocialActivitiesEvent> events = new ArrayList<>();
Map<Class, SocialAdapter> socialAdapters = socialAdapterRepositoryAPI.getSocialAdapters();
for (SocialAdapter adapter : socialAdapters.values()) {
events.addAll(socialTimeLineRepositoryAPI.getLastEventTimeline(adapter, new HashMap()));
}
return events;
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class SocialTimelineRulesQuery method executeAllRules.
@Override
@SuppressWarnings("unchecked")
public List<SocialActivitiesEvent> executeAllRules() {
List<SocialActivitiesEvent> events = new ArrayList<>();
try {
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession("social-session");
List<SocialActivitiesEvent> socialEvents = new ArrayList<>();
kSession.setGlobal("socialEvents", socialEvents);
kSession.setGlobal("maxResults", Integer.MAX_VALUE);
kSession.setGlobal("queryAPI", this);
kSession.fireAllRules();
events = (List<SocialActivitiesEvent>) kSession.getGlobal("socialEvents");
} catch (Exception e) {
throw new RulesExecutionQueryException(e);
}
return events;
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class ResourceAddedEventAdapter method toSocial.
@Override
public SocialActivitiesEvent toSocial(Object object) {
ResourceAddedEvent event = (ResourceAddedEvent) object;
SocialUser socialUser = socialUserRepositoryAPI.findSocialUser(event.getSessionInfo().getIdentity().getIdentifier());
String additionalInfo = "Added";
String description = getCommitDescription(event);
return new SocialActivitiesEvent(socialUser, HomePageTypes.RESOURCE_ADDED_EVENT.name(), new Date()).withLink(event.getPath().getFileName(), event.getPath().toURI()).withAdicionalInfo(additionalInfo).withDescription(description);
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class SocialEventModuleConstraintTest method hasRestrictionsTest.
@Test
public void hasRestrictionsTest() throws Exception {
final WorkspaceProject project = mock(WorkspaceProject.class);
Repository repository = mock(Repository.class);
doReturn(repository).when(project).getRepository();
when(authorizationManager.authorize(repository, user)).thenReturn(false);
eventProject = project;
final SocialActivitiesEvent event = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("otherName", "otherName", SocialActivitiesEvent.LINK_TYPE.VFS);
socialEventModuleConstraint.init();
assertTrue(socialEventModuleConstraint.hasRestrictions(event));
}
Aggregations