diff --git a/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-demo-onboarding-clinical-trial.http b/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-demo-onboarding-clinical-trial.http index 262b421c000..bde41aab24e 100644 --- a/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-demo-onboarding-clinical-trial.http +++ b/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-demo-onboarding-clinical-trial.http @@ -1,5 +1,7 @@ @ucURL=http://localhost:8080 +#@ucURL=http://egeria.pdr-associates.com:8070 + @baseURL=https://localhost:9443 @viewServer=view-server @@ -548,6 +550,25 @@ Content-Type: application/json } +### +# @name initiateGovernanceActionProcess certify-hospital +# Using the named governance action process as a template, initiate a chain of engine actions. + +POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/automated-curation/governance-action-processes/initiate +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "processQualifiedName": "ClinicalTrials:PROJ-CT-TBDF:certify-hospital", + "actionTargets": [ + { + "class" : "NewActionTarget", + "actionTargetName": "hospital", + "actionTargetGUID": "{{hamptonHospitalGUID}}" + }] +} + + ### #=============================================== # Onboard the hospitals diff --git a/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-setup-coco-data-lake.http b/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-setup-coco-data-lake.http index f1aa031a281..a4104f8e959 100644 --- a/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-setup-coco-data-lake.http +++ b/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-setup-coco-data-lake.http @@ -1,8 +1,8 @@ ### # Create the basic structure of the CocoDataLake # -@ucURL=http://localhost:8080 -#@ucURL=http://egeria.pdr-associates.com:8070 +#@ucURL=http://localhost:8080 +@ucURL=http://egeria.pdr-associates.com:8070 @cocoDataLake=/Users/amandachessell/coco_data_lake @@ -67,16 +67,6 @@ Content-Type: application/json } -### -# @name create schema -POST {{ucURL}}/api/2.1/unity-catalog/schemas -Content-Type: application/json - -{ - "name": "teddy_bear_drop_foot", - "catalog_name" : "clinical_trials", - "comment": "Observational study on the Teddy Bear Drop Foot condition." -} ### #---------------------------------------------------------------------------- diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/openlineage-integration-connectors/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/openlineage/GovernanceActionOpenLineageIntegrationConnector.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/openlineage-integration-connectors/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/openlineage/GovernanceActionOpenLineageIntegrationConnector.java index a0024ae35c3..cd7e3c3a5cd 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/openlineage-integration-connectors/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/openlineage/GovernanceActionOpenLineageIntegrationConnector.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/openlineage-integration-connectors/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/openlineage/GovernanceActionOpenLineageIntegrationConnector.java @@ -7,30 +7,19 @@ import org.odpi.openmetadata.accessservices.assetmanager.events.AssetManagerOutTopicEvent; import org.odpi.openmetadata.adapters.connectors.integration.openlineage.ffdc.OpenLineageIntegrationConnectorAuditCode; import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; -import org.odpi.openmetadata.frameworks.openmetadata.metadataelements.ElementClassification; -import org.odpi.openmetadata.frameworks.openmetadata.metadataelements.ElementHeader; import org.odpi.openmetadata.frameworks.governanceaction.properties.ActionTargetElement; import org.odpi.openmetadata.frameworks.governanceaction.properties.EngineActionElement; +import org.odpi.openmetadata.frameworks.openmetadata.enums.EngineActionStatus; +import org.odpi.openmetadata.frameworks.openmetadata.metadataelements.ElementHeader; +import org.odpi.openmetadata.frameworks.openmetadata.types.OpenMetadataProperty; +import org.odpi.openmetadata.frameworks.openmetadata.types.OpenMetadataType; import org.odpi.openmetadata.integrationservices.lineage.connector.LineageIntegratorConnector; -import org.odpi.openmetadata.integrationservices.lineage.connector.LineageIntegratorContext; -import org.odpi.openmetadata.integrationservices.lineage.properties.OpenLineageInputDataSet; -import org.odpi.openmetadata.integrationservices.lineage.properties.OpenLineageJob; -import org.odpi.openmetadata.integrationservices.lineage.properties.OpenLineageNominalTimeRunFacet; -import org.odpi.openmetadata.integrationservices.lineage.properties.OpenLineageOutputDataSet; -import org.odpi.openmetadata.integrationservices.lineage.properties.OpenLineageParentRunFacet; -import org.odpi.openmetadata.integrationservices.lineage.properties.OpenLineageParentRunFacetJob; -import org.odpi.openmetadata.integrationservices.lineage.properties.OpenLineageParentRunFacetRun; -import org.odpi.openmetadata.integrationservices.lineage.properties.OpenLineageRun; -import org.odpi.openmetadata.integrationservices.lineage.properties.OpenLineageRunEvent; -import org.odpi.openmetadata.integrationservices.lineage.properties.OpenLineageRunFacets; +import org.odpi.openmetadata.integrationservices.lineage.properties.*; import java.net.URI; import java.time.ZoneId; import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; +import java.util.*; /** @@ -40,14 +29,8 @@ */ public class GovernanceActionOpenLineageIntegrationConnector extends LineageIntegratorConnector implements AssetManagerEventListener { - private static final String inProgressGovernanceActionStatus = "InProgress"; - private static final String actionedGovernanceActionStatus = "Actioned"; - private static final String invalidGovernanceActionStatus = "Invalid"; - private static final String failedGovernanceActionStatus = "Failed"; - private static final URI producer = URI.create("https://egeria-project.org/"); private final ZoneId zoneId = ZoneId.systemDefault(); - private LineageIntegratorContext myContext = null; /** @@ -70,25 +53,20 @@ public synchronized void start() throws ConnectorCheckedException final String methodName = "start"; - myContext = super.getContext(); - - if (myContext != null) + try { - try + super.getContext().registerListener(this); + } + catch (Exception error) + { + if (auditLog != null) { - myContext.registerListener(this); - } - catch (Exception error) - { - if (auditLog != null) - { - auditLog.logException(methodName, - OpenLineageIntegrationConnectorAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, - error.getClass().getName(), - methodName, - error.getMessage()), - error); - } + auditLog.logException(methodName, + OpenLineageIntegrationConnectorAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + error); } } } @@ -118,35 +96,28 @@ public void processEvent(AssetManagerOutTopicEvent event) ElementHeader elementHeader = event.getElementHeader(); if (((event.getEventType() == AssetManagerEventType.NEW_ELEMENT_CREATED) || + (event.getEventType() == AssetManagerEventType.REFRESH_ELEMENT_EVENT) || (event.getEventType() == AssetManagerEventType.ELEMENT_UPDATED)) && - ("GovernanceAction".equals(elementHeader.getType().getTypeName()))) + (propertyHelper.isTypeOf(elementHeader, OpenMetadataType.ENGINE_ACTION.typeName))) { try { - String previousActionStatus = ""; - - if (event.getPreviousElementProperties() != null) - { - previousActionStatus = event.getPreviousElementProperties().get("actionStatus").toString(); - } - - String currentActionStatus = event.getElementProperties().get("actionStatus").toString(); + String previousActionStatus = getActionStatus(event.getPreviousElementProperties()); + String currentActionStatus = getActionStatus(event.getPreviousElementProperties()); /* * Only output an event if the status has changed. */ if (! previousActionStatus.equals(currentActionStatus)) { - if ((inProgressGovernanceActionStatus.equals(currentActionStatus)) || - (actionedGovernanceActionStatus.equals(currentActionStatus)) || - (failedGovernanceActionStatus.equals(currentActionStatus)) || - (invalidGovernanceActionStatus.equals(currentActionStatus))) + if ((EngineActionStatus.IN_PROGRESS.getName().equals(currentActionStatus)) || + (EngineActionStatus.ACTIONED.getName().equals(currentActionStatus)) || + (EngineActionStatus.FAILED.getName().equals(currentActionStatus)) || + (EngineActionStatus.INVALID.getName().equals(currentActionStatus))) { - EngineActionElement engineAction = myContext.getEngineAction(elementHeader.getGUID()); + EngineActionElement engineAction = super.getContext().getEngineAction(elementHeader.getGUID()); - publishOpenLineageEvent(currentActionStatus, - event.getEventTime(), - engineAction); + publishOpenLineageEvent(currentActionStatus, event.getEventTime(), engineAction); } } @@ -169,38 +140,53 @@ public void processEvent(AssetManagerOutTopicEvent event) } } + /** + * Return the action status from the event. + * + * @param elementProperties properties for the engine action + * @return action status as a string + */ + private String getActionStatus(Map elementProperties) + { + if ((elementProperties != null) && (elementProperties.get(OpenMetadataProperty.ACTION_STATUS.name) != null)) + { + return elementProperties.get(OpenMetadataProperty.ACTION_STATUS.name).toString(); + } + + return ""; + } + /** * Add information about the governance action into an OpenLineage event and publish it. * - * @param governanceActionStatus the status from the entity at the time of the event + * @param engineActionStatus the status from the entity at the time of the event * @param eventTime the time of the change to the entity * @param engineAction source information + * @exception ConnectorCheckedException connector has been asked to stop */ - private void publishOpenLineageEvent(String governanceActionStatus, + private void publishOpenLineageEvent(String engineActionStatus, Date eventTime, - EngineActionElement engineAction) + EngineActionElement engineAction) throws ConnectorCheckedException { OpenLineageRunEvent event = new OpenLineageRunEvent(); event.setProducer(producer); event.setEventTime(getTimeStamp(eventTime)); - - - if (inProgressGovernanceActionStatus.equals(governanceActionStatus)) + if (EngineActionStatus.IN_PROGRESS.getName().equals(engineActionStatus)) { event.setEventType("START"); } - else if (actionedGovernanceActionStatus.equals(governanceActionStatus)) + else if (EngineActionStatus.ACTIONED.getName().equals(engineActionStatus)) { event.setEventType("COMPLETE"); } - else if (failedGovernanceActionStatus.equals(governanceActionStatus)) + else if (EngineActionStatus.FAILED.getName().equals(engineActionStatus)) { event.setEventType("FAIL"); } - else if (invalidGovernanceActionStatus.equals(governanceActionStatus)) + else if (EngineActionStatus.INVALID.getName().equals(engineActionStatus)) { event.setEventType("ABORT"); } @@ -236,29 +222,12 @@ else if (invalidGovernanceActionStatus.equals(governanceActionStatus)) run.setRunId(UUID.fromString(engineAction.getElementHeader().getGUID())); - String anchorGUID = null; - - List classifications = engineAction.getElementHeader().getClassifications(); - - if (classifications != null) - { - for (ElementClassification classification : classifications) - { - if ((classification != null) && ("Anchors".equals(classification.getClassificationName()))) - { - if (classification.getClassificationProperties() != null) - { - anchorGUID = classification.getClassificationProperties().get("anchorGUID").toString(); - } - } - } - } + String anchorGUID = propertyHelper.getAnchorGUID(engineAction.getElementHeader()); OpenLineageRunFacets runFacets = new OpenLineageRunFacets(); if (anchorGUID != null) { - OpenLineageParentRunFacet parentRunFacet = new OpenLineageParentRunFacet(); OpenLineageParentRunFacetJob parentRunFacetJob = new OpenLineageParentRunFacetJob(); OpenLineageParentRunFacetRun parentRunFacetRun = new OpenLineageParentRunFacetRun(); @@ -376,7 +345,7 @@ else if (invalidGovernanceActionStatus.equals(governanceActionStatus)) event.setOutputs(outputDataSets); } - myContext.publishOpenLineageRunEvent(event); + super.getContext().publishOpenLineageRunEvent(event); } diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/EngineActionHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/EngineActionHandler.java index 8b59b62af71..821d46f2edb 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/EngineActionHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/EngineActionHandler.java @@ -565,7 +565,7 @@ private String prepareEngineActionFromType(String userId, * @param serviceSupportedZones supported zones for calling service * @param methodName calling method * - * @return unique identifier of the first governance action + * @return unique identifier of the governance action process instance * @throws InvalidParameterException null qualified name * @throws UserNotAuthorizedException this governance service is not authorized to create a governance action * @throws PropertyServerException there is a problem with the metadata store @@ -721,24 +721,69 @@ public String initiateGovernanceActionProcess(String userId, newTargetsForAction = null; } - return prepareEngineActionFromProcessStep(userId, - null, - governanceActionProcessStepGUID, - governanceActionProcessStepGUIDParameterName, - guard, - false, - requestedStartDate, - null, - userId, - combinedRequestParameters, - requestSourceGUIDs, - newTargetsForAction, - processQualifiedName + UUID.randomUUID(), // Unique identifier for the process instance - processQualifiedName, - originatorServiceName, - originatorEngineName, - serviceSupportedZones, - methodName); + /* + * Create a process instance for this run of the process. + */ + Date processInstanceStartTime = new Date(); + + String processInstanceQualifiedName = repositoryHelper.getStringProperty(serviceName, + OpenMetadataProperty.QUALIFIED_NAME.name, + governanceActionProcessEntity.getProperties(), + methodName) + "@" + processInstanceStartTime; + String processInstanceName = repositoryHelper.getStringProperty(serviceName, + OpenMetadataProperty.NAME.name, + governanceActionProcessEntity.getProperties(), + methodName) + "@" + processInstanceStartTime; + ProcessBuilder processBuilder = new ProcessBuilder(OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.typeGUID, + OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.typeName, + processInstanceQualifiedName, + processInstanceName, + null, + null, + null, + processInstanceStartTime, + null, + repositoryHelper, + serviceName, + serverName); + + processBuilder.setAnchors(userId, + governanceActionProcessEntity.getGUID(), + OpenMetadataType.GOVERNANCE_ACTION_PROCESS_TYPE_NAME, + OpenMetadataType.ASSET.typeName, + methodName); + + String processInstanceGUID = this.createBeanInRepository(userId, + null, + null, + OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.typeGUID, + OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.typeName, + OpenMetadataType.ASSET.typeName, + processBuilder, + false, + new Date(), + methodName); + + prepareEngineActionFromProcessStep(userId, + processInstanceGUID, + governanceActionProcessStepGUID, + governanceActionProcessStepGUIDParameterName, + guard, + false, + requestedStartDate, + null, + userId, + combinedRequestParameters, + requestSourceGUIDs, + newTargetsForAction, + processInstanceQualifiedName, + processQualifiedName, + originatorServiceName, + originatorEngineName, + serviceSupportedZones, + methodName); + + return processInstanceGUID; } else { @@ -1018,17 +1063,6 @@ private String prepareEngineActionFromProcessStep(String userId, List mandatoryGuards = this.getMandatoryGuards(userId, governanceActionProcessStepGUID); - /* - * If the anchorGUID is null, it means the previous engine action was the first in the process. - * Subsequent governance actions will have the first engine action as their anchorGUID. - */ - String newAnchorGUID = anchorGUID; - - if (anchorGUID == null) - { - newAnchorGUID = previousEngineActionGUID; - } - String engineActionGUID = getEngineActionForProcessStep(userId, governanceActionProcessStepName + ":" + UUID.randomUUID(), domainIdentifier, @@ -1046,7 +1080,7 @@ private String prepareEngineActionFromProcessStep(String userId, requestParameters, governanceActionProcessStepGUID, governanceActionProcessStepName, - newAnchorGUID, + anchorGUID, processName, requestSourceName, originatorServiceName, @@ -2649,7 +2683,7 @@ private void markActionTargetsAsComplete(String userId, OpenMetadataType.TARGET_FOR_ACTION.typeGUID, OpenMetadataType.TARGET_FOR_ACTION.typeName, 2, - false, + true, false, 0, 0, effectiveTime, @@ -2741,6 +2775,9 @@ private void initiateNextEngineActions(String userId, { final String nextGovernanceActionProcessStepParameterName = "nextActionProcessStep.getEntityTwoProxy().getGUID()"; + /* + * Only need to do something if the completing engine action is part of a process. + */ if (previousGovernanceActionProcessStepGUID != null) { /* @@ -2823,7 +2860,87 @@ private void initiateNextEngineActions(String userId, } } } + else + { + /* + * No more steps in the current branch of the process. Is this the end of the process? + */ + final String processNameParameterName = "processName"; + + List specificMatchPropertyNames = new ArrayList<>(); + specificMatchPropertyNames.add(OpenMetadataProperty.PROCESS_NAME.name); + + List actionsInProcess = this.getEntitiesByValue(userId, + processName, + processNameParameterName, + OpenMetadataType.ENGINE_ACTION.typeGUID, + OpenMetadataType.ENGINE_ACTION.typeName, + specificMatchPropertyNames, + true, + true, + null, + null, + false, + false, + serviceSupportedZones, + null, + 0, + 0, + effectiveTime, + methodName); + + if (actionsInProcess != null) + { + int incompleteActions = 0; + + for (EntityDetail actionInProcess : actionsInProcess) + { + if (actionInProcess != null) + { + int storedStatus = repositoryHelper.getEnumPropertyOrdinal(serviceName, + OpenMetadataProperty.ACTION_STATUS.name, + actionInProcess.getProperties(), + methodName); + + if ((storedStatus == EngineActionStatus.REQUESTED.getOrdinal()) || + (storedStatus == EngineActionStatus.APPROVED.getOrdinal()) || + (storedStatus == EngineActionStatus.WAITING.getOrdinal()) || + (storedStatus == EngineActionStatus.ACTIVATING.getOrdinal()) || + (storedStatus == EngineActionStatus.IN_PROGRESS.getOrdinal())) + { + incompleteActions++; + } + } + } + + if (incompleteActions == 0) + { + final String anchorGUIDParameterName = "anchorGUID"; + /* + * The anchorGUID should be the guid of the process. + */ + this.updateBeanInRepository(userId, + null, + null, + anchorGUID, + anchorGUIDParameterName, + OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.typeGUID, + OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.typeName, + false, + false, + serviceSupportedZones, + repositoryHelper.addDatePropertyToInstance(serviceName, + null, + OpenMetadataProperty.PROCESS_END_TIME.name, + new Date(), + methodName), + true, + effectiveTime, + methodName); + } + } } + } } diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ProcessBuilder.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ProcessBuilder.java index bad3f59f6d6..f83721ea6b9 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ProcessBuilder.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ProcessBuilder.java @@ -6,8 +6,10 @@ import org.odpi.openmetadata.frameworks.openmetadata.types.OpenMetadataProperty; import org.odpi.openmetadata.frameworks.openmetadata.types.OpenMetadataType; 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.repositoryconnector.OMRSRepositoryHelper; +import java.util.Date; import java.util.Map; /** @@ -16,9 +18,12 @@ */ public class ProcessBuilder extends AssetBuilder { - private final String formula = null; - private final String formulaType = null; - private final String implementationLanguage = null; + private String formula = null; + private String formulaType = null; + private String implementationLanguage = null; + private Date processStartTime = null; + private Date processEndTime = null; + /** * Creation constructor used when working with classifications @@ -39,6 +44,106 @@ public class ProcessBuilder extends AssetBuilder } + /** + * Constructor used when working with entities + * + * @param typeGUID unique identifier for the type of this process + * @param typeName unique name for the type of this process + * @param qualifiedName unique name + * @param name display name + * @param description description* @param formula formula + * @param formulaType formulaType + * @param implementationLanguage language + * @param deployedImplementationType deployed implementation type + * @param repositoryHelper helper methods + * @param serviceName name of this OMAS + * @param serverName name of local server + */ + ProcessBuilder(String typeGUID, + String typeName, + String qualifiedName, + String name, + String description, + String formula, + String formulaType, + String implementationLanguage, + String deployedImplementationType, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(qualifiedName, + name, + null, + null, + description, + deployedImplementationType, + null, + typeGUID, + typeName, + null, + InstanceStatus.ACTIVE, + repositoryHelper, + serviceName, + serverName); + + this.formula = formula; + this.formulaType = formulaType; + this.implementationLanguage = implementationLanguage; + } + + + /** + * Constructor used when working with entities + * + * @param typeGUID unique identifier for the type of this process + * @param typeName unique name for the type of this process + * @param qualifiedName unique name + * @param name display name + * @param description description + * @param formula formula + * @param formulaType formulaType + * @param processStartTime date + * @param processEndTime date + * @param repositoryHelper helper methods + * @param serviceName name of this OMAS + * @param serverName name of local server + */ + ProcessBuilder(String typeGUID, + String typeName, + String qualifiedName, + String name, + String description, + String formula, + String formulaType, + Date processStartTime, + Date processEndTime, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(qualifiedName, + name, + null, + null, + description, + null, + null, + typeGUID, + typeName, + null, + InstanceStatus.ACTIVE, + repositoryHelper, + serviceName, + serverName); + + this.formula = formula; + this.formulaType = formulaType; + this.processStartTime = processStartTime; + this.processEndTime = processEndTime; + } + + /** * Creation constructor used when working with classifications * @@ -62,6 +167,7 @@ public class ProcessBuilder extends AssetBuilder } + /** * Return the supplied bean properties in an InstanceProperties object. * @@ -92,6 +198,18 @@ public InstanceProperties getInstanceProperties(String methodName) throws Inval implementationLanguage, methodName); + properties = repositoryHelper.addDatePropertyToInstance(serviceName, + properties, + OpenMetadataProperty.PROCESS_START_TIME.name, + processStartTime, + methodName); + + properties = repositoryHelper.addDatePropertyToInstance(serviceName, + properties, + OpenMetadataProperty.PROCESS_END_TIME.name, + processEndTime, + methodName); + return properties; } } diff --git a/open-metadata-implementation/engine-services/survey-action/survey-action-server/src/main/java/org/odpi/openmetadata/engineservices/surveyaction/handlers/SurveyActionServiceHandler.java b/open-metadata-implementation/engine-services/survey-action/survey-action-server/src/main/java/org/odpi/openmetadata/engineservices/surveyaction/handlers/SurveyActionServiceHandler.java index 4cc498544ea..b2c71edffc2 100644 --- a/open-metadata-implementation/engine-services/survey-action/survey-action-server/src/main/java/org/odpi/openmetadata/engineservices/surveyaction/handlers/SurveyActionServiceHandler.java +++ b/open-metadata-implementation/engine-services/survey-action/survey-action-server/src/main/java/org/odpi/openmetadata/engineservices/surveyaction/handlers/SurveyActionServiceHandler.java @@ -207,8 +207,6 @@ public void run() try { - super.disconnect(); - if (completionActionTargets == null) { completionActionTargets = new ArrayList<>(); @@ -229,6 +227,8 @@ public void run() surveyContext.getAnnotationStore().setCompletionMessage(messageText); super.recordCompletionStatus(completionStatus, completionGuards, completionRequestParameters, completionActionTargets, messageText); + + super.disconnect(); } catch (Exception ignore) { diff --git a/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/client/OpenGovernanceClientBase.java b/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/client/OpenGovernanceClientBase.java index b44a9f2a20b..6c9bd2d2b90 100644 --- a/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/client/OpenGovernanceClientBase.java +++ b/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/client/OpenGovernanceClientBase.java @@ -290,7 +290,7 @@ public String initiateGovernanceActionType(String userId, * @param originatorServiceName unique name of the requesting governance service (if initiated by a governance engine). * @param originatorEngineName optional unique name of the governance engine (if initiated by a governance engine). * - * @return unique identifier of the first engine action of the process + * @return unique identifier of the governance action process instance * @throws InvalidParameterException null or unrecognized qualified name of the process * @throws UserNotAuthorizedException the caller is not authorized to create a governance action process * @throws PropertyServerException there is a problem with the metadata store diff --git a/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/client/OpenMetadataClientBase.java b/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/client/OpenMetadataClientBase.java index a287819dacc..a90ae8b59e7 100644 --- a/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/client/OpenMetadataClientBase.java +++ b/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/client/OpenMetadataClientBase.java @@ -3815,7 +3815,7 @@ public void deleteRelatedElementsInStore(String userId, * @param originatorServiceName unique name of the requesting governance service (if initiated by a governance engine). * @param originatorEngineName optional unique name of the governance engine (if initiated by a governance engine). * - * @return unique identifier of the first engine action of the process + * @return unique identifier of the governance action process instance * @throws InvalidParameterException null or unrecognized qualified name of the process * @throws UserNotAuthorizedException the userId is not permitted to perform this operation * @throws PropertyServerException there is a problem with the metadata store diff --git a/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/OpenGovernanceRESTServices.java b/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/OpenGovernanceRESTServices.java index 07ce60673ef..cae6d132c59 100644 --- a/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/OpenGovernanceRESTServices.java +++ b/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/OpenGovernanceRESTServices.java @@ -3311,7 +3311,7 @@ public GUIDResponse initiateGovernanceActionType(String * @param userId caller's userId * @param requestBody properties to initiate the new instance of the process * - * @return unique identifier of the first governance action of the process or + * @return unique identifier of the governance action process instance or * InvalidParameterException null or unrecognized qualified name of the process * UserNotAuthorizedException this governance action service is not authorized to create a governance action process * PropertyServerException there is a problem with the metadata store diff --git a/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/spring/OpenGovernanceResource.java b/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/spring/OpenGovernanceResource.java index cf8839d47a2..72003ab70d1 100644 --- a/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/spring/OpenGovernanceResource.java +++ b/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/spring/OpenGovernanceResource.java @@ -1010,7 +1010,7 @@ public GUIDResponse initiateGovernanceActionType(@PathVariable String * @param userId caller's userId * @param requestBody properties to initiate the new instance of the process * - * @return unique identifier of the first engine action of the process or + * @return unique identifier of the governance action process instance or * InvalidParameterException null or unrecognized qualified name of the process * UserNotAuthorizedException the caller is not authorized to create a governance action process * PropertyServerException there is a problem with the metadata store diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionContext.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionContext.java index fde9ee713d0..6fe7a81324b 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionContext.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionContext.java @@ -2818,7 +2818,7 @@ public String initiateGovernanceActionType(String governanceActio * @param actionTargets map of action target names to GUIDs for the resulting governance action service * @param startTime future start time or null for "as soon as possible". * - * @return unique identifier of the first governance action of the process + * @return unique identifier of the governance action process instance * * @throws InvalidParameterException null or unrecognized qualified name of the process * @throws UserNotAuthorizedException this governance action service is not authorized to create a governance action process diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceContext.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceContext.java index 9e0de95810f..b5acaa68171 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceContext.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceContext.java @@ -163,7 +163,7 @@ String initiateGovernanceActionType(String governanceActionTypeQu * @param actionTargets map of action target names to GUIDs for the resulting governance action service * @param startTime future start time or null for "as soon as possible". * - * @return unique identifier of the first governance action of the process + * @return unique identifier of the governance action process instance * * @throws InvalidParameterException null or unrecognized qualified name of the process * @throws UserNotAuthorizedException this governance action service is not authorized to create a governance action process diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/search/PropertyHelper.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/search/PropertyHelper.java index e237112e36a..88a8e20a084 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/search/PropertyHelper.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/search/PropertyHelper.java @@ -136,6 +136,34 @@ public String getDomainName(ElementControlHeader elementControlHeader) } + /** + * Return the anchorGUID for an element. + * + * @param elementHeader header of the element + * @return unique identifier or null; + */ + public String getAnchorGUID(ElementHeader elementHeader) + { + List classifications = elementHeader.getClassifications(); + + if (classifications != null) + { + for (ElementClassification classification : classifications) + { + if ((classification != null) && (OpenMetadataType.ANCHORS_CLASSIFICATION.typeName.equals(classification.getClassificationName()))) + { + if (classification.getClassificationProperties() != null) + { + return classification.getClassificationProperties().get(OpenMetadataProperty.ANCHOR_GUID.name).toString(); + } + } + } + } + + return null; + } + + /** * Return the search properties that requests elements with an exactly matching name in any of the listed property names. * diff --git a/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/StewardshipAction.java b/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/StewardshipAction.java index eb740f1c0eb..81bdfa01e74 100644 --- a/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/StewardshipAction.java +++ b/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/StewardshipAction.java @@ -214,7 +214,7 @@ public String initiateGovernanceActionType(String governanceActio * @param originatorServiceName unique name of the requesting governance service (if initiated by a governance engine). * @param originatorEngineName optional unique name of the governance engine (if initiated by a governance engine). * - * @return unique identifier of the first engine action of the process + * @return unique identifier of the governance action process instance * @throws InvalidParameterException null or unrecognized qualified name of the process * @throws UserNotAuthorizedException the caller is not authorized to create a governance action process * @throws PropertyServerException there is a problem with the metadata store diff --git a/open-metadata-implementation/frameworks/open-metadata-framework/src/main/java/org/odpi/openmetadata/frameworks/openmetadata/types/OpenMetadataProperty.java b/open-metadata-implementation/frameworks/open-metadata-framework/src/main/java/org/odpi/openmetadata/frameworks/openmetadata/types/OpenMetadataProperty.java index 482a21ec706..618cec3a938 100644 --- a/open-metadata-implementation/frameworks/open-metadata-framework/src/main/java/org/odpi/openmetadata/frameworks/openmetadata/types/OpenMetadataProperty.java +++ b/open-metadata-implementation/frameworks/open-metadata-framework/src/main/java/org/odpi/openmetadata/frameworks/openmetadata/types/OpenMetadataProperty.java @@ -168,6 +168,16 @@ public enum OpenMetadataProperty */ FORMULA_TYPE("formulaType", "string", "Format of the expression provided in the formula attribute.", "SQL", "dd9b24cb-0359-4915-8b6b-9eae251adc1c"), + /** + * Time that a transient process started. + */ + PROCESS_START_TIME("processStartTime", "date", "Time that a transient process started.", null, "f2c4180f-a803-42d6-9eb1-2bd29bd20d88"), + + /** + * Time that a transient process ended. + */ + PROCESS_END_TIME("processEndTime", "date", "Time that a transient process ended.", null, "2179e4e3-b640-403a-a2bb-10da5c39acf6"), + /** * Is this element visible to all, or only the author? */ diff --git a/open-metadata-implementation/frameworks/open-metadata-framework/src/main/java/org/odpi/openmetadata/frameworks/openmetadata/types/OpenMetadataType.java b/open-metadata-implementation/frameworks/open-metadata-framework/src/main/java/org/odpi/openmetadata/frameworks/openmetadata/types/OpenMetadataType.java index 813af076caa..a6be9991b1e 100644 --- a/open-metadata-implementation/frameworks/open-metadata-framework/src/main/java/org/odpi/openmetadata/frameworks/openmetadata/types/OpenMetadataType.java +++ b/open-metadata-implementation/frameworks/open-metadata-framework/src/main/java/org/odpi/openmetadata/frameworks/openmetadata/types/OpenMetadataType.java @@ -1592,6 +1592,15 @@ public enum OpenMetadataType "90dea768-2b9e-4a3c-b065-95efcfd5a48f", "The element(s) that form the initial list of targets for action that are passed to the engine action as part of a request to run this governance action process. Additional targets for action can be supplied by the caller."), + /** + * Represents a single run of a governance action process. It is linked to the parent governance action process using the ProcessHierarchy relationship.. + */ + GOVERNANCE_ACTION_PROCESS_INSTANCE("206a6e44-ffe7-408b-8e59-79842d362776", + "GovernanceActionProcessInstance", + OpenMetadataWikiPages.MODEL_0462_GOVERNANCE_ACTION_PROCESSES, + "6fcfbc4c-f08d-4946-a311-e76237fa1263", + "Represents a single run of a governance action process. It is linked to the parent governance action process using the ProcessHierarchy relationship."), + /** * An engine action that has been created to support the active governance of the open metadata ecosystem and/or digital landscape. */ diff --git a/open-metadata-implementation/view-services/automated-curation/automated-curation-server/src/main/java/org/odpi/openmetadata/viewservices/automatedcuration/server/AutomatedCurationRESTServices.java b/open-metadata-implementation/view-services/automated-curation/automated-curation-server/src/main/java/org/odpi/openmetadata/viewservices/automatedcuration/server/AutomatedCurationRESTServices.java index 9ea0fac1b5c..49884fea543 100644 --- a/open-metadata-implementation/view-services/automated-curation/automated-curation-server/src/main/java/org/odpi/openmetadata/viewservices/automatedcuration/server/AutomatedCurationRESTServices.java +++ b/open-metadata-implementation/view-services/automated-curation/automated-curation-server/src/main/java/org/odpi/openmetadata/viewservices/automatedcuration/server/AutomatedCurationRESTServices.java @@ -1810,7 +1810,7 @@ public GUIDResponse initiateGovernanceActionType(String * @param serverName name of server instance to route request to * @param requestBody properties to initiate the new instance of the process * - * @return unique identifier of the first governance action of the process or + * @return unique identifier of the governance action process instance or * InvalidParameterException null or unrecognized qualified name of the process * UserNotAuthorizedException this governance action service is not authorized to create a governance action process * PropertyServerException there is a problem with the metadata store diff --git a/open-metadata-implementation/view-services/automated-curation/automated-curation-spring/src/main/java/org/odpi/openmetadata/viewservices/automatedcuration/server/spring/AutomatedCurationResource.java b/open-metadata-implementation/view-services/automated-curation/automated-curation-spring/src/main/java/org/odpi/openmetadata/viewservices/automatedcuration/server/spring/AutomatedCurationResource.java index 88a6f2b7924..d235ee22ab8 100644 --- a/open-metadata-implementation/view-services/automated-curation/automated-curation-spring/src/main/java/org/odpi/openmetadata/viewservices/automatedcuration/server/spring/AutomatedCurationResource.java +++ b/open-metadata-implementation/view-services/automated-curation/automated-curation-spring/src/main/java/org/odpi/openmetadata/viewservices/automatedcuration/server/spring/AutomatedCurationResource.java @@ -631,7 +631,7 @@ public GUIDResponse initiateGovernanceActionType(@PathVariable String * @param serverName name of server instance to route request to * @param requestBody properties to initiate the new instance of the process * - * @return unique identifier of the first engine action of the process or + * @return unique identifier of the governance action process instance or * InvalidParameterException null or unrecognized qualified name of the process * UserNotAuthorizedException the caller is not authorized to create a governance action process * PropertyServerException there is a problem with the metadata store diff --git a/open-metadata-implementation/view-services/template-manager/Egeria-template-manager-omvs.http b/open-metadata-implementation/view-services/template-manager/Egeria-template-manager-omvs.http index 4933e991123..cae412d7c4d 100644 --- a/open-metadata-implementation/view-services/template-manager/Egeria-template-manager-omvs.http +++ b/open-metadata-implementation/view-services/template-manager/Egeria-template-manager-omvs.http @@ -20,52 +20,327 @@ Content-Type: application/json ### -# @name findTemplates -# Retrieve the metadata elements that contain the requested string in its Template classification. -# Optional Request parameters -# * elementTypeName optional type name for the template -# * viewServiceURLMarker optional view service URL marker (overrides accessServiceURLMarker) -# * accessServiceURLMarker optional access service URL marker used to identify which back end service to call (default digital-architecture) -# * startFrom paging start point (default 0) -# * pageSize maximum results that can be returned (default 0) -# -# Further Information: https://egeria-project.org/services/gaf-metadata-management/ - -POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/template-manager/templates/by-search-string +# ===================================================================================================================== +# Maintain the metadata elements that makes up the template + +@metadataElementGUID=add guid here +@classificationName=add name here +@relationshipGUID=add guid here + +### +# @name createMetadataElementInStore +# Create a new metadata element in the metadata store. The type name comes from the open metadata types. +# The selected type also controls the names and types of the properties that are allowed. +# This version of the method allows access to advanced features such as multiple states and +# effectivity dates. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements Authorization: Bearer {{token}} Content-Type: application/json { - "class": "TemplateClassificationRequestBody", - "templateClassificationProperties": { - "class": "TemplateClassificationProperties", - "name" : "add value here", - "description" : "add value here", - "versionIdentifier" : "add value here", - "additionalProperties" : { - "propertyName2" : "propertyValue", - "propertyName1" : "propertyValue" - } - } + "class" : "NewOpenMetadataElementRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "typeName" : "", + "initialStatus" : "ACTIVE", + "initialClassifications" : {}, + "anchorGUID" : "", + "isOwnAnchor" : false, + "effectiveFrom" : "{{$isoTimestamp}}", + "effectiveTo": "{{$isoTimestamp}}", + "properties" : {}, + "parentGUID" : "", + "parentRelationshipTypeName" : "", + "parentRelationshipProperties" : {}, + "parentAtEnd1" : true, + "effectiveTime" : "{{$isoTimestamp}}" } + ### +# @name createMetadataElementFromTemplate +# Create a new metadata element in the metadata store using a template. The type name comes from the open metadata types. +# The selected type also controls the names and types of the properties that are allowed. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements/from-template +Authorization: Bearer {{token}} +Content-Type: application/json + { - "class": "TemplateClassificationRequestBody", - "templateClassificationProperties": { - "class": "TemplateClassificationProperties", - "name" : "add value here", - "description" : "add value here", - "versionIdentifier" : "add value here", - "additionalProperties" : { - "propertyName2" : "propertyValue", - "propertyName1" : "propertyValue" + "class" : "TemplateRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "typeName" : "", + "templateGUID" : "", + "anchorGUID" : "", + "isOwnAnchor" : false, + "effectiveFrom" : "{{$isoTimestamp}}", + "effectiveTo": "{{$isoTimestamp}}", + "replacementProperties" : { }, + "placeholderProperties" : { + "placeholderName1" : "placeholderValue1", + "placeholderName2" : "placeholderValue2" + }, + "parentGUID" : "", + "parentRelationshipTypeName" : "", + "parentRelationshipProperties" : {}, + "parentAtEnd1" : true, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name updateMetadataElementInStore +# Update the properties of a specific metadata element. The properties must match the type definition associated with the +# metadata element when it was created. However, it is possible to update a few properties, or replace all them by +# the value used in the replaceProperties flag. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements/{{metadataElementGUID}}/update-properties +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "UpdatePropertiesRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name updateMetadataElementStatusInStore +# Update the status of specific metadata element. The new status must match a status value that is defined for the element's type +# assigned when it was created. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements/{{metadataElementGUID}}/update-status +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "UpdateStatusRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name updateMetadataElementEffectivityInStore +# Update the effectivity dates control the visibility of the element through specific APIs. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements/{{metadataElementGUID}}/update-effectivity +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "UpdateEffectivityDatesRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "effectiveFrom" : "{{$isoTimestamp}}", + "effectiveTo": "{{$isoTimestamp}}", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name deleteMetadataElementInStore +# Delete a specific metadata element. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements/{{metadataElementGUID}}/delete +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "UpdateRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name archiveMetadataElementInStore +# Archive a specific metadata element. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements/{{metadataElementGUID}}/archive +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "ArchiveRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "archiveProperties" : { + "archiveDate" : "{{$isoTimestamp}}", + "archiveProcess" : "", + "archiveProperties": { + "propertyName1" : "propertyValue1", + "propertyName2" : "propertyValue2" } }, - "specification" : { - "specificationFieldName" : [ { - "propertyName1" : "propertyValue", - "propertyName2" : "propertyValue" - }] - } + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name classifyMetadataElementInStore +# Add a new classification to the metadata element. Note that only one classification with the same name can be attached to +# a metadata element. + + POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements/{{metadataElementGUID}}/classifications/{{classificationName}} +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "NewClassificationRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" } + + +### +# @name reclassifyMetadataElementInStore +# Update the properties of a classification that is currently attached to a specific metadata element. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements/{{metadataElementGUID}}/classifications/{{classificationName}}/update-properties +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "UpdatePropertiesRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name updateClassificationEffectivityInStore +# Update the effectivity dates of a specific classification attached to a metadata element. +# The effectivity dates control the visibility of the classification through specific APIs. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements/{{metadataElementGUID}}/classifications/{{classificationName}}/update-effectivity +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "UpdateEffectivityDatesRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "effectiveFrom" : "{{$isoTimestamp}}", + "effectiveTo": "{{$isoTimestamp}}", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name declassifyMetadataElementInStore +# Remove the named classification from a specific metadata element. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/metadata-elements/{{metadataElementGUID}}/classifications/{{classificationName}}/delete +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "UpdateRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name createRelatedElementsInStore +# Create a relationship between two metadata elements. It is important to put the right element at each end of the relationship +# according to the type definition since this will affect how the relationship is interpreted. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/related-elements +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "NewRelatedElementsRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name updateRelatedElementsInStore +# Update the properties associated with a relationship. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/related-elements/{{relationshipGUID}}/update-properties +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "UpdatePropertiesRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name updateRelatedElementsEffectivityInStore +# Update the effectivity dates of a specific relationship between metadata elements. +# The effectivity dates control the visibility of the classification through specific APIs. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/related-elements/{{relationshipGUID}}/update-effectivity +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "UpdateEffectivityDatesRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "effectiveFrom" : "{{$isoTimestamp}}", + "effectiveTo": "{{$isoTimestamp}}", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name deleteRelatedElementsInStore +# Delete a relationship between two metadata elements. + +POST {{baseURL}}/api/open-metadata/servers/{{viewServer}}/api/open-metadata/template-manager/related-elements/{{relationshipGUID}}/delete +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "UpdateRequestBody", + "externalSourceGUID" : "", + "externalSourceName" : "", + "forLineage" : false, + "forDuplicateProcessing" : false, + "effectiveTime" : "{{$isoTimestamp}}" +} + diff --git a/open-metadata-implementation/view-services/template-manager/template-manager-server/src/main/java/org/odpi/openmetadata/viewservices/templatemanager/server/TemplateManagerRESTServices.java b/open-metadata-implementation/view-services/template-manager/template-manager-server/src/main/java/org/odpi/openmetadata/viewservices/templatemanager/server/TemplateManagerRESTServices.java index 3f278e45208..b88f12ae254 100644 --- a/open-metadata-implementation/view-services/template-manager/template-manager-server/src/main/java/org/odpi/openmetadata/viewservices/templatemanager/server/TemplateManagerRESTServices.java +++ b/open-metadata-implementation/view-services/template-manager/template-manager-server/src/main/java/org/odpi/openmetadata/viewservices/templatemanager/server/TemplateManagerRESTServices.java @@ -3,11 +3,15 @@ package org.odpi.openmetadata.viewservices.templatemanager.server; +import org.odpi.openmetadata.accessservices.digitalarchitecture.client.OpenMetadataStoreClient; import org.odpi.openmetadata.commonservices.ffdc.RESTCallLogger; +import org.odpi.openmetadata.commonservices.ffdc.RESTCallToken; import org.odpi.openmetadata.commonservices.ffdc.RESTExceptionHandler; -import org.odpi.openmetadata.frameworkservices.gaf.rest.OpenMetadataElementsResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworkservices.gaf.rest.*; import org.odpi.openmetadata.tokencontroller.TokenController; -import org.odpi.openmetadata.viewservices.templatemanager.rest.TemplateClassificationRequestBody; import org.slf4j.LoggerFactory; @@ -32,30 +36,919 @@ public TemplateManagerRESTServices() { } + + /** + * Create a new metadata element in the metadata store. The type name comes from the open metadata types. + * The selected type also controls the names and types of the properties that are allowed. + * This version of the method allows access to advanced features such as multiple states and + * effectivity dates. + * + * @param serverName name of server instance to route request to + * @param requestBody properties for the new element + * + * @return unique identifier of the new metadata element + * InvalidParameterException the type name, status or one of the properties is invalid + * UserNotAuthorizedException the governance action service is not authorized to create this type of element + * PropertyServerException there is a problem with the metadata store + */ + public GUIDResponse createMetadataElementInStore(String serverName, + NewOpenMetadataElementRequestBody requestBody) + { + final String methodName = "createMetadataElementInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + response.setGUID(handler.createMetadataElementInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + requestBody.getTypeName(), + requestBody.getInitialStatus(), + requestBody.getInitialClassifications(), + requestBody.getAnchorGUID(), + requestBody.getIsOwnAnchor(), + requestBody.getEffectiveFrom(), + requestBody.getEffectiveTo(), + requestBody.getProperties(), + requestBody.getParentGUID(), + requestBody.getParentRelationshipTypeName(), + requestBody.getParentRelationshipProperties(), + requestBody.getParentAtEnd1())); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Create a new metadata element in the metadata store using a template. The type name comes from the open metadata types. + * The selected type also controls the names and types of the properties that are allowed. + * + * @param serverName name of server instance to route request to + * @param requestBody properties for the new element + * + * @return unique identifier of the new metadata element + * InvalidParameterException the type name, status or one of the properties is invalid + * UserNotAuthorizedException the governance action service is not authorized to create this type of element + * PropertyServerException there is a problem with the metadata store + */ + public GUIDResponse createMetadataElementFromTemplate(String serverName, + TemplateRequestBody requestBody) + { + final String methodName = "createMetadataElementFromTemplate"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + response.setGUID(handler.createMetadataElementFromTemplate(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + requestBody.getTypeName(), + requestBody.getAnchorGUID(), + requestBody.getIsOwnAnchor(), + requestBody.getEffectiveFrom(), + requestBody.getEffectiveTo(), + requestBody.getTemplateGUID(), + requestBody.getReplacementProperties(), + requestBody.getPlaceholderPropertyValues(), + requestBody.getParentGUID(), + requestBody.getParentRelationshipTypeName(), + requestBody.getParentRelationshipProperties(), + requestBody.getParentAtEnd1())); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update the properties of a specific metadata element. The properties must match the type definition associated with the + * metadata element when it was created. However, it is possible to update a few properties, or replace all them by + * the value used in the replaceProperties flag. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param requestBody new properties + * + * @return void or + * InvalidParameterException either the unique identifier or the properties are invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse updateMetadataElementInStore(String serverName, + String metadataElementGUID, + UpdatePropertiesRequestBody requestBody) + { + final String methodName = "updateMetadataElementInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.updateMetadataElementInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + metadataElementGUID, + requestBody.getReplaceProperties(), + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getProperties(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update the status of specific metadata element. The new status must match a status value that is defined for the element's type + * assigned when it was created. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param requestBody new status values - use null to leave as is + * + * @return void or + * InvalidParameterException either the unique identifier or the status are invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse updateMetadataElementStatusInStore(String serverName, + String metadataElementGUID, + UpdateStatusRequestBody requestBody) + { + final String methodName = "updateMetadataElementStatusInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.updateMetadataElementStatusInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + metadataElementGUID, + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getNewStatus(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + + /** + * Update the effectivity dates control the visibility of the element through specific APIs. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param requestBody new status values - use null to leave as is + * + * @return void or + * InvalidParameterException either the unique identifier or the status are invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse updateMetadataElementEffectivityInStore(String serverName, + String metadataElementGUID, + UpdateEffectivityDatesRequestBody requestBody) + { + final String methodName = "updateMetadataElementEffectivityInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.updateMetadataElementEffectivityInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + metadataElementGUID, + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getEffectiveFrom(), + requestBody.getEffectiveTo(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Delete a specific metadata element. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param requestBody null request body + * + * @return void or + * InvalidParameterException the unique identifier is null or invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to delete this element + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse deleteMetadataElementInStore(String serverName, + String metadataElementGUID, + UpdateRequestBody requestBody) + { + final String methodName = "deleteMetadataElementInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.deleteMetadataElementInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + metadataElementGUID, + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Archive a specific metadata element. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param requestBody null request body + * + * @return void or + * InvalidParameterException the unique identifier is null or invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to archive this element + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse archiveMetadataElementInStore(String serverName, + String metadataElementGUID, + ArchiveRequestBody requestBody) + { + final String methodName = "archiveMetadataElementInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.archiveMetadataElementInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + metadataElementGUID, + requestBody.getArchiveProperties(), + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Add a new classification to the metadata element. Note that only one classification with the same name can be attached to + * a metadata element. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName name of the classification to add (if the classification is already present then use reclassify) + * @param requestBody properties to store in the new classification. These must conform to the valid properties associated with the + * classification name + * + * @return void or + * InvalidParameterException the unique identifier or classification name is null or invalid in some way; properties do not match the + * valid properties associated with the classification's type definition + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse classifyMetadataElementInStore(String serverName, + String metadataElementGUID, + String classificationName, + NewClassificationRequestBody requestBody) + { + final String methodName = "classifyMetadataElementInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.classifyMetadataElementInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + metadataElementGUID, + classificationName, + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getEffectiveFrom(), + requestBody.getEffectiveTo(), + requestBody.getProperties(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update the properties of a classification that is currently attached to a specific metadata element. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName unique name of the classification to update + * @param requestBody new properties for the classification + * + * @return void or + * InvalidParameterException the unique identifier or classification name is null or invalid in some way; properties do not match the + * valid properties associated with the classification's type definition + * UserNotAuthorizedException the governance action service is not authorized to update this element/classification + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse reclassifyMetadataElementInStore(String serverName, + String metadataElementGUID, + String classificationName, + UpdatePropertiesRequestBody requestBody) + { + final String methodName = "reclassifyMetadataElementInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.reclassifyMetadataElementInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + metadataElementGUID, + classificationName, + requestBody.getReplaceProperties(), + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getProperties(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update the effectivity dates of a specific classification attached to a metadata element. + * The effectivity dates control the visibility of the classification through specific APIs. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName unique name of the classification to update + * @param requestBody the dates when this element is active / inactive - null for no restriction + * + * @return void or + * InvalidParameterException either the unique identifier or the status are invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse updateClassificationEffectivityInStore(String serverName, + String metadataElementGUID, + String classificationName, + UpdateEffectivityDatesRequestBody requestBody) + { + final String methodName = "updateClassificationEffectivityInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.updateClassificationEffectivityInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + metadataElementGUID, + classificationName, + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getEffectiveFrom(), + requestBody.getEffectiveTo(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Remove the named classification from a specific metadata element. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName unique name of the classification to remove + * @param requestBody null request body + * + * @return void or + * InvalidParameterException the unique identifier or classification name is null or invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to remove this classification + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse declassifyMetadataElementInStore(String serverName, + String metadataElementGUID, + String classificationName, + UpdateRequestBody requestBody) + { + final String methodName = "declassifyMetadataElementInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.declassifyMetadataElementInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + metadataElementGUID, + classificationName, + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Create a relationship between two metadata elements. It is important to put the right element at each end of the relationship + * according to the type definition since this will affect how the relationship is interpreted. + * + * @param serverName name of server instance to route request to + * @param requestBody the properties of the relationship + * + * @return unique identifier of the new relationship or + * InvalidParameterException the unique identifier's of the metadata elements are null or invalid in some way; the properties are + * not valid for this type of relationship + * UserNotAuthorizedException the governance action service is not authorized to create this type of relationship + * PropertyServerException there is a problem with the metadata store + */ + public GUIDResponse createRelatedElementsInStore(String serverName, + NewRelatedElementsRequestBody requestBody) + { + final String methodName = "createRelatedElementsInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + response.setGUID(handler.createRelatedElementsInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + requestBody.getTypeName(), + requestBody.getMetadataElement1GUID(), + requestBody.getMetadataElement2GUID(), + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getEffectiveFrom(), + requestBody.getEffectiveTo(), + requestBody.getProperties(), + requestBody.getEffectiveTime())); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update the properties associated with a relationship. + * + * @param serverName name of server instance to route request to + * @param relationshipGUID unique identifier of the relationship to update + * @param requestBody new properties for the relationship + * + * @return void or + * InvalidParameterException the unique identifier of the relationship is null or invalid in some way; the properties are + * not valid for this type of relationship + * UserNotAuthorizedException the governance action service is not authorized to update this relationship + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse updateRelatedElementsInStore(String serverName, + String relationshipGUID, + UpdatePropertiesRequestBody requestBody) + { + final String methodName = "updateRelatedElementsInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.updateRelatedElementsInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + relationshipGUID, + requestBody.getReplaceProperties(), + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getProperties(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + /** - * Retrieve the elements with the template classification. The request can include the . + * Update the effectivity dates of a specific relationship between metadata elements. + * The effectivity dates control the visibility of the classification through specific APIs. * * @param serverName name of server instance to route request to - * @param elementTypeName optional type name for the template - * @param viewServiceURLMarker optional view service URL marker (overrides accessServiceURLMarker) - * @param accessServiceURLMarker optional access service URL marker used to identify which back end service to call - * @param startFrom paging start point - * @param pageSize maximum results that can be returned - * @param requestBody searchString to retrieve + * @param relationshipGUID unique identifier of the relationship to update + * @param requestBody the dates when this element is active / inactive - null for no restriction * - * @return list of matching metadata elements (or null if no elements match the name) or - * InvalidParameterException the qualified name is null - * UserNotAuthorizedException the governance action service is not able to access the element - * PropertyServerException there is a problem accessing the metadata store + * @return void or + * InvalidParameterException either the unique identifier or the status are invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store */ - public OpenMetadataElementsResponse findTemplates(String serverName, - String elementTypeName, - String viewServiceURLMarker, - String accessServiceURLMarker, - int startFrom, - int pageSize, - TemplateClassificationRequestBody requestBody) + public VoidResponse updateRelatedElementsEffectivityInStore(String serverName, + String relationshipGUID, + UpdateEffectivityDatesRequestBody requestBody) { - return null; // todo + final String methodName = "updateRelatedElementsEffectivityInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.updateRelatedElementsEffectivityInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + relationshipGUID, + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getEffectiveFrom(), + requestBody.getEffectiveTo(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Delete a relationship between two metadata elements. + * + * @param serverName name of server instance to route request to + * @param relationshipGUID unique identifier of the relationship to delete + * @param requestBody null request body + * + * @return void or + * InvalidParameterException the unique identifier of the relationship is null or invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to delete this relationship + * PropertyServerException there is a problem with the metadata store + */ + public VoidResponse deleteRelatedElementsInStore(String serverName, + String relationshipGUID, + UpdateRequestBody requestBody) + { + final String methodName = "deleteRelatedElementsInStore"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + OpenMetadataStoreClient handler = instanceHandler.getOpenMetadataStoreClient(userId, serverName, methodName); + + if (requestBody != null) + { + handler.deleteRelatedElementsInStore(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + relationshipGUID, + requestBody.getForLineage(), + requestBody.getForDuplicateProcessing(), + requestBody.getEffectiveTime()); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; } } diff --git a/open-metadata-implementation/view-services/template-manager/template-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/templatemanager/server/spring/TemplateManagerResource.java b/open-metadata-implementation/view-services/template-manager/template-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/templatemanager/server/spring/TemplateManagerResource.java index 5df5b88a679..e0283920efe 100644 --- a/open-metadata-implementation/view-services/template-manager/template-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/templatemanager/server/spring/TemplateManagerResource.java +++ b/open-metadata-implementation/view-services/template-manager/template-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/templatemanager/server/spring/TemplateManagerResource.java @@ -3,10 +3,10 @@ package org.odpi.openmetadata.viewservices.templatemanager.server.spring; import io.swagger.v3.oas.annotations.ExternalDocumentation; -import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import org.odpi.openmetadata.frameworkservices.gaf.rest.OpenMetadataElementsResponse; -import org.odpi.openmetadata.viewservices.templatemanager.rest.TemplateClassificationRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.odpi.openmetadata.frameworkservices.gaf.rest.*; import org.odpi.openmetadata.viewservices.templatemanager.server.TemplateManagerRESTServices; import org.springframework.web.bind.annotation.*; @@ -34,41 +34,351 @@ public TemplateManagerResource() /** - * Retrieve the elements with the template classification. The request can include the . + * Create a new metadata element in the metadata store. The type name comes from the open metadata types. + * The selected type also controls the names and types of the properties that are allowed. + * This version of the method allows access to advanced features such as multiple states and + * effectivity dates. * * @param serverName name of server instance to route request to - * @param elementTypeName optional type name for the template - * @param viewServiceURLMarker optional view service URL marker (overrides accessServiceURLMarker) - * @param accessServiceURLMarker optional access service URL marker used to identify which back end service to call - * @param startFrom paging start point - * @param pageSize maximum results that can be returned - * @param requestBody searchString to retrieve - * - * @return list of matching metadata elements (or null if no elements match the name) or - * InvalidParameterException the qualified name is null - * UserNotAuthorizedException the governance action service is not able to access the element - * PropertyServerException there is a problem accessing the metadata store - */ - @PostMapping(path = "/templates/by-search-string") - - @Operation(summary="findTemplates", - description="Retrieve the metadata elements that contain the requested string in its template classification.", - externalDocs=@ExternalDocumentation(description="Further Information", - url="https://egeria-project.org/services/gaf-metadata-management/")) - - public OpenMetadataElementsResponse findTemplates(@PathVariable String serverName, - @RequestParam (required = false) - String elementTypeName, - @RequestParam (required = false) - String viewServiceURLMarker, - @RequestParam (required = false, defaultValue = "digital-architecture") - String accessServiceURLMarker, - @RequestParam (required = false, defaultValue = "0") - int startFrom, - @RequestParam (required = false, defaultValue = "0") - int pageSize, - @RequestBody TemplateClassificationRequestBody requestBody) - { - return restAPI.findTemplates(serverName, elementTypeName, viewServiceURLMarker, accessServiceURLMarker, startFrom, pageSize, requestBody); + * @param requestBody properties for the new element + * + * @return unique identifier of the new metadata element + * InvalidParameterException the type name, status or one of the properties is invalid + * UserNotAuthorizedException the governance action service is not authorized to create this type of element + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements") + + public GUIDResponse createMetadataElementInStore(@PathVariable String serverName, + @RequestBody NewOpenMetadataElementRequestBody requestBody) + { + return restAPI.createMetadataElementInStore(serverName, requestBody); } + + + /** + * Create a new metadata element in the metadata store using a template. The type name comes from the open metadata types. + * The selected type also controls the names and types of the properties that are allowed. + * + * @param serverName name of server instance to route request to + * @param requestBody properties for the new element + * + * @return unique identifier of the new metadata element + * InvalidParameterException the type name, status or one of the properties is invalid + * UserNotAuthorizedException the governance action service is not authorized to create this type of element + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements/from-template") + + public GUIDResponse createMetadataElementFromTemplate(@PathVariable String serverName, + @RequestBody TemplateRequestBody requestBody) + { + return restAPI.createMetadataElementFromTemplate(serverName, requestBody); + } + + + /** + * Update the properties of a specific metadata element. The properties must match the type definition associated with the + * metadata element when it was created. However, it is possible to update a few properties, or replace all them by + * the value used in the replaceProperties flag. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param requestBody new properties + * + * @return void or + * InvalidParameterException either the unique identifier or the properties are invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements/{metadataElementGUID}/update-properties") + + public VoidResponse updateMetadataElementInStore(@PathVariable String serverName, + @PathVariable String metadataElementGUID, + @RequestBody UpdatePropertiesRequestBody requestBody) + { + return restAPI.updateMetadataElementInStore(serverName, metadataElementGUID, requestBody); + } + + + /** + * Update the status of specific metadata element. The new status must match a status value that is defined for the element's type + * assigned when it was created. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param requestBody new status values - use null to leave as is + * + * @return void or + * InvalidParameterException either the unique identifier or the status are invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements/{metadataElementGUID}/update-status") + + public VoidResponse updateMetadataElementStatusInStore(@PathVariable String serverName, + @PathVariable String metadataElementGUID, + @RequestBody UpdateStatusRequestBody requestBody) + { + return restAPI.updateMetadataElementStatusInStore(serverName, metadataElementGUID, requestBody); + } + + + + /** + * Update the effectivity dates control the visibility of the element through specific APIs. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param requestBody new status values - use null to leave as is + * + * @return void or + * InvalidParameterException either the unique identifier or the status are invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements/{metadataElementGUID}/update-effectivity") + + public VoidResponse updateMetadataElementEffectivityInStore(@PathVariable String serverName, + @PathVariable String metadataElementGUID, + @RequestBody UpdateEffectivityDatesRequestBody requestBody) + { + return restAPI.updateMetadataElementEffectivityInStore(serverName, metadataElementGUID, requestBody); + } + + + /** + * Delete a specific metadata element. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param requestBody null request body + * + * @return void or + * InvalidParameterException the unique identifier is null or invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to delete this element + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements/{metadataElementGUID}/delete") + + public VoidResponse deleteMetadataElementInStore(@PathVariable String serverName, + @PathVariable String metadataElementGUID, + @RequestBody(required = false) UpdateRequestBody requestBody) + { + return restAPI.deleteMetadataElementInStore(serverName,metadataElementGUID, requestBody); + } + + + /** + * Archive a specific metadata element. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param requestBody null request body + * + * @return void or + * InvalidParameterException the unique identifier is null or invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to archive this element + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements/{metadataElementGUID}/archive") + + public VoidResponse archiveMetadataElementInStore(@PathVariable String serverName, + @PathVariable String metadataElementGUID, + @RequestBody(required = false) ArchiveRequestBody requestBody) + { + return restAPI.archiveMetadataElementInStore(serverName, metadataElementGUID, requestBody); + } + + + /** + * Add a new classification to the metadata element. Note that only one classification with the same name can be attached to + * a metadata element. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName name of the classification to add (if the classification is already present then use reclassify) + * @param requestBody properties to store in the new classification. These must conform to the valid properties associated with the + * classification name + * + * @return void or + * InvalidParameterException the unique identifier or classification name is null or invalid in some way; properties do not match the + * valid properties associated with the classification's type definition + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements/{metadataElementGUID}/classifications/{classificationName}") + + public VoidResponse classifyMetadataElementInStore(@PathVariable String serverName, + @PathVariable String metadataElementGUID, + @PathVariable String classificationName, + @RequestBody NewClassificationRequestBody requestBody) + { + return restAPI.classifyMetadataElementInStore(serverName, metadataElementGUID, classificationName, requestBody); + } + + + /** + * Update the properties of a classification that is currently attached to a specific metadata element. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName unique name of the classification to update + * @param requestBody new properties for the classification + * + * @return void or + * InvalidParameterException the unique identifier or classification name is null or invalid in some way; properties do not match the + * valid properties associated with the classification's type definition + * UserNotAuthorizedException the governance action service is not authorized to update this element/classification + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements/{metadataElementGUID}/classifications/{classificationName}/update-properties") + + public VoidResponse reclassifyMetadataElementInStore(@PathVariable String serverName, + @PathVariable String metadataElementGUID, + @PathVariable String classificationName, + @RequestBody UpdatePropertiesRequestBody requestBody) + { + return restAPI.reclassifyMetadataElementInStore(serverName, metadataElementGUID, classificationName, requestBody); + } + + + /** + * Update the effectivity dates of a specific classification attached to a metadata element. + * The effectivity dates control the visibility of the classification through specific APIs. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName unique name of the classification to update + * @param requestBody the dates when this element is active / inactive - null for no restriction + * + * @return void or + * InvalidParameterException either the unique identifier or the status are invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements/{metadataElementGUID}/classifications/{classificationName}/update-effectivity") + + public VoidResponse updateClassificationEffectivityInStore(@PathVariable String serverName, + @PathVariable String metadataElementGUID, + @PathVariable String classificationName, + @RequestBody UpdateEffectivityDatesRequestBody requestBody) + { + return restAPI.updateClassificationEffectivityInStore(serverName, metadataElementGUID, classificationName, requestBody); + } + + + /** + * Remove the named classification from a specific metadata element. + * + * @param serverName name of server instance to route request to + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName unique name of the classification to remove + * @param requestBody null request body + * + * @return void or + * InvalidParameterException the unique identifier or classification name is null or invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to remove this classification + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/metadata-elements/{metadataElementGUID}/classifications/{classificationName}/delete") + + public VoidResponse declassifyMetadataElementInStore(@PathVariable String serverName, + @PathVariable String metadataElementGUID, + @PathVariable String classificationName, + @RequestBody UpdateRequestBody requestBody) + { + return restAPI.declassifyMetadataElementInStore(serverName, metadataElementGUID, classificationName, requestBody); + } + + + /** + * Create a relationship between two metadata elements. It is important to put the right element at each end of the relationship + * according to the type definition since this will affect how the relationship is interpreted. + * + * @param serverName name of server instance to route request to + * @param requestBody the properties of the relationship + * + * @return unique identifier of the new relationship or + * InvalidParameterException the unique identifier's of the metadata elements are null or invalid in some way; the properties are + * not valid for this type of relationship + * UserNotAuthorizedException the governance action service is not authorized to create this type of relationship + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/related-elements") + + public GUIDResponse createRelatedElementsInStore(@PathVariable String serverName, + @RequestBody NewRelatedElementsRequestBody requestBody) + { + return restAPI.createRelatedElementsInStore(serverName, requestBody); + } + + + /** + * Update the properties associated with a relationship. + * + * @param serverName name of server instance to route request to + * @param relationshipGUID unique identifier of the relationship to update + * @param requestBody new properties for the relationship + * + * @return void or + * InvalidParameterException the unique identifier of the relationship is null or invalid in some way; the properties are + * not valid for this type of relationship + * UserNotAuthorizedException the governance action service is not authorized to update this relationship + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/related-elements/{relationshipGUID}/update-properties") + + public VoidResponse updateRelatedElementsInStore(@PathVariable String serverName, + @PathVariable String relationshipGUID, + @RequestBody UpdatePropertiesRequestBody requestBody) + { + return restAPI.updateRelatedElementsInStore(serverName, relationshipGUID, requestBody); + } + + + /** + * Update the effectivity dates of a specific relationship between metadata elements. + * The effectivity dates control the visibility of the classification through specific APIs. + * + * @param serverName name of server instance to route request to + * @param relationshipGUID unique identifier of the relationship to update + * @param requestBody the dates when this element is active / inactive - null for no restriction + * + * @return void or + * InvalidParameterException either the unique identifier or the status are invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to update this element + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/related-elements/{relationshipGUID}/update-effectivity") + + public VoidResponse updateRelatedElementsEffectivityInStore(@PathVariable String serverName, + @PathVariable String relationshipGUID, + @RequestBody UpdateEffectivityDatesRequestBody requestBody) + { + return restAPI.updateRelatedElementsEffectivityInStore(serverName, relationshipGUID, requestBody); + } + + + /** + * Delete a relationship between two metadata elements. + * + * @param serverName name of server instance to route request to + * @param relationshipGUID unique identifier of the relationship to delete + * @param requestBody null request body + * + * @return void or + * InvalidParameterException the unique identifier of the relationship is null or invalid in some way + * UserNotAuthorizedException the governance action service is not authorized to delete this relationship + * PropertyServerException there is a problem with the metadata store + */ + @PostMapping(path = "/related-elements/{relationshipGUID}/delete") + + public VoidResponse deleteRelatedElementsInStore(@PathVariable String serverName, + @PathVariable String relationshipGUID, + @RequestBody UpdateRequestBody requestBody) + { + return restAPI.deleteRelatedElementsInStore(serverName, relationshipGUID, requestBody); + } + } diff --git a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java index eec01712ae4..69783e4b3a8 100644 --- a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java +++ b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java @@ -337,12 +337,23 @@ private EntityDef getVirtualRelationalTableEntity() private void update0462GovernanceActionProcesses() { + this.archiveBuilder.addEntityDef(getGovernanceActionProcessInstanceEntity()); this.archiveBuilder.addRelationshipDef(getTargetForActionType()); this.archiveBuilder.addRelationshipDef(getTargetForActionProcess()); this.archiveBuilder.addTypeDefPatch(updateGovernanceActionProcessFlow()); } + private EntityDef getGovernanceActionProcessInstanceEntity() + { + return archiveHelper.getDefaultEntityDef(OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.typeGUID, + OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.typeName, + this.archiveBuilder.getEntityDef(OpenMetadataType.TRANSIENT_EMBEDDED_PROCESS.typeName), + OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.description, + OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.descriptionGUID, + OpenMetadataType.GOVERNANCE_ACTION_PROCESS_INSTANCE.wikiURL); + } + private RelationshipDef getTargetForActionType() { RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(OpenMetadataType.TARGET_FOR_ACTION_TYPE,