UimaSupport { public Collection<Relation> getRelations(Entity e) { try { JCas jCas = e.getCAS().getJCas(); Collection<Relation> relations = JCasUtil.select(jCas, Relation.class); return relations.stream() .filter(r -> r.getSource() == e || r.getTarget() == e) .collect(Collectors.toList()); } catch (UIMAException ue) { monitor.warn("Unable to get relations from entity", ue); return Collections.emptyList(); } } UimaSupport(
      String pipelineName,
      Class<?> clazz,
      BaleenHistory history,
      UimaMonitor monitor,
      boolean mergeDistinctEntities); String getPipelineName(); void add(Annotation... annotations); void add(Collection<? extends Annotation> annotations); void remove(Collection<? extends Annotation> annotations); void remove(Annotation... annotations); void mergeWithNew(Annotation newAnnotation, Annotation... annotations); void mergeWithNew(Annotation newAnnotation, Collection<? extends Annotation> annotations); void mergeWithExisting(Annotation existingAnnotation, Annotation... annotations); void mergeWithExisting(
      Annotation existingAnnotation, Collection<? extends Annotation> annotations); void mergeWithExistingNoCoref(
      Annotation existingAnnotation, Collection<? extends Annotation> annotations); void addToHistory(CAS cas, HistoryEvent event); void addToHistory(JCas jCas, HistoryEvent event); DocumentHistory getDocumentHistory(JCas jCas); static DocumentAnnotation getDocumentAnnotation(JCas jCas); Collection<Relation> getRelations(Entity e);  }
@Test public void testGetRelations() { UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false); Person p1 = new Person(jCas); p1.setBegin(0); p1.setEnd(0); p1.addToIndexes(); Person p2 = new Person(jCas); p2.setBegin(0); p2.setEnd(0); p2.addToIndexes(); Person p3 = new Person(jCas); p3.setBegin(1); p3.setEnd(1); p3.addToIndexes(); Relation r1 = new Relation(jCas); r1.setBegin(0); r1.setEnd(1); r1.setSource(p2); r1.setTarget(p3); r1.addToIndexes(); Relation r2 = new Relation(jCas); r2.setBegin(0); r2.setEnd(0); r2.setSource(p1); r2.setTarget(p2); r2.addToIndexes(); List<Relation> relations = new ArrayList<>(support.getRelations(p1)); assertEquals(1, relations.size()); assertEquals(r2, relations.get(0)); relations = new ArrayList<>(support.getRelations(p2)); assertEquals(2, relations.size()); assertEquals(r1, relations.get(0)); assertEquals(r2, relations.get(1)); relations = new ArrayList<>(support.getRelations(p3)); assertEquals(1, relations.size()); assertEquals(r1, relations.get(0)); }