@valtimo/migration 4.15.3-next-main.16 → 4.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,360 +6,360 @@ import { AlertService, WidgetModule } from '@valtimo/components';
6
6
  import { RouterModule } from '@angular/router';
7
7
  import { CommonModule } from '@angular/common';
8
8
  import { AuthGuardService } from '@valtimo/security';
9
- import { ROLE_ADMIN } from '@valtimo/contract';
9
+ import { ROLE_ADMIN } from '@valtimo/config';
10
10
  import { ReactiveFormsModule, FormsModule } from '@angular/forms';
11
11
  import { TranslateModule } from '@ngx-translate/core';
12
12
 
13
- /*
14
- * Copyright 2015-2020 Ritense BV, the Netherlands.
15
- *
16
- * Licensed under EUPL, Version 1.2 (the "License");
17
- * you may not use this file except in compliance with the License.
18
- * You may obtain a copy of the License at
19
- *
20
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
21
- *
22
- * Unless required by applicable law or agreed to in writing, software
23
- * distributed under the License is distributed on an "AS IS" basis,
24
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
- * See the License for the specific language governing permissions and
26
- * limitations under the License.
27
- */
28
- class MigrationService {
29
- constructor() { }
30
- }
31
- MigrationService.ɵprov = ɵɵdefineInjectable({ factory: function MigrationService_Factory() { return new MigrationService(); }, token: MigrationService, providedIn: "root" });
32
- MigrationService.decorators = [
33
- { type: Injectable, args: [{
34
- providedIn: 'root',
35
- },] }
36
- ];
13
+ /*
14
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
15
+ *
16
+ * Licensed under EUPL, Version 1.2 (the "License");
17
+ * you may not use this file except in compliance with the License.
18
+ * You may obtain a copy of the License at
19
+ *
20
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software
23
+ * distributed under the License is distributed on an "AS IS" basis,
24
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ * See the License for the specific language governing permissions and
26
+ * limitations under the License.
27
+ */
28
+ class MigrationService {
29
+ constructor() { }
30
+ }
31
+ MigrationService.ɵprov = ɵɵdefineInjectable({ factory: function MigrationService_Factory() { return new MigrationService(); }, token: MigrationService, providedIn: "root" });
32
+ MigrationService.decorators = [
33
+ { type: Injectable, args: [{
34
+ providedIn: 'root',
35
+ },] }
36
+ ];
37
37
  MigrationService.ctorParameters = () => [];
38
38
 
