Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add cancel command for an engine action #8055

Merged
merged 2 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ distributions {
{ include 'Egeria*.http' }
from { "$rootProject.projectDir/open-metadata-implementation/view-services/glossary-workflow" }
{ include 'Egeria*.http' }
from { "$rootProject.projectDir/open-metadata-implementation/user-security/user-authn" }
{ include 'Egeria*.http' }
from { "$rootProject.projectDir/open-metadata-conformance-suite" }
{ include 'Egeria*.http' }
fileMode = 0755
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.odpi.openmetadata.commonservices.ffdc.exceptions.OMAGCheckedExceptionBase;
import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition;

import java.io.Serial;
import java.util.Map;

/**
Expand All @@ -16,8 +17,9 @@
* The aim is to be able to uniquely identify the cause and remedy for the error.
*/
public class AssetCatalogException extends OMAGCheckedExceptionBase {

private static final long serialVersionUID = 1L;

@Serial
private static final long serialVersionUID = 1L;

/**
* This is the typical constructor used for creating an AssetCatalogException.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
@JsonSubTypes.Type(value = LineageSyncEvent.class, name = "LineageSyncEvent")
})

public abstract class AssetLineageEventHeader implements Serializable {

public abstract class AssetLineageEventHeader
{
private long eventVersionId = 1L;

private AssetLineageEventType assetLineageEventType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class LineageEntityEvent extends AssetLineageEventHeader {
public class LineageEntityEvent extends AssetLineageEventHeader
{

private LineageEntity lineageEntity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class LineageRelationshipEvent extends AssetLineageEventHeader {
public class LineageRelationshipEvent extends AssetLineageEventHeader
{
private LineageRelationship lineageRelationship;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class LineageRelationshipsEvent extends AssetLineageEventHeader {

public class LineageRelationshipsEvent extends AssetLineageEventHeader
{
private RelationshipsContext relationshipsContext;

public RelationshipsContext getRelationshipsContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;

/**
* The lineage event contains information used for internal processing of data
*
* LineageSyncEvent is used to notify external consumers about AssetLineage internal processing.
* It can contain details such as publishSummary and/or updateSummary created by corresponding internal processing phases of AssetLineage.
*/
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
Expand All @@ -26,14 +26,8 @@
@Setter
@EqualsAndHashCode(callSuper = true)
@ToString
/**
*
* LineageSyncEvent is used to notify external consumers about AssetLineage internal processing.
* It can contain details such as publishSummary and/or updateSummary created by corresponding internal processing phases of AssetLineage.
*
*/
public class LineageSyncEvent extends AssetLineageEventHeader {

public class LineageSyncEvent extends AssetLineageEventHeader
{
/**
* LineagePublishSummary is used to describe summary as result of AssetLineage lineagePublish activity that completed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition;
import org.odpi.openmetadata.frameworks.connectors.ffdc.OCFCheckedExceptionBase;

import java.io.Serial;
import java.util.Map;

/**
* AssetLineageException provides a checked exception for reporting errors found when using
* the Asset Lineage OMAS services.
*/
public class AssetLineageException extends OCFCheckedExceptionBase {
@Serial
private static final long serialVersionUID = 1L;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
/* Copyright Contributors to the ODPi Egeria project. */
package org.odpi.openmetadata.accessservices.assetlineage.model;

import java.io.Serializable;

public class GenericStub implements Serializable {



public class GenericStub
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ public B getNewBean(Class<B> beanClass,
*/
B returnBean = beanClass.getDeclaredConstructor().newInstance();

if (returnBean instanceof FileElement)
if (returnBean instanceof FileElement bean)
{
FileElement bean = (FileElement) returnBean;
FileProperties fileProperties = new FileProperties();

bean.setElementHeader(super.getMetadataElementHeader(beanClass, entity, methodName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition;
import org.odpi.openmetadata.frameworks.connectors.ffdc.OCFCheckedExceptionBase;

import java.io.Serial;
import java.util.Map;

/**
Expand All @@ -18,7 +19,8 @@
*/
public abstract class CommunityProfileCheckedExceptionBase extends OCFCheckedExceptionBase
{
private static final long serialVersionUID = 1L;
@Serial
private static final long serialVersionUID = 1L;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition;

import java.io.Serial;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
Expand All @@ -15,8 +16,8 @@
*/
public class NoProfileForUserException extends CommunityProfileCheckedExceptionBase
{
private static final long serialVersionUID = 1L;

@Serial
private static final long serialVersionUID = 1L;
private String userId;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@Deprecated
public class StatusRequestBody implements Serializable
{
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ else if (repositoryHelper.isTypeOf(serviceName, actualTypeName, OpenMetadataType
{
ActionTargetElement actionTargetElement = new ActionTargetElement();

actionTargetElement.setActionTargetRelationshipGUID(relationship.getGUID());
actionTargetElement.setActionTargetName(this.removeActionTargetName(instanceProperties));
actionTargetElement.setStatus(this.removeActionStatus(OpenMetadataType.STATUS_PROPERTY_NAME, instanceProperties));
actionTargetElement.setStatus(this.removeActionStatus(OpenMetadataType.ACTION_STATUS_PROPERTY_NAME, instanceProperties));
actionTargetElement.setStartDate(this.removeStartDate(instanceProperties));
actionTargetElement.setCompletionDate(this.removeCompletionDate(instanceProperties));
actionTargetElement.setCompletionMessage(this.removeCompletionMessage(instanceProperties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public GovernanceActionProcessRESTServices()


/* =====================================================================================================================
* A governance action process describes a well defined series of steps that gets something done.
* A governance action process describes a well-defined series of steps that gets something done.
* The steps are defined using GovernanceActionTypes.
*/

Expand Down Expand Up @@ -97,17 +97,18 @@ public GUIDResponse createGovernanceActionProcess(String

Map<String, Object> extendedProperties = new HashMap<>();
extendedProperties.put(OpenMetadataProperty.FORMULA.name, processProperties.getFormula());
extendedProperties.put(OpenMetadataType.IMPLEMENTATION_LANGUAGE_PROPERTY_NAME, processProperties.getImplementationLanguage());
extendedProperties.put(OpenMetadataProperty.FORMULA_TYPE.name, processProperties.getFormulaType());
extendedProperties.put(OpenMetadataType.DOMAIN_IDENTIFIER_PROPERTY_NAME, processProperties.getDomainIdentifier());

Date effectiveTime = new Date();

response.setGUID(handler.createAssetInRepository(userId,
null,
null,
processProperties.getQualifiedName(),
processProperties.getTechnicalName(),
processProperties.getDisplayName(),
processProperties.getVersionIdentifier(),
processProperties.getTechnicalDescription(),
processProperties.getDescription(),
processProperties.getAdditionalProperties(),
OpenMetadataType.GOVERNANCE_ACTION_PROCESS_TYPE_NAME,
extendedProperties,
Expand All @@ -116,27 +117,6 @@ public GUIDResponse createGovernanceActionProcess(String
null,
effectiveTime,
methodName));

final String guidParameter = "processGUID";

if (response.getGUID() != null)
{
handler.maintainSupplementaryProperties(userId,
response.getGUID(),
guidParameter,
OpenMetadataType.GOVERNANCE_ACTION_PROCESS_TYPE_NAME,
processProperties.getQualifiedName(),
processProperties.getDisplayName(),
processProperties.getSummary(),
processProperties.getDescription(),
processProperties.getAbbreviation(),
processProperties.getUsage(),
false,
false,
false,
effectiveTime,
methodName);
}
}
else
{
Expand All @@ -163,23 +143,14 @@ private InstanceStatus getProcessStatus(ProcessStatus processStatus)
{
if (processStatus != null)
{
switch (processStatus)
return switch (processStatus)
{
case UNKNOWN:
return InstanceStatus.UNKNOWN;

case DRAFT:
return InstanceStatus.DRAFT;

case PROPOSED:
return InstanceStatus.PROPOSED;

case APPROVED:
return InstanceStatus.APPROVED;

case ACTIVE:
return InstanceStatus.ACTIVE;
}
case UNKNOWN -> InstanceStatus.UNKNOWN;
case DRAFT -> InstanceStatus.DRAFT;
case PROPOSED -> InstanceStatus.PROPOSED;
case APPROVED -> InstanceStatus.APPROVED;
case ACTIVE -> InstanceStatus.ACTIVE;
};
}

return InstanceStatus.ACTIVE;
Expand Down Expand Up @@ -224,7 +195,7 @@ public VoidResponse updateGovernanceActionProcess(String

Map<String, Object> extendedProperties = new HashMap<>();
extendedProperties.put(OpenMetadataProperty.FORMULA.name, processProperties.getFormula());
extendedProperties.put(OpenMetadataType.IMPLEMENTATION_LANGUAGE_PROPERTY_NAME, processProperties.getImplementationLanguage());
extendedProperties.put(OpenMetadataProperty.FORMULA_TYPE.name, processProperties.getFormulaType());

Date effectiveTime = new Date();

Expand All @@ -235,8 +206,8 @@ public VoidResponse updateGovernanceActionProcess(String
processGUIDParameterName,
processProperties.getQualifiedName(),
processProperties.getVersionIdentifier(),
processProperties.getTechnicalName(),
processProperties.getTechnicalDescription(),
processProperties.getDisplayName(),
processProperties.getDescription(),
processProperties.getAdditionalProperties(),
OpenMetadataType.GOVERNANCE_ACTION_PROCESS_TYPE_GUID,
OpenMetadataType.GOVERNANCE_ACTION_PROCESS_TYPE_NAME,
Expand Down Expand Up @@ -265,22 +236,6 @@ public VoidResponse updateGovernanceActionProcess(String
effectiveTime,
methodName);
}

handler.maintainSupplementaryProperties(userId,
processGUID,
processGUIDParameterName,
OpenMetadataType.GOVERNANCE_ACTION_PROCESS_TYPE_NAME,
processProperties.getQualifiedName(),
processProperties.getDisplayName(),
processProperties.getSummary(),
processProperties.getDescription(),
processProperties.getAbbreviation(),
processProperties.getUsage(),
requestBody.getMergeUpdate(),
false,
false,
effectiveTime,
methodName);
}
else
{
Expand Down Expand Up @@ -1098,7 +1053,6 @@ public GovernanceActionTypeElementResponse getFirstActionType(String serverName,
GovernanceActionProcessStepHandler<GovernanceActionTypeElement> handler = instanceHandler.getGovernanceActionProcessStepHandler(userId,
serverName,
methodName);

response.setElement(handler.getFirstProcessStep(userId,
processGUID,
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class GovernanceActionResource
* PropertyServerException there was a problem detected by the metadata store.
*/
@PostMapping(path = "/governance-actions/{governanceActionGUID}/status/update")

public VoidResponse updateGovernanceActionStatus(@PathVariable String serverName,
@PathVariable String userId,
@PathVariable String governanceActionGUID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ public enum GovernanceServerEventType implements Serializable
"Requested Engine Action",
"New request to run a governance service."),

/**
* New request to run a governance service.
*/
CANCELLED_ENGINE_ACTION_EVENT(5,
"Cancelled Engine Action",
"Request to stop a governance service."),

;

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,17 @@ public enum GovernanceServerAuditCode implements AuditLogMessageSet
"This is not necessarily an error if the server is connected to a cohort where members are also connected to other cohorts, of there is strict security in place that is restricting what this server can see.",
"Review the exception to reassure yourself that this is expected behavior."),

/**
* OMAS-GOVERNANCE-SERVER-0023 - The Governance Server Open Metadata Access Service (OMAS) sent notification of a cancelled engine action {0} for Governance Engine {1} ({2})
*/
CANCELLED_ENGINE_ACTION("OMAS-GOVERNANCE-SERVER-0023",
AuditLogRecordSeverityLevel.INFO,
"The Governance Server Open Metadata Access Service (OMAS) sent notification of a cancelled engine action {0} for Governance Engine {1} ({2})",
"The access service sends out notifications about cancelled engine actions to Engine Hosts so " +
"they can stop the execution of the requested governance service.",
"This is part of the normal operation of the service. No action is required if this action is expected " +
"beyond verifying that the requested action is correctly shutdown."),

;


Expand Down
Loading
Loading