use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class SocialEventRepositoryConstraintTest method hasRestrictionsTest.
@Test
public void hasRestrictionsTest() throws Exception {
final SocialActivitiesEvent event = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("otherName", "otherName", SocialActivitiesEvent.LINK_TYPE.VFS);
socialEventRepositoryConstraint.init();
assertTrue(socialEventRepositoryConstraint.hasRestrictions(event));
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class SocialEventRepositoryConstraintTest method hasRestrictionsBecauseThrowsAnExceptionTest.
@Test
public void hasRestrictionsBecauseThrowsAnExceptionTest() throws Exception {
returnRepo = repository;
SocialEventRepositoryConstraint socialEventRepositoryConstraintSpy = spy(this.socialEventRepositoryConstraint);
final SocialActivitiesEvent vfsEvent = new SocialActivitiesEvent(socialUser, "type", new Date());
socialEventRepositoryConstraintSpy.init();
assertFalse(socialEventRepositoryConstraintSpy.hasRestrictions(vfsEvent));
when(socialEventRepositoryConstraintSpy.getEventRepository(vfsEvent)).thenThrow(RuntimeException.class);
assertTrue(socialEventRepositoryConstraintSpy.hasRestrictions(vfsEvent));
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class SocialTimelineRulesQuery method getNEventsFromEachType.
@Override
public List<SocialActivitiesEvent> getNEventsFromEachType(int numberOfEvents, String... typeNames) {
List<SocialActivitiesEvent> events = new ArrayList<>();
for (String type : typeNames) {
PagedSocialQuery query = socialTypeTimelinePagedRepositoryAPI.getEventTimeline(type, new SocialPaged(numberOfEvents), new HashMap());
events.addAll(query.socialEvents());
}
return events;
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class SocialTimelineRulesQuery method executeSpecificRule.
@Override
@SuppressWarnings("unchecked")
public List<SocialActivitiesEvent> executeSpecificRule(Map<String, String> globals, final String drlName, String maxResults) {
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("queryAPI", this);
kSession.setGlobal("maxResults", new Integer(maxResults));
for (String key : globals.keySet()) {
kSession.setGlobal(key, globals.get(key));
}
kSession.fireAllRules(new AgendaFilter() {
@Override
public boolean accept(Match match) {
String rulename = match.getRule().getName();
if (rulename.equals(drlName)) {
return true;
}
return false;
}
});
events = (List<SocialActivitiesEvent>) kSession.getGlobal("socialEvents");
} catch (Exception e) {
throw new RulesExecutionQueryException(e);
}
return events;
}
Aggregations