public Resource build() { resource = ResourceUtils.renameResource(getResource(), getUriBuilder().build().toString()); return resource; }
private Model reanonimisePathBlankNodes(Resource resource, RDFNode rdfNode) { Model pathModel = ModelFactory.createDefaultModel(); pathModel.add(rdfNode.getModel()); pathModel.add(resource, SHACL.resultPath, rdfNode); ImmutableSet<Resource> resources = ImmutableSet.copyOf(pathModel.listSubjects()); resources.stream() .filter(Resource::isAnon) .filter(r -> r != resource) .forEach(r -> ResourceUtils.renameResource(r, null)); return pathModel; } }
private Model reanonimisePathBlankNodes(Resource resource, RDFNode rdfNode) { Model pathModel = ModelFactory.createDefaultModel(); pathModel.add(rdfNode.getModel()); pathModel.add(resource, SHACL.resultPath, rdfNode); ImmutableSet<Resource> resources = ImmutableSet.copyOf(pathModel.listSubjects()); resources.stream() .filter(Resource::isAnon) .filter(r -> r != resource) .forEach(r -> ResourceUtils.renameResource(r, null)); return pathModel; } }
private void renamePortal(Resource portal, String namespace, Model model) { model.enterCriticalSection(Lock.WRITE); try { ResourceUtils.renameResource(portal, namespace + portal.getLocalName()); } finally { model.leaveCriticalSection(); } }
/** * Extracts RDF Metadata triple from XML files * * @param internalPath path to the XML file relative to package root * @return RDF Metadata through GRDDL XSLT of given XML file */ public Model getXMLFileMetadata(String internalPath) { Model rdfModel = null; try { ByteArrayOutputStream out = new ByteArrayOutputStream(); OdfXMLHelper helper = new OdfXMLHelper(); if (mRdfFileExtractionTemplate == null) { String filePath = "file:" + OdfPackageDocument.class.getClassLoader().getResource("grddl/odf2rdf.xsl").getPath(); URI uri = new URI(filePath); InputSource inputSource = new InputSource(uri.toString()); mRdfFileExtractionTemplate = TransformerFactory.newInstance().newTemplates(new SAXSource(inputSource)); } helper.transform(this.getPackage(), internalPath, mRdfFileExtractionTemplate, new StreamResult(out)); String RDFBaseUri = Util.getRDFBaseUri(this.getPackage().getBaseURI(), internalPath); rdfModel = ModelFactory.createDefaultModel(); rdfModel.read(new InputStreamReader(new ByteArrayInputStream(out.toByteArray()), "utf-8"), RDFBaseUri); // remove the last SLASH at the end of the RDFBaseUri: // test_rdfmeta.odt/ --> test_rdfmeta.odt ResourceUtils.renameResource(rdfModel.getResource(RDFBaseUri), RDFBaseUri.substring(0, RDFBaseUri.length() - 1)); } catch (Exception ex) { Logger.getLogger(OdfPackageDocument.class.getName()).log(Level.SEVERE, null, ex); } return rdfModel; } }
public static class Pair<E> { private E first; private E second; public Pair(E first, E second) { this.first = first; this.second = second; } public E getFirst() { return first; } public E getSecond() { return second; } }
ResourceUtils.renameResource(t, namespace + LOCAL_NAME_PREPEND + randomInt);
r = ResourceUtils.renameResource(r, iri); return r; };
r = ResourceUtils.renameResource(r, iri); return r; };
/** * Reads the InputStream into a Model. Sets a 'fantasy URI' as base URI and * handles it gracefully if the model read from the string defines its own base * URI. Special care is taken that the null relative URI ('<>') is replaced by * the baseURI. * * @param in * @param rdfLanguage * @return a Model (possibly empty) */ public static Model readRdfSnippet(final InputStream in, final String rdfLanguage) { org.apache.jena.rdf.model.Model model = ModelFactory.createDefaultModel(); if (in == null) return model; String baseURI = "no:uri"; model.setNsPrefix("", baseURI); model.read(in, baseURI, rdfLanguage); String baseURIAfterReading = model.getNsPrefixURI(""); if (baseURIAfterReading == null) { model.setNsPrefix("", baseURI); } else if (!baseURI.equals(baseURIAfterReading)) { // the string representation of the model specified a base URI, but we used a // different one for reading. // We need to make sure that the one that is now set is the only one used ResourceUtils.renameResource(model.getResource(baseURI), model.getNsPrefixURI("")); } return model; }
/** * Reads the InputStream into a Model. Sets a 'fantasy URI' as base URI and * handles it gracefully if the model read from the string defines its own base * URI. Special care is taken that the null relative URI ('<>') is replaced by * the baseURI. * * @param in * @param rdfLanguage * @return a Model (possibly empty) */ public static Model readRdfSnippet(final Reader in, final String rdfLanguage) { org.apache.jena.rdf.model.Model model = ModelFactory.createDefaultModel(); if (in == null) return model; String baseURI = "no:uri"; model.setNsPrefix("", baseURI); model.read(in, baseURI, rdfLanguage); String baseURIAfterReading = model.getNsPrefixURI(""); if (baseURIAfterReading == null) { model.setNsPrefix("", baseURI); } else if (!baseURI.equals(baseURIAfterReading)) { // the string representation of the model specified a base URI, but we used a // different one for reading. // We need to make sure that the one that is now set is the only one used ResourceUtils.renameResource(model.getResource(baseURI), model.getNsPrefixURI("")); } return model; }
/** * Get RDF metadata from manifest.rdf and those rdf files registered in the * manifest.xml as "application/rdf+xml" through GRDDL XSLT * http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415072_253892949 */ public Model getManifestRDFMetadata() throws Exception { Model m = ModelFactory.createDefaultModel(); for (String internalPath : this.getPackage().getFilePaths()) { if (Util.isSubPathOf(internalPath, this.getDocumentPath()) && this.getPackage().getMediaTypeString(internalPath).endsWith("application/rdf+xml")) { Model m1 = ModelFactory.createDefaultModel(); String RDFBaseUri = Util.getRDFBaseUri(this.getPackage().getBaseURI(), internalPath); m1.read(new InputStreamReader(this.getPackage().getInputStream(internalPath), "utf-8"), RDFBaseUri); // remove the last SLASH at the end of the RDFBaseUri: // test_rdfmeta.odt/ --> test_rdfmeta.odt ResourceUtils.renameResource(m1.getResource(RDFBaseUri), RDFBaseUri.substring(0, RDFBaseUri.length() - 1)); if (m1.size() > 0) { m = m.union(m1); } } } return m; }
ResourceUtils.renameResource(res, uri);
/** * If we are loading the application metadata for the first time, set the * URI of the Portal based on the default namespace. */ private void setPortalUriOnFirstTime(Model model, ServletContext ctx) { // Only a single portal is permitted in the initialization data Resource portalResource = null; ClosableIterator<Resource> portalResIt = model .listSubjectsWithProperty(RDF.type, model.getResource(VitroVocabulary.PORTAL)); try { if (portalResIt.hasNext()) { Resource portalRes = portalResIt.next(); if (portalRes.isAnon()) { portalResource = portalRes; } } } finally { portalResIt.close(); } if (portalResource != null) { ResourceUtils.renameResource(portalResource, getDefaultNamespace(ctx) + "portal1"); } }
? pattern.replace("$$$", value) : pattern + value; ResourceUtils.renameResource(outRes, namespaceEtc + suffix);
ResourceUtils.renameResource(outRes,getNextURI(namespaceEtc,dedupUnionModel)); doneSet.add(res.getId()); ResourceUtils.renameResource(outRes,getNextURI(namespaceEtc, dedupUnionModel)); doneSet.add(res.getId());
ResourceUtils.renameResource(res,newURIStr);
Resource e = ResourceUtils.renameResource( a, NS + "e" ); Resource anon = ResourceUtils.renameResource( e, null ); f.addProperty( p, f ); Resource f1 = ResourceUtils.renameResource( f, NS +"f1" ); assertFalse( "Should be no f statements", m.listStatements( f, null, (RDFNode) null).hasNext() ); assertTrue( "f1 has p f1", f1.hasProperty( p, f1 ) );
Resource e = ResourceUtils.renameResource( a, NS + "e" ); Resource anon = ResourceUtils.renameResource( e, null ); f.addProperty( p, f ); Resource f1 = ResourceUtils.renameResource( f, NS +"f1" ); assertFalse( "Should be no f statements", m.listStatements( f, null, (RDFNode) null).hasNext() ); assertTrue( "f1 has p f1", f1.hasProperty( p, f1 ) );