Search in sources :

Example 1 with SocialActivitiesEvent

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);
}
Also used : CommentAddedEvent(org.kie.workbench.common.services.shared.discussion.CommentAddedEvent) SocialUser(org.ext.uberfire.social.activities.model.SocialUser) SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) Date(java.util.Date)

Example 2 with SocialActivitiesEvent

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;
}
Also used : HashMap(java.util.HashMap) SocialAdapter(org.ext.uberfire.social.activities.service.SocialAdapter) SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) ArrayList(java.util.ArrayList)

Example 3 with SocialActivitiesEvent

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;
}
Also used : SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) ArrayList(java.util.ArrayList) KieServices(org.kie.api.KieServices) KieSession(org.kie.api.runtime.KieSession) KieContainer(org.kie.api.runtime.KieContainer)

Example 4 with SocialActivitiesEvent

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);
}
Also used : SocialUser(org.ext.uberfire.social.activities.model.SocialUser) ResourceAddedEvent(org.uberfire.workbench.events.ResourceAddedEvent) SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) Date(java.util.Date)

Example 5 with SocialActivitiesEvent

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));
}
Also used : Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) Date(java.util.Date) Test(org.junit.Test)

Aggregations

SocialActivitiesEvent (org.ext.uberfire.social.activities.model.SocialActivitiesEvent)24 Date (java.util.Date)20 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)4 SocialUser (org.ext.uberfire.social.activities.model.SocialUser)4 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)3 HashMap (java.util.HashMap)2 Repository (org.guvnor.structure.repositories.Repository)2 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)2 KieServices (org.kie.api.KieServices)2 KieContainer (org.kie.api.runtime.KieContainer)2 KieSession (org.kie.api.runtime.KieSession)2 ContextNotActiveException (javax.enterprise.context.ContextNotActiveException)1 PagedSocialQuery (org.ext.uberfire.social.activities.model.PagedSocialQuery)1 SocialPaged (org.ext.uberfire.social.activities.model.SocialPaged)1 SocialAdapter (org.ext.uberfire.social.activities.service.SocialAdapter)1 NewRepositoryEvent (org.guvnor.structure.repositories.NewRepositoryEvent)1 AgendaFilter (org.kie.api.runtime.rule.AgendaFilter)1 Match (org.kie.api.runtime.rule.Match)1 CommentAddedEvent (org.kie.workbench.common.services.shared.discussion.CommentAddedEvent)1