use of org.odpi.openmetadata.connector.sas.repository.connector.mapping.RelationshipMapping in project egeria-connector-sas-viya by odpi.
the class RepositoryEventMapper method getMappedRelationship.
/**
* Retrieve the mapped OMRS relationship for the provided SAS Catalog relationship.
*
* @param catalogRelationship the SAS Catalog relationship to translate to OMRS
* @return Relationship
*/
private Relationship getMappedRelationship(SASCatalogObject catalogRelationship) {
// TODO: this needs to handle both self-referencing (generated) relationships and "normal" relationships,
// currently only handling the latter?
Relationship result = null;
RelationshipMapping mapping = new RelationshipMapping(catalogOMRSRepositoryConnector, catalogOMRSMetadataCollection.getTypeDefStore(), null, /*catalogOMRSMetadataCollection.getAttributeTypeDefStore(),*/
new SASCatalogGuid(catalogRelationship.getGuid(), null), catalogRelationship, null);
try {
result = mapping.getRelationship();
} catch (RepositoryErrorException e) {
log.error("Unable to map relationship to OMRS Relationship: {}", catalogRelationship, e);
}
return result;
}
use of org.odpi.openmetadata.connector.sas.repository.connector.mapping.RelationshipMapping 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