Search in sources :

Example 1 with RelationshipNotKnownException

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();
    }
}
Also used : SASCatalogObject(org.odpi.openmetadata.connector.sas.repository.connector.mapping.SASCatalogObject) RelationshipMapping(org.odpi.openmetadata.connector.sas.repository.connector.mapping.RelationshipMapping) Relationship(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship) SASCatalogGuid(org.odpi.openmetadata.connector.sas.repository.connector.model.SASCatalogGuid) TypeDefNotSupportedException(org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeDefNotSupportedException) FunctionNotSupportedException(org.odpi.openmetadata.repositoryservices.ffdc.exception.FunctionNotSupportedException) TypeDefConflictException(org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeDefConflictException) TypeDefKnownException(org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeDefKnownException) PagingErrorException(org.odpi.openmetadata.repositoryservices.ffdc.exception.PagingErrorException) RelationshipNotKnownException(org.odpi.openmetadata.repositoryservices.ffdc.exception.RelationshipNotKnownException) PropertyErrorException(org.odpi.openmetadata.repositoryservices.ffdc.exception.PropertyErrorException) InvalidTypeDefException(org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidTypeDefException) EntityNotKnownException(org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException) TypeErrorException(org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeErrorException) UserNotAuthorizedException(org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException) RepositoryErrorException(org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException) InvalidParameterException(org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException)

Aggregations

RelationshipMapping (org.odpi.openmetadata.connector.sas.repository.connector.mapping.RelationshipMapping)1 SASCatalogObject (org.odpi.openmetadata.connector.sas.repository.connector.mapping.SASCatalogObject)1 SASCatalogGuid (org.odpi.openmetadata.connector.sas.repository.connector.model.SASCatalogGuid)1 Relationship (org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship)1 EntityNotKnownException (org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException)1 FunctionNotSupportedException (org.odpi.openmetadata.repositoryservices.ffdc.exception.FunctionNotSupportedException)1 InvalidParameterException (org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException)1 InvalidTypeDefException (org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidTypeDefException)1 PagingErrorException (org.odpi.openmetadata.repositoryservices.ffdc.exception.PagingErrorException)1 PropertyErrorException (org.odpi.openmetadata.repositoryservices.ffdc.exception.PropertyErrorException)1 RelationshipNotKnownException (org.odpi.openmetadata.repositoryservices.ffdc.exception.RelationshipNotKnownException)1 RepositoryErrorException (org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException)1 TypeDefConflictException (org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeDefConflictException)1 TypeDefKnownException (org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeDefKnownException)1 TypeDefNotSupportedException (org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeDefNotSupportedException)1 TypeErrorException (org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeErrorException)1 UserNotAuthorizedException (org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException)1