Java Code Examples for org.openrdf.model.impl.ValueFactoryImpl#getInstance()
The following examples show how to use
org.openrdf.model.impl.ValueFactoryImpl#getInstance() .
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: JoinRMLPerformer.java From GeoTriples with Apache License 2.0 | 6 votes |
/** * Compare expressions from join to complete it * * @param node current object in parent iteration * @param dataset * @param map */ @Override public Collection<Statement> perform(Object node, SesameDataSet dataset, TriplesMap map) { List<Statement> statements=new LinkedList<>(); Value object = processor.processSubjectMap(dataset, map.getSubjectMap(), node); if (object == null){ return statements; } log.debug("[JoinRMLPerformer:addTriples] Subject " + subject + " Predicate " + predicate + "Object " + object.toString()); //add the join triple ValueFactory myFactory = ValueFactoryImpl.getInstance(); Statement st = myFactory.createStatement((Resource) subject, predicate, (Value) object); //dataset.add(subject, predicate, object); dataset.addStatement(st); statements.add(st); return statements; }
Example 2
Source File: ValueOfMarshall.java From anno4j with Apache License 2.0 | 6 votes |
public ValueOfMarshall(ValueFactory vf, Class<T> type) throws NoSuchMethodException { this.vf = vf; ValueFactoryImpl uf = ValueFactoryImpl.getInstance(); this.datatype = uf.createURI("java:", type.getName()); try { this.valueOfMethod = type.getDeclaredMethod("valueOf", new Class[] { String.class }); if (!Modifier.isStatic(valueOfMethod.getModifiers())) throw new NoSuchMethodException("valueOf Method is not static"); if (!type.equals(valueOfMethod.getReturnType())) throw new NoSuchMethodException("Invalid return type"); } catch (NoSuchMethodException e) { try { this.valueOfMethod = type.getDeclaredMethod("getInstance", new Class[] { String.class }); if (!Modifier.isStatic(valueOfMethod.getModifiers())) throw new NoSuchMethodException( "getInstance Method is not static"); if (!type.equals(valueOfMethod.getReturnType())) throw new NoSuchMethodException("Invalid return type"); } catch (NoSuchMethodException e2) { throw e; } } }
Example 3
Source File: ObjectConstructorMarshall.java From anno4j with Apache License 2.0 | 6 votes |
public ObjectConstructorMarshall(ValueFactory vf, Class<T> type) throws NoSuchMethodException { this.vf = vf; ValueFactory uf = ValueFactoryImpl.getInstance(); this.datatype = uf.createURI("java:", type.getName()); try { constructor = type.getConstructor(new Class[] { String.class }); } catch (NoSuchMethodException e) { try { constructor = type .getConstructor(new Class[] { CharSequence.class }); } catch (NoSuchMethodException e1) { throw e; } } }
Example 4
Source File: RowProcessor.java From GeoTriples with Apache License 2.0 | 6 votes |
/** * Construct a RowProcessor by initializing its fields with pre-calculated variables. * It is used in order to create a copy of an existing RowProcessor. * * @param in_headers input headers * @param subjTemplates input subject templates * @param subjTokens input subject tokens * @param subjReplacements_pos input sublect replacements * @param objTemplates input object templates * @param objTokens input object tokens * @param objReplacements_pos input object replacements * @param objTemplatesMap input object templates map */ public RowProcessor(Set<String> in_headers, List<String> subjTemplates, List<List<String>> subjTokens ,List<List<String>> subjReplacements_pos, List<String> objTemplates, List<List<String>> objTokens ,List<List<String>> objReplacements_pos, Map<String, Integer> objTemplatesMap){ super(); config_replacements = Config.variables; factory = ValueFactoryImpl.getInstance(); rml_factory = new ConcreteRMLProcessorFactory(); headers = in_headers; subj_templates = subjTemplates; subj_tokens = subjTokens; subj_replacements_pos = subjReplacements_pos; obj_templates = objTemplates; obj_tokens = objTokens; obj_templatesMap = objTemplatesMap; obj_replacements_pos = objReplacements_pos; }
Example 5
Source File: RowProcessor.java From GeoTriples with Apache License 2.0 | 6 votes |
/** * Constructor */ public RowProcessor(){ super(); config_replacements = Config.variables; subj_templates = new ArrayList<>(); subj_tokens = new ArrayList<>(); subj_replacements_pos = new ArrayList<>(); obj_templates = new ArrayList<>(); obj_tokens = new ArrayList<>(); obj_templatesMap = new HashMap<>(); obj_replacements_pos = new ArrayList<>(); factory = ValueFactoryImpl.getInstance(); rml_factory = new ConcreteRMLProcessorFactory(); }
Example 6
Source File: AbstractRMLProcessor.java From GeoTriples with Apache License 2.0 | 6 votes |
@Override public Collection<Statement> processSubjectTypeMap(SesameDataSet dataset, Resource subject, SubjectMap subjectMap, Object node) { List<Statement> statements=new LinkedList<>(); ValueFactory myFactory = ValueFactoryImpl.getInstance(); // Add the type triples Set<org.openrdf.model.URI> classIRIs = subjectMap.getClassIRIs(); if (subject != null) for (org.openrdf.model.URI classIRI : classIRIs) { Statement st = myFactory.createStatement((Resource) subject, RDF.TYPE, (Value) classIRI); //dataset.add(subject, predicate, object); dataset.addStatement(st); statements.add(st); //dataset.add(subject, RDF.TYPE, classIRI); } return statements; }
Example 7
Source File: WriteStatementsKnowledgeStore.java From EventCoreference with Apache License 2.0 | 6 votes |
static public org.openrdf.model.Statement castJenaOpenRdf(com.hp.hpl.jena.rdf.model.Statement jenaStatement, String modelName) { org.openrdf.model.Statement statement = null; try { ValueFactory valueFactory = ValueFactoryImpl.getInstance(); URI modelURI = valueFactory.createURI(modelName); URI subject = valueFactory.createURI(jenaStatement.getSubject().getURI()); URI sem = valueFactory.createURI(jenaStatement.getPredicate().getURI()); if (jenaStatement.getObject().isLiteral()) { Literal objectLiteral = valueFactory.createLiteral(jenaStatement.getObject().toString()); statement = valueFactory.createStatement(subject, sem, objectLiteral, modelURI); } else { URI objectUri = valueFactory.createURI(jenaStatement.getObject().asResource().getURI()); statement = valueFactory.createStatement(subject, sem, objectUri, modelURI); } } catch (Exception e) { System.out.println("jenaStatement.toString() = " + jenaStatement.toString()); e.printStackTrace(); } return statement; }
Example 8
Source File: Test_Ticket_789.java From database with GNU General Public License v2.0 | 5 votes |
private void populate() throws Exception { final ValueFactoryImpl vf = ValueFactoryImpl.getInstance(); final Statement[] a = new Statement[] { vf.createStatement(s, p, o, c), vf.createStatement(s, p, o, namedGraph1), vf.createStatement(s, p1, o, namedGraph2), vf.createStatement(s, p, o, defaultGraph1), vf.createStatement(s, p, p, defaultGraph2), vf.createStatement(p, p, p, c) }; final AddOp addOp = new AddOp(Arrays.asList(a)); m_repo.add(addOp); }
Example 9
Source File: JoinReferenceRMLPerformer.java From GeoTriples with Apache License 2.0 | 5 votes |
/** * Compare expressions from join to complete it * * @param node current object in parent iteration * @param dataset * @param map */ @Override public Collection<Statement> perform(Object node, SesameDataSet dataset, TriplesMap map) { List<Statement> statements=new LinkedList<>(); //Value object = processor.processSubjectMap(dataset, map.getSubjectMap(), node); List<Object> objects = processor.extractValueFromNode(node, expr); if (objects == null){ return statements; } log.debug("[JoinReferenceRMLPerformer:addTriples] Subject " + subject + " Predicate " + predicate + "Object " + objects.toString()); ValueFactory myFactory = ValueFactoryImpl.getInstance(); //add the join triple for(Object obj:objects){ Statement st = myFactory.createStatement((Resource) subject, predicate, (Value) new LiteralImpl(obj.toString().trim())); //dataset.add(subject, predicate, object); dataset.addStatement(st); statements.add(st); //dataset.add(subject, predicate, new LiteralImpl(obj.toString().trim())); } return statements; }
Example 10
Source File: RoleMapperTest.java From anno4j with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); vf = ValueFactoryImpl.getInstance(); ObjectRepositoryFactory factory = new ObjectRepositoryFactory(); mapper = factory.createRoleMapper(vf); }
Example 11
Source File: RoleMapperTest.java From anno4j with Apache License 2.0 | 5 votes |
public void testMixinName() throws Exception { RoleMapper rm = new RoleMapper(); ValueFactoryImpl vf = ValueFactoryImpl.getInstance(); rm.addConcept(MixedClassName.class, vf.createURI("urn:MixedClass")); Collection<Class<?>> roles = rm.findRoles(vf.createURI("urn:MixedClass")); assertTrue(roles.contains(BehaviourClass.class)); }
Example 12
Source File: RoleMapperTest.java From anno4j with Apache License 2.0 | 5 votes |
public void testMixinClass() throws Exception { RoleMapper rm = new RoleMapper(); ValueFactoryImpl vf = ValueFactoryImpl.getInstance(); rm.addConcept(MixedClass.class, vf.createURI("urn:MixedClass")); Collection<Class<?>> roles = rm.findRoles(vf.createURI("urn:MixedClass")); assertTrue(roles.contains(BehaviourClass.class)); }
Example 13
Source File: RoleMapper.java From anno4j with Apache License 2.0 | 4 votes |
public RoleMapper() { this(ValueFactoryImpl.getInstance()); }
Example 14
Source File: RDFUtils.java From mustard with MIT License | 4 votes |
private static void addStatement(DTGraph<String,String> graph, Statement stmt, boolean newObject, boolean splitLiteral, Map<String, DTNode<String,String>> nodeMap) { DTNode<String,String> n1 = nodeMap.get(stmt.getSubject().toString()); if (n1 == null) { n1 = graph.add(stmt.getSubject().toString()); nodeMap.put(stmt.getSubject().toString(), n1); } DTNode<String, String> n2 = null; List<DTNode<String,String>> nodeList = new ArrayList<DTNode<String,String>>(); if (stmt.getObject() instanceof Resource) { n2 = nodeMap.get(stmt.getObject().toString()); if (n2 == null) { n2 = graph.add(stmt.getObject().toString()); nodeMap.put(stmt.getObject().toString(), n2); } nodeList.add(n2); } else { // Literal if (splitLiteral) { ValueFactory factory = ValueFactoryImpl.getInstance(); Literal orgLit = (Literal)stmt.getObject(); WordIterator wi = new WordIterator(orgLit.getLabel()); while (wi.hasNext()) { String word = wi.next(); Literal lit; // Retain the original datatype/language tag if (orgLit.getDatatype() != null) { lit = factory.createLiteral(word, orgLit.getDatatype()); } else if (orgLit.getLanguage() != null) { lit = factory.createLiteral(word, orgLit.getLanguage()); } else { lit = factory.createLiteral(word); } n2 = nodeMap.get(lit.toString()); if (n2 == null || newObject) { n2 = graph.add(lit.toString()); nodeMap.put(lit.toString(), n2); } nodeList.add(n2); } } else { n2 = nodeMap.get(stmt.getObject().toString()); // toString() should be different from stringValue() if (n2 == null) { n2 = graph.add(stmt.getObject().toString()); if (!newObject) { nodeMap.put(stmt.getObject().toString(), n2); } } nodeList.add(n2); } } for (DTNode<String,String> n : nodeList) { // Statements are unique, since they are in a Set, thus we have never seem this particular edge before, we know that. n1.connect(n, stmt.getPredicate().toString()); } }
Example 15
Source File: StressTestConcurrentRestApiRequests.java From database with GNU General Public License v2.0 | 4 votes |
@Override protected void doApplyToNamespace(final RemoteRepository repo, final UUID uuid) throws Exception { /* * Setup data to be deleted. * * Note: This uses SELECT rather than CONSTRUCT since we need to get * the graph as well when addressing a QUADS mode namespace. */ final ValueFactory vf = ValueFactoryImpl.getInstance(); final Collection<Statement> stmts = new ArrayList<>(batchSize); TupleQueryResult result = null; try { if (quads) { result = repo.prepareTupleQuery( "SELECT * WHERE {GRAPH ?g {?s ?p ?o} }") .evaluate(); } else { result = repo.prepareTupleQuery( "SELECT * WHERE {?s ?p ?o}").evaluate(); } while (result.hasNext() && stmts.size() < batchSize) { final BindingSet bset = result.next(); final Resource s = (Resource) bset.getBinding("s") .getValue(); final URI p = (URI) bset.getBinding("p").getValue(); final Value o = (Value) bset.getBinding("o").getValue(); final Resource g = (Resource) (quads ? bset.getBinding("g") .getValue() : null); final Statement stmt = quads ? vf.createStatement(s, p, o, g) : vf.createStatement(s, p, o); stmts.add(stmt); } } finally { if (result != null) result.close(); } // do mutation. repo.remove(new RemoteRepository.RemoveOp(stmts), uuid); }
Example 16
Source File: OwlNormalizer.java From anno4j with Apache License 2.0 | 4 votes |
private ValueFactory getValueFactory() { return ValueFactoryImpl.getInstance(); }
Example 17
Source File: CRUDServlet.java From cumulusrdf with Apache License 2.0 | 4 votes |
@Override public void init() { _valueFactory = ValueFactoryImpl.getInstance(); }
Example 18
Source File: LinkedDataServlet.java From cumulusrdf with Apache License 2.0 | 4 votes |
@Override public void init() throws ServletException { _valueFactory = ValueFactoryImpl.getInstance(); }
Example 19
Source File: LiteralManager.java From anno4j with Apache License 2.0 | 4 votes |
public LiteralManager() { this(ValueFactoryImpl.getInstance(), ValueFactoryImpl.getInstance()); }
Example 20
Source File: TestBigdataValueSerialization.java From database with GNU General Public License v2.0 | 3 votes |
protected void setUp() throws Exception { super.setUp(); fixture = new BigdataValueSerializer<Value>( ValueFactoryImpl.getInstance()); }