Revert "Split out selector implementation to address java compilation issue"
This reverts commit c35690e5e3
.
This commit is contained in:
parent
c35690e5e3
commit
b103a7b3ce
3 changed files with 35 additions and 2 deletions
|
@ -4,6 +4,7 @@ sudo: false
|
|||
jdk:
|
||||
- oraclejdk8
|
||||
- oraclejdk7
|
||||
- openjdk8
|
||||
- openjdk7
|
||||
|
||||
env:
|
||||
|
|
|
@ -192,8 +192,7 @@ public class RDFServiceVirtuoso extends RDFServiceSparql {
|
|||
// If the object is a numeric literal
|
||||
if (object.isLiteral() && isNumeric(object.asLiteral().getDatatypeURI())) {
|
||||
// Find a matching statement in the triple store, based on normalized numeric values
|
||||
double num = Double.parseDouble(object.asLiteral().getString());
|
||||
StmtIterator matching = fromTripleStoreModel.listStatements(subject.asResource(), predicate, fromTripleStoreModel.createTypedLiteral(num));
|
||||
StmtIterator matching = fromTripleStoreModel.listStatements(new VirtuosoDoubleSelector(subject.asResource(), predicate, object));
|
||||
|
||||
// For every matching statement
|
||||
// Rewrite the object as the one in the file model (they are the same, just differ in datatype)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/* $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;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue