use of org.openrdf.model.impl.StatementImpl in project incubator-rya by apache.
the class StatementSerializer method readStatement.
public static Statement readStatement(String subjectString, String predicateString, String objectString, String contextString) {
Resource subject = createResource(subjectString);
URI predicate = VALUE_FACTORY.createURI(predicateString);
boolean isObjectLiteral = objectString.startsWith("\"");
Value object = null;
if (isObjectLiteral) {
object = parseLiteral(objectString);
} else {
object = createResource(objectString);
}
if (contextString == null || contextString.isEmpty()) {
return new StatementImpl(subject, predicate, object);
} else {
Resource context = VALUE_FACTORY.createURI(contextString);
return new ContextStatementImpl(subject, predicate, object, context);
}
}
use of org.openrdf.model.impl.StatementImpl in project incubator-rya by apache.
the class GeoWaveIndexerSfTest method genericStatementGml.
private static Statement genericStatementGml(final Geometry geo, final URI encodingMethod) {
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("uri:" + NAMES.get(geo));
final URI predicate = GeoConstants.GEO_AS_GML;
final String gml;
if (encodingMethod == USE_JTS_LIB_ENCODING) {
gml = geoToGmlUseJtsLib(geo);
} else if (encodingMethod == USE_ROUGH_ENCODING) {
gml = geoToGmlRough(geo);
} else {
throw new Error("invalid encoding method: " + encodingMethod);
// System.out.println("===created GML====");
// System.out.println(gml);
// System.out.println("========== GML====");
}
final Value object = vf.createLiteral(gml, GeoConstants.XMLSCHEMA_OGC_GML);
return new StatementImpl(subject, predicate, object);
}
use of org.openrdf.model.impl.StatementImpl in project incubator-rya by apache.
the class GeoWaveIndexerSfTest method genericStatementWkt.
private static Statement genericStatementWkt(final Geometry geo) {
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("uri:" + NAMES.get(geo));
final URI predicate = GeoConstants.GEO_AS_WKT;
final Value object = vf.createLiteral(geo.toString(), GeoConstants.XMLSCHEMA_OGC_WKT);
return new StatementImpl(subject, predicate, object);
}
use of org.openrdf.model.impl.StatementImpl in project incubator-rya by apache.
the class AccumuloTemporalIndexerTest method testStoreStatementBadInterval.
/**
* Test method for {@link AccumuloTemporalIndexer#storeStatement(convertStatement(org.openrdf.model.Statement)}
*
* @throws NoSuchAlgorithmException
*/
@Test
public void testStoreStatementBadInterval() throws IOException, AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException, NoSuchAlgorithmException {
// count rows expected to store:
int rowsStoredExpected = 0;
ValueFactory vf = new ValueFactoryImpl();
URI pred1_atTime = vf.createURI(URI_PROPERTY_AT_TIME);
// Test: Should not store an improper date interval, and log a warning (log warning not tested).
final String invalidDateIntervalString = "[bad,interval]";
// Silently logs a warning for bad dates.
tIndexer.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj1"), pred1_atTime, vf.createLiteral(invalidDateIntervalString))));
final String validDateIntervalString = "[2016-12-31T20:59:59-05:00,2016-12-31T21:00:00-05:00]";
tIndexer.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj2"), pred1_atTime, vf.createLiteral(validDateIntervalString))));
rowsStoredExpected++;
tIndexer.flush();
int rowsStoredActual = printTables("junit testing: Temporal intervals stored in testStoreStatement", null, null);
// 2 index entries per interval statement
Assert.assertEquals("Only good intervals should be stored.", rowsStoredExpected * 2, rowsStoredActual);
}
use of org.openrdf.model.impl.StatementImpl in project incubator-rya by apache.
the class AccumuloTemporalIndexerTest method testStoreStatementsSameTime.
@Test
public void testStoreStatementsSameTime() throws IOException, NoSuchAlgorithmException, AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
ValueFactory vf = new ValueFactoryImpl();
URI pred1_atTime = vf.createURI(URI_PROPERTY_AT_TIME);
URI pred2_circa = vf.createURI(URI_PROPERTY_CIRCA);
// These are the same datetime instant but from different time
// zones.
// This is an arbitrary zone, BRST=Brazil, better if not local.
final String ZONETestDateInBRST = "2014-12-31T23:59:59-02:00";
final String ZONETestDateInZulu = "2015-01-01T01:59:59Z";
final String ZONETestDateInET = "2014-12-31T20:59:59-05:00";
// These all should be stored because they are in the predicate list.
// BUT they will get converted to the same exact datetime in UTC.
// So we have to make the key distinct! Good luck indexer!
Statement s1 = new StatementImpl(vf.createURI("foo:subj1"), pred2_circa, vf.createLiteral(ZONETestDateInET));
Statement s2 = new StatementImpl(vf.createURI("foo:subj2"), pred1_atTime, vf.createLiteral(ZONETestDateInZulu));
Statement s3 = new StatementImpl(vf.createURI("foo:subj3"), pred1_atTime, vf.createLiteral(ZONETestDateInBRST));
int rowsStoredExpected = 0;
tIndexer.storeStatement(convertStatement(s1));
rowsStoredExpected++;
tIndexer.storeStatement(convertStatement(s2));
rowsStoredExpected++;
tIndexer.storeStatement(convertStatement(s3));
rowsStoredExpected++;
int rowsStoredActual = printTables("junit testing: Duplicate times stored", null, /*System.out*/
null);
Assert.assertEquals("Number of Duplicate times stored, 1 means duplicates not handled correctly.", rowsStoredExpected * 4, rowsStoredActual);
}
Aggregations