Skip to content

Commit

Permalink
Fixed compare two xml data (#2285)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuhaib-aot authored Oct 21, 2024
1 parent f0ecfd0 commit bb65e5f
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions forms-flow-web/src/helper/processHelper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { extractDataFromDiagram } from "../components/Modeler/helpers/helper";
import BpmnModeler from "bpmn-js/lib/Modeler";
import BpmnModdle from 'bpmn-moddle';
import isEqual from "lodash/isEqual";
const modeler = new BpmnModeler();
const bpmnModdle = new BpmnModdle();
// export const createBpmnForm = (xml, deploymentName, tenantKey, applyAllTenants) => {
// const form = new FormData();
// // Deployment Name
Expand Down Expand Up @@ -31,26 +31,16 @@ const modeler = new BpmnModeler();



export const parseBpmn = (xmlString) => {
return new Promise((resolve, reject) => {
modeler.importXML(xmlString, (err) => {
if (err) {
reject(err);
} else {
// Get the internal JSON representation
const definitions = modeler.getDefinitions();
resolve(definitions);
}
});
});
export const parseBpmn = async(xmlString) => {
const { rootElement: definitionsA } = await bpmnModdle.fromXML(xmlString);
return definitionsA;
};

export const compareXML = async (xmlString1, xmlString2) => {
try {
// Parse both BPMN XMLs to their JSON structure
const bpmn1 = await parseBpmn(xmlString1);
const bpmn2 = await parseBpmn(xmlString2);

// Compare the JSON structures
return isEqual(bpmn1, bpmn2);
} catch (error) {
Expand Down

0 comments on commit bb65e5f

Please sign in to comment.