Skip to content

Commit

Permalink
LOV dependency / cleanup #34 #39
Browse files Browse the repository at this point in the history
  • Loading branch information
jimkont committed Sep 26, 2015
1 parent 26b99aa commit de22e0b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -39,21 +39,21 @@ public final class LOVUtils {
"} \n" +
"ORDER BY ?vocabPrefix ";

private LOVUtils(){}
public LOVEndpoint(){}


/**
* <p>getAllLOVEntries.</p>
*
* @return a {@link java.util.List} object.
*/
public static List<LOVEntry> getAllLOVEntries() {
public List<SchemaEntry> getAllLOVEntries() {

List<LOVEntry> lovEntries = new LinkedList<>();
QueryExecutionFactory qef = new QueryExecutionFactoryHttp(getLovEndpointURI(), Arrays.asList(LOVUtils.getLovGraph()));
List<SchemaEntry> 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()) {
Expand All @@ -70,42 +70,12 @@ public static List<LOVEntry> 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);
}

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;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @version $Id: $Id
* @since 0.7.6
*/
public final class LOVEntry implements Comparable<LOVEntry>{
public final class SchemaEntry implements Comparable<SchemaEntry>{

private final String prefix; // prefix is a unique identifier for all entries
private final String vocabularyURI;
Expand All @@ -22,7 +22,7 @@ public final class LOVEntry implements Comparable<LOVEntry>{
* @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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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());
}

Expand All @@ -108,16 +108,7 @@ public static void fillSchemaServiceFromLOV() {
log.info("Loaded " + count + " additional schema declarations from LOV SPARQL Endpoint");
}

/**
* <p>fileExists.</p>
*
* @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();
}


/**
* <p>getFirstItemInCollection.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit de22e0b

Please sign in to comment.