@Override @Transactional public TagSet createTagSet(String aDescription, String aTagSetName, String aLanguage, String[] aTags, String[] aTagDescription, Project aProject) throws IOException { TagSet tagSet = new TagSet(); tagSet.setDescription(aDescription); tagSet.setLanguage(aLanguage); tagSet.setName(aTagSetName); tagSet.setProject(aProject); createTagSet(tagSet); int i = 0; for (String tagName : aTags) { Tag tag = new Tag(); tag.setTagSet(tagSet); tag.setDescription(aTagDescription[i]); tag.setName(tagName); createTag(tag); i++; } return tagSet; }
@Override protected void toJson(String aChoice, JSONStringer aStringer) throws JSONException { String description = Select2TextFeatureEditor.this.getModelObject().tagset .stream() .filter(t -> t.getName().equals(aChoice)) .findFirst() .map(t -> t.getDescription()).orElse(""); super.toJson(aChoice, aStringer); //aStringer.key("description").value(description); } });
@Override public void onSubmit() { Tag tag = TagDetailForm.this.getModelObject(); if (tag.getName().equals("|")) { error("[|] is not allowed!"); return; } if (tag.getId() == 0) { tag.setTagSet(tagSetDetailForm.getModelObject()); if (annotationService.existsTag(tag.getName(), tagSetDetailForm.getModelObject())) { error("This tag is already added for this tagset!"); } else { String username = SecurityContextHolder.getContext() .getAuthentication().getName(); User user = repository.getUser(username); try { annotationService.createTag(tag, user); } catch (IOException e) { error("unable to create a log file while creating the Tag " + ":" + ExceptionUtils.getRootCauseMessage(e)); } tagDetailForm.setModelObject(new Tag()); } } } });
@Override protected List<Tag> getChoices(String aTerm) { List<Tag> matches = new ArrayList<>(); // If adding own tags is allowed, the always return the current input as the // first choice. boolean inputAsFirstResult = isNotBlank(aTerm) && KendoAutoCompleteTextFeatureEditor.this.getModelObject().feature .getTagset().isCreateTag(); if (inputAsFirstResult) { matches.add(new Tag(aTerm, "New unsaved tag...")); } KendoAutoCompleteTextFeatureEditor.this.getModelObject().tagset.stream() .filter(t -> isBlank(aTerm) || containsIgnoreCase(t.getName(), aTerm)) // If we added the input term as the first result and by freak accident // it is even returned as a result, then skip it. .filter(t -> !(inputAsFirstResult && t.getName().equals(aTerm))) .limit(maxResults) .forEach(matches::add);; return matches; }
selectedTag = new Tag(); selectedTag.setName(model.getObject()); && !annotationService.existsTag(model.getObject(), feature.getTagset())) { selectedTag = new Tag(); selectedTag.setName(model.getObject()); selectedTag.setTagSet(feature.getTagset()); if (model.getObject() != null) { selectedTag.getName()); selectedFeatureValues.put(feature, model.getObject());
private void writeFeatureEditorModelsToCas(TypeAdapter aAdapter, JCas aJCas) throws IOException { List<FeatureState> featureStates = featureList.getModelObject(); LOG.trace("writeFeatureEditorModelsToCas()"); List<AnnotationFeature> features = new ArrayList<>(); for (FeatureState featureState : featureStates) { features.add(featureState.feature); // For string features with extensible tagsets, extend the tagset if (CAS.TYPE_NAME_STRING.equals(featureState.feature.getType())) { String value = (String) featureState.value; if (value != null && featureState.feature.getTagset() != null && featureState.feature.getTagset().isCreateTag() && !annotationService.existsTag(value, featureState.feature.getTagset())) { Tag selectedTag = new Tag(); selectedTag.setName(value); selectedTag.setTagSet(featureState.feature.getTagset()); annotationService.createTag(selectedTag); } } LOG.trace("writeFeatureEditorModelsToCas() " + featureState.feature.getUiName() + " = " + featureState.value); aAdapter.setFeatureValue(sourceDocument.getObject(), username.getObject(), aJCas, getModelObject().getId(), featureState.feature, featureState.value); } }
Map<String, String> getBindTags() { AnnotationFeature f = annotationService .listAnnotationFeature(getModelObject().getSelectedAnnotationLayer()).get(0); TagSet tagSet = f.getTagset(); Map<Character, String> tagNames = new LinkedHashMap<>(); Map<String, String> bindTag2Key = new LinkedHashMap<>(); for (Tag tag : annotationService.listTags(tagSet)) { if (tagNames.containsKey(tag.getName().toLowerCase().charAt(0))) { String oldBinding = tagNames.get(tag.getName().toLowerCase().charAt(0)); String newBinding = oldBinding + tag.getName().toLowerCase().charAt(0); tagNames.put(tag.getName().toLowerCase().charAt(0), newBinding); bindTag2Key.put(newBinding, tag.getName()); } else { tagNames.put(tag.getName().toLowerCase().charAt(0), tag.getName().toLowerCase().substring(0, 1)); bindTag2Key.put(tag.getName().toLowerCase().substring(0, 1), tag.getName()); } } return bindTag2Key; }
@Override @Transactional public void createTag(Tag aTag) { if (isNull(aTag.getId())) { entityManager.persist(aTag); } else { entityManager.merge(aTag); } try (MDC.MDCCloseable closable = MDC.putCloseable(Logging.KEY_PROJECT_ID, String.valueOf(aTag.getTagSet().getProject().getId()))) { TagSet tagset = aTag.getTagSet(); Project project = tagset.getProject(); log.info("Created tag [{}]({}) in tagset [{}]({}) in project [{}]({})", aTag.getName(), aTag.getId(), tagset.getName(), tagset.getId(), project.getName(), project.getId()); } }
if (value.getValue().equalsIgnoreCase(tag.getName())) { tag.setReordered(true);
@Override public void onSubmit() { tagDetailForm.setDefaultModelObject(new Tag()); } });
private void actionSave(AjaxRequestTarget aTarget, Form<Tag> aForm) { selectedTag.getObject().setTagSet(selectedTagSet.getObject()); annotationSchemaService.createTag(selectedTag.getObject()); // Reload whole page because master panel also needs to be reloaded. aTarget.add(getPage()); }
/** * Transfer the values from the UI traits model ({@link Traits}) to the actual traits model * {{@link LinkFeatureTraits}} and then store them. */ private void writeTraits() { LinkFeatureTraits t = new LinkFeatureTraits(); traits.getObject().getDefaultSlots().stream() .map(tag -> tag.getId()) .forEach(t.getDefaultSlots()::add); getFeatureSupport().writeTraits(feature.getObject(), t); }
selectedTag = new Tag(); selectedTag.setName(model.getObject()); && !annotationService.existsTag(model.getObject(), feature.getTagset())) { selectedTag = new Tag(); selectedTag.setName(model.getObject()); selectedTag.setTagSet(feature.getTagset()); if (model.getObject() != null) { selectedTag.getName());
private void writeFeatureEditorModelsToCas(TypeAdapter aAdapter, JCas aJCas) throws IOException { List<FeatureState> featureStates = featureList.getModelObject(); LOG.trace("writeFeatureEditorModelsToCas()"); List<AnnotationFeature> features = new ArrayList<>(); for (FeatureState featureState : featureStates) { features.add(featureState.feature); // For string features with extensible tagsets, extend the tagset if (CAS.TYPE_NAME_STRING.equals(featureState.feature.getType())) { String value = (String) featureState.value; if (value != null && featureState.feature.getTagset() != null && featureState.feature.getTagset().isCreateTag() && !annotationService.existsTag(value, featureState.feature.getTagset())) { Tag selectedTag = new Tag(); selectedTag.setName(value); selectedTag.setTagSet(featureState.feature.getTagset()); annotationService.createTag(selectedTag); } } LOG.trace("writeFeatureEditorModelsToCas() " + featureState.feature.getUiName() + " = " + featureState.value); aAdapter.setFeatureValue(sourceDocument.getObject(), username.getObject(), aJCas, getModelObject().getId(), featureState.feature, featureState.value); } }
.filter(t -> isBlank(aTerm) || containsIgnoreCase(t.getName(), aTerm))
@Override protected List<Tag> getChoices(String aTerm) { List<Tag> matches = new ArrayList<>(); // If adding own tags is allowed, the always return the current input as the // first choice. boolean inputAsFirstResult = isNotBlank(aTerm) && KendoAutoCompleteTextFeatureEditor.this.getModelObject().feature .getTagset().isCreateTag(); if (inputAsFirstResult) { matches.add(new Tag(aTerm, "New unsaved tag...")); } KendoAutoCompleteTextFeatureEditor.this.getModelObject().tagset.stream() .filter(t -> isBlank(aTerm) || containsIgnoreCase(t.getName(), aTerm)) // If we added the input term as the first result and by freak accident // it is even returned as a result, then skip it. .filter(t -> !(inputAsFirstResult && t.getName().equals(aTerm))) .limit(maxResults) .forEach(matches::add);; return matches; }
@Override @Transactional public void createTag(Tag aTag) { if (isNull(aTag.getId())) { entityManager.persist(aTag); } else { entityManager.merge(aTag); } try (MDC.MDCCloseable closable = MDC.putCloseable(Logging.KEY_PROJECT_ID, String.valueOf(aTag.getTagSet().getProject().getId()))) { TagSet tagset = aTag.getTagSet(); Project project = tagset.getProject(); log.info("Created tag [{}]({}) in tagset [{}]({}) in project [{}]({})", aTag.getName(), aTag.getId(), tagset.getName(), tagset.getId(), project.getName(), project.getId()); } }
if (allRecommendationLabels.contains(tag.getName())) { tag.setReordered(true); reorderedTagList.add(tag);
public TagDetailForm(String id) super(id, new CompoundPropertyModel<Tag>(new EntityModel<Tag>(new Tag()))); add(new TextField<String>("name").setRequired(true)); + ExceptionUtils.getRootCauseMessage(e)); tagDetailForm.setModelObject(new Tag()); tag.setTagSet(tagSetDetailForm.getModelObject()); annotationService.removeTag(tag); tagDetailForm.setModelObject(new Tag()); TagDetailForm.this.setModelObject(new Tag());