@Override public Statement getStatementProperty( Property p ) { return asResource().getRequiredProperty( p ); }
@Override public Statement getProperty(Property p) { return getResource().getRequiredProperty( p ); }
/** * Answer true if this option is set to true, either on the command line * or in the config model * * @return boolean */ protected boolean isTrue( List<String> cmdLineArgs, Resource confRoot ) { if (cmdLineArgs.contains( m_cmdLineForm )) { return true; } if (confRoot.hasProperty( m_prop )) { return confRoot.getRequiredProperty( m_prop ).getBoolean(); } return false; }
/** * Answer the resource value of the parameter if set, or null otherwise. * * @return String */ protected Resource getResource( List<String> cmdLineArgs, Resource confRoot ) { int index = cmdLineArgs.indexOf( m_cmdLineForm ); if (index >= 0) { try { return confRoot.getModel().getResource( cmdLineArgs.get( index + 1 ) ); } catch (IndexOutOfBoundsException e) { System.err.println( "Value for parameter " + m_cmdLineForm + " not set! Aborting."); } } if (m_prop != null && confRoot.hasProperty( m_prop )) { return confRoot.getRequiredProperty( m_prop ).getResource(); } // not set return null; }
/** * Return the value of the parameter if set, or null otherwise. Note command line * has precedence. * * @return The argument value as an RDFNode */ protected RDFNode getValue( List<String> cmdLineArgs, Resource confRoot ) { int index = cmdLineArgs.indexOf( m_cmdLineForm ); if (index >= 0) { try { return ResourceFactory.createPlainLiteral( cmdLineArgs.get( index + 1 ) ); } catch (IndexOutOfBoundsException e) { throw new SchemagenException( "Value for parameter " + m_cmdLineForm + " not set! Aborting.", e ); } } if (m_prop != null && confRoot != null && confRoot.hasProperty( m_prop )) { return confRoot.getRequiredProperty( m_prop ).getObject(); } // not set return null; }
/** * <p> * Helper method for setting the list tail, that assumes we have * a resource that is a list. * </p> * * @param root The resource representing the list cell we're setting the * tail of * @param tail The new tail for this list, as a resource. * @return The old tail, as a resource. */ protected static Resource setTailAux( Resource root, Resource tail, Property pTail ) { Statement current = root.getRequiredProperty( pTail ); Resource oldTail = current.getResource(); // out with the old, in with the new current.remove(); root.addProperty( pTail, tail ); return oldTail; }
String name = mapping.getRequiredProperty(LocationMappingVocab.name) .getString() ; String altName = mapping.getRequiredProperty(LocationMappingVocab.altName) .getString() ; addAltEntry(name, altName) ; String prefix = mapping.getRequiredProperty(LocationMappingVocab.prefix) .getString() ; String altPrefix = mapping.getRequiredProperty(LocationMappingVocab.altPrefix) .getString() ; addAltPrefix(prefix, altPrefix) ;
String name = mapping.getRequiredProperty(LocationMappingVocab.name) .getString() ; String altName = mapping.getRequiredProperty(LocationMappingVocab.altName) .getString() ; locMap.addAltEntry(name, altName) ; String prefix = mapping.getRequiredProperty(LocationMappingVocab.prefix) .getString() ; String altPrefix = mapping.getRequiredProperty(LocationMappingVocab.altPrefix) .getString() ; locMap.addAltPrefix(prefix, altPrefix) ;
RDFNode n0 = r0.getRequiredProperty( head ).getObject(); RDFNode n1 = r1.getRequiredProperty( head ).getObject(); r0 = r0.getRequiredProperty( tail ).getResource(); r1 = r1.getRequiredProperty( tail ).getResource();
/** * @return A statement that is suitable for a typed node construction or * null. */ private Statement getType(Resource r) { Statement rslt; try { if (r instanceof Statement) { rslt = ((Statement) r).getStatementProperty(RDF.type); if (rslt == null || (!rslt.getObject().equals(RDF.Statement))) error("Statement type problem"); } else { rslt = r.getRequiredProperty(RDF.type); } } catch (PropertyNotFoundException rdfe) { if (r instanceof Statement) error("Statement type problem"); rslt = null; } if (rslt == null || isOKType(rslt.getObject()) == -1) return null; return rslt; }
Statement subj = r.getRequiredProperty(RDF.subject); Statement pred = r.getRequiredProperty(RDF.predicate); Statement obj = r.getRequiredProperty(RDF.object); RDFNode nobj = obj.getObject(); Resource rsubj = (Resource) subj.getObject();
private void buildRows(Resource root) { // Now the results themselves int count = 0 ; StmtIterator solnIter = root.listProperties(ResultSetGraphVocab.solution) ; for ( ; solnIter.hasNext() ; ) { Resource soln = solnIter.nextStatement().getResource() ; count++ ; Binding rb = buildBinding(soln) ; rows.add(rb) ; } solnIter.close() ; if ( root.hasProperty(ResultSetGraphVocab.size)) { try { int size = root.getRequiredProperty(ResultSetGraphVocab.size).getInt() ; if ( size != count ) Log.warn(this, "Warning: Declared size = "+size+" : Count = "+count) ; } catch (JenaException rdfEx) {} } }
private void buildRows(Resource root) { // Now the results themselves int count = 0 ; StmtIterator solnIter = root.listProperties(ResultSetGraphVocab.solution) ; for ( ; solnIter.hasNext() ; ) { Resource soln = solnIter.nextStatement().getResource() ; count++ ; Binding rb = buildBinding(soln) ; rows.add(rb) ; } solnIter.close() ; if ( root.hasProperty(ResultSetGraphVocab.size)) { try { int size = root.getRequiredProperty(ResultSetGraphVocab.size).getInt() ; if ( size != count ) Log.warn(this, "Warning: Declared size = "+size+" : Count = "+count) ; } catch (JenaException rdfEx) {} } }
String var = binding.getRequiredProperty(ResultSetGraphVocab.variable).getString() ; try { RDFNode val = binding.getRequiredProperty(ResultSetGraphVocab.value).getObject() ; rb.add(Var.alloc(var), val.asNode()) ; } catch (PropertyNotFoundException ex)
String var = binding.getRequiredProperty(ResultSetGraphVocab.variable).getString() ; try { RDFNode val = binding.getRequiredProperty(ResultSetGraphVocab.value).getObject() ; rb.add(Var.alloc(var), val.asNode()) ; } catch (PropertyNotFoundException ex)
l = l.getRequiredProperty( tail ).getResource(); index++; found = l.hasProperty( head, value );
l = l.getRequiredProperty( tail ).getResource(); found = (last && l.hasProperty( tail, nil )) || (!last && (--i == 0));
public void addQueryMetadata( Model meta, Resource anExec, String selectQuery, String viewQuery, Source source, boolean listEndpoint ) { Resource EP = meta.createResource( SPARQL.Service ); // source.addMetadata( EP ); Resource url = EP.getRequiredProperty( API.sparqlEndpoint ).getResource(); EP.addProperty( SPARQL.url, url ); // Resource exec = anExec.inModel(meta); if (listEndpoint) { Resource sr = meta.createResource( SPARQL.QueryResult ); sr.addProperty( SPARQL.query, inValue( meta, selectQuery ) ); sr.addProperty( SPARQL.endpoint, EP ); exec.addProperty( API.selectionResult, sr ); } // Resource vr = meta.createResource( SPARQL.QueryResult ); vr.addProperty( SPARQL.query, inValue( meta, viewQuery ) ); vr.addProperty( SPARQL.endpoint, EP ); exec.addProperty( API.viewingResult, vr ); }