Skip to content

Commit

Permalink
discovery using graph
Browse files Browse the repository at this point in the history
  • Loading branch information
NourEldin-Ali committed May 27, 2024
1 parent 3648efc commit d61e4e8
Show file tree
Hide file tree
Showing 10 changed files with 1,429 additions and 524 deletions.
41 changes: 32 additions & 9 deletions open-bpmn.metamodel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,56 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.release>11</maven.compiler.release>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.openbpmn.bpmn.discovery.BPMNDiscovery</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>13.0-rc1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.5</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>13.0-rc1</version>
</dependency>
<dependency>
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-core</artifactId>
<version>1.5.2</version>
</dependency>
<!-- JUnit Tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>



</dependencies>
Expand Down
42 changes: 42 additions & 0 deletions open-bpmn.metamodel/src/main/java/org/openbpmn/bpmn/BPMNModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1948,4 +1948,46 @@ private void writeXml(Document doc, OutputStream output) throws TransformerExcep

// === BUGFIX END ===
}

public String getXml() throws TransformerException {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);

transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");

/*
* The following code section is to handle a bad implementation in the
* Imixs-BPMN (Eclipse-BPMN2) implementation
*
* To ensure that the Open-BPMN model file is still readable by eclipse-bpmn we
* need to remove the whitespace before and after CDATA tags.
*
* See details: https://github.com/imixs/open-bpmn/issues/194
*
* Otherwise we could just do here:
*
* StreamResult result = new StreamResult(output);
* transformer.transform(source, result);
*/
// === BUGFIX START ===

// first transform the result xml into a string
StringWriter w = new StringWriter();
Result dest = new StreamResult(w);
transformer.transform(source, dest);
String xmlString = w.toString();
// No indentation (whitespace) for elements with a CDATA section.
// See
// https://stackoverflow.com/questions/55853220/handling-change-in-newlines-by-xml-transformation-for-cdata-from-java-8-to-java/75568933
// xmlString =
// xmlString.replaceAll(">\\s*+(<\\!\\[CDATA\\[(.|\\n|\\r\\n)*?]\\]>)\\s*</",
// ">$1</");
xmlString = BPMNXMLUtil.cleanCDATAWhiteSpace(xmlString);
return xmlString;
// write output

}
}
Loading

0 comments on commit d61e4e8

Please sign in to comment.