org.eclipse.rdf4j.model.impl.SimpleValueFactory Java Examples
The following examples show how to use
org.eclipse.rdf4j.model.impl.SimpleValueFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransactionParallelBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Benchmark public boolean transaction100ParallelTransactions() { SimpleValueFactory vf = SimpleValueFactory.getInstance(); IntStream .range(0, 100) .mapToObj(k -> IntStream .range(0, 10) .mapToObj(i -> vf.createStatement(vf.createBNode(), RDFS.LABEL, vf.createLiteral(i))) .collect(Collectors.toList())) .collect(Collectors.toList()) .parallelStream() .forEach(list -> { try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(IsolationLevels.READ_COMMITTED); connection.add(list); connection.commit(); } }); return hasStatement(); }
Example #2
Source File: ProjectionEvaluatorTest.java From rya with Apache License 2.0 | 6 votes |
/** * This Projection enumerates all of the variables that were in the query, none of them are anonymous, and * none of them insert constants. */ @Test public void changesNothing() throws Exception { // Read the projection object from a SPARQL query. final Projection projection = getProjection( "SELECT ?person ?employee ?business " + "WHERE { " + "?person <urn:talksTo> ?employee . " + "?employee <urn:worksAt> ?business . " + "}"); // Create a Binding Set that contains the result of the WHERE clause. final ValueFactory vf = SimpleValueFactory.getInstance(); final MapBindingSet bs = new MapBindingSet(); bs.addBinding("person", vf.createIRI("urn:Alice")); bs.addBinding("employee", vf.createIRI("urn:Bob")); bs.addBinding("business", vf.createIRI("urn:TacoJoint")); final VisibilityBindingSet original = new VisibilityBindingSet(bs, "a|b"); // Execute the projection. final VisibilityBindingSet result = ProjectionEvaluator.make(projection).project(original); assertEquals(original, result); }
Example #3
Source File: BindingSetOutputFormatterTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void unaryResult() { // Create the input binding set. final ValueFactory vf = SimpleValueFactory.getInstance(); final MapBindingSet bindingSet = new MapBindingSet(); bindingSet.addBinding("person", vf.createIRI("urn:Alice")); bindingSet.addBinding("age", vf.createLiteral(34)); final VisibilityBindingSet visBs = new VisibilityBindingSet(bindingSet, "a"); // Mock the processor context that will be invoked. final ProcessorContext context = mock(ProcessorContext.class); // Run the test. final BindingSetOutputFormatter formatter = new BindingSetOutputFormatter(); formatter.init(context); formatter.process("key", ProcessorResult.make(new UnaryResult(visBs))); // Verify the mock was invoked with the expected output. verify(context, times(1)).forward(eq("key"), eq(visBs)); }
Example #4
Source File: GeoTemporalProviderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void twoPatternsOneFilter_test() throws Exception { final ValueFactory vf = SimpleValueFactory.getInstance(); final Value geo = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT); final Value temp = vf.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString()); final IRI tempPred = vf.createIRI(URI_PROPERTY_AT_TIME); final String query = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" + "PREFIX geos: <http://www.opengis.net/def/function/geosparql/>" + "PREFIX time: <tag:rya-rdf.org,2015:temporal#>" + "SELECT * WHERE { " + "?subj <" + tempPred + "> ?time ."+ "?subj <" + GeoConstants.GEO_AS_WKT + "> ?loc . " + " FILTER(geos:sfContains(?loc, " + geo + ")) . " + "}"; final QuerySegment<EventQueryNode> node = getQueryNode(query); final List<EventQueryNode> nodes = provider.getExternalSets(node); assertEquals(0, nodes.size()); }
Example #5
Source File: KnowledgeBaseMapping.java From inception with Apache License 2.0 | 6 votes |
@JsonCreator public KnowledgeBaseMapping(@JsonProperty("class") String aClassIri, @JsonProperty("subclass-of") String aSubclassIri, @JsonProperty("instance-of") String aTypeIri, @JsonProperty("subproperty-of") String aSubPropertyIri, @JsonProperty("description") String aDescriptionIri, @JsonProperty("label") String aLabelIri, @JsonProperty("property-type") String aPropertyTypeIri, @JsonProperty("property-label") String aPropertyLabelIri, @JsonProperty("property-description") String aPropertyDescriptionIri) { SimpleValueFactory vf = SimpleValueFactory.getInstance(); classIri = vf.createIRI(aClassIri); subclassIri = vf.createIRI(aSubclassIri); typeIri = vf.createIRI(aTypeIri); subPropertyIri = vf.createIRI(aSubPropertyIri); descriptionIri = vf.createIRI(aDescriptionIri); labelIri = vf.createIRI(aLabelIri); propertyTypeIri = vf.createIRI(aPropertyTypeIri); propertyLabelIri = vf.createIRI(aPropertyLabelIri); propertyDescriptionIri = vf.createIRI(aPropertyDescriptionIri); }
Example #6
Source File: DatatypeBenchmarkLinear.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Setup(Level.Iteration) public void setUp() { Logger root = (Logger) LoggerFactory.getLogger(ShaclSailConnection.class.getName()); root.setLevel(ch.qos.logback.classic.Level.INFO); allStatements = new ArrayList<>(NUMBER_OF_TRANSACTIONS); SimpleValueFactory vf = SimpleValueFactory.getInstance(); for (int j = 0; j < NUMBER_OF_TRANSACTIONS; j++) { List<Statement> statements = new ArrayList<>(BenchmarkConfigs.STATEMENTS_PER_TRANSACTION); allStatements.add(statements); for (int i = 0; i < BenchmarkConfigs.STATEMENTS_PER_TRANSACTION; i++) { IRI iri = vf.createIRI("http://example.com/" + i + "_" + j); statements.add(vf.createStatement(iri, RDF.TYPE, RDFS.RESOURCE)); statements.add(vf.createStatement(iri, FOAF.AGE, vf.createLiteral(i))); } } System.gc(); }
Example #7
Source File: GeoTemporalProviderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void twoSubjOneFilter_test() throws Exception { final ValueFactory vf = SimpleValueFactory.getInstance(); final Value geo = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT); final Value temp = vf.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString()); final IRI tempPred = vf.createIRI(URI_PROPERTY_AT_TIME); final String query = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" + "PREFIX geos: <http://www.opengis.net/def/function/geosparql/>" + "PREFIX time: <tag:rya-rdf.org,2015:temporal#>" + "SELECT * WHERE { " + "?subj <" + tempPred + "> ?time ."+ "?subj <" + GeoConstants.GEO_AS_WKT + "> ?loc . " + "?subj2 <" + tempPred + "> ?time2 ."+ "?subj2 <" + GeoConstants.GEO_AS_WKT + "> ?loc2 . " + " FILTER(geos:sfContains(?loc, " + geo + ")) . " + " FILTER(time:equals(?time, " + temp + ")) . " + "}"; final QuerySegment<EventQueryNode> node = getQueryNode(query); final List<EventQueryNode> nodes = provider.getExternalSets(node); assertEquals(1, nodes.size()); }
Example #8
Source File: SPARQLQueryBuilderTest.java From inception with Apache License 2.0 | 6 votes |
private void initRdfsMapping() { ValueFactory vf = SimpleValueFactory.getInstance(); kb.setClassIri(RDFS.CLASS); kb.setSubclassIri(RDFS.SUBCLASSOF); kb.setTypeIri(RDF.TYPE); kb.setLabelIri(RDFS.LABEL); kb.setPropertyTypeIri(RDF.PROPERTY); kb.setDescriptionIri(RDFS.COMMENT); // We are intentionally not using RDFS.LABEL here to ensure we can test the label // and property label separately kb.setPropertyLabelIri(SKOS.PREF_LABEL); // We are intentionally not using RDFS.COMMENT here to ensure we can test the description // and property description separately kb.setPropertyDescriptionIri(vf.createIRI("http://schema.org/description")); kb.setSubPropertyIri(RDFS.SUBPROPERTYOF); }
Example #9
Source File: MaxCountBenchmarkEmpty.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Setup(Level.Invocation) public void setUp() { Logger root = (Logger) LoggerFactory.getLogger(ShaclSailConnection.class.getName()); root.setLevel(ch.qos.logback.classic.Level.INFO); SimpleValueFactory vf = SimpleValueFactory.getInstance(); allStatements = BenchmarkConfigs.generateStatements(((statements, i, j) -> { IRI iri = vf.createIRI("http://example.com/" + i + "_" + j); statements.add(vf.createStatement(iri, RDF.TYPE, RDFS.RESOURCE)); statements.add(vf.createStatement(iri, RDFS.LABEL, vf.createLiteral("label" + i))); })); System.gc(); }
Example #10
Source File: HalyardTableUtilsScanTest.java From Halyard with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws Exception { table = HalyardTableUtils.getTable(HBaseServerTestInstance.getInstanceConfig(), "testScan", true, 0); allStatements = new HashSet<>(); SimpleValueFactory vf = SimpleValueFactory.getInstance(); allStatements.add(vf.createStatement(vf.createIRI(SUBJ1), vf.createIRI(PRED1), vf.createLiteral(EXPL1), vf.createIRI(CTX1))); allStatements.add(vf.createStatement(vf.createIRI(SUBJ2), vf.createIRI(PRED2), vf.createLiteral(EXPL2), vf.createIRI(CTX2))); long timestamp = System.currentTimeMillis(); for (Statement st : allStatements) { for (KeyValue kv : HalyardTableUtils.toKeyValues(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext(), false, timestamp)) { table.put(new Put(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(), kv.getTimestamp()).add(kv)); } } table.flushCommits(); }
Example #11
Source File: AddRemoveBenchmarkEmpty.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Setup(Level.Iteration) public void setUp() { Logger root = (Logger) LoggerFactory.getLogger(ShaclSailConnection.class.getName()); root.setLevel(ch.qos.logback.classic.Level.INFO); allStatements = new ArrayList<>(BenchmarkConfigs.NUMBER_OF_TRANSACTIONS); SimpleValueFactory vf = SimpleValueFactory.getInstance(); for (int j = 0; j < BenchmarkConfigs.NUMBER_OF_TRANSACTIONS; j++) { List<Statement> statements = new ArrayList<>(BenchmarkConfigs.STATEMENTS_PER_TRANSACTION); allStatements.add(statements); for (int i = 0; i < BenchmarkConfigs.STATEMENTS_PER_TRANSACTION; i++) { statements.add( vf.createStatement(vf.createIRI("http://example.com/" + i + "_" + j), RDF.TYPE, RDFS.RESOURCE)); statements.add(vf.createStatement(vf.createIRI("http://example.com/" + i + "_" + j), FOAF.AGE, vf.createLiteral(i))); } } System.gc(); }
Example #12
Source File: HalyardExportJDBCTypesTest.java From Halyard with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws Exception { ValueFactory vf = SimpleValueFactory.getInstance(); HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), TABLE, true, 0, true, 0, null, null); sail.initialize(); for (int i=1; i<10; i++) { sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/date"), vf.createLiteral(new Date(100 + i, i, i))); Date d = new Date(100 + i, i, i, i, i, i); sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/time"), vf.createLiteral(d)); sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/timestamp"), vf.createLiteral(new Date(d.getTime() + i))); // add millis sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/string"), vf.createLiteral("value" + i)); sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/boolean"), vf.createLiteral(i < 5)); sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/byte"), vf.createLiteral((byte)i)); sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/double"), vf.createLiteral((double)i/100.0)); sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/float"), vf.createLiteral((float)i/10.0)); sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/int"), vf.createLiteral(i * 100)); sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/long"), vf.createLiteral((long)i * 10000000000l)); sail.addStatement(vf.createIRI("http://whatever/subj" + i), vf.createIRI("http://whatever/short"), vf.createLiteral((short)(i * 10))); } sail.commit(); sail.shutDown(); }
Example #13
Source File: MongoFreeTextIndexerIT.java From rya with Apache License 2.0 | 6 votes |
@Test public void testSearch() throws Exception { try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) { f.setConf(conf); f.init(); final ValueFactory vf = SimpleValueFactory.getInstance(); final IRI subject = vf.createIRI("foo:subj"); final IRI predicate = RDFS.LABEL; final Value object = vf.createLiteral("this is a new hat"); final IRI context = vf.createIRI("foo:context"); final Statement statement = vf.createStatement(subject, predicate, object, context); f.storeStatement(RdfToRyaConversions.convertStatement(statement)); f.flush(); assertEquals(Sets.newHashSet(), getSet(f.queryText("asdf", EMPTY_CONSTRAINTS))); assertEquals(Sets.newHashSet(statement), getSet(f.queryText("new", EMPTY_CONSTRAINTS))); assertEquals(Sets.newHashSet(statement), getSet(f.queryText("hat new", EMPTY_CONSTRAINTS))); } }
Example #14
Source File: SPARQLJSONTupleBackgroundTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testNonStandardDistinct() throws Exception { SPARQLResultsJSONParser parser = new SPARQLResultsJSONParser(SimpleValueFactory.getInstance()); QueryResultCollector handler = new QueryResultCollector(); parser.setQueryResultHandler(handler); InputStream stream = this.getClass().getResourceAsStream("/sparqljson/non-standard-distinct.srj"); assertNotNull("Could not find test resource", stream); parser.parseQueryResult(stream); // there must be 1 variable assertEquals(1, handler.getBindingNames().size()); // first must be called "Concept", etc., assertEquals("Concept", handler.getBindingNames().get(0)); // -1 results assertEquals(100, handler.getBindingSets().size()); }
Example #15
Source File: SPARQLProtocolSession.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public SPARQLProtocolSession(HttpClient client, ExecutorService executor) { this.httpClient = client; this.httpContext = new HttpClientContext(); this.background = new BackgroundResultExecutor(executor); valueFactory = SimpleValueFactory.getInstance(); httpContext.setCookieStore(new BasicCookieStore()); // parser used for processing server response data should be lenient parserConfig.addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES); parserConfig.addNonFatalError(BasicParserSettings.VERIFY_LANGUAGE_TAGS); // configure the maximum url length for SPARQL query GET requests int maximumUrlLength = DEFAULT_MAXIMUM_URL_LENGTH; String propertyValue = System.getProperty(MAXIMUM_URL_LENGTH_PARAM); if (propertyValue != null) { try { maximumUrlLength = Integer.parseInt(propertyValue); } catch (NumberFormatException e) { throw new RDF4JConfigException("integer value expected for property " + MAXIMUM_URL_LENGTH_PARAM, e); } } this.maximumUrlLength = maximumUrlLength; }
Example #16
Source File: HBaseSailTest.java From Halyard with Apache License 2.0 | 6 votes |
@Test public void testEvaluate() throws Exception { ValueFactory vf = SimpleValueFactory.getInstance(); Resource subj = vf.createIRI("http://whatever/subj/"); IRI pred = vf.createIRI("http://whatever/pred/"); Value obj = vf.createLiteral("whatever"); CloseableIteration<? extends Statement, SailException> iter; HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null); SailRepository rep = new SailRepository(sail); rep.initialize(); sail.addStatement(subj, pred, obj); sail.commit(); TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}"); TupleQueryResult res = q.evaluate(); assertTrue(res.hasNext()); rep.shutDown(); }
Example #17
Source File: MemURITest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void compareURIs(String uri) throws Exception { IRI uriImpl = SimpleValueFactory.getInstance().createIRI(uri); MemIRI memURI = new MemIRI(this, uriImpl.getNamespace(), uriImpl.getLocalName()); assertEquals("MemURI not equal to URIImpl for: " + uri, uriImpl, memURI); assertEquals("MemURI has different hash code than URIImpl for: " + uri, uriImpl.hashCode(), memURI.hashCode()); }
Example #18
Source File: LiteralsTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)} * . */ @Test public void testCreateLiteralOrFailObjectByte() throws Exception { Object obj = new Integer(42).byteValue(); Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj); assertNotNull(l); assertEquals(l.getDatatype(), XMLSchema.BYTE); assertEquals(l.getLabel(), "42"); }
Example #19
Source File: MongoGeoIndexerIT.java From rya with Apache License 2.0 | 5 votes |
@Test public void testDeleteSearch() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { f.setConf(conf); f.init(); final ValueFactory vf = SimpleValueFactory.getInstance(); final Resource subject = vf.createIRI("foo:subj"); final IRI predicate = GeoConstants.GEO_AS_WKT; final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT); final Resource context = vf.createIRI("foo:context"); final Statement statement = vf.createStatement(subject, predicate, object, context); f.storeStatement(convertStatement(statement)); f.flush(); f.deleteStatement(convertStatement(statement)); // test a ring that the point would be inside of if not deleted final double[] in = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 }; final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(in, 2)); final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {}); assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS))); // test a ring that the point would be outside of if not deleted final double[] out = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 }; final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(out, 2)); final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {}); assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS))); // test a ring for the whole world and make sure the point is gone // Geomesa is a little sensitive around lon 180, so we only go to 179 final double[] world = { -180, 90, 179, 90, 179, -90, -180, -90, -180, 90 }; final LinearRing rWorld = gf.createLinearRing(new PackedCoordinateSequence.Double(world, 2)); final Polygon pWorld = gf.createPolygon(rWorld, new LinearRing[] {}); assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pWorld, EMPTY_CONSTRAINTS))); } }
Example #20
Source File: GeoWaveIndexerTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testRestrictPredicatesSearch() throws Exception { conf.setStrings(ConfigUtils.GEO_PREDICATES_LIST, "pred:1,pred:2"); try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) { f.setConf(conf); f.purge(conf); final ValueFactory vf = SimpleValueFactory.getInstance(); final Point point = gf.createPoint(new Coordinate(10, 10)); final Value pointValue = vf.createLiteral("Point(10 10)", GeoConstants.XMLSCHEMA_OGC_WKT); final IRI invalidPredicate = GeoConstants.GEO_AS_WKT; // These should not be stored because they are not in the predicate list f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj1"), invalidPredicate, pointValue))); f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj2"), invalidPredicate, pointValue))); final IRI pred1 = vf.createIRI("pred:1"); final IRI pred2 = vf.createIRI("pred:2"); // These should be stored because they are in the predicate list final Statement s3 = vf.createStatement(vf.createIRI("foo:subj3"), pred1, pointValue); final Statement s4 = vf.createStatement(vf.createIRI("foo:subj4"), pred2, pointValue); f.storeStatement(convertStatement(s3)); f.storeStatement(convertStatement(s4)); // This should not be stored because the object is not valid wkt f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj5"), pred1, vf.createLiteral("soint(10 10)")))); // This should not be stored because the object is not a literal f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj6"), pred1, vf.createIRI("p:Point(10 10)")))); f.flush(); final Set<Statement> actual = getSet(f.queryEquals(point, EMPTY_CONSTRAINTS)); Assert.assertEquals(2, actual.size()); Assert.assertTrue(actual.contains(s3)); Assert.assertTrue(actual.contains(s4)); } }
Example #21
Source File: RyaTypeWritable.java From rya with Apache License 2.0 | 5 votes |
@Override public void readFields(final DataInput dataInput) throws IOException { final SimpleValueFactory vfi = SimpleValueFactory.getInstance(); final String data = dataInput.readLine(); final String dataTypeString = dataInput.readLine(); final String language = dataInput.readLine(); final IRI dataType = vfi.createIRI(dataTypeString); final String validatedLanguage = LiteralLanguageUtils.validateLanguage(language, dataType); ryatype.setData(data); ryatype.setDataType(dataType); ryatype.setLanguage(validatedLanguage); }
Example #22
Source File: EndpointFactory.java From CostFed with GNU Affero General Public License v3.0 | 5 votes |
public static Endpoint loadEndpoint(Config config, HttpClient httpClient, Model graph, Resource repNode, Value repType) throws FedXException { EndpointProvider repProvider; // NativeStore => Sesame native store implementation if (repType.equals(SimpleValueFactory.getInstance().createLiteral("NativeStore"))){ repProvider = new NativeStoreProvider(config); return repProvider.loadEndpoint(new NativeGraphRepositoryInformation(graph, repNode) ); } // SPARQL Repository => SPARQLRepository else if (repType.equals(SimpleValueFactory.getInstance().createLiteral("SPARQLEndpoint"))){ repProvider = new SPARQLProvider(config, httpClient); return repProvider.loadEndpoint(new SPARQLGraphRepositoryInformation(graph, repNode) ); } // Remote Repository else if (repType.equals(SimpleValueFactory.getInstance().createLiteral("RemoteRepository"))){ repProvider = new RemoteRepositoryProvider(config); return repProvider.loadEndpoint(new RemoteRepositoryGraphRepositoryInformation(graph, repNode) ); } // other generic type else if (repType.equals(SimpleValueFactory.getInstance().createLiteral("Other"))) { // TODO add reflection techniques to allow for flexibility throw new UnsupportedOperationException("Operation not yet supported for generic type."); } else { throw new FedXRuntimeException("Repository type not supported: " + repType.stringValue()); } }
Example #23
Source File: QueryAlgebraUtil.java From CostFed with GNU Affero General Public License v3.0 | 5 votes |
public static Statement toStatement(StatementPattern stmt, BindingSet bindings) { Value subj = getVarValue(stmt.getSubjectVar(), bindings); Value pred = getVarValue(stmt.getPredicateVar(), bindings); Value obj = getVarValue(stmt.getObjectVar(), bindings); // TODO context return SimpleValueFactory.getInstance().createStatement((Resource)subj, (IRI)pred, obj); }
Example #24
Source File: LiteralsTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.model.util.Literals#createLiteral(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)} * . */ @Test public void testCreateLiteralObjectDate() throws Exception { Object obj = new Date(); Literal l = Literals.createLiteral(SimpleValueFactory.getInstance(), obj); assertNotNull(l); assertEquals(l.getDatatype(), XMLSchema.DATETIME); }
Example #25
Source File: JoinProcessorIT.java From rya with Apache License 2.0 | 5 votes |
@Test public void manyJoins() throws Exception { // Enumerate some topics that will be re-used final String ryaInstance = UUID.randomUUID().toString(); final UUID queryId = UUID.randomUUID(); final String statementsTopic = KafkaTopics.statementsTopic(ryaInstance); final String resultsTopic = KafkaTopics.queryResultsTopic(ryaInstance, queryId); // Setup a topology. final String query = "SELECT * WHERE { " + "?person <urn:talksTo> ?employee ." + "?employee <urn:worksAt> ?business ." + "?employee <urn:hourlyWage> ?wage ." + " }"; final TopologyFactory factory = new TopologyFactory(); final TopologyBuilder builder = factory.build(query, statementsTopic, resultsTopic, new RandomUUIDFactory()); // Create some statements that generate a bunch of right SP results. final ValueFactory vf = SimpleValueFactory.getInstance(); final List<VisibilityStatement> statements = new ArrayList<>(); statements.add( new VisibilityStatement( vf.createStatement(vf.createIRI("urn:Alice"), vf.createIRI("urn:talksTo"), vf.createIRI("urn:Bob")), "a") ); statements.add( new VisibilityStatement( vf.createStatement(vf.createIRI("urn:Bob"), vf.createIRI("urn:worksAt"), vf.createIRI("urn:BurgerJoint")), "a") ); statements.add( new VisibilityStatement( vf.createStatement(vf.createIRI("urn:Bob"), vf.createIRI("urn:hourlyWage"), vf.createLiteral(7.25)), "a") ); // Make the expected results. final Set<VisibilityBindingSet> expected = new HashSet<>(); final MapBindingSet bs = new MapBindingSet(); bs.addBinding("person", vf.createIRI("urn:Alice")); bs.addBinding("employee", vf.createIRI("urn:Bob")); bs.addBinding("business", vf.createIRI("urn:BurgerJoint")); bs.addBinding("wage", vf.createLiteral(7.25)); expected.add( new VisibilityBindingSet(bs, "a") ); // Run the test. RyaStreamsTestUtil.runStreamProcessingTest(kafka, statementsTopic, resultsTopic, builder, statements, expected, VisibilityBindingSetDeserializer.class); }
Example #26
Source File: LiteralsTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)} * . */ @Test public void testCreateLiteralOrFailObjectShort() throws Exception { Object obj = Short.parseShort("42"); Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj); assertNotNull(l); assertEquals(l.getDatatype(), XMLSchema.SHORT); assertEquals("42", l.getLabel()); }
Example #27
Source File: MongoGeoIndexerIT.java From rya with Apache License 2.0 | 5 votes |
@Test public void testRestrictPredicatesSearch() throws Exception { try (final MongoGeoIndexer f = new MongoGeoIndexer()) { conf.setStrings(ConfigUtils.GEO_PREDICATES_LIST, "pred:1,pred:2"); f.setConf(conf); f.init(); final ValueFactory vf = SimpleValueFactory.getInstance(); final Point point = gf.createPoint(new Coordinate(10, 10)); final Value pointValue = vf.createLiteral("Point(10 10)", GeoConstants.XMLSCHEMA_OGC_WKT); final IRI invalidPredicate = GeoConstants.GEO_AS_WKT; // These should not be stored because they are not in the predicate list f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj1"), invalidPredicate, pointValue))); f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj2"), invalidPredicate, pointValue))); final IRI pred1 = vf.createIRI("pred:1"); final IRI pred2 = vf.createIRI("pred:2"); // These should be stored because they are in the predicate list final Statement s3 = vf.createStatement(vf.createIRI("foo:subj3"), pred1, pointValue); final Statement s4 = vf.createStatement(vf.createIRI("foo:subj4"), pred2, pointValue); f.storeStatement(convertStatement(s3)); f.storeStatement(convertStatement(s4)); // This should not be stored because the object is not valid wkt f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj5"), pred1, vf.createLiteral("soint(10 10)")))); // This should not be stored because the object is not a literal f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj6"), pred1, vf.createIRI("p:Point(10 10)")))); f.flush(); final Set<Statement> actual = getSet(f.queryEquals(point, EMPTY_CONSTRAINTS)); assertEquals(2, actual.size()); assertTrue(actual.contains(s3)); assertTrue(actual.contains(s4)); } }
Example #28
Source File: MemoryStoreConfig.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Resource export(Model graph) { Resource implNode = super.export(graph); graph.setNamespace("ms", NAMESPACE); if (persist) { graph.add(implNode, PERSIST, BooleanLiteral.TRUE); } if (syncDelay != 0) { graph.add(implNode, SYNC_DELAY, SimpleValueFactory.getInstance().createLiteral(syncDelay)); } return implNode; }
Example #29
Source File: LiteralsTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)} * . */ @Test public void testCreateLiteralOrFailObjectDate() throws Exception { Object obj = new Date(); Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj); assertNotNull(l); assertEquals(l.getDatatype(), XMLSchema.DATETIME); }
Example #30
Source File: ProtocolTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testDecodeContext() { ValueFactory vf = SimpleValueFactory.getInstance(); assertEquals(vf.createBNode("bnode1"), Protocol.decodeContext("_:bnode1", vf)); assertEquals(vf.createIRI("urn:test"), Protocol.decodeContext("<urn:test>", vf)); // RDF* triples are resources but they can't be used as context values try { Protocol.decodeContext("<<<urn:a> <urn:b> <urn:c>>>", SimpleValueFactory.getInstance()); fail("Must fail with exception"); } catch (IllegalArgumentException e) { // ignore } }