diff --git a/open-metadata-implementation/access-services/governance-engine/governance-engine-server/src/main/java/org/odpi/openmetadata/accessservices/governanceengine/server/handlers/GovernedAssetHandler.java b/open-metadata-implementation/access-services/governance-engine/governance-engine-server/src/main/java/org/odpi/openmetadata/accessservices/governanceengine/server/handlers/GovernedAssetHandler.java index 8117f6bf36f..846bea00aaf 100644 --- a/open-metadata-implementation/access-services/governance-engine/governance-engine-server/src/main/java/org/odpi/openmetadata/accessservices/governanceengine/server/handlers/GovernedAssetHandler.java +++ b/open-metadata-implementation/access-services/governance-engine/governance-engine-server/src/main/java/org/odpi/openmetadata/accessservices/governanceengine/server/handlers/GovernedAssetHandler.java @@ -9,6 +9,7 @@ import org.odpi.openmetadata.accessservices.governanceengine.api.ffdc.exceptions.*; import org.odpi.openmetadata.accessservices.governanceengine.api.objects.GovernanceClassificationUsage; import org.odpi.openmetadata.accessservices.governanceengine.api.objects.GovernedAsset; +import org.odpi.openmetadata.accessservices.governanceengine.server.util.PropertyUtils; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDef; @@ -236,7 +237,9 @@ private void addClassificationInfoToEntry(GovernedAsset entry, EntityDetail enti ip.entrySet().stream().forEach(props -> { // TODO Mapping of types between OMRS and Ranger should be abstracted // TODO Mapping of alpha name is fragile - temporary for initial debug - m.put(props.getKey(), props.getValue().toString()); + //m.put(props.getKey(), props.getValue().toString()); + m.put(props.getKey(), PropertyUtils.getStringForPropertyValue(props.getValue())); + }); } } diff --git a/open-metadata-implementation/access-services/governance-engine/governance-engine-server/src/main/java/org/odpi/openmetadata/accessservices/governanceengine/server/util/PropertyUtils.java b/open-metadata-implementation/access-services/governance-engine/governance-engine-server/src/main/java/org/odpi/openmetadata/accessservices/governanceengine/server/util/PropertyUtils.java new file mode 100644 index 00000000000..bba0cd9fdc0 --- /dev/null +++ b/open-metadata-implementation/access-services/governance-engine/governance-engine-server/src/main/java/org/odpi/openmetadata/accessservices/governanceengine/server/util/PropertyUtils.java @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +package org.odpi.openmetadata.accessservices.governanceengine.server.util; + + +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EnumPropertyValue; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.PrimitivePropertyValue; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.PrimitiveDefCategory; + +public class PropertyUtils { + + public static String getStringForPropertyValue(InstancePropertyValue ipv) { + + // First deal with primitive types + if (ipv instanceof PrimitivePropertyValue) { + PrimitiveDefCategory primtype = + ((PrimitivePropertyValue) ipv).getPrimitiveDefCategory(); + switch (primtype) { + // case may be unnecessary since all of these types we expect .toString() to work 'sensibly' but leaving + // for future decoding options + case OM_PRIMITIVE_TYPE_STRING: + return (String) ((PrimitivePropertyValue) ipv).getPrimitiveValue(); + case OM_PRIMITIVE_TYPE_INT: + case OM_PRIMITIVE_TYPE_BIGDECIMAL: + case OM_PRIMITIVE_TYPE_BIGINTEGER: + case OM_PRIMITIVE_TYPE_BOOLEAN: + case OM_PRIMITIVE_TYPE_BYTE: + case OM_PRIMITIVE_TYPE_CHAR: + case OM_PRIMITIVE_TYPE_DATE: + case OM_PRIMITIVE_TYPE_DOUBLE: + case OM_PRIMITIVE_TYPE_FLOAT: + case OM_PRIMITIVE_TYPE_LONG: + case OM_PRIMITIVE_TYPE_SHORT: + // For these primitive types we will just use tostring + return ((PrimitivePropertyValue)ipv).getPrimitiveValue().toString(); + case OM_PRIMITIVE_TYPE_UNKNOWN: + default: + // We don't know how to convert to string, so will ignore / leave as null + return ""; + } + + } else + { + if (ipv instanceof EnumPropertyValue) { + return ((EnumPropertyValue) ipv).getSymbolicName(); + } + else + { + // We WILL NOT decode ArrayPropertyValue, InstancePropertyValueMock, MapPropertyValue, + // StructPropertyValue + return ""; + } + } + + } + + +}