-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
300 changed files
with
148,993 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>fr.sparna.rdf.shacl</groupId> | ||
<artifactId>shacl-play-root-pom</artifactId> | ||
<version>0.0.1</version> | ||
<packaging>pom</packaging> | ||
|
||
<name>SHACL-Play root pom</name> | ||
|
||
<modules> | ||
<module>shacl-validator</module> | ||
<module>shacl-printer</module> | ||
<module>shacl-app</module> | ||
<module>shacl-play</module> | ||
</modules> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>1.8</java.version> | ||
<jena.version>3.11.0</jena.version> | ||
<jtwig.version>5.87.0.RELEASE</jtwig.version> | ||
<!-- library versions --> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
|
||
<!-- for command-line parsing --> | ||
<dependency> | ||
<groupId>com.beust</groupId> | ||
<artifactId>jcommander</artifactId> | ||
<version>1.72</version> | ||
</dependency> | ||
|
||
<!-- Jena --> | ||
<dependency> | ||
<groupId>org.apache.jena</groupId> | ||
<artifactId>jena-core</artifactId> | ||
<version>${jena.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jena</groupId> | ||
<artifactId>jena-arq</artifactId> | ||
<version>${jena.version}</version> | ||
</dependency> | ||
|
||
<!-- logging --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>1.7.25</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.2.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.6</version> | ||
</dependency> | ||
|
||
<!-- Testing: JUnit --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.7</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- SHACL --> | ||
<dependency> | ||
<groupId>org.topbraid</groupId> | ||
<artifactId>shacl</artifactId> | ||
<version>1.3.1-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<!-- JTWIG --> | ||
<dependency> | ||
<groupId>org.jtwig</groupId> | ||
<artifactId>jtwig-core</artifactId> | ||
<version>${jtwig.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jtwig</groupId> | ||
<artifactId>jtwig-translate-extension</artifactId> | ||
<version>${jtwig.version}</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
</dependencyManagement> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/target/ | ||
/output/ | ||
/.project | ||
/.classpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/org.eclipse.jdt.core.prefs | ||
/org.eclipse.wst.common.component | ||
/org.eclipse.wst.common.project.facet.core.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>fr.sparna.rdf.shacl</groupId> | ||
<artifactId>shacl-app</artifactId> | ||
<version>0.0.1</version> | ||
<packaging>jar</packaging> | ||
<name>shacl-app</name> | ||
|
||
<parent> | ||
<groupId>fr.sparna.rdf.shacl</groupId> | ||
<artifactId>shacl-play-root-pom</artifactId> | ||
<version>0.0.1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
|
||
<properties> | ||
<jackson-version>2.9.3</jackson-version> | ||
<jtwig-version>5.86.1.RELEASE</jtwig-version> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.7.0</version> | ||
<configuration> | ||
<source>${java.version}</source> | ||
<target>${java.version}</target> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>1.3.2</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<shadedArtifactAttached>true</shadedArtifactAttached> | ||
<shadedClassifierName>onejar</shadedClassifierName> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.DSA</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<manifestEntries> | ||
<Main-Class>fr.sparna.rdf.shacl.app.Main</Main-Class> | ||
<Class-Path>.</Class-Path> | ||
</manifestEntries> | ||
</transformer> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.beust</groupId> | ||
<artifactId>jcommander</artifactId> | ||
</dependency> | ||
<!-- Testing: JUnit --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
<!-- Logging --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
</dependency> | ||
|
||
<!-- Commons IO --> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>fr.sparna.rdf.shacl</groupId> | ||
<artifactId>shacl-validator</artifactId> | ||
<version>0.0.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>fr.sparna.rdf.shacl</groupId> | ||
<artifactId>shacl-printer</artifactId> | ||
<version>0.0.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.jena</groupId> | ||
<artifactId>jena-arq</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
</project> |
23 changes: 23 additions & 0 deletions
23
shacl-app/src/main/java/fr/sparna/rdf/shacl/app/ArgumentsMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package fr.sparna.rdf.shacl.app; | ||
|
||
import com.beust.jcommander.Parameter; | ||
|
||
public class ArgumentsMain { | ||
|
||
@Parameter( | ||
names = { "-h", "--help" }, | ||
description = "Affiche le message d'aide", | ||
help = true | ||
) | ||
private boolean help = false; | ||
|
||
|
||
public boolean isHelp() { | ||
return help; | ||
} | ||
|
||
public void setHelp(boolean help) { | ||
this.help = help; | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
shacl-app/src/main/java/fr/sparna/rdf/shacl/app/CliCommandIfc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package fr.sparna.rdf.shacl.app; | ||
|
||
public interface CliCommandIfc { | ||
|
||
public void execute(Object args) throws Exception; | ||
} |
50 changes: 50 additions & 0 deletions
50
shacl-app/src/main/java/fr/sparna/rdf/shacl/app/InputModelReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package fr.sparna.rdf.shacl.app; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.net.MalformedURLException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.apache.jena.rdf.model.Model; | ||
import org.apache.jena.rdf.model.ModelFactory; | ||
import org.apache.jena.riot.RDFDataMgr; | ||
import org.apache.jena.riot.RDFLanguages; | ||
import org.apache.jena.vocabulary.RDF; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class InputModelReader { | ||
|
||
private static Logger log = LoggerFactory.getLogger(InputModelReader.class.getName()); | ||
|
||
public static Model readInputModel(List<File> inputs) throws MalformedURLException { | ||
Model inputModel = ModelFactory.createDefaultModel(); | ||
|
||
for (File inputFile : inputs) { | ||
log.debug("Reading input from file : "+inputFile.getAbsolutePath()); | ||
|
||
if(inputFile.isDirectory()) { | ||
for(File f : inputFile.listFiles()) { | ||
inputModel.add(readInputModel(Collections.singletonList(f))); | ||
} | ||
} else { | ||
if(RDFLanguages.filenameToLang(inputFile.getName()) != null) { | ||
try { | ||
RDFDataMgr.read(inputModel, new FileInputStream(inputFile), RDF.getURI(), RDFLanguages.filenameToLang(inputFile.getName())); | ||
} catch (FileNotFoundException ignore) { | ||
ignore.printStackTrace(); | ||
} | ||
} else { | ||
log.error("Unknown RDF format for file "+inputFile.getAbsolutePath()); | ||
} | ||
} | ||
} | ||
|
||
return inputModel; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package fr.sparna.rdf.shacl.app; | ||
|
||
import com.beust.jcommander.JCommander; | ||
import com.beust.jcommander.MissingCommandException; | ||
import com.beust.jcommander.ParameterException; | ||
|
||
import fr.sparna.rdf.shacl.app.infer.ArgumentsInfer; | ||
import fr.sparna.rdf.shacl.app.infer.Infer; | ||
import fr.sparna.rdf.shacl.app.owl2shacl.ArgumentsOwl2Shacl; | ||
import fr.sparna.rdf.shacl.app.owl2shacl.Owl2Shacl; | ||
import fr.sparna.rdf.shacl.app.report.ArgumentsGenerateReport; | ||
import fr.sparna.rdf.shacl.app.report.GenerateReport; | ||
import fr.sparna.rdf.shacl.app.summary.ArgumentsGenerateSummary; | ||
import fr.sparna.rdf.shacl.app.summary.GenerateSummary; | ||
import fr.sparna.rdf.shacl.app.validate.ArgumentsValidate; | ||
import fr.sparna.rdf.shacl.app.validate.Validate; | ||
|
||
public class Main { | ||
|
||
enum COMMAND { | ||
|
||
REPORT(new ArgumentsGenerateReport(), new GenerateReport()), | ||
SUMMARY(new ArgumentsGenerateSummary(), new GenerateSummary()), | ||
INFER(new ArgumentsInfer(), new Infer()), | ||
OWL2SHACL(new ArgumentsOwl2Shacl(), new Owl2Shacl()), | ||
VALIDATE(new ArgumentsValidate(), new Validate()); | ||
|
||
private CliCommandIfc command; | ||
private Object arguments; | ||
|
||
private COMMAND(Object arguments, CliCommandIfc command) { | ||
this.command = command; | ||
this.arguments = arguments; | ||
} | ||
|
||
public CliCommandIfc getCommand() { | ||
return command; | ||
} | ||
|
||
public Object getArguments() { | ||
return arguments; | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
Main main = new Main(); | ||
main.run(args); | ||
} | ||
|
||
public void run(String[] args) throws Exception { | ||
ArgumentsMain main = new ArgumentsMain(); | ||
JCommander jc = new JCommander(main); | ||
for (COMMAND aCOMMAND : COMMAND.values()) { | ||
jc.addCommand(aCOMMAND.name().toLowerCase(), aCOMMAND.getArguments()); | ||
} | ||
|
||
try { | ||
jc.parse(args); | ||
// a mettre avant ParameterException car c'est une sous-exception | ||
} catch (MissingCommandException e) { | ||
// if no command was found, exit with usage message and error code | ||
System.err.println("Commande inconnue."); | ||
jc.usage(); | ||
System.exit(-1); | ||
} catch (ParameterException e) { | ||
System.err.println(e.getMessage()); | ||
jc.usage(jc.getParsedCommand()); | ||
System.exit(-1); | ||
} | ||
|
||
// if help was requested, print it and exit with a normal code | ||
if(main.isHelp()) { | ||
jc.usage(); | ||
System.exit(0); | ||
} | ||
|
||
// if no command was found (0 parameters passed in command line) | ||
// exit with usage message and error code | ||
if(jc.getParsedCommand() == null) { | ||
System.err.println("Pas de commande trouvée."); | ||
jc.usage(); | ||
System.exit(-1); | ||
} | ||
// executes the command with the associated arguments | ||
COMMAND.valueOf(jc.getParsedCommand().toUpperCase()).getCommand().execute( | ||
COMMAND.valueOf(jc.getParsedCommand().toUpperCase()).getArguments() | ||
); | ||
|
||
} | ||
|
||
|
||
} |
Oops, something went wrong.