@Test public void testEntityAdded() { UimaMonitor monitor = new UimaMonitor(PIPELINE, this.getClass()); monitor.entityAdded(ENTITY_TYPE_1); monitor.entityAdded(ENTITY_TYPE_1); monitor.entityAdded(ENTITY_TYPE_2); monitor.entityAdded(ENTITY_TYPE_2); monitor.entityAdded(ENTITY_TYPE_1); monitor.persistCounts(); Metrics m = MetricsFactory.getMetrics(PIPELINE, this.getClass()); assertEquals(3, m.getCounter(ENTITY_TYPE_1 + "-added").getCount()); assertEquals(2, m.getCounter(ENTITY_TYPE_2 + "-added").getCount()); }
/** * Add an annotation to the JCas index, notifying UimaMonitor of the fact we have done so * * @param annot Annotation(s) to add */ public void add(Collection<? extends Annotation> annotations) { for (Annotation annot : annotations) { annot.addToIndexes(); monitor.entityAdded(annot.getType().getName()); if (annot instanceof Entity) { Entity entity = (Entity) annot; // Add in a value if it doesn't have one if (Strings.isNullOrEmpty(entity.getValue())) { entity.setValue(annot.getCoveredText()); } addToHistory(annot.getCAS(), HistoryEvents.createAdded((Recordable) annot, referrer)); } } }
/** * Add an annotation to the JCas index, notifying UimaMonitor of the fact we have done so * * @param annot Annotation(s) to add */ public void add(Collection<? extends Annotation> annotations) { for (Annotation annot : annotations) { annot.addToIndexes(); monitor.entityAdded(annot.getType().getName()); if (annot instanceof Entity) { Entity entity = (Entity) annot; // Add in a value if it doesn't have one if (Strings.isNullOrEmpty(entity.getValue())) { entity.setValue(annot.getCoveredText()); } addToHistory(annot.getCAS(), HistoryEvents.createAdded((Recordable) annot, referrer)); } } }