Search in sources :

Example 6 with FeatureState

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState in project webanno by webanno.

the class AnnotationDetailEditorPanel method actionCreateForward.

private void actionCreateForward(AjaxRequestTarget aTarget, JCas aJCas, boolean aIsForwarded) throws IOException, AnnotationException {
    LOG.trace("actionForward(isForwarded: {})", aIsForwarded);
    if (isAnnotationFinished()) {
        throw new AnnotationException("This document is already closed. Please ask your " + "project manager to re-open it via the Monitoring page");
    }
    AnnotatorState state = getModelObject();
    // Re-set the selected layer from the drop-down since it might have changed if we
    // have previously created a relation annotation
    state.setSelectedAnnotationLayer(annotationFeatureForm.getLayerSelector().getModelObject());
    internalCommitAnnotation(aTarget, aJCas);
    if (!aIsForwarded) {
        if (state.getSelection().getEnd() >= state.getWindowEndOffset()) {
            autoScroll(aJCas, true);
        }
        List<FeatureState> featureStates = getModelObject().getFeatureStates();
        if (featureStates.get(0).value != null) {
            LOG.info("BEGIN auto-forward annotation for tagset-based annotation");
            AnnotationFS nextToken = WebAnnoCasUtil.getNextToken(aJCas, state.getSelection().getBegin(), state.getSelection().getEnd());
            if (nextToken != null) {
                if (getModelObject().getWindowEndOffset() > nextToken.getBegin()) {
                    state.getSelection().selectSpan(aJCas, nextToken.getBegin(), nextToken.getEnd());
                    actionCreateForward(aTarget, aJCas, true);
                }
            }
            LOG.info("END auto-forward annotation for tagset-based annotation");
        } else {
            LOG.info("BEGIN auto-forward annotation for free-text annotation");
            // remove the entire annotation.
            if (featureStates.get(0).value == null) {
                TypeAdapter adapter = annotationService.getAdapter(state.getSelectedAnnotationLayer());
                AnnotationFS fs = selectByAddr(aJCas, state.getSelection().getAnnotation().getId());
                deleteAnnotation(aJCas, state, fs, featureStates.get(0).feature.getLayer(), adapter);
            }
            AnnotationFS nextToken = WebAnnoCasUtil.getNextToken(aJCas, state.getSelection().getBegin(), state.getSelection().getEnd());
            if (nextToken != null) {
                if (getModelObject().getWindowEndOffset() > nextToken.getBegin()) {
                    state.getSelection().selectSpan(aJCas, nextToken.getBegin(), nextToken.getEnd());
                    actionCreateForward(aTarget, aJCas, true);
                }
            }
            LOG.info("END auto-forward annotation for free-text annotation");
        }
        LOG.trace("onAutoForward()");
        onAutoForward(aTarget);
    }
    aTarget.add(annotationFeatureForm);
    internalCompleteAnnotation(aTarget, aJCas);
}
Also used : AnnotationFS(org.apache.uima.cas.text.AnnotationFS) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) TypeAdapter(de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.TypeAdapter) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) FeatureState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState)

Example 7 with FeatureState

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState in project webanno by webanno.

the class FeatureStateModel method setObject.

@Override
public void setObject(FeatureState object) {
    FeatureState fm = state.getObject().getFeatureState(feature);
    fm.value = object.value;
// Probably don't need to copy the other fields
}
Also used : FeatureState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState)

Example 8 with FeatureState

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState in project webanno by webanno.

the class SlotFeatureSupport method createEditor.

@Override
public FeatureEditor createEditor(String aId, MarkupContainer aOwner, AnnotationActionHandler aHandler, final IModel<AnnotatorState> aStateModel, final IModel<FeatureState> aFeatureStateModel) {
    FeatureState featureState = aFeatureStateModel.getObject();
    final FeatureEditor editor;
    switch(featureState.feature.getMultiValueMode()) {
        case ARRAY:
            switch(featureState.feature.getLinkMode()) {
                case WITH_ROLE:
                    editor = new LinkFeatureEditor(aId, aOwner, aHandler, aStateModel, aFeatureStateModel);
                    break;
                default:
                    throw unsupportedFeatureTypeException(featureState);
            }
            break;
        case NONE:
            throw unsupportedLinkModeException(featureState);
        default:
            throw unsupportedMultiValueModeException(featureState);
    }
    return editor;
}
Also used : LinkFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.LinkFeatureEditor) FeatureState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState) LinkFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.LinkFeatureEditor) FeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.FeatureEditor)

