@Override public long getDocument(FeatureValueUpdatedEvent aEvent) { return aEvent.getDocument().getId(); }
@Override public String getAnnotator(FeatureValueUpdatedEvent aEvent) { return aEvent.getUser(); }
@Override public String getDetails(FeatureValueUpdatedEvent aEvent) { try { // FIXME This may fail for slot features... let's see. FeatureChangeDetails details = new FeatureChangeDetails(aEvent.getFS(), aEvent.getNewValue(), aEvent.getOldValue()); return JSONUtil.toJsonString(details); } catch (IOException e) { log.error("Unable to log event [{}]", aEvent, e); return "<ERROR>"; } } }
/** * Listens to the user setting a feature on an annotation in the main annotation editor. Mind * that we do not need to listen to the creation of annotations since they have no effect on * the active learning sidebar as long as they have no features set. */ @OnEvent public void onFeatureValueUpdated(FeatureValueUpdatedEvent aEvent) { AnnotatorState state = getModelObject(); ActiveLearningUserState alState = alStateModel.getObject(); // If the user creates a new annotation at the site of the suggestion that is currently // offered to the user, then the AL should move on to the next available suggestion if ( alState.isSessionActive() && (!alState.getSuggestion().isPresent() || ( aEvent.getUser().equals(state.getUser().getUsername()) && aEvent.getDocument().equals(state.getDocument()) && aEvent.getFeature().getLayer().equals(alState.getLayer()) && aEvent.getFeature().getName().equals(alState.getSuggestion().get().getFeature()))) ) { reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget(), aEvent.getFeature().getLayer()); } }
@Override public void setFeatureValue(SourceDocument aDocument, String aUsername, JCas aJcas, int aAddress, AnnotationFeature aFeature, Object aValue) { FeatureStructure fs = selectByAddr(aJcas, FeatureStructure.class, aAddress); Object oldValue = getValue(fs, aFeature); featureSupportRegistry.getFeatureSupport(aFeature).setFeatureValue(aJcas, aFeature, aAddress, aValue); Object newValue = getValue(fs, aFeature); if (!Objects.equals(oldValue, newValue)) { publishEvent(new FeatureValueUpdatedEvent(this, aDocument, aUsername, fs, aFeature, newValue, oldValue)); } }
/** * Listens to the user setting a feature on an annotation in the main annotation editor. Mind * that we do not need to listen to the creation of annotations since they have no effect on * the active learning sidebar as long as they have no features set. */ @OnEvent public void onFeatureValueUpdated(FeatureValueUpdatedEvent aEvent) { AnnotatorState state = getModelObject(); ActiveLearningUserState alState = alStateModel.getObject(); // If the user creates a new annotation at the site of the suggestion that is currently // offered to the user, then the AL should move on to the next available suggestion if ( alState.isSessionActive() && (!alState.getSuggestion().isPresent() || ( aEvent.getUser().equals(state.getUser().getUsername()) && aEvent.getDocument().equals(state.getDocument()) && aEvent.getFeature().getLayer().equals(alState.getLayer()) && aEvent.getFeature().getName().equals(alState.getSuggestion().get().getFeature()))) ) { reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget(), aEvent.getFeature().getLayer()); } }
@Override public void setFeatureValue(SourceDocument aDocument, String aUsername, JCas aJcas, int aAddress, AnnotationFeature aFeature, Object aValue) { FeatureStructure fs = selectByAddr(aJcas, FeatureStructure.class, aAddress); Object oldValue = getValue(fs, aFeature); featureSupportRegistry.getFeatureSupport(aFeature).setFeatureValue(aJcas, aFeature, aAddress, aValue); Object newValue = getValue(fs, aFeature); if (!Objects.equals(oldValue, newValue)) { publishEvent(new FeatureValueUpdatedEvent(this, aDocument, aUsername, fs, aFeature, newValue, oldValue)); } }
@Override public String getDetails(FeatureValueUpdatedEvent aEvent) { try { // FIXME This may fail for slot features... let's see. FeatureChangeDetails details = new FeatureChangeDetails(aEvent.getFS(), aEvent.getNewValue(), aEvent.getOldValue()); return JSONUtil.toJsonString(details); } catch (IOException e) { log.error("Unable to log event [{}]", aEvent, e); return "<ERROR>"; } } }
@Override public long getDocument(FeatureValueUpdatedEvent aEvent) { return aEvent.getDocument().getId(); }
@Override public String getAnnotator(FeatureValueUpdatedEvent aEvent) { return aEvent.getUser(); }
@Override public long getProject(FeatureValueUpdatedEvent aEvent) { return aEvent.getDocument().getProject().getId(); }
@Override public long getProject(FeatureValueUpdatedEvent aEvent) { return aEvent.getDocument().getProject().getId(); }