Refine search
protected static void addRangeTypes( Model result, Model schema ) { Model toAdd = ModelFactory.createDefaultModel(); for (StmtIterator it = schema.listStatements( ANY, RDFS.range, ANY ); it.hasNext();) { Statement s = it.nextStatement(); RDFNode type = s.getObject(); Property property = s.getSubject().as( Property.class ); for (StmtIterator x = result.listStatements( ANY, property, ANY ); x.hasNext();) { RDFNode ob = x.nextStatement().getObject(); if (ob.isResource()) toAdd.add( (Resource) ob, RDF.type, type ); } } result.add( toAdd ); }
/** * Add a configuration description for this reasoner into a partial * configuration specification model. * @param configSpec a Model into which the configuration information should be placed * @param base the Resource to which the configuration parameters should be added. */ @Override public void addDescription(Model configSpec, Resource base) { if (configuration != null) { StmtIterator i = configuration.listProperties(); while (i.hasNext()) { Statement st = i.nextStatement(); configSpec.add(base, st.getPredicate(), st.getObject()); } } }
public static String getAsStringValue(Resource r, Property p) { if ( ! atmostOneProperty(r, p) ) throw new NotUniqueException(r, p) ; Statement s = r.getProperty(p) ; if ( s == null ) return null ; if ( s.getObject().isResource() ) return s.getResource().getURI() ; return s.getString() ; }
@Override public Statement map1( Statement o ) { Statement s = o; return inModel.createStatement( newSubject, s.getPredicate(), s.getObject() ); } };
/** sameAs - is this statement equal to the statement o? We can't assume o is a StatementImpl */ private final boolean sameAs( Statement o ) { return subject.equals( o.getSubject() ) && predicate.equals( o.getPredicate() ) && object.equals( o.getObject() ); }
protected static void addSubclassesFrom( Model result, Model schema ) { for (StmtIterator it = schema.listStatements( ANY, RDFS.subClassOf, ANY ); it.hasNext();) { Statement s = it.nextStatement(); if (s.getSubject().isURIResource() && s.getObject().isURIResource()) result.add( s ); } }
while (stmtIter.hasNext()) { Statement stmt = stmtIter.next(); Resource type = stmt.getSubject().getPropertyResourceValue(RDF.type); if (type == null || !type.equals(RDF.Statement)) { statementsToRemove.add(stmt); Statement stmt1 = r.getProperty(logModel.getProperty(logNs + "destinationFileSize")); Long fileSizeInLogFile = Long.valueOf(stmt1.getObject().toString()); Long actualFileSize = new Long(new File(destinationFileName).length()); if (fileSizeInLogFile.longValue() != actualFileSize.longValue()) { Long reifiedModelFileSizeInLogFile = Long.valueOf(stmt2.getObject().toString()); Long actualReifiedModelFileSize = new Long(new File(reifiedModelFileName).length()); if (reifiedModelFileSizeInLogFile.longValue() != actualReifiedModelFileSize.longValue()) { Property prop = stmt.getPredicate(); RDFNode node = stmt.getObject(); if (verbose) log.info("Found in last time log " + prop.getLocalName() + " " + node.toString()); ReifiedStatement rstmt = rsExistingIter.next(); Statement st = rstmt.getProperty(DC.source); String source = st.getObject().toString(); if (mappingDocument.findLogicalTableMappingByUri(source) != null) { if (logicalTableMapping.getUri().equals(source)) { subjects.add(st.getSubject().getURI()); subjects.add(st.getSubject().getURI());
thisMetaPage.addProperty( API.definition, uriForDefinition ); URI emv_uri = URIUtils.replaceQueryParam( URIUtils.newURI(thisMetaPage.getURI()), "_metadata", "all" ); thisMetaPage.addProperty( API.extendedMetadataVersion, metaModel.createResource( emv_uri.toString() ) ); thisMetaPage.addProperty( RDF.type, API.Page ); Resource l = licence.inModel(thisMetaPage.getModel()); thisMetaPage.addProperty(DCTerms.license, l); thisMetaPage.getModel().add(ResourceUtils.reachableClosure(l)); for (Resource d: notices) { thisMetaPage.addProperty(ELDA_API.notice, d); thisMetaPage.getModel().add(ResourceUtils.reachableClosure(d)); Model toRemove = ModelFactory.createDefaultModel(); for (Statement s: thisMetaPage.listProperties().toList()) { if (mc.drop(s.getPredicate())) { boolean isItems = s.getPredicate().equals(API.items); boolean isPrimaryTopic = s.getPredicate().equals(FOAF.primaryTopic); boolean isTypePage = s.getPredicate().equals(RDF.type) && s.getObject().equals(API.Page); boolean keep = isItems || isPrimaryTopic || (demandPage && isTypePage); if (!keep) toRemove.add(s);
try { Model model = ModelFactory.createDefaultModel(); model.read((in), ""); StmtIterator iter; Statement stmt; iter = model.listStatements(); while (iter.hasNext()) { stmt = (Statement) iter.next(); String sub = stmt.getSubject().getURI(); String obj = stmt.getObject().toString(); if (sub != null) { try { if (stmt.getPredicate().getURI().indexOf("subClassOf") > 0) {
/** * Returns a pair of models. The first contains any statement containing at * least one blank node. The second contains all remaining statements. * @param g * @return */ private Model[] separateStatementsWithBlankNodes(Graph g) { Model gm = ModelFactory.createModelForGraph(g); Model blankNodeModel = ModelFactory.createDefaultModel(); Model nonBlankNodeModel = ModelFactory.createDefaultModel(); StmtIterator sit = gm.listStatements(); while (sit.hasNext()) { Statement stmt = sit.nextStatement(); if (!stmt.getSubject().isAnon() && !stmt.getObject().isAnon()) { nonBlankNodeModel.add(stmt); } else { blankNodeModel.add(stmt); } } Model[] result = new Model[2]; result[0] = blankNodeModel; result[1] = nonBlankNodeModel; return result; }
protected static void addSupertypes( Model result ) { Model temp = ModelFactory.createDefaultModel(); for (StmtIterator it = result.listStatements( ANY, RDF.type, ANY ); it.hasNext();) { Statement s = it.nextStatement(); Resource c = AssemblerHelp.getResource( s ); for (StmtIterator subclasses = result.listStatements( c, RDFS.subClassOf, ANY ); subclasses.hasNext();) { RDFNode type = subclasses.nextStatement().getObject(); // System.err.println( ">> adding super type: subject " + s.getSubject() + ", type " + type ); temp.add( s.getSubject(), RDF.type, type ); } } result.add( temp ); }
new SimpleSelector(null, ResourceMapConstants.IS_DESCRIBED_BY_PROPERTY, (Object) null); StmtIterator sItr = m.listStatements(isDescribedBySelector); while (sItr.hasNext()) { final Statement stmt = sItr.next(); final String rdfUri = stmt.getObject().toString(); if (loadedRems.contains(rdfUri)) { LOG.trace("Already loaded ReM from {}", rdfUri); Model loaded = ModelFactory.createDefaultModel(); RDFReader reader = loaded.getReader(); reader.setProperty(ResourceMapConstants.JENA_ERROR_MODE_URI, ResourceMapConstants.JENA_ERROR_MODE_STRICT); ResourceMapUtil.loadRDF(reader, loaded, baseDir, rdfUri); loadedRems.add(rdfUri); m = load(m.union(loaded), baseDir, loadedRems);
protected static void addDomainTypes( Model result, Model schema ) { for (StmtIterator it = schema.listStatements( ANY, RDFS.domain, ANY ); it.hasNext();) { Statement s = it.nextStatement(); Property property = s.getSubject().as( Property.class ); RDFNode type = s.getObject(); for (StmtIterator x = result.listStatements( ANY, property, ANY ); x.hasNext();) { Statement t = x.nextStatement(); result.add( t.getSubject(), RDF.type, type ); } } }
private static List<Resource> equivalentTypes( Resource type ) { List<Resource> types = new ArrayList<Resource>(); types.add( type ); for (StmtIterator it = type.getModel().listStatements( ANY, OWL.equivalentClass, type ); it.hasNext();) types.add( it.nextStatement().getSubject() ); return types; }
Model m = ModelFactory.createDefaultModel(); for (StmtIterator i = r.listProperties(); i.hasNext(); ) { Statement s = i.nextStatement(); m.add( s ); if (s.getObject() instanceof Resource) { queue.add( s.getObject() );
private void createGraphNodeToTriplesNodeMap(KR2RMLMapping kr2rmlMapping) throws FileNotFoundException, UnsupportedEncodingException{ StmtIterator itr = model.listStatements(null, model.getProperty(Uris.KM_NODE_ID_URI), (RDFNode)null); Resource subject; Map<String,String> graphNodeIdToTriplesMapIdMap = kr2rmlMapping.getAuxInfo().getGraphNodeIdToTriplesMapIdMap(); while (itr.hasNext()) { Statement subjMapToNodeIdStmt = itr.next(); String nodeId = subjMapToNodeIdStmt.getObject().toString(); subject = subjMapToNodeIdStmt.getSubject(); if (subject != null) { StmtIterator itr2 = model.listStatements(null, model.getProperty(Uris.RR_SUBJECTMAP_URI), subject); while (itr2.hasNext()) { String triplesMapId = itr2.next().getSubject().toString(); graphNodeIdToTriplesMapIdMap.put(nodeId, triplesMapId); } } } }
private void restitchItemLists(Model given, Model recon) { Statement G = given.listStatements(ANY, API.items, ANY).toList().get(0); Resource page = G.getSubject(); // Statement S = recon.listStatements(ANY, API.items, ANY).toList().get(0); Resource items = S.getObject().asResource(); S.remove(); recon.add(page, API.items, items); recon.removeAll(ANY, others, ANY); }
private Statement normaliseLiterals(Statement s) { RDFNode O = s.getObject(); if (O.isLiteral()) if (XSD.xstring.getURI().equals(O.asNode().getLiteralDatatypeURI())) { Model M = s.getModel(); Resource S = s.getSubject(); Property P = s.getPredicate(); return M.createStatement(S, P, O.asNode().getLiteralLexicalForm()); } return s; } }
/** Convert a model to a set of nodes with edges to other nodes */ void convert(Model m) { for (StmtIterator it = m.listStatements(); it.hasNext();) { Statement s = it.next(); RDFNode o = s.getObject(); if (o.isResource()) convert(s.getSubject(), o.asResource()); } }
protected Content getInitialContent( Assembler a, Resource root ) { Model partial = ModelFactory.createDefaultModel(); Resource combined = partial.createResource(); for (StmtIterator it = root.listProperties( JA.initialContent ); it.hasNext();) transferContentProperties( partial, it.nextStatement().getResource(), combined ); return contentFromModel( a, root, partial, combined ); }