Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#7147 Update schema attribute in asset manager , changed to ensure that dataType is updated #7221

Merged
merged 31 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c9cfaad
git7147 add classifications to update schema attribute
davidradl Nov 30, 2022
905d164
Merge branch 'main' of https://github.com/odpi/egeria into git7147
davidradl Dec 2, 2022
621aa55
git7147 correct schema attribute update to pick up datatype
davidradl Dec 2, 2022
0fdf2af
git7147 correct schema attribute update to pick up datatype
davidradl Dec 2, 2022
5f7b770
Merge branch 'main' of https://github.com/odpi/egeria into git7147
davidradl Dec 2, 2022
63fd957
git7147 address review comments
davidradl Dec 3, 2022
ead2b01
git7147 address sonatype
davidradl Dec 3, 2022
bbbe891
git7147 amend formula logic
davidradl Dec 4, 2022
e60c400
git7147 align code
davidradl Dec 4, 2022
bccf34d
git7147 amend formula processing
davidradl Dec 4, 2022
2d99e9e
git7147 amend formula processing
davidradl Dec 4, 2022
46108d5
git7147 amend javadoc
davidradl Dec 4, 2022
ac3c3f6
git7147 remove extra file
davidradl Dec 4, 2022
9c62cbb
git7147 remove unneded variables
davidradl Dec 4, 2022
8fa5f7a
Merge branch 'main' of https://github.com/odpi/egeria into git7147
davidradl Dec 5, 2022
dd8eb70
git7147 fix handle formula in create shema attribute
davidradl Dec 5, 2022
d0aff92
git7147 fix merge logic for calculated value
davidradl Dec 6, 2022
c559e70
git7147 switch order of classification checks
davidradl Dec 6, 2022
67bdf8e
Merge branch 'main' of https://github.com/odpi/egeria into git7147
davidradl Dec 6, 2022
71dc39e
git7147 address sonartype null check
davidradl Dec 6, 2022
97e334a
Merge branch 'main' of https://github.com/odpi/egeria into git7147
davidradl Dec 7, 2022
7dccf95
git7147 address review feedback
davidradl Dec 7, 2022
50c6556
git7147 address review feedback
davidradl Dec 7, 2022
257985a
Merge branch 'main' of https://github.com/odpi/egeria into git7147
davidradl Dec 7, 2022
ecb48f1
git7147 address review feedback
davidradl Dec 8, 2022
16198e4
git7147 address review feedback
davidradl Dec 8, 2022
0c76754
git7147 address review feedback
davidradl Dec 8, 2022
dbd0bab
git7147 address review feedback
davidradl Dec 8, 2022
c92de3d
Merge branch 'main' of https://github.com/odpi/egeria into git7147
davidradl Dec 9, 2022
5c96931
Merge branch 'main' into git7147
davidradl Dec 13, 2022
f49778c
Merge branch 'main' into git7147
davidradl Dec 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException;
import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader;
import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship;
Expand Down Expand Up @@ -363,13 +364,15 @@ private SchemaTypeBuilder getSchemaTypeBuilder(SchemaTypeProperties schemaType,
schemaType.getUsage(),
schemaType.getEncodingStandard(),
schemaType.getNamespace(),
schemaType.getFormula(),
schemaType.getAdditionalProperties(),
typeGUID,
typeName,
schemaType.getExtendedProperties(),
repositoryHelper,
serviceName,
serverName);
serverName
);
davidradl marked this conversation as resolved.
Show resolved Hide resolved

