use of org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry in project incubator-atlas by apache.
the class TestAtlasTypeRegistry method addType.
private boolean addType(AtlasTypeRegistry typeRegistry, AtlasBaseTypeDef typeDef) {
boolean ret = false;
AtlasTransientTypeRegistry ttr = null;
try {
ttr = typeRegistry.lockTypeRegistryForUpdate();
ttr.addType(typeDef);
ret = true;
} catch (AtlasBaseException excp) {
// ignore
} finally {
typeRegistry.releaseTypeRegistryForUpdate(ttr, ret);
}
return ret;
}
use of org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry in project incubator-atlas by apache.
the class RestUtilsTest method createRegistry.
private AtlasTypeRegistry createRegistry(List<AtlasEntityDef> toConvert) throws AtlasBaseException {
AtlasTypeRegistry reg = new AtlasTypeRegistry();
AtlasTransientTypeRegistry tmp = reg.lockTypeRegistryForUpdate();
tmp.addTypes(toConvert);
reg.releaseTypeRegistryForUpdate(tmp, true);
return reg;
}
use of org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry 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.type.AtlasTypeRegistry.AtlasTransientTypeRegistry in project incubator-atlas by apache.
the class AtlasTypeDefGraphStore method updateEnumDefByGuid.
@Override
@GraphTransaction
public AtlasEnumDef updateEnumDefByGuid(String guid, AtlasEnumDef enumDef) throws AtlasBaseException {
AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit();
tryUpdateByGUID(guid, enumDef, ttr);
return getEnumDefStore(ttr).updateByGuid(guid, enumDef);
}
use of org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry in project incubator-atlas by apache.
the class AtlasTypeDefGraphStore method updateEntityDefByName.
@Override
@GraphTransaction
public AtlasEntityDef updateEntityDefByName(String name, AtlasEntityDef entityDef) throws AtlasBaseException {
AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit();
tryUpdateByName(name, entityDef, ttr);
return getEntityDefStore(ttr).updateByName(name, entityDef);
}
Aggregations