@Override public String toString() { return toString(new StringBuilder()).toString(); } }
@Override public String toString() { return toString(new StringBuilder()).toString(); } }
private Object mapVertexToRelationshipAttribute(AtlasVertex entityVertex, AtlasEntityType entityType, AtlasAttribute attribute) throws AtlasBaseException { Object ret = null; AtlasRelationshipDef relationshipDef = graphHelper.getRelationshipDef(entityVertex, entityType, attribute.getName()); if (relationshipDef == null) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID, "relationshipDef is null"); } AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2(); AtlasEntityType endDef1Type = typeRegistry.getEntityTypeByName(endDef1.getType()); AtlasEntityType endDef2Type = typeRegistry.getEntityTypeByName(endDef2.getType()); AtlasRelationshipEndDef attributeEndDef = null; if (endDef1Type.isTypeOrSuperTypeOf(entityType.getTypeName()) && StringUtils.equals(endDef1.getName(), attribute.getName())) { attributeEndDef = endDef1; } else if (endDef2Type.isTypeOrSuperTypeOf(entityType.getTypeName()) && StringUtils.equals(endDef2.getName(), attribute.getName())) { attributeEndDef = endDef2; } if (attributeEndDef == null) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID, relationshipDef.toString()); } switch (attributeEndDef.getCardinality()) { case SINGLE: ret = mapRelatedVertexToObjectId(entityVertex, attribute); break; case LIST: case SET: ret = mapRelationshipArrayAttribute(entityVertex, attribute); break; } return ret; }
private Object mapVertexToRelationshipAttribute(AtlasVertex entityVertex, AtlasEntityType entityType, AtlasAttribute attribute) throws AtlasBaseException { Object ret = null; AtlasRelationshipDef relationshipDef = graphHelper.getRelationshipDef(entityVertex, entityType, attribute.getName()); if (relationshipDef == null) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID, "relationshipDef is null"); } AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2(); AtlasEntityType endDef1Type = typeRegistry.getEntityTypeByName(endDef1.getType()); AtlasEntityType endDef2Type = typeRegistry.getEntityTypeByName(endDef2.getType()); AtlasRelationshipEndDef attributeEndDef = null; if (endDef1Type.isTypeOrSuperTypeOf(entityType.getTypeName()) && StringUtils.equals(endDef1.getName(), attribute.getName())) { attributeEndDef = endDef1; } else if (endDef2Type.isTypeOrSuperTypeOf(entityType.getTypeName()) && StringUtils.equals(endDef2.getName(), attribute.getName())) { attributeEndDef = endDef2; } if (attributeEndDef == null) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID, relationshipDef.toString()); } switch (attributeEndDef.getCardinality()) { case SINGLE: ret = mapRelatedVertexToObjectId(entityVertex, attribute); break; case LIST: case SET: ret = mapRelationshipArrayAttribute(entityVertex, attribute); break; } return ret; }