Search in sources :

Example 11 with SocialActivitiesEvent

use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.

the class NewRepositoryEventAdapter method toSocial.

@Override
public SocialActivitiesEvent toSocial(Object object) {
    NewRepositoryEvent event = (NewRepositoryEvent) object;
    SocialUser socialUser = null;
    try {
        socialUser = socialUserRepositoryAPI.findSocialUser(loggedUser.getIdentifier());
    } catch (ContextNotActiveException e) {
        // clean repository
        socialUser = new SocialUser("system");
    }
    String additionalInfo = "Created";
    return new SocialActivitiesEvent(socialUser, ExtendedTypes.NEW_REPOSITORY_EVENT, new Date()).withAdicionalInfo(additionalInfo).withLink(event.getNewRepository().getAlias(), event.getNewRepository().getUri()).withDescription("");
}
Also used : SocialUser(org.ext.uberfire.social.activities.model.SocialUser) ContextNotActiveException(javax.enterprise.context.ContextNotActiveException) SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) NewRepositoryEvent(org.guvnor.structure.repositories.NewRepositoryEvent) Date(java.util.Date)

Example 12 with SocialActivitiesEvent

use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.

the class ResourceUpdatedEventAdapter method toSocial.

@Override
public SocialActivitiesEvent toSocial(Object object) {
    ResourceUpdatedEvent event = (ResourceUpdatedEvent) object;
    SocialUser socialUser = socialUserRepositoryAPI.findSocialUser(event.getSessionInfo().getIdentity().getIdentifier());
    String additionalInfo = "Edited";
    String description = getCommitDescription(event);
    return new SocialActivitiesEvent(socialUser, HomePageTypes.RESOURCE_UPDATE_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) SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) ResourceUpdatedEvent(org.uberfire.workbench.events.ResourceUpdatedEvent) Date(java.util.Date)

Example 13 with SocialActivitiesEvent

use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.

the class SocialEventModuleConstraintTest method hasNoRestrictionsTest.

@Test
public void hasNoRestrictionsTest() throws Exception {
    final WorkspaceProject project = mock(WorkspaceProject.class);
    Repository repository = mock(Repository.class);
    doReturn(repository).when(project).getRepository();
    when(authorizationManager.authorize(repository, user)).thenReturn(true);
    eventProject = project;
    final SocialActivitiesEvent vfsEvent = new SocialActivitiesEvent(socialUser, "type", new Date());
    final SocialActivitiesEvent moduleEvent = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("otherName", "otherName", SocialActivitiesEvent.LINK_TYPE.CUSTOM);
    socialEventModuleConstraint.init();
    assertFalse(socialEventModuleConstraint.hasRestrictions(vfsEvent));
    assertFalse(socialEventModuleConstraint.hasRestrictions(moduleEvent));
}
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)

Example 14 with SocialActivitiesEvent

use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.

the class SocialEventModuleConstraintTest method ifThereIsNoLoggedUserInScopeShouldNotHaveRestrictions.

@Test
public void ifThereIsNoLoggedUserInScopeShouldNotHaveRestrictions() throws Exception {
    when(userCDIContextHelper.thereIsALoggedUserInScope()).thenReturn(false);
    final SocialActivitiesEvent restrictedEvent = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("otherName", "otherName");
    socialEventModuleConstraint.init();
    assertFalse(socialEventModuleConstraint.hasRestrictions(restrictedEvent));
}
Also used : SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) Date(java.util.Date) Test(org.junit.Test)

Example 15 with SocialActivitiesEvent

use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.

the class SocialEventModuleConstraintTest method hasNoRestrictionsForOtherSocialEventsTest.

@Test
public void hasNoRestrictionsForOtherSocialEventsTest() throws Exception {
    final WorkspaceProject project = mock(WorkspaceProject.class);
    eventProject = project;
    final SocialActivitiesEvent customEventOtherType = new SocialActivitiesEvent(socialUser, "type", new Date()).withLink("link", "link", SocialActivitiesEvent.LINK_TYPE.CUSTOM);
    assertFalse(socialEventModuleConstraint.hasRestrictions(customEventOtherType));
}
Also used : 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