Search in sources :

Example 56 with StringValue

use of org.apache.wicket.util.string.StringValue in project webanno by webanno.

the class BratAnnotationEditor method actionLookupNormData.

private Object actionLookupNormData(AjaxRequestTarget aTarget, IRequestParameters request, VID paramId) throws AnnotationException, IOException {
    NormDataResponse response = new NormDataResponse();
    // We interpret the databaseParam as the feature which we need to look up the feature
    // support
    StringValue databaseParam = request.getParameterValue("database");
    // We interpret the key as the feature value or as a kind of query to be handled by the
    // feature support
    StringValue keyParam = request.getParameterValue("key");
    StringValue layerParam = request.getParameterValue(PARAM_SPAN_TYPE);
    if (layerParam.isEmpty() || keyParam.isEmpty() || databaseParam.isEmpty()) {
        return response;
    }
    String database = databaseParam.toString();
    long layerId = decodeTypeName(layerParam.toString());
    AnnotatorState state = getModelObject();
    AnnotationLayer layer = annotationService.getLayer(state.getProject(), layerId).orElseThrow(() -> new AnnotationException("Layer with ID [" + layerId + "] does not exist in project [" + state.getProject().getName() + "](" + state.getProject().getId() + ")"));
    AnnotationFeature feature = annotationService.getFeature(database, layer);
    // Check where the query needs to be routed: to an editor extension or to a feature support
    if (paramId.isSynthetic()) {
        String extensionId = paramId.getExtensionId();
        response.setResults(extensionRegistry.getExtension(extensionId).renderLazyDetails(state.getDocument(), state.getUser(), paramId, feature, keyParam.toString()).stream().map(d -> new NormalizationQueryResult(d.getLabel(), d.getValue())).collect(Collectors.toList()));
        return response;
    }
    try {
        response.setResults(featureSupportRegistry.findExtension(feature).renderLazyDetails(feature, keyParam.toString()).stream().map(d -> new NormalizationQueryResult(d.getLabel(), d.getValue())).collect(Collectors.toList()));
    } catch (Exception e) {
        LOG.error("Unable to load data", e);
        error("Unable to load data: " + ExceptionUtils.getRootCauseMessage(e));
    }
    return response;
}
Also used : NormalizationQueryResult(de.tudarmstadt.ukp.clarin.webanno.brat.render.model.NormalizationQueryResult) NormDataResponse(de.tudarmstadt.ukp.clarin.webanno.brat.message.NormDataResponse) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) StringValue(org.apache.wicket.util.string.StringValue) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) IOException(java.io.IOException) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 57 with StringValue

use of org.apache.wicket.util.string.StringValue in project webanno by webanno.

the class AnnotationPage method createUrlFragmentBehavior.

private UrlParametersReceivingBehavior createUrlFragmentBehavior() {
    return new UrlParametersReceivingBehavior() {

        private static final long serialVersionUID = -3860933016636718816L;

        @Override
        protected void onParameterArrival(IRequestParameters aRequestParameters, AjaxRequestTarget aTarget) {
            StringValue project = aRequestParameters.getParameterValue(PAGE_PARAM_PROJECT_ID);
            StringValue projectName = aRequestParameters.getParameterValue(PAGE_PARAM_PROJECT_NAME);
            StringValue document = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT_ID);
            StringValue name = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT_NAME);
            StringValue focus = aRequestParameters.getParameterValue(PAGE_PARAM_FOCUS);
            // on a project
            if (document.isEmpty() && name.isEmpty() && focus.isEmpty()) {
                return;
            }
            SourceDocument previousDoc = getModelObject().getDocument();
            handleParameters(project, projectName, document, name, focus, false);
            // tabs may have changed depending on user rights
            if (previousDoc == null) {
                leftSidebar.refreshTabs(aTarget);
            }
            updateDocumentView(aTarget, previousDoc, focus);
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UrlParametersReceivingBehavior(de.tudarmstadt.ukp.clarin.webanno.support.wicketstuff.UrlParametersReceivingBehavior) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) StringValue(org.apache.wicket.util.string.StringValue) IRequestParameters(org.apache.wicket.request.IRequestParameters)

Aggregations

StringValue (org.apache.wicket.util.string.StringValue)57 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)22 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 IOException (java.io.IOException)7 Test (org.junit.Test)7 Task (com.evolveum.midpoint.task.api.Task)6 Url (org.apache.wicket.request.Url)5 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)4 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)4 WebSession (org.apache.openmeetings.web.app.WebSession)4 RestartResponseException (org.apache.wicket.RestartResponseException)4 IRequestParameters (org.apache.wicket.request.IRequestParameters)4 AnnotationException (de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException)3 AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3