use of org.apache.atlas.repository.graphdb.AtlasVertex in project incubator-atlas by apache.
the class AtlasGraphUtilsV1 method typeHasInstanceVertex.
public static boolean typeHasInstanceVertex(String typeName) throws AtlasBaseException {
AtlasGraphQuery query = AtlasGraphProvider.getGraphInstance().query().has(Constants.TYPE_NAME_PROPERTY_KEY, AtlasGraphQuery.ComparisionOperator.EQUAL, typeName);
Iterator<AtlasVertex> results = query.vertices().iterator();
boolean hasInstanceVertex = results != null && results.hasNext();
if (LOG.isDebugEnabled()) {
LOG.debug("typeName {} has instance vertex {}", typeName, hasInstanceVertex);
}
return hasInstanceVertex;
}
use of org.apache.atlas.repository.graphdb.AtlasVertex in project incubator-atlas by apache.
the class AtlasEntityDefStoreV1 method getByName.
@Override
public AtlasEntityDef getByName(String name) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEntityDefStoreV1.getByName({})", name);
}
AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
}
vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, TypeCategory.class);
AtlasEntityDef ret = toEntityDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEntityDefStoreV1.getByName({}): {}", name, ret);
}
return ret;
}
use of org.apache.atlas.repository.graphdb.AtlasVertex in project incubator-atlas by apache.
the class AtlasEntityDefStoreV1 method deleteByName.
@Override
public void deleteByName(String name, Object preDeleteResult) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEntityDefStoreV1.deleteByName({}, {})", name, preDeleteResult);
}
AtlasVertex vertex;
if (preDeleteResult == null || !(preDeleteResult instanceof AtlasVertex)) {
vertex = preDeleteByName(name);
} else {
vertex = (AtlasVertex) preDeleteResult;
}
typeDefStore.deleteTypeVertex(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEntityDefStoreV1.deleteByName({}, {})", name, preDeleteResult);
}
}
use of org.apache.atlas.repository.graphdb.AtlasVertex in project incubator-atlas by apache.
the class AtlasEntityDefStoreV1 method preDeleteByGuid.
@Override
public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEntityDefStoreV1.preDeleteByGuid({})", guid);
}
AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);
String typeName = AtlasGraphUtilsV1.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);
if (AtlasGraphUtilsV1.typeHasInstanceVertex(typeName)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName);
}
if (ret == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
}
typeDefStore.deleteTypeVertexOutEdges(ret);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEntityDefStoreV1.preDeleteByGuid({}): {}", guid, ret);
}
return ret;
}
use of org.apache.atlas.repository.graphdb.AtlasVertex in project incubator-atlas by apache.
the class AtlasEntityDefStoreV1 method preDeleteByName.
@Override
public AtlasVertex preDeleteByName(String name) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEntityDefStoreV1.preDeleteByName({})", name);
}
AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
if (AtlasGraphUtilsV1.typeHasInstanceVertex(name)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
}
if (ret == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
}
typeDefStore.deleteTypeVertexOutEdges(ret);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEntityDefStoreV1.preDeleteByName({}): {}", name, ret);
}
return ret;
}
Aggregations