Skip to content

Commit

Permalink
Merged version 1.6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
vruusmann committed Dec 8, 2024
2 parents b38c044 + 21018df commit e391e49
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 35 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ jobs:
java: [ 11, 12, 13, 14, 15, 16, 17 ]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
cache: 'maven'
- run: mvn -B package --file pom.xml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ Java Class Model API for Predictive Model Markup Language (PMML).

JPMML-Model library JAR files (together with accompanying Java source and Javadocs JAR files) are released via [Maven Central Repository](https://repo1.maven.org/maven2/org/jpmml/).

The current version is **1.6.6** (1 October, 2024).
The current version is **1.6.7** (20 November, 2024).

```xml
<dependency>
<groupId>org.jpmml</groupId>
<artifactId>pmml-model</artifactId>
<version>1.6.6</version>
<version>1.6.7</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pmml-model-gwt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,9 @@ public void write(int b) throws IOException {
} else

if(string.endsWith(">")){
String updatedString = string.replace(Version.PMML_4_4.getNamespaceURI(), this.version.getNamespaceURI());
string = string.replace(Version.PMML_4_4.getNamespaceURI(), this.version.getNamespaceURI());

if(Objects.equals(string, updatedString)){
throw new IllegalStateException();
}

super.out.write(updatedString.getBytes("UTF-8"));
super.out.write(string.getBytes("UTF-8"));

this.buffer = null;
} else
Expand Down
19 changes: 19 additions & 0 deletions pmml-model/src/main/java/org/jpmml/model/SAXUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
*/
package org.jpmml.model;

import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.Result;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;

import jakarta.xml.bind.JAXBException;
import org.jpmml.model.filters.CountFilter;
Expand All @@ -26,6 +32,19 @@ public class SAXUtil {
private SAXUtil(){
}

static
public void transform(InputSource source, Result result, XMLFilter... filters) throws IOException, TransformerConfigurationException, ParserConfigurationException, SAXException {
SAXTransformerFactory transformerFactory = (SAXTransformerFactory)TransformerFactory.newInstance();

TransformerHandler transformerHandler = transformerFactory.newTransformerHandler();
transformerHandler.setResult(result);

XMLReader xmlReader = SAXUtil.createFilteredReader(SAXUtil.createXMLReader(), filters);
xmlReader.setContentHandler(transformerHandler);

xmlReader.parse(source);
}

/**
* @see ImportFilter
* @see SkipFilter
Expand Down
54 changes: 54 additions & 0 deletions pmml-model/src/test/java/org/jpmml/model/PMMLOutputStreamTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2024 Villu Ruusmann
*/
package org.jpmml.model;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;

import javax.xml.transform.stream.StreamResult;

import org.dmg.pmml.PMML;
import org.dmg.pmml.Version;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class PMMLOutputStreamTest {

@Test
public void marshal() throws Exception {
PMML pmml = new PMML();

try {
marshal(pmml, Version.XPMML);

fail();
} catch(IllegalArgumentException iae){
// Ignored
}

String string = marshal(pmml, Version.PMML_4_4);

assertTrue(string.contains(Version.PMML_4_4.getNamespaceURI()));
assertFalse(string.contains(Version.PMML_4_3.getNamespaceURI()));

string = marshal(pmml, Version.PMML_4_3);

assertFalse(string.contains(Version.PMML_4_4.getNamespaceURI()));
assertTrue(string.contains(Version.PMML_4_3.getNamespaceURI()));
}

static
private String marshal(PMML pmml, Version version) throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();

try(OutputStream os = new PMMLOutputStream(buffer, version)){
JAXBUtil.marshalPMML(pmml, new StreamResult(os));
}

return buffer.toString("UTF-8");
}
}
13 changes: 1 addition & 12 deletions pmml-model/src/test/java/org/jpmml/model/SchemaUpdateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;

import jakarta.xml.bind.JAXBException;
Expand Down Expand Up @@ -42,16 +39,8 @@ public byte[] upgradeToLatest(byte[] bytes) throws IOException, ParserConfigurat
public byte[] downgrade(byte[] bytes, Version version) throws IOException, TransformerConfigurationException, ParserConfigurationException, SAXException {
ByteArrayOutputStream result = new ByteArrayOutputStream();

SAXTransformerFactory transformerFactory = (SAXTransformerFactory)TransformerFactory.newInstance();

TransformerHandler transformer = transformerFactory.newTransformerHandler();
transformer.setResult(new StreamResult(result));

ExportFilter exportFilter = new ExportFilter(SAXUtil.createXMLReader(), version);
exportFilter.setContentHandler(transformer);

try(InputStream is = new ByteArrayInputStream(bytes)){
exportFilter.parse(new InputSource(is));
SAXUtil.transform(new InputSource(is), new StreamResult(result), new ExportFilter(version));
}

return result.toByteArray();
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,23 @@
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>[5.0.0, 5.6.0]</version>
<version>[5.0.0, 5.6.2]</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>[2.11.0, 2.17.2]</version>
<version>[2.11.0, 2.18.2]</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>[2.11.0, 2.17.2]</version>
<version>[2.11.0, 2.18.2]</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>[2.11.0, 2.17.2]</version>
<version>[2.11.0, 2.18.2]</version>
</dependency>

<!-- Inherited from org.glassfish.jaxb:jaxb-bom via org.glassfish.jaxb:jaxb-runtime dependency -->
Expand Down Expand Up @@ -214,7 +214,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.2</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
Expand Down Expand Up @@ -265,7 +265,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.10.0</version>
<version>3.11.1</version>
<configuration>
<source>1.8</source>
<javadocVersion>1.8</javadocVersion>
Expand Down Expand Up @@ -323,7 +323,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.17.1</version>
<version>2.18.0</version>
</plugin>
<plugin>
<groupId>de.jutzig</groupId>
Expand Down

0 comments on commit e391e49

Please sign in to comment.