39
- /*
40
- * Copyright 2015-2020 Ritense BV, the Netherlands.
41
- *
42
- * Licensed under EUPL, Version 1.2 (the "License");
43
- * you may not use this file except in compliance with the License.
44
- * You may obtain a copy of the License at
45
- *
46
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
47
- *
48
- * Unless required by applicable law or agreed to in writing, software
49
- * distributed under the License is distributed on an "AS IS" basis,
50
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51
- * See the License for the specific language governing permissions and
52
- * limitations under the License.
53
- */
54
- class MigrationProcessDiagramComponent {
55
- constructor(logger) {
56
- this.logger = logger;
57
- this.flowNodeMap = null;
58
- this.loaded = new EventEmitter();
59
- }
60
- ngOnInit() {
61
- this.bpmnJS = new BpmnJS();
62
- this.bpmnJS.on('import.done', ({ error }) => {
63
- if (!error) {
64
- const canvas = this.bpmnJS.get('canvas');
65
- canvas.zoom('fit-viewport', 'auto');
66
- }
67
- });
68
- }
69
- ngOnDestroy() {
70
- if (this.bpmnJS) {
71
- this.bpmnJS.destroy();
72
- }
73
- }
74
- clear() {
75
- this.bpmnJS.clear();
76
- }
77
- loadXml(xml) {
78
- this.bpmnJS.attachTo(this.el.nativeElement);
79
- this.bpmnJS.importXML(xml, err => {
80
- this.logger.debug(err);
81
- const processElements = this.bpmnJS.getDefinitions().rootElements.filter(function (element) {
82
- return element.isExecutable;
83
- });
84
- this.flowNodeMap = processElements[0].flowElements.filter(function (element) {
85
- if (element.name === null || element.name === '') {
86
- element.name = element.id;
87
- }
88
- return element.$type !== 'bpmn:SequenceFlow';
89
- });
90
- this.loaded.emit(this.name);
91
- });
92
- }
93
- }
94
- MigrationProcessDiagramComponent.decorators = [
95
- { type: Component, args: [{
96
- selector: 'valtimo-migration-process-diagram',
97
- template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div #ref class=\"diagram-container\"></div>\n",
98
- styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.diagram-container-switch-holder{width:100%;z-index:1000}.diagram-container{height:48vh}"]
99
- },] }
100
- ];
101
- MigrationProcessDiagramComponent.ctorParameters = () => [
102
- { type: NGXLogger }
103
- ];
104
- MigrationProcessDiagramComponent.propDecorators = {
105
- el: [{ type: ViewChild, args: ['ref',] }],
106
- name: [{ type: Input }],
107
- loaded: [{ type: Output }]
39
+ /*
40
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
41
+ *
42
+ * Licensed under EUPL, Version 1.2 (the "License");
43
+ * you may not use this file except in compliance with the License.
44
+ * You may obtain a copy of the License at
45
+ *
46
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
47
+ *
48
+ * Unless required by applicable law or agreed to in writing, software
49
+ * distributed under the License is distributed on an "AS IS" basis,
50
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51
+ * See the License for the specific language governing permissions and
52
+ * limitations under the License.
53
+ */
54
+ class MigrationProcessDiagramComponent {
55
+ constructor(logger) {
56
+ this.logger = logger;
57
+ this.flowNodeMap = null;
58
+ this.loaded = new EventEmitter();
59
+ }
60
+ ngOnInit() {
61
+ this.bpmnJS = new BpmnJS();
62
+ this.bpmnJS.on('import.done', ({ error }) => {
63
+ if (!error) {
64
+ const canvas = this.bpmnJS.get('canvas');
65
+ canvas.zoom('fit-viewport', 'auto');
66
+ }
67
+ });
68
+ }
69
+ ngOnDestroy() {
70
+ if (this.bpmnJS) {
71
+ this.bpmnJS.destroy();
72
+ }
73
+ }
74
+ clear() {
75
+ this.bpmnJS.clear();
76
+ }
77
+ loadXml(xml) {
78
+ this.bpmnJS.attachTo(this.el.nativeElement);
79
+ this.bpmnJS.importXML(xml, err => {
80
+ this.logger.debug(err);
81
+ const processElements = this.bpmnJS.getDefinitions().rootElements.filter(function (element) {
82
+ return element.isExecutable;
83
+ });
84
+ this.flowNodeMap = processElements[0].flowElements.filter(function (element) {
85
+ if (element.name === null || element.name === '') {
86
+ element.name = element.id;
87
+ }
88
+ return element.$type !== 'bpmn:SequenceFlow';
89
+ });
90
+ this.loaded.emit(this.name);
91
+ });
92
+ }
93
+ }
94
+ MigrationProcessDiagramComponent.decorators = [
95
+ { type: Component, args: [{
96
+ selector: 'valtimo-migration-process-diagram',
97
+ template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div #ref class=\"diagram-container\"></div>\n",
98
+ styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.diagram-container-switch-holder{width:100%;z-index:1000}.diagram-container{height:48vh}"]
99
+ },] }
100
+ ];
101
+ MigrationProcessDiagramComponent.ctorParameters = () => [
102
+ { type: NGXLogger }
103
+ ];
104
+ MigrationProcessDiagramComponent.propDecorators = {
105
+ el: [{ type: ViewChild, args: ['ref',] }],
106
+ name: [{ type: Input }],
107
+ loaded: [{ type: Output }]
108
108
  };
109
109
 
110
- /*
111
- * Copyright 2015-2020 Ritense BV, the Netherlands.
112
- *
113
- * Licensed under EUPL, Version 1.2 (the "License");
114
- * you may not use this file except in compliance with the License.
115
- * You may obtain a copy of the License at
116
- *
117
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
118
- *
119
- * Unless required by applicable law or agreed to in writing, software
120
- * distributed under the License is distributed on an "AS IS" basis,
121
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122
- * See the License for the specific language governing permissions and
123
- * limitations under the License.
124
- */
125
- class MigrationComponent {
126
- constructor(processService, logger, alertService) {
127
- this.processService = processService;
128
- this.logger = logger;
129
- this.alertService = alertService;
130
- this.processDefinitions = [];
131
- this.selectedVersions = {
132
- source: [],
133
- target: [],
134
- };
135
- this.selectedId = {
136
- source: null,
137
- target: null,
138
- };
139
- this.loaded = {
140
- source: false,
141
- target: false,
142
- };
143
- this.fields = {
144
- source: {
145
- definition: null,
146
- version: null,
147
- },
148
- target: {
149
- definition: null,
150
- version: null,
151
- },
152
- };
153
- this.processCount = null;
154
- this.uniqueFlowNodeMap = [];
155
- this.taskMapping = {};
156
- this.diagram = null;
157
- }
158
- ngOnInit() {
159
- this.loadProcessDefinitions();
160
- }
161
- ngAfterViewInit() {
162
- this.diagram = {
163
- source: this.sourceDiagram,
164
- target: this.targetDiagram,
165
- };
166
- }
167
- get taskMappingLength() {
168
- return Object.keys(this.taskMapping).length;
169
- }
170
- loadProcessDefinitions() {
171
- this.processService
172
- .getProcessDefinitions()
173
- .subscribe((processDefinitions) => {
174
- this.processDefinitions = processDefinitions;
175
- });
176
- }
177
- loadProcessDefinitionVersions(key, type) {
178
- this.fields[type].definition = key;
179
- this.selectedVersions[type] = [];
180
- this.clearProcess(type);
181
- if (key) {
182
- this.processService
183
- .getProcessDefinitionVersions(key)
184
- .subscribe((processDefinitionVersions) => {
185
- this.selectedVersions[type] = processDefinitionVersions;
186
- });
187
- }
188
- }
189
- loadProcess(id, type) {
190
- this.fields[type].version = id;
191
- this.clearProcess(type);
192
- if (id) {
193
- this.loadProcessDefinitionXML(id, type);
194
- if (type === 'source') {
195
- this.loadProcessCount(id);
196
- }
197
- }
198
- }
199
- clearProcess(type) {
200
- this.loaded[type] = false;
201
- this.selectedId[type] = null;
202
- this.diagram[type].clear();
203
- if (type === 'source') {
204
- this.processCount = null;
205
- }
206
- }
207
- loadProcessDefinitionXML(id, type) {
208
- this.processService.getProcessDefinitionXml(id).subscribe(xml => {
209
- this.diagram[type].loadXml(xml['bpmn20Xml']);
210
- this.selectedId[type] = id;
211
- });
212
- }
213
- loadProcessCount(id) {
214
- this.processService.getProcessCount(id).subscribe(response => {
215
- this.processCount = response.count;
216
- });
217
- }
218
- setUniqueFlowNodeMap() {
219
- this.uniqueFlowNodeMap = [];
220
- const sourceFlowNodeMap = this.sourceDiagram.flowNodeMap;
221
- const targetFlowNodeMap = this.targetDiagram.flowNodeMap;
222
- if (sourceFlowNodeMap != null && targetFlowNodeMap != null) {
223
- this.uniqueFlowNodeMap = sourceFlowNodeMap.filter(sourceFlowNode => !targetFlowNodeMap.some(targetFlowNode => sourceFlowNode.id === targetFlowNode.id &&
224
- sourceFlowNode.$type === targetFlowNode.$type));
225
- }
226
- }
227
- getFilteredTargetFlowNodeMap(flowNodeType) {
228
- const targetFlowNodeMap = this.targetDiagram.flowNodeMap;
229
- return targetFlowNodeMap.filter(function (flowNode) {
230
- return flowNode.$type === flowNodeType;
231
- });
232
- }
233
- diagramLoaded(diagramName) {
234
- this.loaded[diagramName] = true;
235
- if (this.loaded.source && this.loaded.target) {
236
- this.taskMapping = {};
237
- this.setUniqueFlowNodeMap();
238
- }
239
- }
240
- migrateProcess() {
241
- this.processService
242
- .migrateProcess(this.selectedId.source, this.selectedId.target, this.taskMapping)
243
- .subscribe(res => {
244
- this.alertService.success('Process successfully migrated!');
245
- this.clearProcess('source');
246
- this.clearProcess('target');
247
- this.fields = {
248
- source: {
249
- definition: null,
250
- version: null,
251
- },
252
- target: {
253
- definition: null,
254
- version: null,
255
- },
256
- };
257
- }, err => {
258
- this.alertService.error('Process migration failed!');
259
- this.logger.debug(err);
260
- });
261
- }
262
- }
263
- MigrationComponent.decorators = [
264
- { type: Component, args: [{
265
- selector: 'valtimo-migration',
266
- template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div class=\"main-content\">\n <div class=\"container-fluid\">\n <div class=\"row mb-5\">\n <div class=\"col-12\">\n <div class=\"alert alert-warning pl-2 plr-2\" role=\"alert\">\n <div class=\"icon\"><span class=\"mdi mdi-alert-triangle\"></span></div>\n <div class=\"message\" [innerHTML]=\"'Process migration warning' | translate\"></div>\n </div>\n </div>\n </div>\n <div class=\"row mb-5\">\n <div class=\"col-4\">\n <label for=\"sourceDef\">Source Definition</label>\n <select\n class=\"form-control\"\n id=\"sourceDef\"\n [ngModel]=\"fields.source.definition\"\n (ngModelChange)=\"loadProcessDefinitionVersions($event, 'source')\"\n >\n <option [ngValue]=\"null\" selected>- Source Definition -</option>\n <option *ngFor=\"let processDef of processDefinitions\" [ngValue]=\"processDef.key\">\n {{ processDef.name }}\n </option>\n </select>\n </div>\n <div class=\"col-2\">\n <label for=\"sourceVer\">Source Version</label>\n <select\n class=\"form-control\"\n id=\"sourceVer\"\n [ngModel]=\"fields.source.version\"\n (ngModelChange)=\"loadProcess($event, 'source')\"\n >\n <option [ngValue]=\"null\" selected>- Source Version -</option>\n <option *ngFor=\"let processVer of selectedVersions.source\" [ngValue]=\"processVer.id\">\n {{ processVer.version }}\n </option>\n </select>\n </div>\n <div class=\"col-4\">\n <label for=\"targetDef\">Target Definition</label>\n <select\n class=\"form-control\"\n id=\"targetDef\"\n [ngModel]=\"fields.target.definition\"\n (ngModelChange)=\"loadProcessDefinitionVersions($event, 'target')\"\n >\n <option [ngValue]=\"null\" selected>- Target Definition -</option>\n <option *ngFor=\"let processDef of processDefinitions\" [ngValue]=\"processDef.key\">\n {{ processDef.name }}\n </option>\n </select>\n </div>\n <div class=\"col-2\">\n <label for=\"targetVer\">Target Version</label>\n <select\n class=\"form-control\"\n id=\"targetVer\"\n [ngModel]=\"fields.target.version\"\n (ngModelChange)=\"loadProcess($event, 'target')\"\n >\n <option [ngValue]=\"null\" selected>- Target Version -</option>\n <option *ngFor=\"let processVer of selectedVersions.target\" [ngValue]=\"processVer.id\">\n {{ processVer.version }}\n </option>\n </select>\n </div>\n </div>\n\n <div class=\"row mb-5\">\n <div class=\"col-6\">\n <valtimo-migration-process-diagram\n name=\"source\"\n (loaded)=\"diagramLoaded($event)\"\n #sourceDiagram\n ></valtimo-migration-process-diagram>\n </div>\n <div class=\"col-6\">\n <valtimo-migration-process-diagram\n name=\"target\"\n (loaded)=\"diagramLoaded($event)\"\n #targetDiagram\n ></valtimo-migration-process-diagram>\n </div>\n </div>\n <table class=\"table table-striped mb-5\" *ngIf=\"selectedId.source && selectedId.target\">\n <tr *ngFor=\"let node of uniqueFlowNodeMap\">\n <td>{{ node.name ? node.name : node.id }}</td>\n <td>\n <select class=\"form-control\" (change)=\"taskMapping[node.id] = $event.target.value\">\n <option [value]=\"null\" disabled selected>- Choose Target -</option>\n <option\n *ngFor=\"let targetFlowNode of getFilteredTargetFlowNodeMap(node.$type)\"\n [value]=\"targetFlowNode.id\"\n >\n {{ targetFlowNode.name ? targetFlowNode.name : targetFlowNode.id }}\n </option>\n </select>\n </td>\n </tr>\n </table>\n <hr />\n <div class=\"btn-group mb-5\">\n <button\n [disabled]=\"\n (uniqueFlowNodeMap.length !== taskMappingLength && uniqueFlowNodeMap.length > 0) ||\n !loaded.source ||\n !loaded.target\n \"\n (click)=\"migrateProcess()\"\n class=\"btn btn-primary\"\n >\n Migrate\n <span *ngIf=\"processCount !== null\" class=\"badge badge-pill badge-secondary\">{{\n processCount\n }}</span>\n </button>\n </div>\n </div>\n</div>\n",
267
- styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */"]
268
- },] }
269
- ];
270
- MigrationComponent.ctorParameters = () => [
271
- { type: ProcessService },
272
- { type: NGXLogger },
273
- { type: AlertService }
274
- ];
275
- MigrationComponent.propDecorators = {
276
- sourceDiagram: [{ type: ViewChild, args: ['sourceDiagram',] }],
277
- targetDiagram: [{ type: ViewChild, args: ['targetDiagram',] }]
110
+ /*
111
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
112
+ *
113
+ * Licensed under EUPL, Version 1.2 (the "License");
114
+ * you may not use this file except in compliance with the License.
115
+ * You may obtain a copy of the License at
116
+ *
117
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
118
+ *
119
+ * Unless required by applicable law or agreed to in writing, software
120
+ * distributed under the License is distributed on an "AS IS" basis,
121
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122
+ * See the License for the specific language governing permissions and
123
+ * limitations under the License.
124
+ */
125
+ class MigrationComponent {
126
+ constructor(processService, logger, alertService) {
127
+ this.processService = processService;
128
+ this.logger = logger;
129
+ this.alertService = alertService;
130
+ this.processDefinitions = [];
131
+ this.selectedVersions = {
132
+ source: [],
133
+ target: [],
134
+ };
135
+ this.selectedId = {
136
+ source: null,
137
+ target: null,
138
+ };
139
+ this.loaded = {
140
+ source: false,
141
+ target: false,
142
+ };
143
+ this.fields = {
144
+ source: {
145
+ definition: null,
146
+ version: null,
147
+ },
148
+ target: {
149
+ definition: null,
150
+ version: null,
151
+ },
152
+ };
153
+ this.processCount = null;
154
+ this.uniqueFlowNodeMap = [];
155
+ this.taskMapping = {};
156
+ this.diagram = null;
157
+ }
158
+ ngOnInit() {
159
+ this.loadProcessDefinitions();
160
+ }
161
+ ngAfterViewInit() {
162
+ this.diagram = {
163
+ source: this.sourceDiagram,
164
+ target: this.targetDiagram,
165
+ };
166
+ }
167
+ get taskMappingLength() {
168
+ return Object.keys(this.taskMapping).length;
169
+ }
170
+ loadProcessDefinitions() {
171
+ this.processService
172
+ .getProcessDefinitions()
173
+ .subscribe((processDefinitions) => {
174
+ this.processDefinitions = processDefinitions;
175
+ });
176
+ }
177
+ loadProcessDefinitionVersions(key, type) {
178
+ this.fields[type].definition = key;
179
+ this.selectedVersions[type] = [];
180
+ this.clearProcess(type);
181
+ if (key) {
182
+ this.processService
183
+ .getProcessDefinitionVersions(key)
184
+ .subscribe((processDefinitionVersions) => {
185
+ this.selectedVersions[type] = processDefinitionVersions;
186
+ });
187
+ }
188
+ }
189
+ loadProcess(id, type) {
190
+ this.fields[type].version = id;
191
+ this.clearProcess(type);
192
+ if (id) {
193
+ this.loadProcessDefinitionXML(id, type);
194
+ if (type === 'source') {
195
+ this.loadProcessCount(id);
196
+ }
197
+ }
198
+ }
199
+ clearProcess(type) {
200
+ this.loaded[type] = false;
201
+ this.selectedId[type] = null;
202
+ this.diagram[type].clear();
203
+ if (type === 'source') {
204
+ this.processCount = null;
205
+ }
206
+ }
207
+ loadProcessDefinitionXML(id, type) {
208
+ this.processService.getProcessDefinitionXml(id).subscribe(xml => {
209
+ this.diagram[type].loadXml(xml['bpmn20Xml']);
210
+ this.selectedId[type] = id;
211
+ });
212
+ }
213
+ loadProcessCount(id) {
214
+ this.processService.getProcessCount(id).subscribe(response => {
215
+ this.processCount = response.count;
216
+ });
217
+ }
218
+ setUniqueFlowNodeMap() {
219
+ this.uniqueFlowNodeMap = [];
220
+ const sourceFlowNodeMap = this.sourceDiagram.flowNodeMap;
221
+ const targetFlowNodeMap = this.targetDiagram.flowNodeMap;
222
+ if (sourceFlowNodeMap != null && targetFlowNodeMap != null) {
223
+ this.uniqueFlowNodeMap = sourceFlowNodeMap.filter(sourceFlowNode => !targetFlowNodeMap.some(targetFlowNode => sourceFlowNode.id === targetFlowNode.id &&
224
+ sourceFlowNode.$type === targetFlowNode.$type));
225
+ }
226
+ }
227
+ getFilteredTargetFlowNodeMap(flowNodeType) {
228
+ const targetFlowNodeMap = this.targetDiagram.flowNodeMap;
229
+ return targetFlowNodeMap.filter(function (flowNode) {
230
+ return flowNode.$type === flowNodeType;
231
+ });
232
+ }
233
+ diagramLoaded(diagramName) {
234
+ this.loaded[diagramName] = true;
235
+ if (this.loaded.source && this.loaded.target) {
236
+ this.taskMapping = {};
237
+ this.setUniqueFlowNodeMap();
238
+ }
239
+ }
240
+ migrateProcess() {
241
+ this.processService
242
+ .migrateProcess(this.selectedId.source, this.selectedId.target, this.taskMapping)
243
+ .subscribe(res => {
244
+ this.alertService.success('Process successfully migrated!');
245
+ this.clearProcess('source');
246
+ this.clearProcess('target');
247
+ this.fields = {
248
+ source: {
249
+ definition: null,
250
+ version: null,
251
+ },
252
+ target: {
253
+ definition: null,
254
+ version: null,
255
+ },
256
+ };
257
+ }, err => {
258
+ this.alertService.error('Process migration failed!');
259
+ this.logger.debug(err);
260
+ });
261
+ }
262
+ }
263
+ MigrationComponent.decorators = [
264
+ { type: Component, args: [{
265
+ selector: 'valtimo-migration',
266
+ template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div class=\"main-content\">\n <div class=\"container-fluid\">\n <div class=\"row mb-5\">\n <div class=\"col-12\">\n <div class=\"alert alert-warning pl-2 plr-2\" role=\"alert\">\n <div class=\"icon\"><span class=\"mdi mdi-alert-triangle\"></span></div>\n <div class=\"message\" [innerHTML]=\"'Process migration warning' | translate\"></div>\n </div>\n </div>\n </div>\n <div class=\"row mb-5\">\n <div class=\"col-4\">\n <label for=\"sourceDef\">Source Definition</label>\n <select\n class=\"form-control\"\n id=\"sourceDef\"\n [ngModel]=\"fields.source.definition\"\n (ngModelChange)=\"loadProcessDefinitionVersions($event, 'source')\"\n >\n <option [ngValue]=\"null\" selected>- Source Definition -</option>\n <option *ngFor=\"let processDef of processDefinitions\" [ngValue]=\"processDef.key\">\n {{ processDef.name }}\n </option>\n </select>\n </div>\n <div class=\"col-2\">\n <label for=\"sourceVer\">Source Version</label>\n <select\n class=\"form-control\"\n id=\"sourceVer\"\n [ngModel]=\"fields.source.version\"\n (ngModelChange)=\"loadProcess($event, 'source')\"\n >\n <option [ngValue]=\"null\" selected>- Source Version -</option>\n <option *ngFor=\"let processVer of selectedVersions.source\" [ngValue]=\"processVer.id\">\n {{ processVer.version }}\n </option>\n </select>\n </div>\n <div class=\"col-4\">\n <label for=\"targetDef\">Target Definition</label>\n <select\n class=\"form-control\"\n id=\"targetDef\"\n [ngModel]=\"fields.target.definition\"\n (ngModelChange)=\"loadProcessDefinitionVersions($event, 'target')\"\n >\n <option [ngValue]=\"null\" selected>- Target Definition -</option>\n <option *ngFor=\"let processDef of processDefinitions\" [ngValue]=\"processDef.key\">\n {{ processDef.name }}\n </option>\n </select>\n </div>\n <div class=\"col-2\">\n <label for=\"targetVer\">Target Version</label>\n <select\n class=\"form-control\"\n id=\"targetVer\"\n [ngModel]=\"fields.target.version\"\n (ngModelChange)=\"loadProcess($event, 'target')\"\n >\n <option [ngValue]=\"null\" selected>- Target Version -</option>\n <option *ngFor=\"let processVer of selectedVersions.target\" [ngValue]=\"processVer.id\">\n {{ processVer.version }}\n </option>\n </select>\n </div>\n </div>\n\n <div class=\"row mb-5\">\n <div class=\"col-6\">\n <valtimo-migration-process-diagram\n name=\"source\"\n (loaded)=\"diagramLoaded($event)\"\n #sourceDiagram\n ></valtimo-migration-process-diagram>\n </div>\n <div class=\"col-6\">\n <valtimo-migration-process-diagram\n name=\"target\"\n (loaded)=\"diagramLoaded($event)\"\n #targetDiagram\n ></valtimo-migration-process-diagram>\n </div>\n </div>\n <table class=\"table table-striped mb-5\" *ngIf=\"selectedId.source && selectedId.target\">\n <tr *ngFor=\"let node of uniqueFlowNodeMap\">\n <td>{{ node.name ? node.name : node.id }}</td>\n <td>\n <select class=\"form-control\" (change)=\"taskMapping[node.id] = $event.target.value\">\n <option [value]=\"null\" disabled selected>- Choose Target -</option>\n <option\n *ngFor=\"let targetFlowNode of getFilteredTargetFlowNodeMap(node.$type)\"\n [value]=\"targetFlowNode.id\"\n >\n {{ targetFlowNode.name ? targetFlowNode.name : targetFlowNode.id }}\n </option>\n </select>\n </td>\n </tr>\n </table>\n <hr />\n <div class=\"btn-group mb-5\">\n <button\n [disabled]=\"\n (uniqueFlowNodeMap.length !== taskMappingLength && uniqueFlowNodeMap.length > 0) ||\n !loaded.source ||\n !loaded.target\n \"\n (click)=\"migrateProcess()\"\n class=\"btn btn-primary\"\n >\n Migrate\n <span *ngIf=\"processCount !== null\" class=\"badge badge-pill badge-secondary\">{{\n processCount\n }}</span>\n </button>\n </div>\n </div>\n</div>\n",
267
+ styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */"]
268
+ },] }
269
+ ];
270
+ MigrationComponent.ctorParameters = () => [
271
+ { type: ProcessService },
272
+ { type: NGXLogger },
273
+ { type: AlertService }
274
+ ];
275
+ MigrationComponent.propDecorators = {
276
+ sourceDiagram: [{ type: ViewChild, args: ['sourceDiagram',] }],
277
+ targetDiagram: [{ type: ViewChild, args: ['targetDiagram',] }]
278
278
  };
279
279
 
280
- /*
281
- * Copyright 2015-2020 Ritense BV, the Netherlands.
282
- *
283
- * Licensed under EUPL, Version 1.2 (the "License");
284
- * you may not use this file except in compliance with the License.
285
- * You may obtain a copy of the License at
286
- *
287
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
288
- *
289
- * Unless required by applicable law or agreed to in writing, software
290
- * distributed under the License is distributed on an "AS IS" basis,
291
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
292
- * See the License for the specific language governing permissions and
293
- * limitations under the License.
294
- */
295
- const ɵ0 = { title: 'Process migration', roles: [ROLE_ADMIN] };
296
- const routes = [
297
- {
298
- path: 'process-migration',
299
- component: MigrationComponent,
300
- canActivate: [AuthGuardService],
301
- data: ɵ0,
302
- },
303
- ];
304
- class MigrationRoutingModule {
305
- }
306
- MigrationRoutingModule.decorators = [
307
- { type: NgModule, args: [{
308
- imports: [CommonModule, RouterModule.forChild(routes)],
309
- exports: [RouterModule],
310
- },] }
280
+ /*
281
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
282
+ *
283
+ * Licensed under EUPL, Version 1.2 (the "License");
284
+ * you may not use this file except in compliance with the License.
285
+ * You may obtain a copy of the License at
286
+ *
287
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
288
+ *
289
+ * Unless required by applicable law or agreed to in writing, software
290
+ * distributed under the License is distributed on an "AS IS" basis,
291
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
292
+ * See the License for the specific language governing permissions and
293
+ * limitations under the License.
294
+ */
295
+ const ɵ0 = { title: 'Process migration', roles: [ROLE_ADMIN] };
296
+ const routes = [
297
+ {
298
+ path: 'process-migration',
299
+ component: MigrationComponent,
300
+ canActivate: [AuthGuardService],
301
+ data: ɵ0,
302
+ },
303
+ ];
304
+ class MigrationRoutingModule {
305
+ }
306
+ MigrationRoutingModule.decorators = [
307
+ { type: NgModule, args: [{
308
+ imports: [CommonModule, RouterModule.forChild(routes)],
309
+ exports: [RouterModule],
310
+ },] }
311
311
  ];
312
312
 
313
- /*
314
- * Copyright 2015-2020 Ritense BV, the Netherlands.
315
- *
316
- * Licensed under EUPL, Version 1.2 (the "License");
317
- * you may not use this file except in compliance with the License.
318
- * You may obtain a copy of the License at
319
- *
320
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
321
- *
322
- * Unless required by applicable law or agreed to in writing, software
323
- * distributed under the License is distributed on an "AS IS" basis,
324
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
325
- * See the License for the specific language governing permissions and
326
- * limitations under the License.
327
- */
328
- class MigrationModule {
329
- }
330
- MigrationModule.decorators = [
331
- { type: NgModule, args: [{
332
- declarations: [MigrationComponent, MigrationProcessDiagramComponent],
333
- imports: [
334
- CommonModule,
335
- MigrationRoutingModule,
336
- ReactiveFormsModule,
337
- WidgetModule,
338
- FormsModule,
339
- TranslateModule,
340
- ],
341
- exports: [MigrationComponent],
342
- },] }
313
+ /*
314
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
315
+ *
316
+ * Licensed under EUPL, Version 1.2 (the "License");
317
+ * you may not use this file except in compliance with the License.
318
+ * You may obtain a copy of the License at
319
+ *
320
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
321
+ *
322
+ * Unless required by applicable law or agreed to in writing, software
323
+ * distributed under the License is distributed on an "AS IS" basis,
324
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
325
+ * See the License for the specific language governing permissions and
326
+ * limitations under the License.
327
+ */
328
+ class MigrationModule {
329
+ }
330
+ MigrationModule.decorators = [
331
+ { type: NgModule, args: [{
332
+ declarations: [MigrationComponent, MigrationProcessDiagramComponent],
333
+ imports: [
334
+ CommonModule,
335
+ MigrationRoutingModule,
336
+ ReactiveFormsModule,
337
+ WidgetModule,
338
+ FormsModule,
339
+ TranslateModule,
340
+ ],
341
+ exports: [MigrationComponent],
342
+ },] }
343
343
  ];
344
344
 
345
- /*
346
- * Copyright 2015-2020 Ritense BV, the Netherlands.
347
- *
348
- * Licensed under EUPL, Version 1.2 (the "License");
349
- * you may not use this file except in compliance with the License.
350
- * You may obtain a copy of the License at
351
- *
352
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
353
- *
354
- * Unless required by applicable law or agreed to in writing, software
355
- * distributed under the License is distributed on an "AS IS" basis,
356
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
357
- * See the License for the specific language governing permissions and
358
- * limitations under the License.
345
+ /*
346
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
347
+ *
348
+ * Licensed under EUPL, Version 1.2 (the "License");
349
+ * you may not use this file except in compliance with the License.
350
+ * You may obtain a copy of the License at
351
+ *
352
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
353
+ *
354
+ * Unless required by applicable law or agreed to in writing, software
355
+ * distributed under the License is distributed on an "AS IS" basis,
356
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
357
+ * See the License for the specific language governing permissions and
358
+ * limitations under the License.
359
359
  */
360
360
 
361
- /**
362
- * Generated bundle index. Do not edit.
361
+ /**
362
+ * Generated bundle index. Do not edit.
363
363
  */
364
364
 
365
365
  export { MigrationComponent, MigrationModule, MigrationService, MigrationProcessDiagramComponent as ɵa, MigrationRoutingModule as ɵb };