if (schemaType instanceof LiteralSchemaTypeProperties)
{
Expand Down Expand Up @@ -1441,7 +1444,8 @@ public void updateSchemaAttribute(String userId,
invalidParameterHandler.validateGUID(schemaAttributeGUID, schemaAttributeGUIDParameterName, methodName);
invalidParameterHandler.validateObject(schemaAttributeProperties, propertiesParameterName, methodName);
invalidParameterHandler.validateName(schemaAttributeProperties.getQualifiedName(), qualifiedNameParameterName, methodName);

SchemaTypeProperties schemaType = schemaAttributeProperties.getSchemaType();
invalidParameterHandler.validateObject(schemaType,"displayName", methodName);
this.validateExternalIdentifier(userId,
schemaAttributeGUID,
schemaAttributeGUIDParameterName,
Expand All @@ -1461,11 +1465,13 @@ public void updateSchemaAttribute(String userId,
getExternalSourceName(correlationProperties),
schemaAttributeGUID,
schemaAttributeGUIDParameterName,
schemaAttributeProperties.getQualifiedName(),
qualifiedNameParameterName,
schemaAttributeBuilder,
schemaAttributeProperties.getTypeName(),
isMergeUpdate,
forLineage,
forDuplicateProcessing,
supportedZones,
schemaAttributeBuilder.getInstanceProperties(methodName),
isMergeUpdate,
effectiveTime,
methodName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ public String createNestedSchemaAttribute(String userId,
{
schemaAttributeBuilder.setAnchors(userId, anchorGUID, methodName);
}
SchemaTypeBuilder schemaTypeBuilder = schemaAttributeBuilder.getSchemaTypeBuilder();

/*
* if there is a a formula then set it into the schemaAttributeBuilder
*/
if (schemaTypeBuilder != null && schemaTypeBuilder.isDerived())
davidradl marked this conversation as resolved.
Show resolved Hide resolved
{
schemaAttributeBuilder.setCalculatedValue(userId, externalSourceGUID, externalSourceName, schemaTypeBuilder.getFormula(), methodName);
}

return this.createNestedSchemaAttribute(userId,
externalSourceGUID,
Expand Down Expand Up @@ -623,8 +632,8 @@ public String createNestedSchemaAttribute(String userId,
invalidParameterHandler.validateName(qualifiedName, qualifiedNameParameterName, methodName);

/*
* Now create the table itself along with its schema type. It also links the resulting table to the database schema type.
* The returned value is the guid of the table.
* Now create the nested schema attribute itself along with its schema type.
* The returned value is the guid of the nested attribute (e.g. table).
*/
String schemaAttributeGUID = this.createBeanInRepository(userId,
externalSourceGUID,
Expand Down Expand Up @@ -1865,6 +1874,166 @@ public void updateSchemaAttribute(String userId,
}
davidradl marked this conversation as resolved.
Show resolved Hide resolved


/**
* Update the properties in a schema attribute.
*
* @param userId calling user
* @param externalSourceGUID unique identifier of software capability representing the caller
* @param externalSourceName unique name of software capability representing the caller
* @param schemaAttributeGUID unique identifier of the metadata element to connect the new schema attribute to
* @param schemaAttributeGUIDParameterName parameter name supplying schemaAttributeGUID
* @param qualifiedName unique identifier for this schema type
* @param qualifiedNameParameterName name of parameter supplying the qualified name
* @param schemaAttributeBuilder schema attribute builder
* @param typeName name of the type of this element - which defines the valid extended properties
* @param isMergeUpdate should the new properties be merged with existing properties (true) or completely replace them (false)?
* @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned
* @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate
* @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now)
* @param methodName calling method
*
* @throws InvalidParameterException one of the parameters is invalid
* @throws UserNotAuthorizedException the user is not authorized to issue this request
* @throws PropertyServerException there is a problem reported in the open metadata server(s)
*/
public void updateSchemaAttribute(String userId,
String externalSourceGUID,
String externalSourceName,
String schemaAttributeGUID,
String schemaAttributeGUIDParameterName,
String qualifiedName,
String qualifiedNameParameterName,
SchemaAttributeBuilder schemaAttributeBuilder,
davidradl marked this conversation as resolved.
Show resolved Hide resolved
String typeName,
boolean isMergeUpdate,
boolean forLineage,
boolean forDuplicateProcessing,
Date effectiveTime,
String methodName) throws InvalidParameterException,
UserNotAuthorizedException,
PropertyServerException
{
invalidParameterHandler.validateUserId(userId, methodName);
invalidParameterHandler.validateGUID(schemaAttributeGUID, schemaAttributeGUIDParameterName, methodName);

if (! isMergeUpdate)
{
invalidParameterHandler.validateName(qualifiedName, qualifiedNameParameterName, methodName);
}

/*
* Check that the type name requested is valid.
*/
String attributeTypeName = OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_NAME;

if (typeName != null)
{
attributeTypeName = typeName;
}

EntityDetail schemaAttributeEntity = this.getEntityFromRepository(userId,
schemaAttributeGUID,
schemaAttributeGUIDParameterName,
attributeTypeName,
null,
null,
forLineage,
forDuplicateProcessing,
effectiveTime,
methodName);

if (schemaAttributeEntity != null)
{
InstanceProperties instanceProperties = schemaAttributeBuilder.getInstanceProperties(methodName);

this.updateBeanInRepository(userId,
externalSourceGUID,
davidradl marked this conversation as resolved.
Show resolved Hide resolved
externalSourceName,
schemaAttributeGUID,
schemaAttributeGUIDParameterName,
OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_GUID,
OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_NAME,
forLineage,
forDuplicateProcessing,
supportedZones,
instanceProperties,
true,
effectiveTime,
methodName);

SchemaTypeBuilder schemaTypeBuilder = schemaAttributeBuilder.getSchemaTypeBuilder();
if (schemaTypeBuilder != null)
{

/*
* The formula is set if the schema attribute is derived. Need to test the merge semantics.
*/
String formula = schemaTypeBuilder.getFormula();
davidradl marked this conversation as resolved.
Show resolved Hide resolved
if (formula == null)
{
// if we have no formula requested and we are not a merge, any existing
// calculated value classification should be cleared
davidradl marked this conversation as resolved.
Show resolved Hide resolved
if (!isMergeUpdate) {
List<Classification> classifications = schemaAttributeEntity.getClassifications();
if (classifications != null && classifications.size() >0)
{
for (Classification classification : classifications)
davidradl marked this conversation as resolved.
Show resolved Hide resolved
{
if (classification.getName().equals(OpenMetadataAPIMapper.CALCULATED_VALUE_CLASSIFICATION_TYPE_NAME)) {
removeClassificationFromRepository(userId,
externalSourceGUID,
externalSourceName,
schemaAttributeGUID,
schemaAttributeGUIDParameterName,
OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_NAME,
OpenMetadataAPIMapper.CALCULATED_VALUE_CLASSIFICATION_TYPE_GUID,
OpenMetadataAPIMapper.CALCULATED_VALUE_CLASSIFICATION_TYPE_NAME,
forLineage,
forDuplicateProcessing,
effectiveTime,
methodName);
}
}
}
}
} else {
davidradl marked this conversation as resolved.
Show resolved Hide resolved
setClassificationInRepository(userId,
externalSourceGUID,
externalSourceName,
schemaAttributeEntity,
schemaAttributeGUIDParameterName,
attributeTypeName,
OpenMetadataAPIMapper.CALCULATED_VALUE_CLASSIFICATION_TYPE_GUID,
OpenMetadataAPIMapper.CALCULATED_VALUE_CLASSIFICATION_TYPE_NAME,
schemaAttributeBuilder.getCalculatedValueProperties(formula, methodName),
isMergeUpdate,
forLineage,
forDuplicateProcessing,
supportedZones,
effectiveTime,
methodName);

}
// todo this logic assumes the schema type is stored as a classification
setClassificationInRepository(userId,
davidradl marked this conversation as resolved.
Show resolved Hide resolved
externalSourceGUID,externalSourceName,
schemaAttributeEntity,
schemaAttributeGUIDParameterName,
attributeTypeName,
OpenMetadataAPIMapper.TYPE_EMBEDDED_ATTRIBUTE_CLASSIFICATION_TYPE_GUID,
OpenMetadataAPIMapper.TYPE_EMBEDDED_ATTRIBUTE_CLASSIFICATION_TYPE_NAME,
schemaTypeBuilder.getTypeEmbeddedInstanceProperties(methodName),
isMergeUpdate,
forLineage,
forDuplicateProcessing,
supportedZones,
effectiveTime,
methodName);
}
}
}


/**
* Update a schema attribute
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,64 @@ public SchemaTypeBuilder(String qualifiedName,
this.encodingStandard = encodingStandard;
this.namespace = namespace;
}
/**
* Constructor supporting all common properties and formula.
*
* @param qualifiedName unique name of schema type itself
* @param displayName new value for the display name.
* @param description description of the schema type.
* @param versionNumber version of the schema type.
* @param isDeprecated is the schema type deprecated
* @param author name of the author
* @param usage guidance on how the schema should be used.
* @param encodingStandard format of the schema.
* @param namespace namespace where the schema is defined.
* @param formula formula for derived properties
* @param additionalProperties additional properties
* @param typeName unique name of schema sub type
* @param typeId unique identifier of the schema subtype
* @param extendedProperties properties from the subtype.
* @param repositoryHelper helper methods
* @param serviceName name of this OMAS
* @param serverName name of local server
*/
public SchemaTypeBuilder(String qualifiedName,
String displayName,
String description,
String versionNumber,
boolean isDeprecated,
String author,
String usage,
String encodingStandard,
String namespace,
String formula,
Map<String, String> additionalProperties,
String typeId,
String typeName,
Map<String, Object> extendedProperties,
OMRSRepositoryHelper repositoryHelper,
String serviceName,
String serverName
)
davidradl marked this conversation as resolved.
Show resolved Hide resolved
{
this(qualifiedName,
displayName,
davidradl marked this conversation as resolved.
Show resolved Hide resolved
description,
versionNumber,
isDeprecated,
author,
usage,
encodingStandard,
namespace,
additionalProperties,
typeId,
typeName,
extendedProperties,
repositoryHelper,
serviceName,
serverName);
setDerivedProperties(formula);
}


/**
Expand Down Expand Up @@ -356,6 +414,15 @@ public boolean isDerived()
{
return (! (formula == null));
}
davidradl marked this conversation as resolved.
Show resolved Hide resolved
/**
* Return the formula expression.
*
* @return string
*/
public String getFormula()
{
return formula;
}


/**
Expand Down