Search in sources :

Example 1 with TagStorableMapping

use of com.hortonworks.registries.tag.TagStorableMapping in project registry by hortonworks.

the class CatalogTagService method getTaggedEntities.

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

Example 2 with TagStorableMapping

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

Example 3 with TagStorableMapping

use of com.hortonworks.registries.tag.TagStorableMapping in project registry by hortonworks.

the class CatalogTagService method addTagsForStorable.

@Override
public void addTagsForStorable(TaggedEntity taggedEntity, List<Tag> tags) {
    if (tags != null) {
        for (Tag tag : tags) {
            TagStorableMapping tagStorable = new TagStorableMapping();
            tagStorable.setTagId(tag.getId());
            tagStorable.setStorableNamespace(taggedEntity.getNamespace());
            tagStorable.setStorableId(taggedEntity.getId());
            this.dao.add(tagStorable);
        }
    }
}
Also used : Tag(com.hortonworks.registries.tag.Tag) TagStorableMapping(com.hortonworks.registries.tag.TagStorableMapping)

Example 4 with TagStorableMapping

use of com.hortonworks.registries.tag.TagStorableMapping in project registry by hortonworks.

the class CatalogTagService method getTags.

@Override
public List<Tag> getTags(TaggedEntity taggedEntity) {
    List<Tag> tags = new ArrayList<>();
    QueryParam qp1 = new QueryParam(TagStorableMapping.FIELD_STORABLE_ID, String.valueOf(taggedEntity.getId()));
    QueryParam qp2 = new QueryParam(TagStorableMapping.FIELD_STORABLE_NAMESPACE, String.valueOf(taggedEntity.getNamespace()));
    for (TagStorableMapping 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) Tag(com.hortonworks.registries.tag.Tag) TagStorableMapping(com.hortonworks.registries.tag.TagStorableMapping)

Aggregations

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