Example 9 with FeatureState

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState in project webanno by webanno.

the class PrimitiveUimaFeatureSupport method createEditor.

@Override
public FeatureEditor createEditor(String aId, MarkupContainer aOwner, AnnotationActionHandler aHandler, final IModel<AnnotatorState> aStateModel, final IModel<FeatureState> aFeatureStateModel) {
    FeatureState featureState = aFeatureStateModel.getObject();
    final FeatureEditor editor;
    switch(featureState.feature.getMultiValueMode()) {
        case NONE:
            switch(featureState.feature.getType()) {
                case CAS.TYPE_NAME_INTEGER:
                    {
                        editor = new NumberFeatureEditor(aId, aOwner, aFeatureStateModel);
                        break;
                    }
                case CAS.TYPE_NAME_FLOAT:
                    {
                        editor = new NumberFeatureEditor(aId, aOwner, aFeatureStateModel);
                        break;
                    }
                case CAS.TYPE_NAME_BOOLEAN:
                    {
                        editor = new BooleanFeatureEditor(aId, aOwner, aFeatureStateModel);
                        break;
                    }
                case CAS.TYPE_NAME_STRING:
                    {
                        editor = new TextFeatureEditor(aId, aOwner, aFeatureStateModel);
                        break;
                    }
                default:
                    throw unsupportedFeatureTypeException(featureState);
            }
            break;
        case // fallthrough
        ARRAY:
            throw unsupportedLinkModeException(featureState);
        default:
            throw unsupportedMultiValueModeException(featureState);
    }
    return editor;
}
Also used : BooleanFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.BooleanFeatureEditor) TextFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.TextFeatureEditor) NumberFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.NumberFeatureEditor) FeatureState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState) BooleanFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.BooleanFeatureEditor) NumberFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.NumberFeatureEditor) TextFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.TextFeatureEditor) FeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.FeatureEditor)

Example 10 with FeatureState

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState in project webanno by webanno.

the class LinkFeatureEditor method onConfigure.

/**
 * Hides feature if "Hide un-constraint feature" is enabled and constraint rules are applied and
 * feature doesn't match any constraint rule
 */
@Override
public void onConfigure() {
    // Update entries for important tags.
    removeAutomaticallyAddedUnusedEntries();
    FeatureState featureState = getModelObject();
    autoAddImportantTags(featureState.tagset, featureState.possibleValues);
    // if enabled and constraints rule execution returns anything other than green
    setVisible(!hideUnconstraintFeature || (getModelObject().indicator.isAffected() && getModelObject().indicator.getStatusColor().equals("green")));
}
Also used : FeatureState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState)

Aggregations

FeatureState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.FeatureState)12 AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)8 TypeAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.TypeAdapter)5 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)5 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)5 AnnotationException (de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException)4 ArcAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.ArcAdapter)3 Selection (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.Selection)3 VID (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.VID)3 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)3 Tag (de.tudarmstadt.ukp.clarin.webanno.model.Tag)3 ArrayList (java.util.ArrayList)3 JCas (org.apache.uima.jcas.JCas)3 AnnotationSchemaService (de.tudarmstadt.ukp.clarin.webanno.api.AnnotationSchemaService)2 DocumentService (de.tudarmstadt.ukp.clarin.webanno.api.DocumentService)2 ProjectService (de.tudarmstadt.ukp.clarin.webanno.api.ProjectService)2 WebAnnoConst (de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst)2 AnnotationEditorExtensionRegistry (de.tudarmstadt.ukp.clarin.webanno.api.annotation.AnnotationEditorExtensionRegistry)2 AnnotationActionHandler (de.tudarmstadt.ukp.clarin.webanno.api.annotation.action.AnnotationActionHandler)2 ChainAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.ChainAdapter)2