Skip to content

Commit

Permalink
Ticket #166: Can Display BPMN workflow file
Browse files Browse the repository at this point in the history
  • Loading branch information
thabart committed Jul 7, 2021
1 parent 0381a46 commit e3c54dc
Show file tree
Hide file tree
Showing 32 changed files with 795 additions and 61 deletions.
24 changes: 24 additions & 0 deletions src/Website/SimpleIdServer.Gateway.Host/ocelot.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,30 @@
"UpstreamPathTemplate": "/workflows/{everything}",
"UpstreamHttpMethod": [ "POST", "GET", "PUT" ]
},
{
"DownstreamPathTemplate": "/processinstances",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 60007
}
],
"UpstreamPathTemplate": "/workflowinstances",
"UpstreamHttpMethod": [ "POST", "GET", "PUT" ]
},
{
"DownstreamPathTemplate": "/processinstances/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 60007
}
],
"UpstreamPathTemplate": "/workflowinstances/{everything}",
"UpstreamHttpMethod": [ "POST", "GET", "PUT" ]
},
{
"DownstreamPathTemplate": "/delegateconfigurations",
"DownstreamScheme": "http",
Expand Down
2 changes: 2 additions & 0 deletions src/Website/SimpleIdServer.Website/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { UserEffects } from './stores/users/effects/user.effects';
import { UserService } from './stores/users/services/user.service';
import { WorkflowEffects } from './stores/workflows/effects/workflow.effects';
import { WorkflowFileService } from './stores/workflows/services/workflowfile.service';
import { WorkflowInstanceService } from './stores/workflows/services/workflowinstance.service';
import { translationFactory } from './translation.util';

export function createTranslateLoader(http: HttpClient) {
Expand Down Expand Up @@ -74,6 +75,7 @@ export function createTranslateLoader(http: HttpClient) {
WorkflowFileService,
GroupService,
HumanTaskDefService,
WorkflowInstanceService,
DelegateConfigurationService,
MetadataService,
{
Expand Down
18 changes: 16 additions & 2 deletions src/Website/SimpleIdServer.Website/src/app/stores/appstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export interface AppState {
delegateConfigurations: fromDelegateConfigurations.DelegateConfigurationLstState,
delegateConfiguration: fromDelegateConfigurations.DelegateConfigurationState,
humanTaskDefs: fromHumanTask.HumanTaskDefLstState,
humanTaskDef: fromHumanTask.HumanTaskState
humanTaskDef: fromHumanTask.HumanTaskState,
workflowInstances: fromWorkflows.SearchWorkflowInstancesState
}

export const selectApplication = (state: AppState) => state.application;
Expand All @@ -47,6 +48,7 @@ export const selectDelegateConfigurations = (state: AppState) => state.delegateC
export const selectDelegateConfiguration = (state: AppState) => state.delegateConfiguration;
export const selectHumanTaskDefs = (state: AppState) => state.humanTaskDefs;
export const selectHumanTaskDef = (state: AppState) => state.humanTaskDef;
export const selectWorkflowInstances = (state: AppState) => state.workflowInstances;

export const selectApplicationResult = createSelector(
selectApplication,
Expand Down Expand Up @@ -268,6 +270,17 @@ export const selectHumanTaskDefResult = createSelector(
}
);

export const selectWorkflowInstancesResult = createSelector(
selectWorkflowInstances,
(state: fromWorkflows.SearchWorkflowInstancesState) => {
if (!state || !state.WorkflowInstances) {
return null;
}

return state.WorkflowInstances;
}
);

export const appReducer = {
application: fromApplications.getApplicationReducer,
applications: fromApplications.getSearchApplicationsReducer,
Expand All @@ -286,5 +299,6 @@ export const appReducer = {
delegateConfigurations: fromDelegateConfigurations.getDelegateConfigurationLstReducer,
delegateConfiguration: fromDelegateConfigurations.getDelegateConfigurationReducer,
humanTaskDefs: fromHumanTask.getHumanTaskLstReducer,
humanTaskDef: fromHumanTask.getHumanTaskReducer
humanTaskDef: fromHumanTask.getHumanTaskReducer,
workflowInstances: fromWorkflows.getWorkflowInstancesReducer
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { createAction, props } from '@ngrx/store';
import { SearchWorkflowFileResult } from '../models/searchworkflowfile.model';
import { SearchWorkflowInstanceResult } from '../models/searchworkflowinstance.model';
import { WorkflowFile } from '../models/workflowfile.model';

export const startSearchFiles = createAction('[Workflows] START_SEARCH_FILES', props<{ startIndex: number, count: number, order: string, direction: string }>());
export const startSearchFiles = createAction('[Workflows] START_SEARCH_FILES', props<{ startIndex: number, count: number, order: string, direction: string, takeLatest: boolean, fileId: string }>());
export const completeSearchFiles = createAction('[Workflows] COMPLETE_SEARCH_FILES', props<{ content: SearchWorkflowFileResult }>());
export const errorSearchFiles = createAction('[Workflows] ERROR_SEARCH_FILES');
export const startGetFile = createAction('[Workflows] START_GET_FILE', props<{ id: string }>());
Expand All @@ -11,3 +12,18 @@ export const errorGetFile = createAction('[Workflows] ERROR_GET_FILE');
export const startUpdateFile = createAction('[Workflows] START_UPDATE_FILE', props<{ id: string, name: string, description: string }>());
export const completeUpdateFile = createAction('[Workflows] COMPLETE_UPDATE_FILE', props<{name: string, description: string}>());
export const errorUpdateFile = createAction('[Workflows] ERROR_UPDATE_FILE');
export const startUpdateFilePayload = createAction('[Workflows] START_UPDATE_FILE_PAYLOAD', props<{ id: string, payload: string }>());
export const completeUpdateFilePayload = createAction('[Workflows] COMPLETE_UPDATE_FILE_PAYLOAD');
export const errorUpdateFilePayload = createAction('[Workflows] ERROR_UPDATE_FILE_PAYLOAD');
export const startPublishFile = createAction('[Workflows] START_PUBLISH_FILE', props<{ id: string }>());
export const completePublishFile = createAction('[Workflows] COMPLETE_PUBLISH_FILE', props<{ id: string }>());
export const errorPublishFile = createAction('[Workflows] ERROR_PUBLISH_FILE');
export const startSearchInstances = createAction('[Workflows] START_SEARCH_INSTANCES', props<{ startIndex: number, count: number, order: string, direction: string, processFileId: string }>());
export const completeSearchInstances = createAction('[Workflows] COMPLETE_SEARCH_INSTANCES', props<{ content: SearchWorkflowInstanceResult }>());
export const errorSearchInstances = createAction('[Workflows] ERROR_SEARCH_INSTANCES');
export const startCreateInstance = createAction('[Workflows] START_CREATE_INSTANCE', props<{ id: string }>());
export const completeCreateInstance = createAction('[Workflows] COMPLETE_CREATE_INSTANCE', props<{ content: SearchWorkflowInstanceResult }>());
export const errorCreateInstance = createAction('[Workflows] ERROR_CREATE_INSTANCE');
export const startInstance = createAction('[Workflows] START_INSTANCE', props<{ id: string }>());
export const completeStartInstance = createAction('[Workflows] COMPLETE_START_INSTANCE');
export const errorStartInstance = createAction('[Workflows] ERROR_START_INSTANCE');
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@ import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { of } from 'rxjs';
import { catchError, map, mergeMap } from 'rxjs/operators';
import { completeGetFile, completeSearchFiles, completeUpdateFile, errorGetFile, errorSearchFiles, errorUpdateFile, startGetFile, startSearchFiles, startUpdateFile } from '../actions/workflow.actions';
import { completeCreateInstance, completeGetFile, completePublishFile, completeSearchFiles, completeSearchInstances, completeStartInstance, completeUpdateFile, completeUpdateFilePayload, errorCreateInstance, errorGetFile, errorPublishFile, errorSearchFiles, errorSearchInstances, errorStartInstance, errorUpdateFile, errorUpdateFilePayload, startCreateInstance, startGetFile, startInstance, startPublishFile, startSearchFiles, startSearchInstances, startUpdateFile, startUpdateFilePayload } from '../actions/workflow.actions';
import { WorkflowFileService } from '../services/workflowfile.service';
import { WorkflowInstanceService } from '../services/workflowinstance.service';

@Injectable()
export class WorkflowEffects {
constructor(
private actions$: Actions,
private workflowFileService: WorkflowFileService,
private workflowInstanceService: WorkflowInstanceService
) { }

@Effect()
searchWorkflowFiles$ = this.actions$
.pipe(
ofType(startSearchFiles),
mergeMap((evt) => {
return this.workflowFileService.search(evt.startIndex, evt.count, evt.order, evt.direction)
return this.workflowFileService.search(evt.startIndex, evt.count, evt.order, evt.direction, evt.takeLatest, evt.fileId)
.pipe(
map(content => completeSearchFiles({ content: content })),
catchError(() => of(errorSearchFiles()))
);
}
)
);
);

@Effect()
getWorkflowFile$ = this.actions$
Expand All @@ -38,7 +40,7 @@ export class WorkflowEffects {
);
}
)
);
);

@Effect()
updateWorkflowFile$ = this.actions$
Expand All @@ -53,4 +55,74 @@ export class WorkflowEffects {
}
)
);

