use of com.hortonworks.streamline.registries.tag.Tag in project streamline 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;
}
use of com.hortonworks.streamline.registries.tag.Tag in project streamline by hortonworks.
the class CatalogTagService method getTags.
@Override
public List<Tag> getTags(TaggedEntity taggedEntity) {
List<Tag> tags = new ArrayList<>();
QueryParam qp1 = new QueryParam(TagStorableMap.FIELD_STORABLE_ID, String.valueOf(taggedEntity.getId()));
QueryParam qp2 = new QueryParam(TagStorableMap.FIELD_STORABLE_NAMESPACE, String.valueOf(taggedEntity.getNamespace()));
for (TagStorableMap mapping : listTagStorableMapping(ImmutableList.of(qp1, qp2))) {
tags.add(getTag(mapping.getTagId()));
}
return tags;
}
use of com.hortonworks.streamline.registries.tag.Tag in project streamline by hortonworks.
the class CatalogTagService method removeTagsFromStorable.
@Override
public void removeTagsFromStorable(TaggedEntity taggedEntity, List<Tag> tags) {
if (tags != null) {
for (Tag tag : tags) {
TagStorableMap tagStorable = new TagStorableMap();
tagStorable.setTagId(tag.getId());
tagStorable.setStorableId(taggedEntity.getId());
tagStorable.setStorableNamespace(taggedEntity.getNamespace());
this.dao.remove(tagStorable.getStorableKey());
}
}
}
use of com.hortonworks.streamline.registries.tag.Tag in project streamline by hortonworks.
the class CatalogTagService method addTagsForStorable.
@Override
public void addTagsForStorable(TaggedEntity taggedEntity, List<Tag> tags) {
if (tags != null) {
for (Tag tag : tags) {
TagStorableMap tagStorable = new TagStorableMap();
tagStorable.setTagId(tag.getId());
tagStorable.setStorableNamespace(taggedEntity.getNamespace());
tagStorable.setStorableId(taggedEntity.getId());
this.dao.add(tagStorable);
}
}
}
use of com.hortonworks.streamline.registries.tag.Tag in project streamline 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;
}
Aggregations