public AtlasRelationshipType(AtlasRelationshipDef relationshipDef) { super(relationshipDef); AtlasRelationshipEndDef end1Def = relationshipDef != null ? relationshipDef.getEndDef1() : null; AtlasRelationshipEndDef end2Def = relationshipDef != null ? relationshipDef.getEndDef2() : null; this.relationshipDef = relationshipDef; this.hasLegacyAttributeEnd = (end1Def != null && end1Def.getIsLegacyAttribute()) || (end2Def != null && end2Def.getIsLegacyAttribute()); }
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); }
@Override public void resolveReferencesPhase2(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { super.resolveReferencesPhase2(typeRegistry); AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2(); String relationshipLabel = null; // if legacyLabel is not specified at both ends, use relationshipDef name as relationship label. // if legacyLabel is specified in any one end, use it as the relationship label for both ends (legacy case). // if legacyLabel is specified at both ends use the respective end's legacyLabel as relationship label (legacy case). if (!endDef1.getIsLegacyAttribute() && !endDef2.getIsLegacyAttribute()) { relationshipLabel = relationshipDef.getRelationshipLabel(); } else if (endDef1.getIsLegacyAttribute() && !endDef2.getIsLegacyAttribute()) { relationshipLabel = getLegacyEdgeLabel(end1Type, endDef1.getName()); } else if (!endDef1.getIsLegacyAttribute() && endDef2.getIsLegacyAttribute()) { relationshipLabel = getLegacyEdgeLabel(end2Type, endDef2.getName()); } addRelationshipAttributeToEndType(endDef1, end1Type, end2Type.getTypeName(), typeRegistry, relationshipLabel); addRelationshipAttributeToEndType(endDef2, end2Type, end1Type.getTypeName(), typeRegistry, relationshipLabel); // add relationship edge direction information addRelationshipEdgeDirection(); }
@Override void resolveReferencesPhase2(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { super.resolveReferencesPhase2(typeRegistry); AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2(); String relationshipLabel = null; // if legacyLabel is not specified at both ends, use relationshipDef name as relationship label. // if legacyLabel is specified in any one end, use it as the relationship label for both ends (legacy case). // if legacyLabel is specified at both ends use the respective end's legacyLabel as relationship label (legacy case). if (!endDef1.getIsLegacyAttribute() && !endDef2.getIsLegacyAttribute()) { relationshipLabel = relationshipDef.getRelationshipLabel(); } else if (endDef1.getIsLegacyAttribute() && !endDef2.getIsLegacyAttribute()) { relationshipLabel = getLegacyEdgeLabel(end1Type, endDef1.getName()); } else if (!endDef1.getIsLegacyAttribute() && endDef2.getIsLegacyAttribute()) { relationshipLabel = getLegacyEdgeLabel(end2Type, endDef2.getName()); } addRelationshipAttributeToEndType(endDef1, end1Type, end2Type.getTypeName(), typeRegistry, relationshipLabel); addRelationshipAttributeToEndType(endDef2, end2Type, end1Type.getTypeName(), typeRegistry, relationshipLabel); // add relationship edge direction information addRelationshipEdgeDirection(); }
private static String getKey(AtlasRelationshipEndDef endDef) { return getKey(endDef.getIsLegacyAttribute(), endDef.getType(), endDef.getName()); }
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 int getLegacyAttributeCount() { int count = 0; for (AtlasRelationshipType rt : typeRegistry.getAllRelationshipTypes()) { AtlasRelationshipDef rd = rt.getRelationshipDef(); if(rd.getEndDef1().getIsLegacyAttribute()) { count++; } if(rd.getEndDef2().getIsLegacyAttribute()) { count++; } } return count; } }
private int getLegacyAttributeCount() { int count = 0; for (AtlasRelationshipType rt : typeRegistry.getAllRelationshipTypes()) { AtlasRelationshipDef rd = rt.getRelationshipDef(); if(rd.getEndDef1().getIsLegacyAttribute()) { count++; } if(rd.getEndDef2().getIsLegacyAttribute()) { count++; } } return count; } }