/** * 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); }
/** * 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); }
/** * Read traits and then transfer the values from the actual traits model * {{@link LinkFeatureTraits}} to the the UI traits model ({@link Traits}). */ private Traits readTraits() { Traits result = new Traits(); LinkFeatureTraits t = getFeatureSupport().readTraits(feature.getObject()); // Add any tags from the tagset which are default slots to the traits editor model listTags().stream() .filter(tag -> t.getDefaultSlots().contains(tag.getId())) .forEach(result.getDefaultSlots()::add); return result; }
/** * Read traits and then transfer the values from the actual traits model * {{@link LinkFeatureTraits}} to the the UI traits model ({@link Traits}). */ private Traits readTraits() { Traits result = new Traits(); LinkFeatureTraits t = getFeatureSupport().readTraits(feature.getObject()); // Add any tags from the tagset which are default slots to the traits editor model listTags().stream() .filter(tag -> t.getDefaultSlots().contains(tag.getId())) .forEach(result.getDefaultSlots()::add); return result; }
@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()); } }
@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()); } }
@Override public void onSubmit() { Tag tag = TagDetailForm.this.getModelObject(); if (tag.getId() != 0) { tag.setTagSet(tagSetDetailForm.getModelObject()); annotationService.removeTag(tag); tagDetailForm.setModelObject(new Tag()); } else { TagDetailForm.this.setModelObject(new Tag()); } } });
@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()); } } } });
public TagEditorPanel(String aId, IModel<TagSet> aTagSet, IModel<Tag> aTag) { super(aId, aTag); setOutputMarkupId(true); setOutputMarkupPlaceholderTag(true); selectedTagSet = aTagSet; selectedTag = aTag; Form<Tag> form = new Form<>("form", CompoundPropertyModel.of(aTag)); add(form); form.add(new TextField<String>("name") .add(new TagExistsValidator()) .setRequired(true)); form.add(new TextArea<String>("description")); form.add(new LambdaAjaxButton<>("save", this::actionSave)); form.add(new LambdaAjaxLink("delete", this::actionDelete) .onConfigure(_this -> _this.setVisible(form.getModelObject().getId() != null))); form.add(new LambdaAjaxLink("cancel", this::actionCancel)); }
public TagEditorPanel(String aId, IModel<TagSet> aTagSet, IModel<Tag> aTag) { super(aId, aTag); setOutputMarkupId(true); setOutputMarkupPlaceholderTag(true); selectedTagSet = aTagSet; selectedTag = aTag; Form<Tag> form = new Form<>("form", CompoundPropertyModel.of(aTag)); add(form); form.add(new TextField<String>("name") .add(new TagExistsValidator()) .setRequired(true)); form.add(new TextArea<String>("description")); form.add(new LambdaAjaxButton<>("save", this::actionSave)); form.add(new LambdaAjaxLink("delete", this::actionDelete) .onConfigure(_this -> _this.setVisible(form.getModelObject().getId() != null))); form.add(new LambdaAjaxLink("cancel", this::actionCancel)); }