Skip to content
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
6 changes: 6 additions & 0 deletions workspaces/orchestrator/.changeset/good-wasps-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@red-hat-developer-hub/backstage-plugin-orchestrator-common': patch
'@red-hat-developer-hub/backstage-plugin-orchestrator': patch
---

removing business key
5 changes: 5 additions & 0 deletions workspaces/orchestrator/.changeset/silly-horses-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@red-hat-developer-hub/backstage-plugin-orchestrator-backend': patch
---

remove business key
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ describe('fetchInstances', () => {
definitionIds,
)}`;
const queryBody =
'id, processName, processId, businessKey, state, start, end, nodes { id }, variables, parentProcessInstance {id, processName, businessKey}';
'id, processName, processId, state, start, end, nodes { id }, variables, parentProcessInstance {id, processName, businessKey}';

const mockProcessInstances: ProcessInstance[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export class DataIndexService {
const graphQlQuery = buildGraphQlQuery({
type: 'ProcessInstances',
queryBody:
'id, processName, processId, businessKey, state, start, end, nodes { id }, variables, parentProcessInstance {id, processName, businessKey}',
'id, processName, processId, state, start, end, nodes { id }, variables, parentProcessInstance {id, processName, businessKey}',
whereClause,
pagination,
});
Expand Down Expand Up @@ -421,7 +421,6 @@ export class DataIndexService {
processName
processId
serviceUrl
businessKey
state
start
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export class OrchestratorService {
serviceUrl: string;
inputData?: ProcessInstanceVariables;
authTokens?: Array<AuthToken>;
businessKey?: string;
}): Promise<WorkflowExecutionResponse | undefined> {
return await this.sonataFlowService.executeWorkflow(args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ export class SonataFlowService {
authTokens?: Array<AuthToken>;
businessKey?: string;
}): Promise<WorkflowExecutionResponse | undefined> {
const urlToFetch = args.businessKey
? `${args.serviceUrl}/${args.definitionId}?businessKey=${args.businessKey}`
: `${args.serviceUrl}/${args.definitionId}`;
const urlToFetch = `${args.serviceUrl}/${args.definitionId}`;
const headers: Record<string, string> = {
'Content-Type': 'application/json',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ export function mapToProcessInstanceDTO(
processName: processInstance.processName,
description: processInstance.description,
serviceUrl: processInstance.serviceUrl,
businessKey: processInstance.businessKey,
endpoint: processInstance.endpoint,
error: processInstance.error,
category: mapWorkflowCategoryDTO(processInstance.category),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ describe('executeWorkflow', () => {
const actualResultV2: ExecuteWorkflowResponseDTO = await v2.executeWorkflow(
workflowData,
workflowInfo.id,
'businessKey',
'someUserEntity',
);

Expand Down Expand Up @@ -490,26 +489,21 @@ describe('getInstanceById', () => {

it('Instance exists, assessment non empty string', async () => {
const processInstance = generateProcessInstance(1);
processInstance.businessKey = 'testBusinessKey';
const assessedBy = generateProcessInstance(1);
assessedBy.id = processInstance.businessKey;

(mockOrchestratorService.fetchInstance as jest.Mock)
.mockResolvedValueOnce(processInstance)
.mockResolvedValueOnce(assessedBy);

// Act
const processInstanceV2: AssessedProcessInstanceDTO =
await v2.getInstanceById(processInstance.id, true);
await v2.getInstanceById(processInstance.id);

// Assert
expect(mockOrchestratorService.fetchInstance).toHaveBeenCalledTimes(2);
expect(processInstanceV2).toBeDefined();
expect(processInstanceV2.instance).toBeDefined();
expect(processInstanceV2.assessedBy).toBeDefined();
expect(processInstanceV2.assessedBy?.id).toEqual(
processInstance.businessKey,
);
expect(processInstanceV2.instance.id).toEqual(processInstance.id);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
ExecuteWorkflowRequestDTO,
ExecuteWorkflowResponseDTO,
Filter,
ProcessInstance,
ProcessInstanceListResultDTO,
ProcessInstanceState,
WorkflowDTO,
Expand Down Expand Up @@ -127,7 +126,6 @@ export class V2 {

public async getInstanceById(
instanceId: string,
includeAssessment: boolean = false,
): Promise<AssessedProcessInstanceDTO> {
const instance = await this.orchestratorService.fetchInstance({
instanceId,
Expand All @@ -137,26 +135,15 @@ export class V2 {
throw new Error(`Couldn't fetch process instance ${instanceId}`);
}

let assessedByInstance: ProcessInstance | undefined;

if (includeAssessment && instance.businessKey) {
assessedByInstance = await this.orchestratorService.fetchInstance({
instanceId: instance.businessKey,
});
}

return {
instance: mapToProcessInstanceDTO(instance),
assessedBy: assessedByInstance
? mapToProcessInstanceDTO(assessedByInstance)
: undefined,
assessedBy: undefined,
};
}

public async executeWorkflow(
executeWorkflowRequestDTO: ExecuteWorkflowRequestDTO,
workflowId: string,
businessKey: string | undefined,
initiatorEntity: string,
): Promise<ExecuteWorkflowResponseDTO> {
const definition = await this.orchestratorService.fetchWorkflowInfo({
Expand All @@ -176,7 +163,6 @@ export class V2 {
},
authTokens: executeWorkflowRequestDTO.authTokens as Array<AuthToken>,
serviceUrl: definition.serviceUrl,
businessKey,
});

if (!executionResponse) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ import {
orchestratorWorkflowSpecificPermission,
orchestratorWorkflowUsePermission,
orchestratorWorkflowUseSpecificPermission,
QUERY_PARAM_BUSINESS_KEY,
QUERY_PARAM_INCLUDE_ASSESSMENT,
WorkflowOverviewListResultDTO,
} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';

Expand Down Expand Up @@ -450,18 +448,12 @@ function setupInternalRoutes(
manageDenyAuthorization(auditEvent);
}

const businessKey = routerApi.v2.extractQueryParam(
c.request,
QUERY_PARAM_BUSINESS_KEY,
);

const executeWorkflowRequestDTO = req.body;

return routerApi.v2
.executeWorkflow(
executeWorkflowRequestDTO,
workflowId,
businessKey,
initiatorEntity,
)
.then(result => {
Expand Down Expand Up @@ -874,15 +866,9 @@ function setupInternalRoutes(
},
});

const includeAssessment = routerApi.v2.extractQueryParam(
c.request,
QUERY_PARAM_INCLUDE_ASSESSMENT,
);

try {
const assessedInstance = await routerApi.v2.getInstanceById(
instanceId,
!!includeAssessment,
);

const workflowId = assessedInstance.instance.processId;
Expand Down
Loading
Loading