use of org.apache.atlas.repository.graphdb.AtlasEdge in project atlas by apache.
the class AtlasRelationshipStoreV1 method createRelationship.
private AtlasEdge createRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship) throws AtlasBaseException {
AtlasEdge ret = null;
try {
ret = getRelationshipEdge(end1Vertex, end2Vertex, relationship.getTypeName());
if (ret == null) {
ret = createRelationshipEdge(end1Vertex, end2Vertex, relationship);
AtlasRelationshipType relationType = typeRegistry.getRelationshipTypeByName(relationship.getTypeName());
if (MapUtils.isNotEmpty(relationType.getAllAttributes())) {
for (AtlasAttribute attr : relationType.getAllAttributes().values()) {
String attrName = attr.getName();
String attrVertexProperty = attr.getVertexPropertyName();
Object attrValue = relationship.getAttribute(attrName);
AtlasGraphUtilsV1.setProperty(ret, attrVertexProperty, attrValue);
}
}
} else {
throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_ALREADY_EXISTS, relationship.getTypeName(), AtlasGraphUtilsV1.getIdFromVertex(end1Vertex), AtlasGraphUtilsV1.getIdFromVertex(end2Vertex));
}
} catch (RepositoryException e) {
throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e);
}
return ret;
}
use of org.apache.atlas.repository.graphdb.AtlasEdge in project atlas by apache.
the class AtlasRelationshipStoreV1 method getById.
@Override
@GraphTransaction
public AtlasRelationship getById(String guid) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> getById({})", guid);
}
AtlasRelationship ret;
AtlasEdge edge = graphHelper.getEdgeForGUID(guid);
ret = entityRetriever.mapEdgeToAtlasRelationship(edge);
if (LOG.isDebugEnabled()) {
LOG.debug("<== getById({}): {}", guid, ret);
}
return ret;
}
use of org.apache.atlas.repository.graphdb.AtlasEdge in project atlas by apache.
the class AtlasTypeDefGraphStoreV1 method deleteTypeVertex.
void deleteTypeVertex(AtlasVertex vertex) throws AtlasBaseException {
Iterator<AtlasEdge> inEdges = vertex.getEdges(AtlasEdgeDirection.IN).iterator();
if (inEdges.hasNext()) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES);
}
Iterable<AtlasEdge> edges = vertex.getEdges(AtlasEdgeDirection.OUT);
for (AtlasEdge edge : edges) {
atlasGraph.removeEdge(edge);
}
atlasGraph.removeVertex(vertex);
}
use of org.apache.atlas.repository.graphdb.AtlasEdge in project atlas by apache.
the class AtlasTypeDefGraphStoreV1 method getOrCreateEdge.
AtlasEdge getOrCreateEdge(AtlasVertex outVertex, AtlasVertex inVertex, String edgeLabel) {
AtlasEdge ret = null;
Iterable<AtlasEdge> edges = outVertex.getEdges(AtlasEdgeDirection.OUT, edgeLabel);
for (AtlasEdge edge : edges) {
if (edge.getInVertex().getId().equals(inVertex.getId())) {
ret = edge;
break;
}
}
if (ret == null) {
ret = addEdge(outVertex, inVertex, edgeLabel);
}
return ret;
}
use of org.apache.atlas.repository.graphdb.AtlasEdge in project atlas by apache.
the class AtlasTypeDefGraphStoreV1 method getTypeNamesFromEdges.
/**
* Get the typename properties from the edges, that are associated with the vertex and have the supplied edge label.
* @param vertex
* @param edgeLabel
* @return set of type names
*/
private Set<String> getTypeNamesFromEdges(AtlasVertex vertex, String edgeLabel) {
Set<String> ret = new HashSet<>();
Iterable<AtlasEdge> edges = vertex.getEdges(AtlasEdgeDirection.OUT, edgeLabel);
for (AtlasEdge edge : edges) {
ret.add(edge.getInVertex().getProperty(Constants.TYPENAME_PROPERTY_KEY, String.class));
}
return ret;
}
Aggregations