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

fix(bpmn-service): fix workflow model audit fields #240

Merged
merged 2 commits into from
Jul 5, 2021
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
18,880 changes: 27 additions & 18,853 deletions packages/user-onboarding/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/user-onboarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@angular/platform-browser": "~11.2.3",
"@angular/platform-browser-dynamic": "~11.2.3",
"@angular/router": "~11.2.3",
"@videogular/ngx-videogular": "^3.0.1",
"json-server": "^0.16.3",
"ngx-webstorage-service": "^4.1.0",
"prettier": "^2.3.0",
Expand Down
4 changes: 1 addition & 3 deletions sandbox/workflow-ms-example/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {BPMTask} from '@sourceloop/bpmn-service/dist/bpm-task';
import path from 'path';
import {SayHelloCommand} from './commands/sayhello.command';
import {BpmnProvider} from './providers/bpmn.provider';
import {MySequence} from './sequence';

export {ApplicationConfig};

Expand All @@ -26,7 +25,6 @@ export class WorkflowHelloworldApplication extends BootMixin(
super(options);

// Set up the custom sequence
this.sequence(MySequence);

// Set up default home page
this.static('/', path.join(__dirname, '../public'));
Expand All @@ -39,7 +37,7 @@ export class WorkflowHelloworldApplication extends BootMixin(

this.bind(WorkflowServiceBindings.Config).toDynamicValue(() => {
return {
useCustomSequence: true,
useCustomSequence: false,
workflowEngineBaseUrl: process.env.CAMUNDA_URL,
};
});
Expand Down
21 changes: 18 additions & 3 deletions sandbox/workflow-ms-example/src/providers/bpmn.provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {bind, BindingScope, Provider, service} from '@loopback/core';
import {AnyObject} from '@loopback/repository';
import {HttpErrors} from '@loopback/rest';
import {WorflowManager, Workflow, WorkflowDto} from '@sourceloop/bpmn-service';
import {WorkflowVersion} from '../../../../services/bpmn-service/dist';
import {CamundaService} from '../services/camunda.service';

@bind({scope: BindingScope.TRANSIENT})
Expand Down Expand Up @@ -44,14 +46,18 @@ export class BpmnProvider implements Provider<WorflowManager> {
Buffer.from(workflowDto.bpmnFile, 'utf-8'),
);
let version = 1;
let id = response.id;
let id;
if (response.deployedProcessDefinitions) {
const processDefinition = Object.values(
//NOSONAR
response.deployedProcessDefinitions, //NOSONAR
)[0] as AnyObject; //NOSONAR
version = processDefinition.version;
id = processDefinition.id;
} else {
throw new HttpErrors.BadRequest(
'Workflow with same name and definition already exists',
);
}
return {
version: version,
Expand Down Expand Up @@ -86,10 +92,19 @@ export class BpmnProvider implements Provider<WorflowManager> {
fileRef: workflowDto.bpmnFile,
};
},
deleteWorkflowById: async workflow => {
await this.camunda.delete(workflow.externalIdentifier);
deleteWorkflowById: async (workflow: Workflow) => {
await this.camunda.delete(
workflow.workflowVersions.map(
(version: WorkflowVersion) => version.externalWorkflowId as string,
),
);
return workflow;
},

deleteWorkflowVersionById: async (version: WorkflowVersion) => {
await this.camunda.deleteVersion(version.externalWorkflowId);
return version;
},
};
}
}
25 changes: 15 additions & 10 deletions sandbox/workflow-ms-example/src/services/camunda.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ export class CamundaService {
this.baseUrl = config?.workflowEngineBaseUrl;
}

/*
* Add service methods here
*/
async create(name: string, file: Buffer) {
const form = new FormData();
form.append(`${name}.bpmn`, file.toString('utf-8'), {
Expand All @@ -32,16 +29,24 @@ export class CamundaService {
return this.http.postFormData(`${this.baseUrl}/deployment/create`, form);
}

async delete(id: string, cascade = true) {
return this.http.delete(`${this.baseUrl}/deployment/${id}`, {
query: {
cascade: cascade,
},
});
async delete(ids: string[]) {
return Promise.all(
ids.map(id =>
this.http.delete(`${this.baseUrl}/process-definition/${id}`, {
query: {
cascade: true,
},
}),
),
);
}

async deleteVersion(id: string) {
return this.http.delete(`${this.baseUrl}/process-definition/${id}`);
}

async get(id: string) {
return this.http.get(`${this.baseUrl}/deployment/${id}`);
return this.http.get(`${this.baseUrl}/process-definition/${id}`);
}

async execute(id: string, input: AnyObject) {
Expand Down
4 changes: 3 additions & 1 deletion sandbox/workflow-ms-example/src/services/http.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export class HttpClientService {

private async handleRes(res: Response) {
if (res.status === STATUS_CODE.OK) {
return res.json();
return res.json().catch(e => ({}));
} else if (res.status === STATUS_CODE.NO_CONTENT) {
return {};
} else {
throw new HttpErrors.BadRequest(await res.text());
}
Expand Down
50 changes: 44 additions & 6 deletions services/bpmn-service/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"security": [
{
"bearerAuth": []
"HTTPBearer": []
}
],
"responses": {
Expand Down Expand Up @@ -49,6 +49,44 @@
"operationId": "WorkflowController.startWorkflow"
}
},
"/workflow/{id}/version/{version}": {
"delete": {
"x-controller-name": "WorkflowController",
"x-operation-name": "deleteVersionById",
"tags": [
"WorkflowController"
],
"security": [
{
"HTTPBearer": []
}
],
"responses": {
"204": {
"description": "Workflow DELETE success"
}
},
"parameters": [
{
"name": "id",
"in": "path",
"schema": {
"type": "string"
},
"required": true
},
{
"name": "version",
"in": "path",
"schema": {
"type": "number"
},
"required": true
}
],
"operationId": "WorkflowController.deleteVersionById"
}
},
"/workflow/{id}": {
"patch": {
"x-controller-name": "WorkflowController",
Expand All @@ -58,7 +96,7 @@
],
"security": [
{
"bearerAuth": []
"HTTPBearer": []
}
],
"responses": {
Expand Down Expand Up @@ -95,7 +133,7 @@
],
"security": [
{
"bearerAuth": []
"HTTPBearer": []
}
],
"responses": {
Expand Down Expand Up @@ -123,7 +161,7 @@
],
"security": [
{
"bearerAuth": []
"HTTPBearer": []
}
],
"responses": {
Expand Down Expand Up @@ -153,7 +191,7 @@
],
"security": [
{
"bearerAuth": []
"HTTPBearer": []
}
],
"responses": {
Expand Down Expand Up @@ -187,7 +225,7 @@
],
"security": [
{
"bearerAuth": []
"HTTPBearer": []
}
],
"responses": {
Expand Down
Loading