Skip to content
Open
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
9 changes: 9 additions & 0 deletions src/helper-modules/process-derivation/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2017-present PROCEED Project Authors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 changes: 26 additions & 0 deletions src/helper-modules/process-derivation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Process derivation

Module that allows the derivation of BPMN processes from SAP BOM data

## About this module

Use src/main.js to derive processes from SAP BOM data.
It provides two functions to derive processes from an Excel file (binary) or a JSON array.
The required file format is documented in JSDOC.

The folder "test_with_web_app" contains a test web application that allows uploading an Excel spreadsheet and mapping the spreadsheet to the expected data structure. It uses the src/main.js for process derivation and can dispplay the resulting process.

## Usage

Call the deriveProcessFromData() or deriveProcessFromExcel() function in main.js with the respective parameters. For more details, see also JSDOC and the provided test cases.
A BPMN XML String is returned.

### deriveProcessFromExcel

You can use one of the following exampels to read a Excel file as binary data to call the derivation with:

FileReader.readAsBinaryString(file).onload((e)=> e.target.result)

OR

fs.readFileSync('/BOM.xlsx', 'binary');
Binary file not shown.
119 changes: 119 additions & 0 deletions src/helper-modules/process-derivation/__tests__/data/testdata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"processSettings": {
"id": "Bike_mr017i5",
"name": "Derived process for: Bike (1.8.2023, 13:47:43)",
"processType": "Private",
"isExecutable": "false",
"taskType": "Task",
"forceConcurrentTasks": false,
"useSubProcesses": false,
"concurrentIntermediateEvent": true,
"subProcessesMaterials": [],
"textAnnotationsContents": [],
"concurrentTasks": false,
"stopOnMaterialTypes": ["ROH", "HIBE"],
"elementAlignment": "Aligned"
},

"processData": {
"Bike_BOM": [
{
"material": "Bike",
"materialName": "Bike",
"quantity": 1,
"unit": "PC",
"category": "L",
"layer": 0,
"materialType": "FERT"
},
{
"material": "A",
"materialName": "Handlebars",
"layer": 1,
"materialType": "HALB",
"quantity": 1,
"unit": "PC"
},
{
"material": "AA",
"materialName": "Gear",
"layer": 2,
"materialType": "ROH",
"quantity": 1,
"unit": "PC"
},
{
"material": "AB",
"materialName": "Bell",
"layer": 2,
"materialType": "ROH",
"quantity": 1,
"unit": "PC"
},
{
"material": "AC",
"materialName": "Brake",
"layer": 2,
"materialType": "ROH",
"quantity": 2,
"unit": "PC"
},
{
"material": "B",
"materialName": "Frame",
"layer": 1,
"materialType": "HALB",
"quantity": 1,
"unit": "PC"
},
{
"material": "BA",
"materialName": "Pedals",
"layer": 2,
"materialType": "ROH",
"quantity": 2,
"unit": "PC"
},
{
"material": "BB",
"materialName": "Cables",
"layer": 2,
"materialType": "ROH",
"quantity": 3,
"unit": "PC"
},
{
"material": "BC",
"materialName": "Chain",
"layer": 2,
"materialType": "ROH",
"quantity": 1,
"unit": "PC"
},
{
"material": "C",
"materialName": "Wheels",
"layer": 1,
"materialType": "HALB",
"quantity": 2,
"unit": "PC"
},
{
"material": "CA",
"materialName": "Tires",
"layer": 2,
"materialType": "ROH",
"quantity": 1,
"unit": "PC"
},
{
"material": "CB",
"materialName": "Spokes",
"layer": 2,
"materialType": "ROH",
"quantity": 12,
"unit": "PC"
}
]
}
}
53 changes: 53 additions & 0 deletions src/helper-modules/process-derivation/__tests__/derivation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const derivation = require('../src/main.js');
const derivationData = require('./data/testdata.json');
const XLSX = require('xlsx');
const fs = require('fs');
const path = require('path');

