@Test public void testNoEvents() throws UIMAException { EntityGraphOptions options = EntityGraphOptions.builder().withEvents(false).build(); EntityGraphFactory factory = createfactory(options); JCas jCas = JCasFactory.createJCas(); JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas); final GraphTraversalSource traversal = graph.traversal(); assertEquals(3, traversal.V().hasLabel(ENTITY).count().next().intValue()); assertEquals(0, traversal.V().hasLabel(EVENT).count().next().intValue()); assertEquals(0, traversal.E().hasLabel(PARTICIPANT_IN).count().next().intValue()); assertEquals(2, traversal.E().hasLabel(RELATION).count().next().intValue()); assertEquals(3, IteratorUtils.count(graph.vertices())); assertEquals(2, IteratorUtils.count(graph.edges())); }
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); try { Set<Class<? extends Entity>> typeClasses = TypeUtils.getTypeClasses(Entity.class, typeNames); EntityGraphOptions.Builder builder = EntityGraphOptions.builder() .withContentHashAsId(contentHashAsId) .withEvents(outputEvents) .withStopFeatures(filterFeatures) .withAggregateProperties(aggregate) .withTypeClasses(typeClasses) .withMultiValueProperties(multiValueProperties) .withDefaultValueStrategy(createValueStrategy(defaultValueStrategyType)) .withValueCoercer(valueCoercer); if (valueStrategyTypes != null) { for (int i = 0; i < valueStrategyTypes.length; i += 2) { builder.withValueStrategy( valueStrategyTypes[i], createValueStrategy(valueStrategyTypes[i + 1])); } } addOptions(builder); factory = new EntityGraphFactory(getMonitor(), builder.build()); } catch (Exception e) { throw new ResourceInitializationException(e); } }
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); try { Set<Class<? extends Entity>> typeClasses = TypeUtils.getTypeClasses(Entity.class, typeNames); EntityGraphOptions.Builder builder = EntityGraphOptions.builder() .withContentHashAsId(contentHashAsId) .withEvents(outputEvents) .withStopFeatures(filterFeatures) .withAggregateProperties(aggregate) .withTypeClasses(typeClasses) .withMultiValueProperties(multiValueProperties) .withDefaultValueStrategy(createValueStrategy(defaultValueStrategyType)) .withValueCoercer(valueCoercer); if (valueStrategyTypes != null) { for (int i = 0; i < valueStrategyTypes.length; i += 2) { builder.withValueStrategy( valueStrategyTypes[i], createValueStrategy(valueStrategyTypes[i + 1])); } } addOptions(builder); factory = new EntityGraphFactory(getMonitor(), builder.build()); } catch (Exception e) { throw new ResourceInitializationException(e); } }