use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class AtlasTypeDefGraphStore method updateGraphStore.
private AtlasTypesDef updateGraphStore(AtlasTypesDef typesDef, AtlasTransientTypeRegistry ttr) throws AtlasBaseException {
AtlasTypesDef ret = new AtlasTypesDef();
AtlasEnumDefStore enumDefStore = getEnumDefStore(ttr);
AtlasStructDefStore structDefStore = getStructDefStore(ttr);
AtlasClassificationDefStore classifiDefStore = getClassificationDefStore(ttr);
AtlasEntityDefStore entityDefStore = getEntityDefStore(ttr);
if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) {
for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
ret.getEnumDefs().add(enumDefStore.update(enumDef));
}
}
if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
for (AtlasStructDef structDef : typesDef.getStructDefs()) {
ret.getStructDefs().add(structDefStore.update(structDef));
}
}
if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
ret.getClassificationDefs().add(classifiDefStore.update(classifiDef));
}
}
if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
ret.getEntityDefs().add(entityDefStore.update(entityDef));
}
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class AtlasTypeDefGraphStore method createUpdateTypesDef.
@Override
@GraphTransaction
public AtlasTypesDef createUpdateTypesDef(AtlasTypesDef typesToCreate, AtlasTypesDef typesToUpdate) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasTypeDefGraphStore.createUpdateTypesDef({}, {})", typesToCreate, typesToUpdate);
}
AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit();
if (!typesToUpdate.isEmpty()) {
ttr.updateTypesWithNoRefResolve(typesToUpdate);
}
// Translate any NOT FOUND errors to BAD REQUEST
tryTypeCreation(typesToCreate, ttr);
AtlasTypesDef ret = addToGraphStore(typesToCreate, ttr);
if (!typesToUpdate.isEmpty()) {
AtlasTypesDef updatedTypes = updateGraphStore(typesToUpdate, ttr);
if (CollectionUtils.isNotEmpty(updatedTypes.getEnumDefs())) {
for (AtlasEnumDef enumDef : updatedTypes.getEnumDefs()) {
ret.getEnumDefs().add(enumDef);
}
}
if (CollectionUtils.isNotEmpty(updatedTypes.getStructDefs())) {
for (AtlasStructDef structDef : updatedTypes.getStructDefs()) {
ret.getStructDefs().add(structDef);
}
}
if (CollectionUtils.isNotEmpty(updatedTypes.getClassificationDefs())) {
for (AtlasClassificationDef classificationDef : updatedTypes.getClassificationDefs()) {
ret.getClassificationDefs().add(classificationDef);
}
}
if (CollectionUtils.isNotEmpty(updatedTypes.getEntityDefs())) {
for (AtlasEntityDef entityDef : updatedTypes.getEntityDefs()) {
ret.getEntityDefs().add(entityDef);
}
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasTypeDefGraphStore.createUpdateTypesDef({}, {}): {}", typesToCreate, typesToUpdate, ret);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class AtlasClassificationDefStoreV1 method getByGuid.
@Override
public AtlasClassificationDef getByGuid(String guid) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasClassificationDefStoreV1.getByGuid({})", guid);
}
AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
}
AtlasClassificationDef ret = toClassificationDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasClassificationDefStoreV1.getByGuid({}): {}", guid, ret);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class AtlasClassificationDefStoreV1 method updateByGuid.
@Override
public AtlasClassificationDef updateByGuid(String guid, AtlasClassificationDef classificationDef) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasClassificationDefStoreV1.updateByGuid({})", guid);
}
validateType(classificationDef);
AtlasType type = typeRegistry.getTypeByGuid(guid);
if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.CLASSIFICATION) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name());
}
AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
}
updateVertexPreUpdate(classificationDef, (AtlasClassificationType) type, vertex);
updateVertexAddReferences(classificationDef, vertex);
AtlasClassificationDef ret = toClassificationDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasClassificationDefStoreV1.updateByGuid({}): {}", guid, ret);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class AtlasClassificationDefStoreV1 method toClassificationDef.
private AtlasClassificationDef toClassificationDef(AtlasVertex vertex) throws AtlasBaseException {
AtlasClassificationDef ret = null;
if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.TRAIT)) {
ret = new AtlasClassificationDef();
AtlasStructDefStoreV1.toStructDef(vertex, ret, typeDefStore);
ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex));
}
return ret;
}
Aggregations