Merge branch 'master' of github.com:ZUGFeRD/mustangproject
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mustangproject</groupId>
|
<groupId>org.mustangproject</groupId>
|
||||||
<artifactId>libraryExtended</artifactId>
|
<artifactId>validator</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<!-- prototypes of new mustangproject versions can be installed by referring to them and installed to the local repo from a jar file with
|
<!-- prototypes of new mustangproject versions can be installed by referring to them and installed to the local repo from a jar file with
|
||||||
mvn install:install-file -Dfile=mustang-1.5.4-SNAPSHOT.jar -DgroupId=org.mustangproject.ZUGFeRD -DartifactId=mustang -Dversion=1.5.4 -Dpackaging=jar -DgeneratePom=true
|
mvn install:install-file -Dfile=mustang-1.5.4-SNAPSHOT.jar -DgroupId=org.mustangproject.ZUGFeRD -DartifactId=mustang -Dversion=1.5.4 -Dpackaging=jar -DgeneratePom=true
|
||||||
@@ -53,6 +53,21 @@
|
|||||||
<version>4.12</version>
|
<version>4.12</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- for directory validation: -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.xmlunit</groupId>
|
||||||
|
<artifactId>xmlunit-core</artifactId>
|
||||||
|
<version>2.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.xmlunit</groupId>
|
||||||
|
<artifactId>xmlunit-assertj</artifactId>
|
||||||
|
<version>2.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- /directory validation: -->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
|
|||||||
0
Mustang-CLI/src/main/java/org/mustangproject/commandline/FileChecker.java
Executable file → Normal file
0
Mustang-CLI/src/main/java/org/mustangproject/commandline/FileChecker.java
Executable file → Normal file
0
Mustang-CLI/src/main/java/org/mustangproject/commandline/FileTraverser.java
Executable file → Normal file
0
Mustang-CLI/src/main/java/org/mustangproject/commandline/FileTraverser.java
Executable file → Normal file
@@ -35,7 +35,7 @@ import org.mustangproject.ZUGFeRD.ZUGFeRDExporter;
|
|||||||
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA1Factory;
|
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA1Factory;
|
||||||
import org.mustangproject.ZUGFeRD.ZUGFeRDImporter;
|
import org.mustangproject.ZUGFeRD.ZUGFeRDImporter;
|
||||||
import org.mustangproject.ZUGFeRD.ZUGFeRDMigrator;
|
import org.mustangproject.ZUGFeRD.ZUGFeRDMigrator;
|
||||||
import org.mustangproject.library.extended.ZUGFeRDValidator;
|
import org.mustangproject.validator.ZUGFeRDValidator;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* This is the command line interface to mustangproject
|
* This is the command line interface to mustangproject
|
||||||
@@ -324,6 +324,10 @@ public class Main {
|
|||||||
|
|
||||||
optionsRecognized=performValidate(sourceName);
|
optionsRecognized=performValidate(sourceName);
|
||||||
|
|
||||||
|
} else if ((action!=null)&&(action.equals("validateExpectValid"))) {
|
||||||
|
|
||||||
|
optionsRecognized=performValidateExpect(true, directoryName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no argument or argument unknown
|
// no argument or argument unknown
|
||||||
printUsage();
|
printUsage();
|
||||||
@@ -354,6 +358,20 @@ public class Main {
|
|||||||
return optionsRecognized;
|
return optionsRecognized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean performValidateExpect(boolean valid, String dirName) {
|
||||||
|
ValidatorFileWalker zfWalk = new ValidatorFileWalker();
|
||||||
|
Path startingDir = Paths.get(dirName);
|
||||||
|
try {
|
||||||
|
Files.walkFileTree(startingDir, zfWalk);
|
||||||
|
|
||||||
|
} catch (IOException e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static void performUpgrade(String xmlName, String outName) throws IOException, TransformerException {
|
private static void performUpgrade(String xmlName, String outName) throws IOException, TransformerException {
|
||||||
|
|
||||||
// Get params from user if not already defined
|
// Get params from user if not already defined
|
||||||
|
|||||||
0
Mustang-CLI/src/main/java/org/mustangproject/commandline/StatRun.java
Executable file → Normal file
0
Mustang-CLI/src/main/java/org/mustangproject/commandline/StatRun.java
Executable file → Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
package org.mustangproject.commandline;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.FileSystems;
|
||||||
|
import java.nio.file.FileVisitResult;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.PathMatcher;
|
||||||
|
import java.nio.file.SimpleFileVisitor;
|
||||||
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.xmlunit.builder.Input;
|
||||||
|
import org.xmlunit.xpath.JAXPXPathEngine;
|
||||||
|
import org.xmlunit.xpath.XPathEngine;
|
||||||
|
import org.mustangproject.validator.ZUGFeRDValidator;
|
||||||
|
|
||||||
|
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
||||||
|
|
||||||
|
public class ValidatorFileWalker
|
||||||
|
extends SimpleFileVisitor<Path> {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ValidatorFileWalker.class.getCanonicalName()); // log
|
||||||
|
protected PathMatcher matcher;
|
||||||
|
protected ZUGFeRDValidator zul;
|
||||||
|
protected int fileCount=1;
|
||||||
|
|
||||||
|
public ValidatorFileWalker() {
|
||||||
|
this.zul = new ZUGFeRDValidator();
|
||||||
|
;
|
||||||
|
matcher = FileSystems.getDefault().getPathMatcher("glob:*.{pdf,xml}");
|
||||||
|
|
||||||
|
}
|
||||||
|
// Print information about
|
||||||
|
// each type of file.
|
||||||
|
@Override
|
||||||
|
public FileVisitResult visitFile(Path file,
|
||||||
|
BasicFileAttributes attr) {
|
||||||
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
//get current date time with Date()
|
||||||
|
Date date = new Date();
|
||||||
|
if ((attr!=null)&&(attr.isRegularFile())) {
|
||||||
|
if (matcher.matches(file.getFileName())) {
|
||||||
|
|
||||||
|
LOGGER.info(String.format("\n@%s Testing file %d: %s ", dateFormat.format(date), fileCount++, file));
|
||||||
|
assertThat(zul.validate(file.toAbsolutePath().toString())).valueByXPath("/validation/summary/@status")
|
||||||
|
.asString()
|
||||||
|
.isEqualTo(
|
||||||
|
"valid");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print each directory visited.
|
||||||
|
@Override
|
||||||
|
public FileVisitResult postVisitDirectory(Path dir,
|
||||||
|
IOException exc) {
|
||||||
|
LOGGER.info("\nDirectory: %s%n", dir);
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there is some error accessing
|
||||||
|
// the file, let the user know.
|
||||||
|
// If you don't override this method
|
||||||
|
// and an error occurs, an IOException
|
||||||
|
// is thrown.
|
||||||
|
@Override
|
||||||
|
public FileVisitResult visitFileFailed(Path file,
|
||||||
|
IOException exc) {
|
||||||
|
LOGGER.error(exc.getMessage(),exc);
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mustangproject</groupId>
|
<groupId>org.mustangproject</groupId>
|
||||||
<artifactId>libraryBasic</artifactId>
|
<artifactId>library</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<!-- prototypes of new mustangproject versions can be installed by referring to them and installed to the local repo from a jar file with
|
<!-- prototypes of new mustangproject versions can be installed by referring to them and installed to the local repo from a jar file with
|
||||||
mvn install:install-file -Dfile=mustang-1.5.4-SNAPSHOT.jar -DgroupId=org.mustangproject.ZUGFeRD -DartifactId=mustang -Dversion=1.5.4 -Dpackaging=jar -DgeneratePom=true
|
mvn install:install-file -Dfile=mustang-1.5.4-SNAPSHOT.jar -DgroupId=org.mustangproject.ZUGFeRD -DartifactId=mustang -Dversion=1.5.4 -Dpackaging=jar -DgeneratePom=true
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package org.mustangproject.library.extended;
|
|
||||||
|
|
||||||
public enum EPart {
|
|
||||||
fx, xr, pdf, none
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
|
public enum EPart {
|
||||||
|
fx, xr, pdf, none
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
public enum ESeverity {
|
public enum ESeverity {
|
||||||
notice, warning, error, fatal, exception
|
notice, warning, error, fatal, exception
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
public class IrrecoverableValidationError extends Exception {
|
public class IrrecoverableValidationError extends Exception {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import org.dom4j.io.XMLWriter;
|
import org.dom4j.io.XMLWriter;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
0
validator/src/main/resources/schema/ad/basic/additional_data_base_schema.xsd
Executable file → Normal file
0
validator/src/main/resources/schema/ad/basic/additional_data_base_schema.xsd
Executable file → Normal file
0
validator/src/main/resources/zugferd2p0_basicwl_minimum.sch
Executable file → Normal file
0
validator/src/main/resources/zugferd2p0_basicwl_minimum.sch
Executable file → Normal file
0
validator/src/main/resources/zugferd2p0_en16931.sch
Executable file → Normal file
0
validator/src/main/resources/zugferd2p0_en16931.sch
Executable file → Normal file
0
validator/src/main/resources/zugferd2p0_extended.sch
Executable file → Normal file
0
validator/src/main/resources/zugferd2p0_extended.sch
Executable file → Normal file
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.mustangproject.library.extended;
|
package org.mustangproject.validator;
|
||||||
|
|
||||||
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
0
validator/src/test/resources/invalidV1.xml
Executable file → Normal file
0
validator/src/test/resources/invalidV1.xml
Executable file → Normal file
Reference in New Issue
Block a user