public TagModel tagToModel(Tags tag) { EntityModel<String> tempVar = new EntityModel<>(); tempVar.setEntity(tag.getTagName()); EntityModel<String> name = tempVar; EntityModel<String> tempVar2 = new EntityModel<>(); tempVar2.setEntity(tag.getDescription()); EntityModel<String> description = tempVar2; ArrayList<TagModel> children = new ArrayList<>(); for (Tags a : tag.getChildren()) { children.add(tagToModel(a)); } TagModel model = new TagModel(); model.setId(tag.getTagId()); model.setName(name); model.setDescription(description); model.setType((tag.getIsReadonly() == null ? false : tag.getIsReadonly()) ? TagModelType.ReadOnly : TagModelType.Regular); model.setSelection(false); model.setParentId(tag.getParentId() == null ? Guid.Empty : tag.getParentId()); model.setChildren(children); for (TagModel child : children) { child.setParent(model); } model.getSelectionChangedEvent().addListener(this); return model; }
@Override public void update(Tags tag) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("description", tag.getDescription()) .addValue("tag_id", tag.getTagId()) .addValue("tag_name", tag.getTagName()) .addValue("parent_id", tag.getParentId()) .addValue("readonly", tag.getIsReadonly()) .addValue("type", tag.getType()); getCallsHandler() .executeModification("Updatetags", parameterSource); }
public void getRootTag(AsyncQuery<Tags> aQuery) { aQuery.converterCallback = source -> { if (source != null) { Tags tag = (Tags) source; Tags root = new Tags(tag.getDescription(), tag.getParentId(), tag.getIsReadonly(), tag.getTagId(), tag.getTagName()); if (tag.getChildren() != null) { fillTagsRecursive(root, tag.getChildren()); } return root; } return new Tags(); }; Frontend.getInstance().runQuery(QueryType.GetRootTag, new QueryParametersBase(), aQuery); }
@Override public void save(Tags tag) { Guid id = tag.getTagId(); if (Guid.isNullOrEmpty(id)) { id = Guid.newGuid(); tag.setTagId(id); } MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("description", tag.getDescription()) .addValue("tag_id", tag.getTagId()) .addValue("tag_name", tag.getTagName()) .addValue("parent_id", tag.getParentId()) .addValue("readonly", tag.getIsReadonly()) .addValue("type", tag.getType()); getCallsHandler().executeModification("Inserttags", parameterSource); }
protected CustomMapSqlParameterSource getParamsSource(Tags tag) { CustomMapSqlParameterSource paramsSource = new CustomMapSqlParameterSource(dbEngineDialect); paramsSource.addValue("description", tag.getDescription()) .addValue("tag_id", tag.getTagId()) .addValue("tag_name", tag.getTagName()) .addValue("parent_id", tag.getParentId()) .addValue("readonly", tag.getIsReadonly()) .addValue("type", tag.getType()); return paramsSource; }