private List<AtlasVertex> getAssignedEntities(AtlasVertex glossaryTerm) { List<AtlasVertex> ret = new ArrayList<>(); AtlasEntityType termType = getTermEntityType(); AtlasAttribute attr = termType.getRelationshipAttribute(TermSearchProcessor.ATLAS_GLOSSARY_TERM_ATTR_ASSIGNED_ENTITIES); Iterator<AtlasEdge> edges = GraphHelper.getEdgesForLabel(glossaryTerm, attr.getRelationshipEdgeLabel(), attr.getRelationshipEdgeDirection()); boolean excludeDeletedEntities = searchParameters.getExcludeDeletedEntities(); if (edges != null) { while (edges.hasNext()) { AtlasEdge edge = edges.next(); AtlasVertex inVertex = edge.getInVertex(); if (excludeDeletedEntities && AtlasGraphUtilsV2.getState(inVertex) == AtlasEntity.Status.DELETED) { continue; } ret.add(inVertex); } } return ret; }
private void addRelationshipEdgeDirection() { AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2(); AtlasAttribute end1Attribute = end1Type.getRelationshipAttribute(endDef1.getName()); AtlasAttribute end2Attribute = end2Type.getRelationshipAttribute(endDef2.getName()); //default relationship edge direction is end1 (out) -> end2 (in) AtlasRelationshipEdgeDirection end1Direction = OUT; AtlasRelationshipEdgeDirection end2Direction = IN; if (endDef1.getIsLegacyAttribute() && endDef2.getIsLegacyAttribute()) { end2Direction = OUT; } else if (!endDef1.getIsLegacyAttribute() && endDef2.getIsLegacyAttribute()) { end1Direction = IN; end2Direction = OUT; } end1Attribute.setRelationshipEdgeDirection(end1Direction); end2Attribute.setRelationshipEdgeDirection(end2Direction); }
private void addRelationshipEdgeDirection() { AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2(); if (StringUtils.equals(endDef1.getType(), endDef2.getType()) && StringUtils.equals(endDef1.getName(), endDef2.getName())) { AtlasAttribute endAttribute = end1Type.getRelationshipAttribute(endDef1.getName()); endAttribute.setRelationshipEdgeDirection(BOTH); } else { AtlasAttribute end1Attribute = end1Type.getRelationshipAttribute(endDef1.getName()); AtlasAttribute end2Attribute = end2Type.getRelationshipAttribute(endDef2.getName()); //default relationship edge direction is end1 (out) -> end2 (in) AtlasRelationshipEdgeDirection end1Direction = OUT; AtlasRelationshipEdgeDirection end2Direction = IN; if (endDef1.getIsLegacyAttribute() && endDef2.getIsLegacyAttribute()) { end2Direction = OUT; } else if (!endDef1.getIsLegacyAttribute() && endDef2.getIsLegacyAttribute()) { end1Direction = IN; end2Direction = OUT; } end1Attribute.setRelationshipEdgeDirection(end1Direction); end2Attribute.setRelationshipEdgeDirection(end2Direction); } }
private String getRelationshipEdgeLabel(AtlasVertex fromVertex, AtlasVertex toVertex, String relationshipTypeName) { if (LOG.isDebugEnabled()) { LOG.debug("getRelationshipEdgeLabel({})", relationshipTypeName); } AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(relationshipTypeName); String ret = relationshipType.getRelationshipDef().getRelationshipLabel(); AtlasRelationshipEndDef endDef1 = relationshipType.getRelationshipDef().getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipType.getRelationshipDef().getEndDef2(); Set<String> fromVertexTypes = getTypeAndAllSuperTypes(AtlasGraphUtilsV2.getTypeName(fromVertex)); Set<String> toVertexTypes = getTypeAndAllSuperTypes(AtlasGraphUtilsV2.getTypeName(toVertex)); AtlasAttribute attribute = null; // validate entity type and all its supertypes contains relationshipDefs end type // e.g. [hive_process -> hive_table] -> [Process -> DataSet] if (fromVertexTypes.contains(endDef1.getType()) && toVertexTypes.contains(endDef2.getType())) { String attributeName = endDef1.getName(); attribute = relationshipType.getEnd1Type().getRelationshipAttribute(attributeName); } else if (fromVertexTypes.contains(endDef2.getType()) && toVertexTypes.contains(endDef1.getType())) { String attributeName = endDef2.getName(); attribute = relationshipType.getEnd2Type().getRelationshipAttribute(attributeName); } if (attribute != null) { ret = attribute.getRelationshipEdgeLabel(); } return ret; }
private String getRelationshipEdgeLabel(AtlasVertex fromVertex, AtlasVertex toVertex, String relationshipTypeName) { if (LOG.isDebugEnabled()) { LOG.debug("getRelationshipEdgeLabel({})", relationshipTypeName); } AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(relationshipTypeName); String ret = relationshipType.getRelationshipDef().getRelationshipLabel(); AtlasRelationshipEndDef endDef1 = relationshipType.getRelationshipDef().getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipType.getRelationshipDef().getEndDef2(); Set<String> fromVertexTypes = getTypeAndAllSuperTypes(AtlasGraphUtilsV2.getTypeName(fromVertex)); Set<String> toVertexTypes = getTypeAndAllSuperTypes(AtlasGraphUtilsV2.getTypeName(toVertex)); AtlasAttribute attribute = null; // validate entity type and all its supertypes contains relationshipDefs end type // e.g. [hive_process -> hive_table] -> [Process -> DataSet] if (fromVertexTypes.contains(endDef1.getType()) && toVertexTypes.contains(endDef2.getType())) { String attributeName = endDef1.getName(); attribute = relationshipType.getEnd1Type().getRelationshipAttribute(attributeName); } else if (fromVertexTypes.contains(endDef2.getType()) && toVertexTypes.contains(endDef1.getType())) { String attributeName = endDef2.getName(); attribute = relationshipType.getEnd2Type().getRelationshipAttribute(attributeName); } if (attribute != null) { ret = attribute.getRelationshipEdgeLabel(); } return ret; }