Skip to content

Commit

Permalink
Merge pull request #7742 from mandy-chessell/code2023
Browse files Browse the repository at this point in the history
Build out schema support
  • Loading branch information
mandy-chessell authored Jun 21, 2023
2 parents d986b09 + c311ca7 commit e7f4c00
Show file tree
Hide file tree
Showing 56 changed files with 11,090 additions and 1,322 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ public enum AssetManagerErrorCode implements ExceptionMessageSet
"provide a scope for the external identifier.",
"Ensure that the asset manager's unique identifier is passed on the request and then retry it."),

/**
* OMAS-ASSET-MANAGER-400-002 At least one of the properties supplied for a new relationship of type {0} are invalid. The {1} exception was returned with error message: {2}
*/
BAD_PARAMETER(400, "OMAS-ASSET-MANAGER-400-002",
"At least one of the properties supplied for a new relationship of type {0} are invalid. The {1} exception was returned with error message: {2}",
"The system is unable to create the requested relationship because it can not parse the properties.",
"Correct the caller's logic so that the properties passed are correctly formatted and retry the request."),

/**
* OMAS-ASSET-MANAGER-404-001 The open metadata repository services are not initialized for the {0} operation
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ public String setupRelatedDataAsset(String userId,
requestBody.setAssetManagerGUID(assetManagerGUID);
requestBody.setAssetManagerName(assetManagerName);
requestBody.setProperties(relationshipProperties);
requestBody.setEffectiveTime(effectiveTime);

final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/data-assets/relationships/{2}/from-asset/{3}/to-asset/{4}?assetManagerIsHome={5}&forLineage={6}&forDuplicateProcessing={7}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ public String createSchemaAttributeFromTemplate(String use
assetManagerName,
externalIdentifierProperties,
methodName));
requestBody.setEffectiveTime(effectiveTime);

final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/schema-elements/{2}/schema-attributes/from-template/{3}?assetManagerIsHome={4}&forLineage={5}&forDuplicateProcessing={6}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,6 @@ public String setupRelatedDataAsset(String userId,
String relationshipTypeGUID = invalidParameterHandler.validateTypeName(relationshipTypeName, null, serviceName, methodName, repositoryHelper);

InstanceProperties instanceProperties = null;
Date effectiveFrom = new Date();
Date effectiveTo = new Date();

if (relationshipProperties != null)
{
Expand Down Expand Up @@ -752,8 +750,8 @@ public String setupRelatedDataAsset(String userId,
relationshipTypeGUID,
relationshipTypeName,
instanceProperties,
effectiveFrom,
effectiveTo,
null,
null,
effectiveTime,
methodName);
}
Expand All @@ -774,8 +772,8 @@ public String setupRelatedDataAsset(String userId,
relationshipTypeGUID,
relationshipTypeName,
instanceProperties,
effectiveFrom,
effectiveTo,
null,
null,
effectiveTime,
methodName);
}
Expand Down Expand Up @@ -846,7 +844,7 @@ public RelationshipElement getAssetRelationship(String userId,


/**
* Concert an OMRS relationship into an Asset Manager's RelationshipElement.
* Convert an OMRS relationship into an Asset Manager's RelationshipElement.
*
* @param relationship retrieved relationship
* @param methodName calling method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.odpi.openmetadata.accessservices.assetmanager.converters.ElementHeaderConverter;
import org.odpi.openmetadata.accessservices.assetmanager.converters.SchemaAttributeConverter;
import org.odpi.openmetadata.accessservices.assetmanager.converters.SchemaTypeConverter;
import org.odpi.openmetadata.accessservices.assetmanager.ffdc.AssetManagerErrorCode;
import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.*;
import org.odpi.openmetadata.accessservices.assetmanager.properties.*;
import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler;
Expand Down Expand Up @@ -597,59 +596,26 @@ public void clearSchemaTypeParent(String userId,
UserNotAuthorizedException,
PropertyServerException
{
final String schemaTypeGUIDParameterName = "schemaTypeGUID";
final String parentElementGUIDParameterName = "parentElementGUID";
final String parentElementTypeParameterName = "parentElementTypeName";

invalidParameterHandler.validateName(parentElementTypeName, parentElementTypeParameterName, methodName);

if ((parentElementTypeName != null) && repositoryHelper.isTypeOf(serviceName,
parentElementTypeName,
OpenMetadataAPIMapper.PORT_TYPE_NAME))
{
schemaTypeHandler.unlinkElementFromElement(userId,
false,
assetManagerGUID,
assetManagerName,
parentElementGUID,
parentElementGUIDParameterName,
parentElementTypeName,
schemaTypeGUID,
schemaTypeGUIDParameterName,
OpenMetadataAPIMapper.SCHEMA_TYPE_TYPE_GUID,
OpenMetadataAPIMapper.SCHEMA_TYPE_TYPE_NAME,
forLineage,
forDuplicateProcessing,
OpenMetadataAPIMapper.PORT_SCHEMA_RELATIONSHIP_TYPE_GUID,
OpenMetadataAPIMapper.PORT_SCHEMA_RELATIONSHIP_TYPE_NAME,
effectiveTime,
methodName);
}
else
{
schemaTypeHandler.unlinkElementFromElement(userId,
false,
assetManagerGUID,
assetManagerName,
parentElementGUID,
parentElementGUIDParameterName,
parentElementTypeName,
schemaTypeGUID,
schemaTypeGUIDParameterName,
OpenMetadataAPIMapper.SCHEMA_TYPE_TYPE_GUID,
OpenMetadataAPIMapper.SCHEMA_TYPE_TYPE_NAME,
forLineage,
forDuplicateProcessing,
OpenMetadataAPIMapper.ASSET_TO_SCHEMA_TYPE_TYPE_GUID,
OpenMetadataAPIMapper.ASSET_TO_SCHEMA_TYPE_TYPE_NAME,
effectiveTime,
methodName);
}
schemaTypeHandler.clearSchemaTypeParent(userId,
assetManagerGUID,
assetManagerName,
schemaTypeGUID,
parentElementGUID,
parentElementTypeName,
forLineage,
forDuplicateProcessing,
effectiveTime,
methodName);
}


/**
* Connect a schema type to a data asset, process or port.
* Create a relationship between two schema elements. The name of the desired relationship, and any properties (including effectivity dates)
* are passed on the API.
*
* @param userId calling user
* @param assetManagerGUID unique identifier of software server capability representing the caller
Expand Down Expand Up @@ -693,57 +659,43 @@ public void setupSchemaElementRelationship(String userId,
final String relationshipTypeParameterName = "relationshipTypeName";
final String propertiesParameterName = "properties";

invalidParameterHandler.validateName(relationshipTypeName, relationshipTypeParameterName, methodName);

String relationshipTypeGUID = invalidParameterHandler.validateTypeName(relationshipTypeName,
null,
serviceName,
methodName,
repositoryHelper);

InstanceProperties instanceProperties = null;

if ((properties != null) && (! properties.getExtendedProperties().isEmpty()))
if (properties != null)
{
try
{
instanceProperties = repositoryHelper.addPropertyMapToInstance(serviceName, null, properties.getExtendedProperties(), methodName);
}
catch (Exception badPropertyException)
{
throw new InvalidParameterException(AssetManagerErrorCode.BAD_PARAMETER.getMessageDefinition(relationshipTypeName,
badPropertyException.getClass().getName(),
badPropertyException.getMessage()),
this.getClass().getName(),
methodName,
badPropertyException,
propertiesParameterName);
}
schemaTypeHandler.setupSchemaElementRelationship(userId,
this.getExternalSourceGUID(assetManagerGUID, assetManagerIsHome),
this.getExternalSourceName(assetManagerName, assetManagerIsHome),
endOneGUID,
endTwoGUID,
relationshipTypeName,
properties.getExtendedProperties(),
effectiveFrom,
effectiveTo,
forLineage,
forDuplicateProcessing,
effectiveTime,
methodName);
}
else
{
schemaTypeHandler.setupSchemaElementRelationship(userId,
this.getExternalSourceGUID(assetManagerGUID, assetManagerIsHome),
this.getExternalSourceName(assetManagerName, assetManagerIsHome),
endOneGUID,
endTwoGUID,
relationshipTypeName,
null,
effectiveFrom,
effectiveTo,
forLineage,
forDuplicateProcessing,
effectiveTime,
methodName);
}

schemaTypeHandler.linkElementToElement(userId,
this.getExternalSourceGUID(assetManagerGUID, assetManagerIsHome),
this.getExternalSourceName(assetManagerName, assetManagerIsHome),
endOneGUID,
endOneParameterName,
OpenMetadataAPIMapper.SCHEMA_ELEMENT_TYPE_NAME,
endTwoGUID,
endTwoParameterName,
OpenMetadataAPIMapper.SCHEMA_ELEMENT_TYPE_NAME,
forLineage,
forDuplicateProcessing,
relationshipTypeGUID,
relationshipTypeName,
instanceProperties,
effectiveFrom,
effectiveTo,
effectiveTime,
methodName);
}


/**
* Remove the relationship between a schema type and its parent data asset, process or port.
* Remove a relationship between two schema elements. The name of the desired relationship is passed on the API.
*
* @param userId calling user
* @param assetManagerGUID unique identifier of software server capability representing the caller
Expand Down Expand Up @@ -773,35 +725,20 @@ public void clearSchemaElementRelationship(String userId,
UserNotAuthorizedException,
PropertyServerException
{
final String endOneParameterName = "endOneGUID";
final String endTwoParameterName = "endTwoGUID";
final String relationshipTypeParameterName = "relationshipTypeName";

invalidParameterHandler.validateName(relationshipTypeName, relationshipTypeParameterName, methodName);

String relationshipTypeGUID = invalidParameterHandler.validateTypeName(relationshipTypeName,
null,
serviceName,
methodName,
repositoryHelper);

schemaTypeHandler.unlinkElementFromElement(userId,
false,
assetManagerGUID,
assetManagerName,
endOneGUID,
endOneParameterName,
OpenMetadataAPIMapper.SCHEMA_ELEMENT_TYPE_NAME,
endTwoGUID,
endTwoParameterName,
OpenMetadataAPIMapper.SCHEMA_ELEMENT_TYPE_GUID,
OpenMetadataAPIMapper.SCHEMA_ELEMENT_TYPE_NAME,
forLineage,
forDuplicateProcessing,
relationshipTypeGUID,
relationshipTypeName,
effectiveTime,
methodName);
schemaTypeHandler.clearSchemaElementRelationship(userId,
assetManagerGUID,
assetManagerName,
endOneGUID,
endTwoGUID,
relationshipTypeName,
forLineage,
forDuplicateProcessing,
effectiveTime,
methodName);
}


Expand Down Expand Up @@ -2084,7 +2021,7 @@ public List<SchemaAttributeElement> getNestedAttributes(String userId,
UserNotAuthorizedException,
PropertyServerException
{
final String elementGUIDParameterName = "schemaAttributeGUID";
final String elementGUIDParameterName = "parentSchemaElementGUID";

List<SchemaAttributeElement> results = schemaAttributeHandler.getAttachedSchemaAttributes(userId,
parentSchemaElementGUID,
Expand Down
Loading

0 comments on commit e7f4c00

Please sign in to comment.