diff --git a/rdfunit-core/src/main/java/org/aksw/rdfunit/utils/RDFWriterFactory.java b/rdfunit-core/src/main/java/org/aksw/rdfunit/io/writer/RDFWriterFactory.java similarity index 98% rename from rdfunit-core/src/main/java/org/aksw/rdfunit/utils/RDFWriterFactory.java rename to rdfunit-core/src/main/java/org/aksw/rdfunit/io/writer/RDFWriterFactory.java index 875917729..55ac48de0 100644 --- a/rdfunit-core/src/main/java/org/aksw/rdfunit/utils/RDFWriterFactory.java +++ b/rdfunit-core/src/main/java/org/aksw/rdfunit/io/writer/RDFWriterFactory.java @@ -1,9 +1,8 @@ -package org.aksw.rdfunit.utils; +package org.aksw.rdfunit.io.writer; import org.aksw.rdfunit.enums.TestCaseExecutionType; import org.aksw.rdfunit.io.format.FormatService; import org.aksw.rdfunit.io.format.SerializationFormat; -import org.aksw.rdfunit.io.writer.*; import java.io.OutputStream; diff --git a/rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/LOVUtils.java b/rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/LOVEndpoint.java similarity index 74% rename from rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/LOVUtils.java rename to rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/LOVEndpoint.java index 41d4f3142..64b2f7c19 100644 --- a/rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/LOVUtils.java +++ b/rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/LOVEndpoint.java @@ -20,9 +20,9 @@ * @since 3 /31/15 4:15 PM * @version $Id: $Id */ -public final class LOVUtils { +public final class LOVEndpoint { - private static final Logger log = LoggerFactory.getLogger(LOVUtils.class); + private static final Logger log = LoggerFactory.getLogger(LOVEndpoint.class); private static final String lovEndpointURI = "http://lov.okfn.org/dataset/lov/sparql"; private static final String lovGraph = "http://lov.okfn.org/dataset/lov"; @@ -39,7 +39,7 @@ public final class LOVUtils { "} \n" + "ORDER BY ?vocabPrefix "; - private LOVUtils(){} + public LOVEndpoint(){} /** @@ -47,13 +47,13 @@ private LOVUtils(){} * * @return a {@link java.util.List} object. */ - public static List getAllLOVEntries() { + public List getAllLOVEntries() { - List lovEntries = new LinkedList<>(); - QueryExecutionFactory qef = new QueryExecutionFactoryHttp(getLovEndpointURI(), Arrays.asList(LOVUtils.getLovGraph())); + List lovEntries = new LinkedList<>(); + QueryExecutionFactory qef = new QueryExecutionFactoryHttp(lovEndpointURI, Arrays.asList(lovGraph)); - try (QueryExecution qe = qef.createQueryExecution(getLOVSparqlQuery())) { + try (QueryExecution qe = qef.createQueryExecution(lovSparqlQuery)) { ResultSet rs = qe.execSelect(); while (rs.hasNext()) { @@ -70,7 +70,7 @@ public static List getAllLOVEntries() { if (row.get("definedBy") != null) { definedBy = row.get("definedBy").asLiteral().getLexicalForm(); } - lovEntries.add(new LOVEntry(prefix, vocab, ns, definedBy)); + lovEntries.add(new SchemaEntry(prefix, vocab, ns, definedBy)); } } catch (Exception e) { log.error("Encountered error when reading schema information from LOV, schema prefixes & auto schema discovery might not work as expected", e); @@ -78,34 +78,4 @@ public static List getAllLOVEntries() { return lovEntries; } - - - /** - * Gets the lOV sparql query. - * - * @return the lOV sparql query - */ - public static String getLOVSparqlQuery() { - return lovSparqlQuery; - } - - /** - * Gets lov endpoint uRI. - * - * @return the lov endpoint uRI - */ - public static String getLovEndpointURI() { - return lovEndpointURI; - } - - /** - * Gets lov graph. - * - * @return the lov graph - */ - public static String getLovGraph() { - return lovGraph; - } - - } diff --git a/rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/LOVEntry.java b/rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/SchemaEntry.java similarity index 88% rename from rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/LOVEntry.java rename to rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/SchemaEntry.java index d315e447c..93616be9e 100644 --- a/rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/LOVEntry.java +++ b/rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/SchemaEntry.java @@ -7,7 +7,7 @@ * @version $Id: $Id * @since 0.7.6 */ -public final class LOVEntry implements Comparable{ +public final class SchemaEntry implements Comparable{ private final String prefix; // prefix is a unique identifier for all entries private final String vocabularyURI; @@ -22,7 +22,7 @@ public final class LOVEntry implements Comparable{ * @param vocabularyNamespace the vocabulary namespace * @param vocabularyDefinedBy the vocabulary defined by */ - public LOVEntry(String prefix, String vocabularyURI, String vocabularyNamespace, String vocabularyDefinedBy) { + public SchemaEntry(String prefix, String vocabularyURI, String vocabularyNamespace, String vocabularyDefinedBy) { this.prefix = prefix; this.vocabularyURI = vocabularyURI; this.vocabularyNamespace = vocabularyNamespace; @@ -36,7 +36,7 @@ public LOVEntry(String prefix, String vocabularyURI, String vocabularyNamespace, * @param vocabularyURI the vocabulary uRI * @param vocabularyNamespace the vocabulary namespace */ - public LOVEntry(String prefix, String vocabularyURI, String vocabularyNamespace) { + public SchemaEntry(String prefix, String vocabularyURI, String vocabularyNamespace) { this(prefix, vocabularyURI, vocabularyNamespace, vocabularyNamespace); } @@ -82,7 +82,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - LOVEntry lovEntry = (LOVEntry) o; + SchemaEntry lovEntry = (SchemaEntry) o; return prefix.equals(lovEntry.prefix); } @@ -108,7 +108,7 @@ public String toString() { /** {@inheritDoc} */ @Override - public int compareTo(LOVEntry o) { + public int compareTo(SchemaEntry o) { return this.prefix.compareTo(o.getPrefix()); } } diff --git a/rdfunit-core/src/main/java/org/aksw/rdfunit/utils/RDFUnitUtils.java b/rdfunit-core/src/main/java/org/aksw/rdfunit/utils/RDFUnitUtils.java index 3a141d054..c1e65ede6 100644 --- a/rdfunit-core/src/main/java/org/aksw/rdfunit/utils/RDFUnitUtils.java +++ b/rdfunit-core/src/main/java/org/aksw/rdfunit/utils/RDFUnitUtils.java @@ -1,7 +1,7 @@ package org.aksw.rdfunit.utils; -import org.aksw.rdfunit.prefix.LOVEntry; -import org.aksw.rdfunit.prefix.LOVUtils; +import org.aksw.rdfunit.prefix.LOVEndpoint; +import org.aksw.rdfunit.prefix.SchemaEntry; import org.aksw.rdfunit.services.SchemaService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -99,7 +99,7 @@ public static void fillSchemaServiceFromFile(InputStream additionalCSV) { public static void fillSchemaServiceFromLOV() { int count = SchemaService.getSize(); - for (LOVEntry entry : LOVUtils.getAllLOVEntries()) { + for (SchemaEntry entry : new LOVEndpoint().getAllLOVEntries()) { SchemaService.addSchemaDecl(entry.getPrefix(), entry.getVocabularyNamespace(), entry.getVocabularyDefinedBy()); } @@ -108,16 +108,7 @@ public static void fillSchemaServiceFromLOV() { log.info("Loaded " + count + " additional schema declarations from LOV SPARQL Endpoint"); } - /** - *

fileExists.

- * - * @param path a {@link java.lang.String} object. - * @return a boolean. - */ - public static boolean fileExists(String path) { - File f = new File(path); - return f.exists(); - } + /** *

getFirstItemInCollection.

diff --git a/rdfunit-validate/src/main/java/org/aksw/rdfunit/validate/cli/ValidateCLI.java b/rdfunit-validate/src/main/java/org/aksw/rdfunit/validate/cli/ValidateCLI.java index a1f998189..20ac9e637 100644 --- a/rdfunit-validate/src/main/java/org/aksw/rdfunit/validate/cli/ValidateCLI.java +++ b/rdfunit-validate/src/main/java/org/aksw/rdfunit/validate/cli/ValidateCLI.java @@ -6,11 +6,13 @@ import org.aksw.rdfunit.RDFUnit; import org.aksw.rdfunit.RDFUnitConfiguration; import org.aksw.rdfunit.coverage.TestCoverageEvaluator; +import org.aksw.rdfunit.io.IOUtils; import org.aksw.rdfunit.io.format.SerializationFormat; import org.aksw.rdfunit.io.reader.RDFReaderException; import org.aksw.rdfunit.io.writer.RDFMultipleWriter; import org.aksw.rdfunit.io.writer.RDFWriter; import org.aksw.rdfunit.io.writer.RDFWriterException; +import org.aksw.rdfunit.io.writer.RDFWriterFactory; import org.aksw.rdfunit.model.interfaces.TestCase; import org.aksw.rdfunit.services.PrefixNSService; import org.aksw.rdfunit.sources.TestSource; @@ -20,7 +22,6 @@ import org.aksw.rdfunit.tests.executors.monitors.SimpleTestExecutorMonitor; import org.aksw.rdfunit.tests.generators.TestGeneratorExecutor; import org.aksw.rdfunit.utils.RDFUnitUtils; -import org.aksw.rdfunit.utils.RDFWriterFactory; import org.aksw.rdfunit.validate.ParameterException; import org.aksw.rdfunit.validate.utils.ValidateUtils; import org.apache.commons.cli.CommandLine; @@ -81,7 +82,7 @@ public static void main(String[] args) throws Exception { } checkNotNull (configuration ); - if (!RDFUnitUtils.fileExists(configuration.getDataFolder())) { + if (!IOUtils.isFile(configuration.getDataFolder())) { log.error("Path : " + configuration.getDataFolder() + " does not exists, use -f argument"); System.exit(1); } diff --git a/rdfunit-validate/src/main/java/org/aksw/rdfunit/validate/ws/RDFUnitWebService.java b/rdfunit-validate/src/main/java/org/aksw/rdfunit/validate/ws/RDFUnitWebService.java index 323686341..e6578e129 100644 --- a/rdfunit-validate/src/main/java/org/aksw/rdfunit/validate/ws/RDFUnitWebService.java +++ b/rdfunit-validate/src/main/java/org/aksw/rdfunit/validate/ws/RDFUnitWebService.java @@ -6,9 +6,9 @@ import org.aksw.rdfunit.io.format.SerializationFormat; import org.aksw.rdfunit.io.writer.RDFWriter; import org.aksw.rdfunit.io.writer.RDFWriterException; +import org.aksw.rdfunit.io.writer.RDFWriterFactory; import org.aksw.rdfunit.sources.TestSource; import org.aksw.rdfunit.tests.TestSuite; -import org.aksw.rdfunit.utils.RDFWriterFactory; import org.aksw.rdfunit.validate.ParameterException; import javax.servlet.ServletException; diff --git a/rdfunit-webdemo/src/main/java/org/aksw/rdfunit/webdemo/view/TestExecutionView.java b/rdfunit-webdemo/src/main/java/org/aksw/rdfunit/webdemo/view/TestExecutionView.java index 8b82cb1d3..0507934e3 100644 --- a/rdfunit-webdemo/src/main/java/org/aksw/rdfunit/webdemo/view/TestExecutionView.java +++ b/rdfunit-webdemo/src/main/java/org/aksw/rdfunit/webdemo/view/TestExecutionView.java @@ -10,6 +10,7 @@ import org.aksw.rdfunit.io.writer.RDFFileWriter; import org.aksw.rdfunit.io.writer.RDFStreamWriter; import org.aksw.rdfunit.io.writer.RDFWriterException; +import org.aksw.rdfunit.io.writer.RDFWriterFactory; import org.aksw.rdfunit.model.interfaces.TestCase; import org.aksw.rdfunit.sources.TestSource; import org.aksw.rdfunit.tests.TestSuite; @@ -21,7 +22,6 @@ import org.aksw.rdfunit.tests.results.StatusTestCaseResult; import org.aksw.rdfunit.tests.results.TestCaseResult; import org.aksw.rdfunit.utils.RDFUnitUtils; -import org.aksw.rdfunit.utils.RDFWriterFactory; import org.aksw.rdfunit.webdemo.RDFUnitDemoSession; import org.aksw.rdfunit.webdemo.utils.CommonAccessUtils; import org.aksw.rdfunit.webdemo.utils.WorkflowUtils;