@Override public void configure(Project aProject) throws IOException { AnnotationLayer neLayer = annotationSchemaService.getLayer(NamedEntity.class.getName(), aProject); annotationSchemaService.createFeature(new AnnotationFeature(aProject, neLayer, "identifier", "identifier", ConceptFeatureSupport.TYPE_ANY_OBJECT, "Linked entity", null)); } }
@Override public void configure(Project aProject) throws IOException { AnnotationLayer neLayer = annotationSchemaService.getLayer(NamedEntity.class.getName(), aProject); annotationSchemaService.createFeature(new AnnotationFeature(aProject, neLayer, "identifier", "identifier", ConceptFeatureSupport.TYPE_ANY_OBJECT, "Linked entity", null)); } }
@Override public ConceptFeatureTraits getFeatureTraits(Project aProject) { AnnotationLayer linkedLayer = annotationService .getLayer(NamedEntity.class.getName(), aProject); AnnotationFeature linkedFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer); FeatureSupport<ConceptFeatureTraits> fs = featureSupportRegistry .getFeatureSupport(linkedFeature); ConceptFeatureTraits traits = fs.readTraits(linkedFeature); return traits; }
@Override public ConceptFeatureTraits getFeatureTraits(Project aProject) { AnnotationLayer linkedLayer = annotationService .getLayer(NamedEntity.class.getName(), aProject); AnnotationFeature linkedFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer); FeatureSupport<ConceptFeatureTraits> fs = featureSupportRegistry .getFeatureSupport(linkedFeature); ConceptFeatureTraits traits = fs.readTraits(linkedFeature); return traits; }
@Override public void onConfigure() { super.onConfigure(); List<LinkWithRoleModel> links = (List<LinkWithRoleModel>) this.getModelObject().value; if (links.size() == 0) { String role = roleModel.role; roleModel = new LinkWithRoleModel(); roleModel.role = role; links.add(roleModel); } else { roleModel = links.get(0); } String linkedType = this.getModelObject().feature.getType(); AnnotationLayer linkedLayer = annotationService .getLayer(linkedType, this.stateModel.getObject().getProject()); linkedAnnotationFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer); }
private void fix(Project aProject, Class<? extends TOP> aLayer, String aLayerType, AnnotationLayer aTokenLayer, String aFeature) { if (annotationSchemaService.existsLayer(aLayer.getName(), aLayerType, aProject)) { AnnotationLayer layer = annotationSchemaService.getLayer(aLayer.getName(), aProject); if (layer.getAttachFeature() == null) { layer.setAttachFeature(annotationSchemaService.getFeature(aFeature, aTokenLayer)); log.info("DATABASE UPGRADE PERFORMED: Fixed attach-feature of layer " + "[{}] ({}) in project [{}] ({})", layer.getUiName(), layer.getId(), aProject.getName(), aProject.getId()); } } } }
@Override public void onConfigure() { super.onConfigure(); List<LinkWithRoleModel> links = (List<LinkWithRoleModel>) this.getModelObject().value; if (links.size() == 0) { String role = roleModel.role; roleModel = new LinkWithRoleModel(); roleModel.role = role; links.add(roleModel); } else { roleModel = links.get(0); } String linkedType = this.getModelObject().feature.getType(); AnnotationLayer linkedLayer = annotationService .getLayer(linkedType, this.stateModel.getObject().getProject()); linkedAnnotationFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer); }
private void fix(Project aProject, Class<? extends TOP> aLayer, String aLayerType, AnnotationLayer aTokenLayer, String aFeature) { if (annotationSchemaService.existsLayer(aLayer.getName(), aLayerType, aProject)) { AnnotationLayer layer = annotationSchemaService.getLayer(aLayer.getName(), aProject); if (layer.getAttachFeature() == null) { layer.setAttachFeature(annotationSchemaService.getFeature(aFeature, aTokenLayer)); log.info("DATABASE UPGRADE PERFORMED: Fixed attach-feature of layer " + "[{}] ({}) in project [{}] ({})", layer.getUiName(), layer.getId(), aProject.getName(), aProject.getId()); } } } }
private void createPOSLayer(Project aProject, TagSet aPosTagset) throws IOException { AnnotationLayer tokenLayer = annotationSchemaService.getLayer(Token.class.getName(), aProject); AnnotationLayer posLayer = new AnnotationLayer(POS.class.getName(), "POS", SPAN_TYPE, aProject, true, AnchoringMode.SINGLE_TOKEN); AnnotationFeature tokenPosFeature = new AnnotationFeature(aProject, tokenLayer, "pos", "pos", POS.class.getName()); annotationSchemaService.createFeature(tokenPosFeature); posLayer.setAttachType(tokenLayer); posLayer.setAttachFeature(tokenPosFeature); annotationSchemaService.createLayer(posLayer); annotationSchemaService.createFeature(new AnnotationFeature(aProject, posLayer, "PosValue", "PosValue", CAS.TYPE_NAME_STRING, "Part-of-speech tag", aPosTagset)); }
private void createPOSLayer(Project aProject, TagSet aPosTagset) throws IOException { AnnotationLayer tokenLayer = annotationSchemaService.getLayer(Token.class.getName(), aProject); AnnotationLayer posLayer = new AnnotationLayer(POS.class.getName(), "POS", SPAN_TYPE, aProject, true, AnchoringMode.SINGLE_TOKEN); AnnotationFeature tokenPosFeature = new AnnotationFeature(aProject, tokenLayer, "pos", "pos", POS.class.getName()); annotationSchemaService.createFeature(tokenPosFeature); posLayer.setAttachType(tokenLayer); posLayer.setAttachFeature(tokenPosFeature); annotationSchemaService.createLayer(posLayer); annotationSchemaService.createFeature(new AnnotationFeature(aProject, posLayer, "PosValue", "PosValue", CAS.TYPE_NAME_STRING, "Part-of-speech tag", aPosTagset)); }
@Override public void configure(Project aProject) throws IOException { TagSet posTagSet = JsonImportUtil.importTagSetFromJson(aProject, new ClassPathResource("/tagsets/mul-pos-ud.json").getInputStream(), annotationSchemaService); AnnotationLayer tokenLayer = annotationSchemaService.getLayer(Token.class.getName(), aProject); AnnotationLayer posLayer = new AnnotationLayer(POS.class.getName(), "POS", SPAN_TYPE, aProject, true, AnchoringMode.SINGLE_TOKEN); AnnotationFeature tokenPosFeature = new AnnotationFeature(aProject, tokenLayer, "pos", "pos", POS.class.getName()); annotationSchemaService.createFeature(tokenPosFeature); posLayer.setAttachType(tokenLayer); posLayer.setAttachFeature(tokenPosFeature); annotationSchemaService.createLayer(posLayer); annotationSchemaService.createFeature(new AnnotationFeature(aProject, posLayer, "PosValue", "PosValue", CAS.TYPE_NAME_STRING, "Part-of-speech tag", posTagSet)); } }
@Override public void configure(Project aProject) throws IOException { TagSet posTagSet = JsonImportUtil.importTagSetFromJson(aProject, new ClassPathResource("/tagsets/mul-pos-ud.json").getInputStream(), annotationSchemaService); AnnotationLayer tokenLayer = annotationSchemaService.getLayer(Token.class.getName(), aProject); AnnotationLayer posLayer = new AnnotationLayer(POS.class.getName(), "POS", SPAN_TYPE, aProject, true, AnchoringMode.SINGLE_TOKEN); AnnotationFeature tokenPosFeature = new AnnotationFeature(aProject, tokenLayer, "pos", "pos", POS.class.getName()); annotationSchemaService.createFeature(tokenPosFeature); posLayer.setAttachType(tokenLayer); posLayer.setAttachFeature(tokenPosFeature); annotationSchemaService.createLayer(posLayer); annotationSchemaService.createFeature(new AnnotationFeature(aProject, posLayer, "PosValue", "PosValue", CAS.TYPE_NAME_STRING, "Part-of-speech tag", posTagSet)); } }
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; }
@Override public void configure(Project aProject) throws IOException { AnnotationLayer tokenLayer = annotationSchemaService.getLayer(Token.class.getName(), aProject); AnnotationFeature tokenLemmaFeature = new AnnotationFeature(aProject, tokenLayer, "lemma", "lemma", Lemma.class.getName()); annotationSchemaService.createFeature(tokenLemmaFeature); AnnotationLayer lemmaLayer = new AnnotationLayer(Lemma.class.getName(), "Lemma", SPAN_TYPE, aProject, true, AnchoringMode.SINGLE_TOKEN); lemmaLayer.setAttachType(tokenLayer); lemmaLayer.setAttachFeature(tokenLemmaFeature); annotationSchemaService.createLayer(lemmaLayer); AnnotationFeature lemmaFeature = new AnnotationFeature(); lemmaFeature.setDescription("lemma Annotation"); lemmaFeature.setName("value"); lemmaFeature.setType(CAS.TYPE_NAME_STRING); lemmaFeature.setProject(aProject); lemmaFeature.setUiName("Lemma"); lemmaFeature.setLayer(lemmaLayer); annotationSchemaService.createFeature(lemmaFeature); } }
private void createLemmaLayer(Project aProject) throws IOException { AnnotationLayer tokenLayer = annotationSchemaService.getLayer(Token.class.getName(), aProject); AnnotationFeature tokenLemmaFeature = new AnnotationFeature(aProject, tokenLayer, "lemma", "lemma", Lemma.class.getName()); annotationSchemaService.createFeature(tokenLemmaFeature); AnnotationLayer lemmaLayer = new AnnotationLayer(Lemma.class.getName(), "Lemma", SPAN_TYPE, aProject, true, AnchoringMode.SINGLE_TOKEN); lemmaLayer.setAttachType(tokenLayer); lemmaLayer.setAttachFeature(tokenLemmaFeature); annotationSchemaService.createLayer(lemmaLayer); AnnotationFeature lemmaFeature = new AnnotationFeature(); lemmaFeature.setDescription("lemma Annotation"); lemmaFeature.setName("value"); lemmaFeature.setType(CAS.TYPE_NAME_STRING); lemmaFeature.setProject(aProject); lemmaFeature.setUiName("Lemma"); lemmaFeature.setLayer(lemmaLayer); annotationSchemaService.createFeature(lemmaFeature); }
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); } }
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); } }
private void importTrainingDocuments(ExportedProject aExProject, Project aProject) throws IOException { ExportedTrainingDocument[] trainingDocuments = aExProject .getArrayProperty(TRAINING_DOCUMENTS, ExportedTrainingDocument.class); for (ExportedTrainingDocument importedTrainingDocument : trainingDocuments) { TrainingDocument trainingDocument = new TrainingDocument(); trainingDocument.setFormat(importedTrainingDocument.getFormat()); trainingDocument.setName(importedTrainingDocument.getName()); trainingDocument.setState(importedTrainingDocument.getState()); trainingDocument.setProject(aProject); trainingDocument.setTimestamp(importedTrainingDocument.getTimestamp()); trainingDocument.setSentenceAccessed(importedTrainingDocument.getSentenceAccessed()); if (importedTrainingDocument.getFeature() != null) { AnnotationLayer trainingLayer = annotationService .getLayer(importedTrainingDocument.getFeature().getLayer(), aProject); AnnotationFeature trainingFeature = annotationService .getFeature(importedTrainingDocument.getFeature().getName(), trainingLayer); trainingDocument.setFeature(trainingFeature); } automationService.createTrainingDocument(trainingDocument); } }