@Effect()
updateWorkflowFilePayload$ = this.actions$
.pipe(
ofType(startUpdateFilePayload),
mergeMap((evt) => {
return this.workflowFileService.updatePayload(evt.id, evt.payload)
.pipe(
map(() => completeUpdateFilePayload()),
catchError(() => of(errorUpdateFilePayload()))
);
}
)
);

@Effect()
publishFile$ = this.actions$
.pipe(
ofType(startPublishFile),
mergeMap((evt) => {
return this.workflowFileService.publish(evt.id)
.pipe(
map((id) => completePublishFile({ id: id })),
catchError(() => of(errorPublishFile()))
);
}
)
);

@Effect()
searchInstances$ = this.actions$
.pipe(
ofType(startSearchInstances),
mergeMap((evt) => {
return this.workflowInstanceService.search(evt.startIndex, evt.count, evt.order, evt.direction, evt.processFileId)
.pipe(
map((content) => completeSearchInstances({ content: content })),
catchError(() => of(errorSearchInstances()))
);
}
)
);

@Effect()
createInstance$ = this.actions$
.pipe(
ofType(startCreateInstance),
mergeMap((evt) => {
return this.workflowInstanceService.create(evt.id)
.pipe(
map((content) => completeCreateInstance({ content: content })),
catchError(() => of(errorCreateInstance()))
);
}
)
);

