use of org.odpi.openmetadata.repositoryservices.ffdc.exception.RelationshipNotKnownException in project egeria-connector-sas-viya by odpi.
the class MetadataCollection method getRelationship.
@Override
public Relationship getRelationship(String userId, String guid) throws InvalidParameterException, RepositoryErrorException, RelationshipNotKnownException {
final String methodName = "getRelationship";
super.getInstanceParameterValidation(userId, guid, methodName);
// Guid cannot be null here, as validation above ensures it is non-null
SASCatalogGuid sasCatalogGuid = SASCatalogGuid.fromGuid(guid);
if (sasCatalogGuid.isGeneratedInstanceGuid()) {
// If this is a self-referencing relationship, we need to construct it by retrieving the entity (not
// a relationship) from Catalog
Relationship relationship = null;
try {
SASCatalogObject entity = repositoryConnector.getEntityByGUID(sasCatalogGuid.getSASCatalogGuid());
if (entity != null) {
relationship = RelationshipMapping.getSelfReferencingRelationship(repositoryConnector, typeDefStore, sasCatalogGuid, entity);
} else {
raiseRelationshipNotKnownException(ErrorCode.RELATIONSHIP_NOT_KNOWN, methodName, null, guid, methodName, repositoryName);
}
} catch (Exception e) {
raiseRelationshipNotKnownException(ErrorCode.RELATIONSHIP_NOT_KNOWN, methodName, e, guid, methodName, repositoryName);
}
return relationship;
} else {
// Otherwise we should be able to directly retrieve a relationship from Catalog
SASCatalogObject relationship = null;
try {
relationship = this.repositoryConnector.getRelationshipByGUID(sasCatalogGuid.getSASCatalogGuid());
} catch (Exception e) {
raiseRelationshipNotKnownException(ErrorCode.RELATIONSHIP_NOT_KNOWN, methodName, e, guid, methodName, repositoryName);
}
if (relationship == null) {
raiseRelationshipNotKnownException(ErrorCode.RELATIONSHIP_NOT_KNOWN, methodName, null, guid, methodName, repositoryName);
}
RelationshipMapping mapping = new RelationshipMapping(repositoryConnector, typeDefStore, attributeTypeDefStore, sasCatalogGuid, relationship, userId);
return mapping.getRelationship();
}
}
Aggregations