Skip to content

Commit 4938ba9

Browse files
committed
refactor: modify workflow schema
1 parent ec42d9d commit 4938ba9

File tree

4 files changed

+50
-27
lines changed

4 files changed

+50
-27
lines changed

src/js/app.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ export let app;
183183
currentDataElements: {
184184
deep: true,
185185
handler(newValue, oldValue) {
186-
const difference = findDifferenceBy(newValue, oldValue, "boxId");
187-
console.log("TCL: handler -> newValue", difference);
186+
// const difference = findDifferenceBy(newValue, oldValue, "boxId");
188187
// for (const { boxId, defaultParams } of difference) {
189188
// setSelectValueInElement(boxId, defaultParams[Types.SELECT.type]);
190189
// setInputValueInElement(boxId, defaultParams[Types.NUMBER.type]);

src/js/layout/utils.js

-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ i++;
186186
*/
187187

188188
export const buildPortAttrs = (name, type, typeAllowed) => {
189-
console.log("TCL: buildPortAttrs -> type", type);
190189
const showPortDetails = layoutSettingsApp.isShowPortsDetailsChecked();
191190
const showPorts = layoutSettingsApp.isShowPortsChecked();
192191
const typeAllowedShort = shortenString(typeAllowed.join(", "), 25);
@@ -228,7 +227,6 @@ export const createPort = (param, group) => {
228227
typeAllowed[0].indexOf("/") < 0
229228
? typeAllowed[0].length
230229
: typeAllowed[0].indexOf("/");
231-
console.log("TCL: typeEnd", typeEnd);
232230
type = typeAllowed[0].substr(
233231
//@TODO diff types ?
234232
0,

src/js/workflows/readWorkflow.js

+34-20
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const readWorkflow = async id => {
1717

1818
const elements = [];
1919
const links = [];
20+
const linksTmp = [];
2021

2122
xml2js.parseString(xml, async (err, json) => {
2223
if (!json.WorkflowDefinition.Steps) {
@@ -27,12 +28,15 @@ export const readWorkflow = async id => {
2728

2829
for (const step of Step) {
2930
const {
30-
Id: [id], // from saveWorkflow, id is defined with the boxId
31+
// Id: [id], // from saveWorkflow, id is defined with the boxId
32+
No: [no],
3133
Inputs: [inputs],
3234
Name: [name],
3335
Service: [service]
3436
} = step;
3537

38+
const boxId = generateUniqueId();
39+
3640
const webserviceObj = getWebserviceById(service.Key[0]);
3741
if (webserviceObj.length) {
3842
alert("step ", name, " not found");
@@ -46,7 +50,7 @@ export const readWorkflow = async id => {
4650
if (Parameter) {
4751
for (const param of Parameter) {
4852
const {
49-
paramName: [name],
53+
Name: [name],
5054
Value: [value]
5155
} = param;
5256

@@ -57,46 +61,56 @@ export const readWorkflow = async id => {
5761
}
5862
}
5963

60-
// store links
6164
if (Data) {
6265
for (const port of Data) {
6366
const {
6467
Value: [value],
6568
Name: [portName]
6669
} = port;
67-
const {
68-
Ref: [ref],
69-
ServiceOutputName: [serviceName]
70-
} = value.WorkflowStep[0];
71-
72-
const source = {
73-
boxId: ref,
74-
portName: serviceName
75-
};
76-
const target = { boxId: id, portName };
77-
links.push({
78-
id: generateUniqueId(),
79-
source,
80-
target
81-
});
70+
linksTmp.push({ targetBoxId: boxId, value, portName });
8271
}
8372
}
8473

85-
const information = { id };
74+
const information = { boxId };
8675

8776
// add element
8877
const param = buildElementFromName(webserviceObj.name);
8978

9079
const element = {
80+
no,
9181
...param,
9282
information,
9383
defaultParams,
94-
boxId: id
84+
boxId
9585
};
9686

9787
elements.push(element);
9888
}
9989
});
10090

91+
for (const link of linksTmp) {
92+
const { targetBoxId, value, portName } = link;
93+
94+
// store links
95+
const {
96+
Ref: [ref],
97+
ServiceOutputName: [serviceName]
98+
} = value.WorkflowStep[0];
99+
100+
// find corresponding step with given ref
101+
const sourceStep = elements.find(({ no }) => no == ref);
102+
const sourceBoxId = sourceStep.boxId;
103+
const source = {
104+
boxId: sourceBoxId,
105+
portName: serviceName
106+
};
107+
const target = { boxId: targetBoxId, portName };
108+
links.push({
109+
id: generateUniqueId(),
110+
source,
111+
target
112+
});
113+
}
114+
101115
app.openWorkflow({ elements, links });
102116
};

src/js/workflows/saveWorkflow.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ export const saveWorkflow = jsonGraph => {
3434
const { value: Value, defaultValue, values } = options;
3535
if (Value != defaultValue.toString()) {
3636
Inputs.Parameter.push({
37-
paramName,
37+
Name: paramName,
3838
Value
3939
});
4040
}
4141
const validity = Validation.checkValue(Value, paramType, values);
4242
if (!validity) {
43-
log.push({ value: Value, paramName, paramType, name: type, boxId });
43+
log.push({
44+
value: Value,
45+
Name: paramName,
46+
paramType,
47+
name: type,
48+
boxId
49+
});
4450
}
4551
}
4652
}
@@ -86,7 +92,7 @@ export const saveWorkflow = jsonGraph => {
8692
const sourceWebservice = Steps.Step.find(el => el.Id == sourceId);
8793

8894
if (sourceWebservice) {
89-
const { Id: Ref } = sourceWebservice;
95+
const { No: Ref } = sourceWebservice;
9096
const p = {
9197
Name: link.target.portName,
9298
Value: {
@@ -123,6 +129,12 @@ export const saveWorkflow = jsonGraph => {
123129
console.log(allFiles); //@TODO send to server to upload as zip
124130
console.log(JSON.stringify(data));
125131

132+
// remove Id to match relax validation schema
133+
for (const step of Steps.Step) {
134+
console.log("TCL: step", step);
135+
delete step.Id;
136+
}
137+
126138
const builder = new xml2js.Builder({ rootName: "Steps" });
127139
const xml = builder.buildObject(Steps);
128140
console.log("TCL: xml", xml);

0 commit comments

Comments
 (0)