use of com.hortonworks.registries.tag.Tag in project registry by hortonworks.
the class TagClient method makeTag.
private Tag makeTag(TagDto tagDto) {
if (tagDto == null)
return null;
List<Tag> parentTags = new ArrayList<>();
if (tagDto.getTagIds() != null) {
for (Long tagId : tagDto.getTagIds()) {
Tag tag = getTag(tagId);
if (tag == null) {
throw new IllegalArgumentException("Tag with id " + tagId + " does not exist.");
}
parentTags.add(tag);
}
}
Tag tag = new Tag();
tag.setId(tagDto.getId());
tag.setName(tagDto.getName());
tag.setDescription(tagDto.getDescription());
tag.setTimestamp(tagDto.getTimestamp());
tag.setTags(parentTags);
return tag;
}
use of com.hortonworks.registries.tag.Tag in project registry by hortonworks.
the class CatalogTagService method getTag.
@Override
public Tag getTag(Long tagId) {
Tag tag = new Tag();
tag.setId(tagId);
Tag result = this.dao.get(new StorableKey(TAG_NAMESPACE, tag.getPrimaryKey()));
if (result != null) {
result.setTags(getTags(getTaggedEntity(result)));
}
return result;
}
use of com.hortonworks.registries.tag.Tag in project registry by hortonworks.
the class CatalogTagService method removeTag.
@Override
public Tag removeTag(Long tagId) {
Tag tag = getTag(tagId);
if (tag != null) {
if (!getEntities(tagId, false).isEmpty()) {
throw new TagNotEmptyException("Tag not empty, has child entities.");
}
removeTagsFromStorable(getTaggedEntity(tag), tag.getTags());
dao.<Tag>remove(new StorableKey(TAG_NAMESPACE, tag.getPrimaryKey()));
}
return tag;
}
use of com.hortonworks.registries.tag.Tag in project registry by hortonworks.
the class CatalogTagService method removeTagsFromStorable.
@Override
public void removeTagsFromStorable(TaggedEntity taggedEntity, List<Tag> tags) {
if (tags != null) {
for (Tag tag : tags) {
TagStorableMapping tagStorable = new TagStorableMapping();
tagStorable.setTagId(tag.getId());
tagStorable.setStorableId(taggedEntity.getId());
tagStorable.setStorableNamespace(taggedEntity.getNamespace());
this.dao.remove(tagStorable.getStorableKey());
}
}
}
use of com.hortonworks.registries.tag.Tag in project registry by hortonworks.
the class CatalogTagService method flatten.
private List<Tag> flatten(List<Tag> tags) {
List<Tag> res = new ArrayList<>();
for (Tag tag : tags) {
res.add(tag);
res.addAll(flatten(tag.getTags()));
}
return res;
}
Aggregations