use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class RangerTagService method getTagsByType.
public List<RangerTag> getTagsByType(String name) {
List<RangerTag> ret = new ArrayList<RangerTag>();
List<XXTag> xxTags = daoMgr.getXXTag().findByName(name);
if (CollectionUtils.isNotEmpty(xxTags)) {
for (XXTag xxTag : xxTags) {
RangerTag tag = populateViewBean(xxTag);
ret.add(tag);
}
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class RangerTagService method getTagsForResourceId.
public List<RangerTag> getTagsForResourceId(Long resourceId) {
List<RangerTag> ret = new ArrayList<RangerTag>();
List<XXTag> xxTags = daoMgr.getXXTag().findForResourceId(resourceId);
if (CollectionUtils.isNotEmpty(xxTags)) {
for (XXTag xxTag : xxTags) {
RangerTag tag = populateViewBean(xxTag);
ret.add(tag);
}
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class TagPredicateUtil method addPredicateForTagType.
private Predicate addPredicateForTagType(final String type, List<Predicate> predicates) {
if (StringUtils.isEmpty(type)) {
return null;
}
Predicate ret = new Predicate() {
@Override
public boolean evaluate(Object object) {
boolean ret = false;
if (object == null) {
return ret;
}
if (object instanceof RangerTagDef) {
RangerTagDef tagDef = (RangerTagDef) object;
ret = StringUtils.equals(type, tagDef.getName());
} else if (object instanceof RangerTag) {
RangerTag tag = (RangerTag) object;
ret = StringUtils.equals(type, tag.getType());
}
return ret;
}
};
if (predicates != null) {
predicates.add(ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class TagPredicateUtil method addPredicateForTagGuid.
private Predicate addPredicateForTagGuid(final String guid, List<Predicate> predicates) {
if (StringUtils.isEmpty(guid)) {
return null;
}
Predicate ret = new Predicate() {
@Override
public boolean evaluate(Object object) {
boolean ret = false;
if (object == null) {
return ret;
}
if (object instanceof RangerTag) {
RangerTag tag = (RangerTag) object;
ret = StringUtils.equals(guid, tag.getGuid());
}
return ret;
}
};
if (predicates != null) {
predicates.add(ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class TestTagREST method test23getTag.
@Test
public void test23getTag() {
RangerTag oldTag = new RangerTag();
oldTag.setId(id);
oldTag.setGuid(gId);
try {
Mockito.when(tagStore.getTag(id)).thenReturn(oldTag);
} catch (Exception e) {
}
RangerTag rangerTag = tagREST.getTag(id);
Assert.assertNotNull(oldTag.getId());
Assert.assertEquals(rangerTag.getId(), oldTag.getId());
Assert.assertEquals(rangerTag.getGuid(), oldTag.getGuid());
try {
Mockito.verify(tagStore).getTag(id);
} catch (Exception e) {
}
}
Aggregations