describe('Tests for the derivation function of this library directly', () => {
beforeEach(() => {});

test('test derivation', async () => {
let process = await derivation.deriveProcessFromData(
derivationData.processSettings,
derivationData.processData
);

expect(typeof process).toBe('string');
expect(process).toContain('<?xml version="1.0" encoding="UTF-8"?>');
expect(process).toContain('<definitions ');
expect(process).toContain('<process ');
expect(process).toContain('<startEvent ');
expect(process).toContain('<endEvent ');
expect(process).toContain('<task ');
expect(process).toContain('<sequenceFlow ');
expect(process).toContain('<parallelGateway ');
expect(process).toContain('<bpmndi:BPMNDiagram ');
expect(process).toContain('<bpmndi:BPMNPlane ');
expect(process).toContain('<bpmndi:BPMNShape ');
expect(process).toContain('<bpmndi:BPMNEdge ');
expect(process).toContain('<dc:Bounds ');
expect(process).toContain('<di:waypoint ');
});

test('test derivation of Excel file without mappings', async () => {
let BOM = fs.readFileSync(path.join(__dirname, '/data/BOM.xlsx'), 'binary');
let process = await derivation.deriveProcessFromExcel(derivationData.processSettings, BOM);

expect(typeof process).toBe('string');
expect(process).toContain('<?xml version="1.0" encoding="UTF-8"?>');
expect(process).toContain('<definitions ');
expect(process).toContain('<process ');
expect(process).toContain('<startEvent ');
expect(process).toContain('<endEvent ');
expect(process).toContain('<task ');
expect(process).toContain('<sequenceFlow ');
expect(process).toContain('<parallelGateway ');
expect(process).toContain('<bpmndi:BPMNDiagram ');
expect(process).toContain('<bpmndi:BPMNPlane ');
expect(process).toContain('<bpmndi:BPMNShape ');
expect(process).toContain('<bpmndi:BPMNEdge ');
expect(process).toContain('<dc:Bounds ');
expect(process).toContain('<di:waypoint ');
});
});
5 changes: 5 additions & 0 deletions src/helper-modules/process-derivation/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const derivation = require('./src/main.js');

module.exports = {
...derivation,
};
17 changes: 17 additions & 0 deletions src/helper-modules/process-derivation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@proceed/process-derivation",
"version": "1.0.0",
"author": "PROCEED Project",
"license": "MIT",
"homepage": "https://proceed.snet.tu-berlin.de/",
"description": "This library provides functions that help import processes and data from SAP BOMs into PROCEED",
"main": "index.js",
"scripts": {
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"bpmn-moddle": "^6.0.7",
"xlsx": "^0.18.5"
}
}
112 changes: 112 additions & 0 deletions src/helper-modules/process-derivation/src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
const VisualElementOffsetX = 125;
const VisualElementOffsetY = 110;

const ShapeSize = {
Task: { width: 100, height: 80 },
SubProcess: { width: 100, height: 80 },
Event: { width: 36, height: 36 },
Gateway: { width: 50, height: 50 },
TextAnnotation: { width: 400, height: 200 },
default: { width: 70, height: 50 },
};

const TaskNames = {
assemble: 'Assemble ',
source: 'Source ',
finalize: 'Finalize ',
combineXY: 'Add X into Y ',
};

const Task = {
none: 'Task',
service: 'ServiceTask',
send: 'SendTask',
user: 'UserTask',
manual: 'ManualTask',
script: 'ScriptTask',
subProcess: 'SubProcess', //? corrects
};

const Event = {
start: 'StartEvent',
end: 'EndEvent',
intermediateCatch: 'IntermediateCatchEvent',
intermediateThrow: 'IntermediateThrowEvent',
};

const Gateway = {
exclusive: 'ExclusiveGateway',
parallel: 'ParallelGateway',
intermediateCatch: 'InclusiveGateway',
complex: 'ComplexGateway',
event: 'EventBasedGateway',
};

const Other = {
textAnnotation: 'TextAnnotation',
association: 'Association',
sequenceFlow: 'SequenceFlow',
};

const NodeTypes = {
rootElements: 'rootElements',
flowElements: 'flowElements',
values: 'values',
diagrams: 'diagrams',
imports: 'imports',
extensionElements: 'extensionElements',
BPMNShape: 'BPMNShape',
};

const ExpectedColNames = {
BOM: {
material: ['Component number', 'MatID', 'material', 'Komponentennummer'],
materialName: ['Object description', 'name', 'Objektkurztext', 'materialName'],
layer: ['Layer', 'Level', 'Lvl', 'Stufe', 'layer'],
materialType: ['Material type', 'type', 'Positionstyp', 'materialType'], // ROH HALB FERT
quantity: ['Comp. Qty (CUn)', 'quantity', 'Komponentenmenge', 'quantity'],
unit: ['Component UoM', 'unit', 'KompMengenEinheit', 'unit'],
// category: ["Item category", "category", "Warengruppe"], // L / T
},

operations: {
operation: ['Operation', 'operation'],
workCenter: ['WorkCenter', 'workCenter'],
description: ['Description', 'description'],
quantity: ['Quantity', 'quantity'],
unit: ['Unit', 'unit'],
},

allocations: {
operation: ['Operation', 'operation'],
component: ['Component', 'component'],
quantity: ['Quantity', 'quantity'],
unit: ['Unit', 'unit'],
// itemNr:["ItemNr"],
// itemCategory:["ItemCategory"],
// materialDescription:["MaterialDescription"],
},
};

//const EventDefinition = {
// message: 'MessageEventDefinition',
// escalation: 'EscalationEventDefinition',
// conditional: 'ConditionalEventDefinition',
// link:'LinkEventDefinition',
// compensate: 'CompensateEventDefinition',
// signal: 'SignalEventDefinition',
// };
//

module.exports = {
VisualElementOffsetX,
VisualElementOffsetY,
ShapeSize,
TaskNames,
Task,
Event,
Gateway,
Other,
NodeTypes,
ExpectedColNames,
};
Loading