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

Add glossary workflow sample #7695

Merged
merged 2 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -825,6 +825,7 @@ protected String createReferenceableFromTemplateWithParent(String
externalIdentifierProperties,
methodName));
requestBody.setParentGUID(parentGUID);
requestBody.setElementProperties(templateProperties);

GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName,
urlTemplate + requestParamsURLTemplate,
Expand Down Expand Up @@ -895,6 +896,7 @@ protected String createReferenceableFromTemplateWithParent(String
externalIdentifierProperties,
methodName));
requestBody.setParentGUID(parentGUID);
requestBody.setElementProperties(templateProperties);

GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName,
urlTemplate + requestParamsURLTemplate,
Expand Down Expand Up @@ -967,6 +969,7 @@ protected String createFeedbackFromTemplateWithParent(String
externalIdentifierProperties,
methodName));
requestBody.setParentGUID(parentGUID);
requestBody.setElementProperties(templateProperties);

GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName,
urlTemplate + requestParamsURLTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,7 @@ public String createGlossaryTermFromTemplate(String userId
externalIdentifierProperties,
methodName));
requestBody.setParentGUID(glossaryGUID);
requestBody.setElementProperties(templateProperties);

GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName,
urlTemplate + requestParamsURLTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,18 @@ public VoidResponse setGlossaryAsEditingGlossary(String serve
requestBody.getEffectiveTime(),
methodName);
}
else if (requestBody.getProperties() == null)
{
GlossaryExchangeHandler handler = instanceHandler.getGlossaryExchangeHandler(userId, serverName, methodName);

handler.setGlossaryAsEditingGlossary(userId,
requestBody.getMetadataCorrelationProperties(),
glossaryGUID,
null,
forLineage,
forDuplicateProcessing,
requestBody.getEffectiveTime(),
methodName); }
else
{
restExceptionHandler.handleInvalidPropertiesObject(EditingGlossaryProperties.class.getName(), methodName);
Expand Down Expand Up @@ -508,6 +520,19 @@ public VoidResponse setGlossaryAsStagingGlossary(String serve
requestBody.getEffectiveTime(),
methodName);
}
else if (requestBody.getProperties() == null)
{
GlossaryExchangeHandler handler = instanceHandler.getGlossaryExchangeHandler(userId, serverName, methodName);

handler.setGlossaryAsStagingGlossary(userId,
requestBody.getMetadataCorrelationProperties(),
glossaryGUID,
null,
forLineage,
forDuplicateProcessing,
requestBody.getEffectiveTime(),
methodName);
}
else
{
restExceptionHandler.handleInvalidPropertiesObject(StagingGlossaryProperties.class.getName(), methodName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.ClassificationOrigin;
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.InstanceStatus;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipDef;
Expand All @@ -22,6 +23,7 @@

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -593,6 +595,33 @@ public void updateGlossaryTermFromTemplate(String userId,

if (templateEntity != null)
{
InstanceProperties templateProperties = null;
if (templateEntity.getProperties() != null)
{
templateProperties = new InstanceProperties();

templateProperties.setEffectiveFromTime(templateEntity.getProperties().getEffectiveFromTime());
templateProperties.setEffectiveToTime(templateEntity.getProperties().getEffectiveToTime());

if (templateEntity.getProperties().getPropertyCount() > 0)
{
Iterator<String> propertyNames = templateEntity.getProperties().getPropertyNames();

while (propertyNames.hasNext())
{
String propertyName = propertyNames.next();

/*
* Ignore qualified name.
*/
if (! OpenMetadataAPIMapper.QUALIFIED_NAME_PROPERTY_NAME.equals(propertyName))
{
templateProperties.setProperty(propertyName, templateEntity.getProperties().getPropertyValue(propertyName));
}
}
}
}

this.updateBeanInRepository(userId,
externalSourceGUID,
externalSourceName,
Expand All @@ -603,41 +632,46 @@ public void updateGlossaryTermFromTemplate(String userId,
forLineage,
forDuplicateProcessing,
supportedZones,
templateEntity.getProperties(),
templateProperties,
isMergeProperties,
effectiveTime,
methodName);

List<String> updatedClassifications = new ArrayList<>();
List<String> updatedClassifications = new ArrayList<>();

if (templateEntity.getClassifications() != null)
{
for (Classification classification : templateEntity.getClassifications())
{
this.setClassificationInRepository(userId,
externalSourceGUID,
externalSourceName,
termEntity,
glossaryTermGUIDParameterName,
OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME,
classification.getType().getTypeDefGUID(),
classification.getType().getTypeDefName(),
classification.getProperties(),
isMergeProperties,
forLineage,
forDuplicateProcessing,
supportedZones,
effectiveTime,
methodName);
updatedClassifications.add(classification.getName());
if (! OpenMetadataAPIMapper.ANCHORS_CLASSIFICATION_TYPE_NAME.equals(classification.getName()))
{
this.setClassificationInRepository(userId,
externalSourceGUID,
externalSourceName,
termEntity,
glossaryTermGUIDParameterName,
OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME,
classification.getType().getTypeDefGUID(),
classification.getType().getTypeDefName(),
classification.getProperties(),
isMergeProperties,
forLineage,
forDuplicateProcessing,
supportedZones,
effectiveTime,
methodName);

updatedClassifications.add(classification.getName());
}
}
}

if ((! isMergeClassifications) && (termEntity.getClassifications() != null))
{
for (Classification classification : termEntity.getClassifications())
{
if (! updatedClassifications.contains(classification.getName()))
if ((! OpenMetadataAPIMapper.ANCHORS_CLASSIFICATION_TYPE_NAME.equals(classification.getName())) &&
(! updatedClassifications.contains(classification.getName())))
{
this.removeClassificationFromRepository(userId,
externalSourceGUID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ public void setClassification(Classification newClassification)
}


/**
* Return whether a particular classification has been set up by the caller.
*
* @param classificationName name of the classification to test for
* @return boolean
*/
public boolean isClassificationSet(String classificationName)
{
if (newClassifications.get(classificationName) != null)
{
return true;
}

return false;
}


/**
* Set up the list of classifications from a template entity.
Expand Down Expand Up @@ -195,7 +211,7 @@ public void setTemplateClassifications(String userId,

for (Classification templateClassification : templateClassifications)
{
if (templateClassification != null)
if ((templateClassification != null) && (! OpenMetadataAPIMapper.ANCHORS_CLASSIFICATION_TYPE_NAME.equals(templateClassification.getName())))
{
try
{
Expand Down Expand Up @@ -227,6 +243,7 @@ public void setTemplateClassifications(String userId,
null,
templateClassification.getProperties());
}

this.newClassifications.put(classification.getName(), classification);
}
catch (TypeErrorException error)
Expand All @@ -238,6 +255,7 @@ public void setTemplateClassifications(String userId,
}
}


/**
* Set up the "TemplateSubstitute" classification for this entity. This is used when a new entity is being created, and it is known to be
* created as a template substitute.
Expand Down Expand Up @@ -270,7 +288,6 @@ public void setTemplateSubstitute(String userId,
}



/**
* Set up the "Anchors" classification for this entity. This is used when a new entity is being created, and it is known to be
* connected to a specific anchor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5759,7 +5759,7 @@ private TemplateProgress createBeanFromTemplate(String us
templateProgress.templateAnchorGUIDs.add(templateAnchorEntity.getGUID());
}

if (templateProgress.beanAnchorGUID != null)
if ((templateProgress.beanAnchorGUID != null) && (! propertyBuilder.isClassificationSet(OpenMetadataAPIMapper.ANCHORS_CLASSIFICATION_TYPE_NAME)))
{
/*
* A bean anchor has been set up on a previous iteration. This value is typically set when the top-level bean is created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The following samples show how to use the Open Metadata Access Services (OMASs)
* **[Governance Program OMAS Client Samples](governance-program-client-samples)** illustrates how to create and maintain
definitions related to a governance program.

* **[Glossary Workflow Samples](glossary-workflow-samples)** show how to manage updates to glossary terms.

* **[Subject Area OMAS Client Samples](subject-area-client-samples)** illustrates how to create and maintain
semantic information in glossaries. This includes glossary terms and subject areas.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Egeria project. -->

# Glossary management samples

The glossary management samples show different styles of managing changes to glossary terms.
They are illustrated through the [Asset Manager OMAS glossary management API](https://odpi.github.io/egeria/org/odpi/openmetadata/accessservices/assetmanager/api/management/GlossaryManagementInterface.html).
This interface is used by [Glossary Workflow OMVS](https://egeria-project.org/services/omvs/glossary-workflow/overview) to provide the backend services for UI that provide complex management interfaces.

----
License: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/),
Copyright Contributors to the Egeria project.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Contributors to the ODPi Egeria project.
*/

plugins {
id 'application'
id "com.github.johnrengelman.shadow"
}

dependencies {
implementation project(':open-metadata-implementation:access-services:asset-manager:asset-manager-client')
compileOnly project(':open-metadata-implementation:access-services:asset-manager:asset-manager-api')
implementation project(':open-metadata-implementation:frameworks:open-connector-framework')
runtimeOnly 'ch.qos.logback:logback-classic'
implementation project(':open-metadata-implementation:adapters:authentication-plugins:http-helper')
compileOnly 'com.fasterxml.jackson.core:jackson-annotations'
}

description = 'Glossary workflow samples'

java {
withJavadocJar()
}

shadowJar {
mainClassName = 'org.odpi.openmetadata.accessservices.assetmanager.samples.glossaryworkflow.GlossaryWorkflowSamples'
archiveClassifier = 'jar-with-dependencies'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright Contributors to the ODPi Egeria project. */
package org.odpi.openmetadata.accessservices.assetmanager.samples.glossaryworkflow;

import org.odpi.openmetadata.accessservices.assetmanager.client.management.GlossaryManagementClient;
import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryProperties;
import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermProperties;
import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermStatus;
import org.odpi.openmetadata.http.HttpHelper;


/**
* GlossaryWorkflowSamples demonstrates different patterns of managing controlled updates to glossary terms.
* There are 4 patterns:
*
* <ul>
* <li>Temporary Editing Glossary</li>
* <li>Rolling Editing Glossary</li>
* <li>Temporary Staging Glossary</li>
* <li>Rolling Staging Glossary</li>
* </ul>
*/
public class GlossaryWorkflowSamples
{
/**
* Main program that controls the operation of the sample. The parameters are passed space separated.
*
* @param args 1. server name, 2. URL root for the server, 3. client userId
*/
public static void main(String[] args)
{
String serverName = "cocoMDS1";
String platformURLRoot = "https://localhost:9443";
String clientUserId = "peterprofile";

if (args != null)
{
if (args.length > 0)
{
serverName = args[0];
}

if (args.length > 2)
{
platformURLRoot = args[2];
}

if (args.length > 3)
{
clientUserId = args[3];
}
}

HttpHelper.noStrictSSL();

System.out.println("===================================");
System.out.println("Temporary Editing Glossary Sample ");
System.out.println("===================================");
System.out.println("Running against server: " + serverName + " at " + platformURLRoot);
System.out.println("Using userId: " + clientUserId);
System.out.println();

try
{
TemporaryEditingGlossary temporaryEditingGlossary = new TemporaryEditingGlossary(serverName, platformURLRoot, clientUserId);
temporaryEditingGlossary.run();
}
catch (Exception error)
{
System.out.println("Exception: " + error.getClass().getName() + " with message " + error.getMessage());
System.exit(-1);
}
}
}
Loading