use of org.apache.atlas.model.typedef.AtlasEnumDef in project incubator-atlas by apache.
the class AtlasEnumDefStoreV1 method getByGuid.
@Override
public AtlasEnumDef getByGuid(String guid) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEnumDefStoreV1.getByGuid({})", guid);
}
AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.ENUM);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
}
AtlasEnumDef ret = toEnumDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEnumDefStoreV1.getByGuid({}): {}", guid, ret);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasEnumDef in project incubator-atlas by apache.
the class AtlasEnumDefStoreV1 method update.
@Override
public AtlasEnumDef update(AtlasEnumDef enumDef) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEnumDefStoreV1.update({})", enumDef);
}
validateType(enumDef);
AtlasEnumDef ret = StringUtils.isNotBlank(enumDef.getGuid()) ? updateByGuid(enumDef.getGuid(), enumDef) : updateByName(enumDef.getName(), enumDef);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEnumDefStoreV1.update({}): {}", enumDef, ret);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasEnumDef in project incubator-atlas by apache.
the class AtlasEnumDefStoreV1 method create.
@Override
public AtlasEnumDef create(AtlasEnumDef enumDef) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEnumDefStoreV1.create({})", enumDef);
}
validateType(enumDef);
AtlasVertex vertex = typeDefStore.findTypeVertexByName(enumDef.getName());
if (vertex != null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, enumDef.getName());
}
vertex = typeDefStore.createTypeVertex(enumDef);
toVertex(enumDef, vertex);
AtlasEnumDef ret = toEnumDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEnumDefStoreV1.create({}): {}", enumDef, ret);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasEnumDef in project incubator-atlas by apache.
the class AtlasTypeDefGraphStore method deleteTypesDef.
@Override
@GraphTransaction
public void deleteTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasTypeDefGraphStore.deleteTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs()));
}
AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit();
AtlasEnumDefStore enumDefStore = getEnumDefStore(ttr);
AtlasStructDefStore structDefStore = getStructDefStore(ttr);
AtlasClassificationDefStore classifiDefStore = getClassificationDefStore(ttr);
AtlasEntityDefStore entityDefStore = getEntityDefStore(ttr);
List<Object> preDeleteStructDefs = new ArrayList<>();
List<Object> preDeleteClassifiDefs = new ArrayList<>();
List<Object> preDeleteEntityDefs = new ArrayList<>();
if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
for (AtlasStructDef structDef : typesDef.getStructDefs()) {
if (StringUtils.isNotBlank(structDef.getGuid())) {
preDeleteStructDefs.add(structDefStore.preDeleteByGuid(structDef.getGuid()));
} else {
preDeleteStructDefs.add(structDefStore.preDeleteByName(structDef.getName()));
}
}
}
if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
if (StringUtils.isNotBlank(classifiDef.getGuid())) {
preDeleteClassifiDefs.add(classifiDefStore.preDeleteByGuid(classifiDef.getGuid()));
} else {
preDeleteClassifiDefs.add(classifiDefStore.preDeleteByName(classifiDef.getName()));
}
}
}
if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
if (StringUtils.isNotBlank(entityDef.getGuid())) {
preDeleteEntityDefs.add(entityDefStore.preDeleteByGuid(entityDef.getGuid()));
} else {
preDeleteEntityDefs.add(entityDefStore.preDeleteByName(entityDef.getName()));
}
}
}
if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
int i = 0;
for (AtlasStructDef structDef : typesDef.getStructDefs()) {
if (StringUtils.isNotBlank(structDef.getGuid())) {
structDefStore.deleteByGuid(structDef.getGuid(), preDeleteStructDefs.get(i));
} else {
structDefStore.deleteByName(structDef.getName(), preDeleteStructDefs.get(i));
}
i++;
}
}
if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
int i = 0;
for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
if (StringUtils.isNotBlank(classifiDef.getGuid())) {
classifiDefStore.deleteByGuid(classifiDef.getGuid(), preDeleteClassifiDefs.get(i));
} else {
classifiDefStore.deleteByName(classifiDef.getName(), preDeleteClassifiDefs.get(i));
}
i++;
}
}
if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
int i = 0;
for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
if (StringUtils.isNotBlank(entityDef.getGuid())) {
entityDefStore.deleteByGuid(entityDef.getGuid(), preDeleteEntityDefs.get(i));
} else {
entityDefStore.deleteByName(entityDef.getName(), preDeleteEntityDefs.get(i));
}
i++;
}
}
if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) {
for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
if (StringUtils.isNotBlank(enumDef.getGuid())) {
enumDefStore.deleteByGuid(enumDef.getGuid());
} else {
enumDefStore.deleteByName(enumDef.getName());
}
}
}
// Remove all from
ttr.removeTypesDef(typesDef);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasTypeDefGraphStore.deleteTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs()));
}
}
use of org.apache.atlas.model.typedef.AtlasEnumDef 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;
}
Aggregations