private Literal createLiteral(ValueFactory f, final String label, final URI datatype, final String languageCode) { if (datatype == null && languageCode == null) return f.createLiteral(label); if (datatype == null) return f.createLiteral(label, languageCode); return f.createLiteral(label, datatype); }
public Literal serialize(Class object) { String label = object.getName(); return vf.createLiteral(label, datatype); } }
@Override public void convert(String ttl, String startTime) { long start_l, stop_l; long ttl_l = Long.parseLong(ttl); stop_l = System.currentTimeMillis(); if (startTime != null) stop_l = Long.parseLong(startTime); start_l = stop_l - ttl_l; start = vf.createLiteral(start_l + ""); stop = vf.createLiteral(stop_l + ""); }
@Test public void testInvalidDateTime() throws Exception { // SES-711 Literal date1 = vf.createLiteral("2004-12-20", XMLSchema.DATETIME); Literal date2 = vf.createLiteral("2004-12-20", XMLSchema.DATETIME); assertEquals(date1, date2); }
@Override public Value bind(final ValueFactory vf, final IGASState<PATHS.VS, PATHS.ES, Void> state, final Value u) { return vf.createLiteral(state.getState(u).depth.get()); }
@Override public ValueConstant visit(ASTFalse node, Object data) throws VisitorException { return new ValueConstant(valueFactory.createLiteral(false)); }
public Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length > 0) { throw new ValueExprEvaluationException("STRUUID requires 0 arguments, got " + args.length); } Literal literal = valueFactory.createLiteral(java.util.UUID.randomUUID().toString()); return literal; }
@Override public Value bind(final ValueFactory vf, final IGASState<PR.VS, PR.ES, Double> state, final Value u) { return vf.createLiteral(state.getState(u).getValue()); }
protected void executeInsert(String where, boolean expected) throws RepositoryException, Exception { final StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { ex:bob rdfs:label \"Bob\" . } WHERE { " + where +" }"); assertFalse(hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); m_repo.prepareUpdate(update.toString()).evaluate(); assertEquals(expected, hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); }
public void addCompleteWorksheetHistory(KR2RMLMapping mapping, Resource mappingRes) throws RepositoryException { URI hasWorksheetHistoryUri = f.createURI(Uris.KM_HAS_WORKSHEET_HISTORY_URI); Value historyLiteral = f.createLiteral(mapping.getWorksheetHistory().toString(4)); con.add(mappingRes, hasWorksheetHistoryUri, historyLiteral); }
private void addLogicalSource(KR2RMLMapping mapping, Worksheet worksheet, Resource mappingRes, URI trMapUri) throws RepositoryException { // Add the Logical table information BNode logTableBNode = f.createBNode(); con.add(logTableBNode, repoURIs.get(Uris.RR_TABLENAME_URI), f.createLiteral(worksheet.getTitle())); con.add(logTableBNode, RDF.TYPE, repoURIs.get(Uris.RR_LOGICAL_TABLE_CLASS_URI)); con.add(logTableBNode, repoURIs.get(Uris.KM_IS_PART_OF_MAPPING_URI), mappingRes); con.add(mappingRes, repoURIs.get(Uris.KM_HAS_LOGICAL_TABLE_URI), logTableBNode); con.add(trMapUri, repoURIs.get(Uris.RR_LOGICAL_TABLE_URI), logTableBNode); }
@Override public Resource export(Graph graph) { Resource implNode = super.export(graph); if (propertiesFile != null) { graph.add(implNode, BigdataConfigSchema.PROPERTIES, graph.getValueFactory().createLiteral(propertiesFile)); } return implNode; }
@Test public void testAddLiteralWithNewline() throws Exception { Literal test = vf.createLiteral("this is a test\n"); testCon.add(bob, RDFS.LABEL, test); assertTrue(NEWLY_ADDED, testCon.hasStatement(bob, RDFS.LABEL, test, false)); }
private void addImplementation(Collection<String> members, Model graph, BNode fedRepoNode, RepositoryConnection con, boolean readonly, boolean distinct) throws OpenRDFException, MalformedURLException { BNode implRoot = valueFactory.createBNode(); addToGraph(graph, fedRepoNode, RepositoryConfigSchema.REPOSITORYIMPL, implRoot); addToGraph(graph, implRoot, RepositoryConfigSchema.REPOSITORYTYPE, valueFactory.createLiteral(SailRepositoryFactory.REPOSITORY_TYPE)); addSail(members, graph, implRoot, con, readonly, distinct); }
public void testLoadSilent() throws Exception { final String update = "LOAD SILENT <file:src/test/com/bigdata/rdf/rio/NOT-FOUND.rdf>"; final String ns = "http://bigdata.com/test/data#"; m_repo.prepareUpdate(update).evaluate(); assertFalse(hasStatement(f.createURI(ns, "mike"), RDFS.LABEL, f.createLiteral("Michael Personick"), true)); }
public Value evaluate(LocalName node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value argValue = evaluate(node.getArg(), bindings); if (argValue instanceof IRI) { IRI uri = (IRI)argValue; return tripleSource.getValueFactory().createLiteral(uri.getLocalName()); } else { throw new ValueExprEvaluationException(); } }
private void addQueryNode(Model m, Resource implNode, IRI predicate, String queryText) { if (null != queryText) { ValueFactory factory = SimpleValueFactory.getInstance(); BNode queryNode = factory.createBNode(); m.add(implNode, predicate, queryNode); m.add(queryNode, RDF.TYPE, SP.CONSTRUCT_CLASS); m.add(queryNode, SP.TEXT_PROPERTY, factory.createLiteral(queryText)); } } }
protected void executeInsert(String where, boolean expected) throws RepositoryException, Exception { final StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { ex:bob rdfs:label \"Bob\" . } WHERE { " + where +" }"); assertFalse(hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); m_repo.prepareUpdate(update.toString()).evaluate(); assertEquals(expected, hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); }
private void setupNamespaces() throws IOException, RDFParseException, RepositoryException { testCon.setNamespace(EXAMPLE, EXAMPLE_NS); testCon.setNamespace(RDF_PREFIX, "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); testCon.setNamespace(RDFS_PREFIX, RDFS_NS); // Translated from earlier RDF document. Is this line even necessary? testCon.add(vf.createURI(EXAMPLE_NS, "Main"), vf.createURI(RDFS_NS, "label"), vf.createLiteral("Main Node")); }
@Override public final void addTypedLiteral(String subj, String pred, String content, String type, String graph) { if (graph == null) { addTypedLiteral(subj, pred, content, type); } else { Literal literal = valueFactory.createLiteral(content, valueFactory.createURI(type)); addQuad(convertNonLiteral(subj), valueFactory.createURI(pred), literal, convertNonLiteral(graph)); } }