private static Tag parent(Tags entity) { if (entity.getParentId() != null) { Tag parent = new Tag(); parent.setId(entity.getParentId().toString()); return parent; } else { return null; } } }
private Tags setUpTagExpectations(Guid tagId) { Tags tags = mock(Tags.class); when(tags.getTagId()).thenReturn(tagId); when(tags.getParentId()).thenReturn(TEMPLATE_ID); return tags; } }
private Tags setUpTagExpectations(Guid tagId) { Tags tags = mock(Tags.class); when(tags.getTagId()).thenReturn(tagId); when(tags.getParentId()).thenReturn(VM_ID); return tags; } }
private Tags setUpTagExpectations(Guid tagId) { Tags tags = mock(Tags.class); when(tags.getTagId()).thenReturn(tagId); when(tags.getParentId()).thenReturn(HOST_ID); return tags; } }
private Tags setUpTagExpectations(Guid tagId) { Tags tags = mock(Tags.class); when(tags.getTagId()).thenReturn(tagId); when(tags.getParentId()).thenReturn(USER_ID); return tags; } }
private Tags setUpTagExpectations(Guid tagId) { Tags tags = mock(Tags.class); when(tags.getTagId()).thenReturn(tagId); when(tags.getParentId()).thenReturn(GROUP_ID); return tags; } }
/** * Ensures that getting all tags for a parent works as expected. */ @Test public void testGetAllForParent() { List<Tags> result = dao.getAllForParent(parent); assertNotNull(result); assertFalse(result.isEmpty()); for (Tags tag : result) { assertEquals(parent, tag.getParentId()); } }
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); }
@Mapping(from = Tag.class, to = Tags.class) public static Tags map(Tag model, Tags template) { Tags entity = template != null ? template : new Tags(); entity.setParentId(parent(model, entity.getParentId())); if (model.isSetId()) { entity.setTagId(GuidUtils.asGuid(model.getId())); } if (model.isSetName()) { entity.setTagName(model.getName()); } if (model.isSetDescription()) { entity.setDescription(model.getDescription()); } return entity; }
@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; }