diff --git a/open-metadata-resources/open-metadata-demos/virtual-data-connector/igc-repository-proxy/src/main/java/org/odpi/openmetadata/virtualdataconnector/igc/connectors/eventmapper/IGCOMRSRepositoryEventMapper.java b/open-metadata-resources/open-metadata-demos/virtual-data-connector/igc-repository-proxy/src/main/java/org/odpi/openmetadata/virtualdataconnector/igc/connectors/eventmapper/IGCOMRSRepositoryEventMapper.java index cfb348a466e..5db9be6a611 100644 --- a/open-metadata-resources/open-metadata-demos/virtual-data-connector/igc-repository-proxy/src/main/java/org/odpi/openmetadata/virtualdataconnector/igc/connectors/eventmapper/IGCOMRSRepositoryEventMapper.java +++ b/open-metadata-resources/open-metadata-demos/virtual-data-connector/igc-repository-proxy/src/main/java/org/odpi/openmetadata/virtualdataconnector/igc/connectors/eventmapper/IGCOMRSRepositoryEventMapper.java @@ -316,11 +316,7 @@ private void processAsset(IGCKafkaEvent igcKafkaEvent) { igcObject.getId(), GLOSSARY_TERM); } else if (igcKafkaEvent.getAction().equals(MODIFY)) { - if (igcObject.getRelatedTerms() != null && igcObject.getRelatedTerms().getItems() != null) { - for (Item item : igcObject.getRelatedTerms().getItems()) { - updateTerm(igcObject, CONFIDENTIALITY, item); - } - } + updateGlossaryTerm(igcObject); } break; case CATEGORY: @@ -373,19 +369,34 @@ private void sendNewRelationshipEvent(Relationship relationship) { } - private void updateTerm(IGCObject igcObject, String classificationTypeName, Item item) { + private void updateGlossaryTerm(IGCObject igcObject) { + + final List classifications = createClassifications(igcObject, CONFIDENTIALITY); + InstanceProperties instanceProperties = getEntityProperties(GLOSSARY_TERM, igcObject); - EntityDetail entity = createClassificationForGlossaryTerm(igcObject.getId(), classificationTypeName, item); + EntityDetail entity = getEntityDetail(igcObject.getId(), + GLOSSARY_TERM, + false, + igcObject.getCreatedBy(), + instanceProperties, + classifications); - repositoryEventProcessor.processClassifiedEntityEvent( + sendUpdateEntityEvent(entity); + } + + private void sendUpdateEntityEvent(EntityDetail entity) { + + repositoryEventProcessor.processUpdatedEntityEvent( sourceName, metadataCollectionId, originatorServerName, originatorServerType, originatorOrganizationName, - entity); + null, + entity + ); - log.info("Classification created " + classificationTypeName + " for " + igcObject.getId()); + log.info("[Entity] update the entity with type = " + entity.getType().getTypeDefName() + "; guid = " + entity.getGUID()); } private void createEntity(IGCColumn igcColumn, String typeName, boolean avoidDuplicate) { @@ -409,15 +420,11 @@ private void createEntity(IGCColumn igcColumn, String typeName, boolean avoidDup private void createEntity(IGCObject igcObject, String typeName, boolean avoidDuplicate) { List classifications = new ArrayList<>(); - if (typeName.equals(GLOSSARY_TERM) && igcObject.getRelatedTerms() != null) { - classifications = getConfidentialityClassification(igcObject); + if (GLOSSARY_TERM.equals(typeName)) { + classifications = createClassifications(igcObject, CONFIDENTIALITY); } - InstanceProperties instanceProperties = getEntityProperties(typeName, - igcObject.getId(), - igcObject.getName(), - igcObject.getShortDescription(), - igcObject.getLongDescription()); + InstanceProperties instanceProperties = getEntityProperties(typeName, igcObject); EntityDetail entityDetail = getEntityDetail(igcObject.getId(), typeName, @@ -558,33 +565,23 @@ private List getPrimaryKeyClassification() { return classificationList; } - private List getConfidentialityClassification(IGCObject igcObject) { + private List createClassifications(IGCObject igcObject, String classificationTypeName) { + List classifications = new ArrayList<>(); - if (igcObject.getRelatedTerms().getItems() != null) { + if (igcObject.getRelatedTerms() != null && igcObject.getRelatedTerms().getItems() != null) { for (Item item : igcObject.getRelatedTerms().getItems()) { - classifications.addAll(getClassification(CONFIDENTIALITY, item.getName())); + final Classification classification = getClassification(classificationTypeName, item.getName()); + if(classification != null){ + classifications.add(classification); + } } } - return classifications; - } - - private EntityDetail createClassificationForGlossaryTerm(String id, String classificationTypeName, Item item) { - List classifications = getClassification(classificationTypeName, item.getName()); - - InstanceProperties instanceProperties = getMandatoryProperty(GLOSSARY_TERM, id); - return getEntityDetail(id, - GLOSSARY_TERM, - false, - null, - instanceProperties, - classifications); + return classifications; } - private List getClassification(String classificationTypeName, String name) { - - List classifications = new ArrayList<>(1); + private Classification getClassification(String classificationTypeName, String name) { try { Classification classification = repositoryHelper.getNewClassification( @@ -598,12 +595,12 @@ private List getClassification(String classificationTypeName, St InstanceProperties classificationProperties = getClassificationProperties(name); classification.setProperties(classificationProperties); - classifications.add(classification); + return classification; } catch (TypeErrorException e) { log.info("Unable to create Classification [type = " + classificationTypeName + "] :" + e.getErrorMessage()); } - return classifications; + return null; } @@ -617,6 +614,35 @@ private InstanceProperties getMandatoryProperty(String typeName, String id) { return instanceProperties; } + private InstanceProperties getEntityProperties(String typeName, IGCObject igcObject) { + + InstanceProperties instanceProperties = getEntityProperties(typeName, + igcObject.getId(), + igcObject.getName(), + igcObject.getShortDescription(), + igcObject.getLongDescription()); + + + if (GLOSSARY_TERM.equals(typeName)) { + Map properties = new HashMap<>(); + + PrimitivePropertyValue example = getStringPropertyValue(igcObject.getExample()); + properties.put("examples", example); + + PrimitivePropertyValue abbreviation = getStringPropertyValue(igcObject.getAbbreviation()); + properties.put("abbreviation", abbreviation); + + PrimitivePropertyValue usage = getStringPropertyValue(igcObject.getUsage()); + properties.put("usage", usage); + + Map instanceProperties1 = instanceProperties.getInstanceProperties(); + properties.putAll(instanceProperties1); + instanceProperties.setInstanceProperties(properties); + } + + return instanceProperties; + } + private InstanceProperties getEntityProperties(String typeName, String id, String name, String shortDescription, String longDescription) { Map properties = new HashMap<>(); @@ -627,9 +653,6 @@ private InstanceProperties getEntityProperties(String typeName, String id, Strin PrimitivePropertyValue displayName = getStringPropertyValue(name); properties.put("displayName", displayName); - PrimitivePropertyValue name_property = getStringPropertyValue(name); - properties.put("name", name_property); - PrimitivePropertyValue summary = getStringPropertyValue(shortDescription); properties.put("summary", summary); diff --git a/open-metadata-resources/open-metadata-demos/virtual-data-connector/igc-repository-proxy/src/main/java/org/odpi/openmetadata/virtualdataconnector/igc/connectors/repositoryconnector/model/IGCObject.java b/open-metadata-resources/open-metadata-demos/virtual-data-connector/igc-repository-proxy/src/main/java/org/odpi/openmetadata/virtualdataconnector/igc/connectors/repositoryconnector/model/IGCObject.java index f278377c376..7bc6079e2d1 100644 --- a/open-metadata-resources/open-metadata-demos/virtual-data-connector/igc-repository-proxy/src/main/java/org/odpi/openmetadata/virtualdataconnector/igc/connectors/repositoryconnector/model/IGCObject.java +++ b/open-metadata-resources/open-metadata-demos/virtual-data-connector/igc-repository-proxy/src/main/java/org/odpi/openmetadata/virtualdataconnector/igc/connectors/repositoryconnector/model/IGCObject.java @@ -21,7 +21,7 @@ "unique", "assigned_to_terms", "related_terms", - "assignedAssets", + "assigned_assets", "_context", "created_on", "allows_null_values", @@ -38,11 +38,14 @@ "odbc_type", "database_table_or_view", "is_a_type_of", - "shortDescription", - "longDescription", - "DatabaseColumns", - "dataConnections", - "dataConnectors" + "short_description", + "long_description", + "database_columns", + "usage", + "example", + "abbreviation", + "data_connections", + "data_connectors" }) public class IGCObject { @@ -103,6 +106,12 @@ public class IGCObject { private DataConnectors dataConnectors; @JsonProperty("data_connections") private DataConnections dataConnections; + @JsonProperty("usage") + private String usage; + @JsonProperty("example") + private String example; + @JsonProperty("abbreviation") + private String abbreviation; @JsonIgnore private Map additionalProperties = new HashMap<>(); @@ -410,4 +419,35 @@ public void setDataConnections(DataConnections dataConnections) { public void setAdditionalProperties(Map additionalProperties) { this.additionalProperties = additionalProperties; } + + @JsonProperty("usage") + public String getUsage() { + return usage; + } + + @JsonProperty("usage") + public void setUsage(String usage) { + this.usage = usage; + } + + @JsonProperty("example") + public String getExample() { + return example; + } + + @JsonProperty("example") + public void setExample(String example) { + this.example = example; + } + + @JsonProperty("abbreviation") + public String getAbbreviation() { + return abbreviation; + } + + @JsonProperty("abbreviation") + public void setAbbreviation(String abbreviation) { + this.abbreviation = abbreviation; + } + } \ No newline at end of file