@Effect()
startInstance$ = this.actions$
.pipe(
ofType(startInstance),
mergeMap((evt) => {
return this.workflowInstanceService.start(evt.id)
.pipe(
map(() => completeStartInstance()),
catchError(() => of(errorStartInstance()))
);
}
)
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

export class ActivityStateHistory {
state: string;
executionDateTime: Date;
message: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export class MessageToken {
name: string;
content: any;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ActivityStateHistory } from "./activitystatehistory.model";

export class NodeInstance {
constructor() {
this.activityStates = [];
}

id: string;
flowNodeId: string;
state: string;
activityState: string;
metadata: any;
activityStates: ActivityStateHistory[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { WorkflowInstance } from "./workflowinstance.model";

export class SearchWorkflowInstanceResult {
startIndex: number;
totalLength: number;
count: number;
content: WorkflowInstance[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export class WorkflowFile {
createDateTime: Date;
updateDateTime: Date;
payload: string;
fileId: string;
version: number;
status: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { WorkflowInstanceExecutionPointer } from "./workflowinstance-executionpointer.model";

export class WorkflowInstanceExecutionPath {
constructor() {
this.executionPointers = [];
}

id: string;
createDateTime: Date;
executionPointers: WorkflowInstanceExecutionPointer[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MessageToken } from "./messagetoken.model";
import { NodeInstance } from "./nodeinstance.model";

export class WorkflowInstanceExecutionPointer {
constructor() {
this.incomingTokens = [];
this.outgoingTokens = [];
}

id: string;
isActive: boolean;
flowNodeId: string;
incomingTokens: MessageToken[];
outgoingTokens: MessageToken[];
flowNodeInstance: NodeInstance;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { WorkflowInstanceExecutionPath } from "./workflowinstance-executionpath.model";

export class WorkflowInstance {
constructor() {
this.executionPaths = [];
}

id: string;
status: string;
processFileId: string;
createDateTime: Date;
updateDateTime: Date;
executionPaths: WorkflowInstanceExecutionPath[];
}
Loading

0 comments on commit e3c54dc

Please sign in to comment.