use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testAddTrait.
@Test(dependsOnMethods = "testGetTraitNames")
public void testAddTrait() throws Exception {
traitName = "PII_Trait" + randomString();
AtlasClassificationDef piiTrait = AtlasTypeUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getClassificationDefs().add(piiTrait);
createType(typesDef);
atlasClientV2.addClassifications(createHiveTable().getGuid(), ImmutableList.of(new AtlasClassification(piiTrait.getName())));
assertEntityAudit(createHiveTable().getGuid(), EntityAuditEvent.EntityAuditAction.TAG_ADD);
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class TypeConverterUtil method toAtlasClassificationDefs.
private static List<AtlasClassificationDef> toAtlasClassificationDefs(List<HierarchicalTypeDefinition<TraitType>> traitTypeDefinitions) throws AtlasBaseException {
List<AtlasClassificationDef> ret = new ArrayList<AtlasClassificationDef>();
for (HierarchicalTypeDefinition<TraitType> traitType : traitTypeDefinitions) {
AtlasClassificationDef classifDef = new AtlasClassificationDef();
List<AtlasAttributeDef> attrDefs = new ArrayList<AtlasAttributeDef>();
classifDef.setName(traitType.typeName);
classifDef.setDescription(traitType.typeDescription);
classifDef.setTypeVersion(traitType.typeVersion);
classifDef.setSuperTypes(traitType.superTypes);
AttributeDefinition[] attrDefinitions = traitType.attributeDefinitions;
for (AttributeDefinition attrDefinition : attrDefinitions) {
attrDefs.add(toAtlasAttributeDef(attrDefinition));
}
classifDef.setAttributeDefs(attrDefs);
ret.add(classifDef);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class AtlasClassificationDefStoreV1 method getByName.
@Override
public AtlasClassificationDef getByName(String name) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasClassificationDefStoreV1.getByName({})", name);
}
AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
}
vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, TypeCategory.class);
AtlasClassificationDef ret = toClassificationDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasClassificationDefStoreV1.getByName({}): {}", name, ret);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class AtlasClassificationDefStoreV1 method update.
@Override
public AtlasClassificationDef update(AtlasClassificationDef classifiDef) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasClassificationDefStoreV1.update({})", classifiDef);
}
validateType(classifiDef);
AtlasClassificationDef ret = StringUtils.isNotBlank(classifiDef.getGuid()) ? updateByGuid(classifiDef.getGuid(), classifiDef) : updateByName(classifiDef.getName(), classifiDef);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasClassificationDefStoreV1.update({}): {}", classifiDef, ret);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class AtlasClassificationDefStoreV1 method create.
@Override
public AtlasClassificationDef create(AtlasClassificationDef classificationDef, Object preCreateResult) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasClassificationDefStoreV1.create({}, {})", classificationDef, preCreateResult);
}
AtlasVertex vertex;
if (preCreateResult == null || !(preCreateResult instanceof AtlasVertex)) {
vertex = preCreate(classificationDef);
} else {
vertex = (AtlasVertex) preCreateResult;
}
updateVertexAddReferences(classificationDef, vertex);
AtlasClassificationDef ret = toClassificationDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasClassificationDefStoreV1.create({}, {}): {}", classificationDef, preCreateResult, ret);
}
return ret;
}
Aggregations