@Deprecated public int getId() { return vid.getId(); }
@Deprecated public int getId() { return vid.getId(); }
@Deprecated public int getId() { return vid.getId(); }
@Deprecated public int getId() { return vid.getId(); }
/** * Returns the first prediction that matches recommendationId and recommenderId * in the given document. */ public Optional<AnnotationSuggestion> getPredictionByVID(SourceDocument aDocument, VID aVID) { return predictions.values().stream() .filter(f -> f.getDocumentName().equals(aDocument.getName())) .filter(f -> f.getId() == aVID.getSubId()) .filter(f -> f.getRecommenderId() == aVID.getId()) .findFirst(); }
@Override public void delete(SourceDocument aDocument, String aUsername, JCas aJCas, VID aVid) { FeatureStructure fs = selectByAddr(aJCas, FeatureStructure.class, aVid.getId()); aJCas.removeFsFromIndexes(fs); }
@Override public void delete(SourceDocument aDocument, String aUsername, JCas aJCas, VID aVid) { FeatureStructure fs = selectByAddr(aJCas, FeatureStructure.class, aVid.getId()); aJCas.removeFsFromIndexes(fs); }
@Override public void delete(SourceDocument aDocument, String aUsername, JCas aJCas, VID aVid) { AnnotationBase fs = selectByAddr(aJCas, AnnotationBase.class, aVid.getId()); aJCas.removeFsFromIndexes(fs); publishEvent(new DocumentMetadataDeletedEvent(this, aDocument, aUsername, fs)); }
@Override public void delete(SourceDocument aDocument, String aUsername, JCas aJCas, VID aVid) { AnnotationBase fs = selectByAddr(aJCas, AnnotationBase.class, aVid.getId()); aJCas.removeFsFromIndexes(fs); publishEvent(new DocumentMetadataDeletedEvent(this, aDocument, aUsername, fs)); }
@Override public void onRender(TypeAdapter aAdapter, VDocument aResponse, Map<AnnotationFS, VArc> aAnnoToArcIdx) { if (aAdapter.getLayer().isCrossSentence()) { return; } try { for (Entry<AnnotationFS, VArc> e : aAnnoToArcIdx.entrySet()) { JCas jcas = e.getKey().getCAS().getJCas(); if (!isBeginInSameSentence(jcas, selectByAddr(jcas, e.getValue().getSource().getId()).getBegin(), selectByAddr(jcas, e.getValue().getTarget().getId()).getBegin())) { aResponse.add(new VComment(new VID(e.getKey()), ERROR, "Crossing sentence bounardies is not permitted.")); } } } catch (CASException e) { throw new IllegalStateException("Unable to obtain JCas"); } }
private void actionDelete(AjaxRequestTarget aTarget) { try { // Load the boiler-plate JCas jCas = jcasProvider.get(); AnnotationBaseFS fs = selectByAddr(jCas, AnnotationBaseFS.class, getModelObject().getId()); AnnotationLayer layer = annotationService.getLayer(project.getObject(), fs); TypeAdapter adapter = annotationService.getAdapter(layer); // Perform actual actions adapter.delete(sourceDocument.getObject(), username.getObject(), jCas, new VID(fs)); // persist changes annotationPage.writeEditorCas(jCas); setModelObject(null); aTarget.add(getParent()); } catch (Exception e) { handleException(DocumentMetadataAnnotationDetailPanel.this, aTarget, e); } }
private void actionDelete(AjaxRequestTarget aTarget) { try { // Load the boiler-plate JCas jCas = jcasProvider.get(); AnnotationBaseFS fs = selectByAddr(jCas, AnnotationBaseFS.class, getModelObject().getId()); AnnotationLayer layer = annotationService.getLayer(project.getObject(), fs); TypeAdapter adapter = annotationService.getAdapter(layer); // Perform actual actions adapter.delete(sourceDocument.getObject(), username.getObject(), jCas, new VID(fs)); // persist changes annotationPage.writeEditorCas(jCas); setModelObject(null); aTarget.add(getParent()); } catch (Exception e) { handleException(DocumentMetadataAnnotationDetailPanel.this, aTarget, e); } }
private Object actionDoAction(AjaxRequestTarget aTarget, IRequestParameters request, JCas jCas, VID paramId) throws IOException { StringValue layerParam = request.getParameterValue(PARAM_SPAN_TYPE); if (!layerParam.isEmpty()) { long layerId = Long.parseLong(layerParam.beforeFirst('_')); AnnotationLayer layer = annotationService.getLayer(layerId); if (!StringUtils.isEmpty(layer.getOnClickJavascriptAction())) { // parse the action List<AnnotationFeature> features = annotationService.listAnnotationFeature(layer); AnnotationFS anno = WebAnnoCasUtil.selectByAddr(jCas, paramId.getId()); Map<String, Object> functionParams = OnClickActionParser.parse(layer, features, getModelObject().getDocument(), anno); // define anonymous function, fill the body and immediately execute String js = String.format("(function ($PARAM){ %s })(%s)", layer.getOnClickJavascriptAction(), JSONUtil.toJsonString(functionParams)); aTarget.appendJavaScript(js); } } return null; }
private Label createSelectedAnnotationTypeLabel() { Label label = new Label("selectedAnnotationType", LoadableDetachableModel.of(() -> { try { return String.valueOf(WebAnnoCasUtil.selectByAddr(editorPanel.getEditorCas(), getModelObject().getSelection().getAnnotation().getId())).trim(); } catch (IOException e) { return ""; } })); label.setOutputMarkupPlaceholderTag(true); // We show the extended info on the selected annotation only when run in development mode label.add(visibleWhen(() -> getModelObject().getSelection().getAnnotation().isSet() && DEVELOPMENT.equals(getApplication().getConfigurationType()))); return label; }
private void actionAnnotate(AjaxRequestTarget aTarget) { try { // When updating an annotation in the sidebar, we must not force a // re-focus after rendering getRequestCycle().setMetaData(IsSidebarAction.INSTANCE, true); // Load the boiler-plate JCas jCas = jcasProvider.get(); AnnotationBaseFS fs = selectByAddr(jCas, AnnotationBaseFS.class, getModelObject().getId()); AnnotationLayer layer = annotationService.getLayer(project.getObject(), fs); TypeAdapter adapter = annotationService.getAdapter(layer); // Update the features of the selected annotation from the values presently in // the feature editors writeFeatureEditorModelsToCas(adapter, jCas); // persist changes annotationPage.writeEditorCas(jCas); } catch (Exception e) { handleException(DocumentMetadataAnnotationDetailPanel.this, aTarget, e); } }
@Override public void delete(SourceDocument aDocument, String aUsername, JCas aJCas, VID aVid) { AnnotationFS fs = selectByAddr(aJCas, AnnotationFS.class, aVid.getId()); aJCas.removeFsFromIndexes(fs); // delete associated attachFeature if (getAttachTypeName() != null) { Type theType = CasUtil.getType(aJCas.getCas(), getAttachTypeName()); Feature attachFeature = theType.getFeatureByBaseName(getAttachFeatureName()); if (attachFeature != null) { CasUtil.selectCovered(aJCas.getCas(), theType, fs.getBegin(), fs.getEnd()).get(0) .setFeatureValue(attachFeature, null); } } publishEvent(new SpanDeletedEvent(this, aDocument, aUsername, getLayer(), fs)); }
@Override public void delete(SourceDocument aDocument, String aUsername, JCas aJCas, VID aVid) { AnnotationFS fs = selectByAddr(aJCas, AnnotationFS.class, aVid.getId()); aJCas.removeFsFromIndexes(fs); // delete associated attachFeature if (getAttachTypeName() != null) { Type theType = CasUtil.getType(aJCas.getCas(), getAttachTypeName()); Feature attachFeature = theType.getFeatureByBaseName(getAttachFeatureName()); if (attachFeature != null) { CasUtil.selectCovered(aJCas.getCas(), theType, fs.getBegin(), fs.getEnd()).get(0) .setFeatureValue(attachFeature, null); } } publishEvent(new SpanDeletedEvent(this, aDocument, aUsername, getLayer(), fs)); }
private void assertParseVid(String aExtensionId, int aLayerId, int aAnnotationID, int aSubAnnotationId, int aAttribute, int aSlot, String aVID) { VID a = VID.parse(aVID); assertEquals(aExtensionId, a.getExtensionId()); assertEquals(aLayerId, a.getLayerId()); assertEquals(aAnnotationID, a.getId()); assertEquals(aSubAnnotationId, a.getSubId()); assertEquals(aAttribute, a.getAttribute()); assertEquals(aSlot, a.getSlot()); } }