Adjust all integer types that can be stored differently in TDB
This commit is contained in:
parent
3475f90fb4
commit
3f655b7408
1 changed files with 24 additions and 11 deletions
|
@ -208,7 +208,7 @@ public class RDFServiceTDB extends RDFServiceJena {
|
||||||
ModelSerializationFormat serializationFormat)
|
ModelSerializationFormat serializationFormat)
|
||||||
throws RDFServiceException {
|
throws RDFServiceException {
|
||||||
return super.isEquivalentGraph(graphURI,
|
return super.isEquivalentGraph(graphURI,
|
||||||
adjustForNonNegativeIntegers(serializedGraph),
|
adjustForIntegers(serializedGraph),
|
||||||
serializationFormat);
|
serializationFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,25 +231,38 @@ public class RDFServiceTDB extends RDFServiceJena {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert all of the references to "nonNegativeInteger" to "integer" in
|
* Convert all of the references to integer compatible type to "integer" in the serialized graph.
|
||||||
* this serialized graph.
|
|
||||||
*
|
*
|
||||||
* This isn't rigorous: it could fail if another property contained the text
|
* TDB converts every valid literal that is compatible with xsd:integer to xsd:integer.
|
||||||
* "nonNegativeInteger" in its name, or if that text were used as part of a
|
*
|
||||||
* string literal. If that happens before this TDB bug is fixed, we'll need
|
* This assumes that every literal has been typed validly. But if the type / lexical value aren't matched,
|
||||||
* to improve this method.
|
* you've probably got bigger problems.
|
||||||
*
|
*
|
||||||
* It also isn't scalable: if we wanted real scalability, we would write to
|
* It also isn't scalable: if we wanted real scalability, we would write to
|
||||||
* a temporary file as we converted.
|
* a temporary file as we converted.
|
||||||
*/
|
*/
|
||||||
private InputStream adjustForNonNegativeIntegers(InputStream serializedGraph)
|
private InputStream adjustForIntegers(InputStream serializedGraph)
|
||||||
throws RDFServiceException {
|
throws RDFServiceException {
|
||||||
try {
|
try {
|
||||||
String raw = IOUtils.toString(serializedGraph, "UTF-8");
|
String raw = IOUtils.toString(serializedGraph, "UTF-8");
|
||||||
String modified = raw.replace("nonNegativeInteger", "integer");
|
String modified = raw;
|
||||||
|
modified = modified.replaceAll(integerPattern, "^^<http://www.w3.org/2001/XMLSchema#integer>");
|
||||||
return new ByteArrayInputStream(modified.getBytes("UTF-8"));
|
return new ByteArrayInputStream(modified.getBytes("UTF-8"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RDFServiceException(e);
|
throw new RDFServiceException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final String integerPattern =
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#int>" + "|" +
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#long>" + "|" +
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#short>" + "|" +
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#unsignedByte>" + "|" +
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#unsignedShort>" + "|" +
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#unsignedInt>" + "|" +
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#unsignedLong>" + "|" +
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#nonPositiveInteger>" + "|" +
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#nonNegativeInteger>" + "|" +
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#positiveInteger>" + "|" +
|
||||||
|
"\\^\\^<http://www.w3.org/2001/XMLSchema#negativeInteger>";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue