Split out selector implementation to address java compilation issue

This commit is contained in:
Graham Triggs 2016-09-18 21:19:21 +01:00
parent 70ba4cedab
commit c35690e5e3
3 changed files with 2 additions and 35 deletions

View file

@ -4,7 +4,6 @@ sudo: false
jdk: jdk:
- oraclejdk8 - oraclejdk8
- oraclejdk7 - oraclejdk7
- openjdk8
- openjdk7 - openjdk7
env: env:

View file

@ -192,7 +192,8 @@ public class RDFServiceVirtuoso extends RDFServiceSparql {
// If the object is a numeric literal // If the object is a numeric literal
if (object.isLiteral() && isNumeric(object.asLiteral().getDatatypeURI())) { if (object.isLiteral() && isNumeric(object.asLiteral().getDatatypeURI())) {
// Find a matching statement in the triple store, based on normalized numeric values // Find a matching statement in the triple store, based on normalized numeric values
StmtIterator matching = fromTripleStoreModel.listStatements(new VirtuosoDoubleSelector(subject.asResource(), predicate, object)); double num = Double.parseDouble(object.asLiteral().getString());
StmtIterator matching = fromTripleStoreModel.listStatements(subject.asResource(), predicate, fromTripleStoreModel.createTypedLiteral(num));
// For every matching statement // For every matching statement
// Rewrite the object as the one in the file model (they are the same, just differ in datatype) // Rewrite the object as the one in the file model (they are the same, just differ in datatype)

View file

@ -1,33 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.rdfservice.impl.virtuoso;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.SimpleSelector;
import org.apache.jena.rdf.model.Statement;
public class VirtuosoDoubleSelector extends SimpleSelector {
public VirtuosoDoubleSelector() {
}
public VirtuosoDoubleSelector(Resource subject, Property predicate, RDFNode object) {
super(subject, predicate, object);
}
@Override
public boolean test(Statement statement) {
RDFNode objectToMatch = statement.getObject();
// Both values are numeric, so compare them as parsed doubles
if (objectToMatch.isLiteral()) {
String num1 = object.asLiteral().getString();
String num2 = objectToMatch.asLiteral().getString();
return Double.parseDouble(num1) == Double.parseDouble(num2);
}
return false;
}
}