@Test public void testEntityRemoved() { UimaMonitor monitor = new UimaMonitor(PIPELINE, this.getClass()); monitor.entityRemoved(ENTITY_TYPE_1); monitor.entityRemoved(ENTITY_TYPE_1); monitor.entityRemoved(ENTITY_TYPE_2); monitor.entityRemoved(ENTITY_TYPE_2); monitor.entityRemoved(ENTITY_TYPE_1); monitor.persistCounts(); Metrics m = MetricsFactory.getMetrics(PIPELINE, this.getClass()); assertEquals(3, m.getCounter(ENTITY_TYPE_1 + "-removed").getCount()); assertEquals(2, m.getCounter(ENTITY_TYPE_2 + "-removed").getCount()); }
/** * Remove an annotation to the JCas index, notifying UimaMonitor of the fact we have done so. * * <p>Relations that refer to the given annotation will also be removed. * * @param annot Annotation(s) to remove */ public void remove(Collection<? extends Annotation> annotations) { for (Annotation annot : annotations) { if (annot instanceof Recordable) { try { addToHistory( annot.getCAS().getJCas(), HistoryEvents.createAdded((Recordable) annot, referrer)); } catch (CASException e) { monitor.error("Unable to add to history on remove", e); } } if (annot instanceof Entity) { for (Relation r : getRelations((Entity) annot)) { monitor.entityRemoved(r.getType().getName()); r.removeFromIndexes(); } } monitor.entityRemoved(annot.getType().getName()); annot.removeFromIndexes(); } }
/** * Remove an annotation to the JCas index, notifying UimaMonitor of the fact we have done so. * * <p>Relations that refer to the given annotation will also be removed. * * @param annot Annotation(s) to remove */ public void remove(Collection<? extends Annotation> annotations) { for (Annotation annot : annotations) { if (annot instanceof Recordable) { try { addToHistory( annot.getCAS().getJCas(), HistoryEvents.createAdded((Recordable) annot, referrer)); } catch (CASException e) { monitor.error("Unable to add to history on remove", e); } } if (annot instanceof Entity) { for (Relation r : getRelations((Entity) annot)) { monitor.entityRemoved(r.getType().getName()); r.removeFromIndexes(); } } monitor.entityRemoved(annot.getType().getName()); annot.removeFromIndexes(); } }