Search in sources :

Example 1 with TagStorableMap

use of com.hortonworks.streamline.registries.tag.TagStorableMap 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;
}
Also used : QueryParam(com.hortonworks.registries.common.QueryParam) ArrayList(java.util.ArrayList) TagStorableMap(com.hortonworks.streamline.registries.tag.TagStorableMap) Tag(com.hortonworks.streamline.registries.tag.Tag)

Example 2 with TagStorableMap

use of com.hortonworks.streamline.registries.tag.TagStorableMap 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());
        }
    }
}
Also used : TagStorableMap(com.hortonworks.streamline.registries.tag.TagStorableMap) Tag(com.hortonworks.streamline.registries.tag.Tag)

Example 3 with TagStorableMap

use of com.hortonworks.streamline.registries.tag.TagStorableMap 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);
        }
    }
}
Also used : TagStorableMap(com.hortonworks.streamline.registries.tag.TagStorableMap) Tag(com.hortonworks.streamline.registries.tag.Tag)

Example 4 with TagStorableMap

use of com.hortonworks.streamline.registries.tag.TagStorableMap in project streamline by hortonworks.

the class CatalogTagService method getTaggedEntities.

private List<TaggedEntity> getTaggedEntities(Long tagId) {
    List<TaggedEntity> taggedEntities = new ArrayList<>();
    QueryParam qp1 = new QueryParam(TagStorableMap.FIELD_TAG_ID, String.valueOf(tagId));
    for (TagStorableMap mapping : listTagStorableMapping(ImmutableList.of(qp1))) {
        taggedEntities.add(new TaggedEntity(mapping.getStorableNamespace(), mapping.getStorableId()));
    }
    return taggedEntities;
}
Also used : TaggedEntity(com.hortonworks.streamline.registries.tag.TaggedEntity) QueryParam(com.hortonworks.registries.common.QueryParam) ArrayList(java.util.ArrayList) TagStorableMap(com.hortonworks.streamline.registries.tag.TagStorableMap)

Aggregations

TagStorableMap (com.hortonworks.streamline.registries.tag.TagStorableMap)4 Tag (com.hortonworks.streamline.registries.tag.Tag)3 QueryParam (com.hortonworks.registries.common.QueryParam)2 ArrayList (java.util.ArrayList)2 TaggedEntity (com.hortonworks.streamline.registries.tag.TaggedEntity)1