public Bundle newNamedBundle(QualifiedName id, Namespace namespace, Collection<Statement> statements) { Bundle res = of.createNamedBundle(); res.setId(id); res.setNamespace(namespace); if (statements != null) { res.getStatement().addAll(statements); } return res; }
public Bundle newNamedBundle(QualifiedName id, Namespace namespace, Collection<Statement> statements) { Bundle res = of.createNamedBundle(); res.setId(id); res.setNamespace(namespace); if (statements != null) { res.getStatement().addAll(statements); } return res; }
public Document expander(Document docIn, Bindings bindings1) { Bundle bun = (Bundle) docIn.getStatementOrBundle().get(0); Groupings grp1 = Groupings.fromDocument(docIn); logger.debug("expander: Found groupings " + grp1); Bundle bun1 = (Bundle) expand(bun, bindings1, grp1).get(0); Document doc1 = pf.newDocument(); doc1.getStatementOrBundle().add(bun1); bun1.setNamespace(Namespace.gatherNamespaces(bun1)); doc1.setNamespace(new Namespace()); return doc1; }
public Document expander(Document docIn, Bindings bindings1) { Bundle bun = (Bundle) docIn.getStatementOrBundle().get(0); Groupings grp1 = Groupings.fromDocument(docIn); logger.debug("expander: Found groupings " + grp1); Bundle bun1 = (Bundle) expand(bun, bindings1, grp1).get(0); Document doc1 = pf.newDocument(); doc1.getStatementOrBundle().add(bun1); bun1.setNamespace(Namespace.gatherNamespaces(bun1)); doc1.setNamespace(new Namespace()); return doc1; }
public Document toDocument() { Document res=pFactory.newDocument(); List<StatementOrBundle> statementOrBundle = res.getStatementOrBundle(); toContainer(statementOrBundle); if (!flatten) { for (QualifiedName bunId: bundleMap.keySet()) { IndexedDocument idoc=bundleMap.get(bunId); Bundle bun=pFactory.newNamedBundle(bunId, null); List<StatementOrBundle> ll=new LinkedList<StatementOrBundle>(); idoc.toContainer(ll); for (StatementOrBundle s: ll) { bun.getStatement().add((Statement) s); } bun.setNamespace(Namespace.gatherNamespaces(bun)); statementOrBundle.add(bun); } } res.setNamespace(Namespace.gatherNamespaces(res)); return res; } private void toContainer(List<StatementOrBundle> statementOrBundle) {
public Document toDocument() { Document res=pFactory.newDocument(); List<StatementOrBundle> statementOrBundle = res.getStatementOrBundle(); toContainer(statementOrBundle); if (!flatten) { for (QualifiedName bunId: bundleMap.keySet()) { IndexedDocument idoc=bundleMap.get(bunId); Bundle bun=pFactory.newNamedBundle(bunId, null); List<StatementOrBundle> ll=new LinkedList<StatementOrBundle>(); idoc.toContainer(ll); for (StatementOrBundle s: ll) { bun.getStatement().add((Statement) s); } bun.setNamespace(Namespace.gatherNamespaces(bun)); statementOrBundle.add(bun); } } res.setNamespace(Namespace.gatherNamespaces(res)); return res; } private void toContainer(List<StatementOrBundle> statementOrBundle) {
/** * After reading a document, this method should be called to ensure that Namespaces are properly chained. * @param document a {@link Document} to update */ public void updateNamespaces(Document document) { Namespace rootNamespace = Namespace.gatherNamespaces(document); document.setNamespace(rootNamespace); for (org.openprovenance.prov.model.Bundle bu: utils.getBundle(document)) { Namespace ns=bu.getNamespace(); if (ns!=null) { ns.setParent(rootNamespace); } else { ns=new Namespace(); ns.setParent(rootNamespace); bu.setNamespace(ns); } } }
public Document makeDoc2000() { Bundle bun1=pFactory.newNamedBundle(q("b1"), null); Bundle bun2=pFactory.newNamedBundle(q("b2"), null); Entity e1=pFactory.newEntity(q("e1")); Entity e2=pFactory.newEntity(q("e2")); bun1.getStatement().add(e1); bun1.getStatement().add(e1); bun2.getStatement().add(e2); bun2.getStatement().add(e2); bun2.getStatement().add(e2); Document doc=pFactory.newDocument(); doc.getStatementOrBundle().add(bun1); bun1.setNamespace(Namespace.gatherNamespaces(bun1)); doc.getStatementOrBundle().add(bun2); bun2.setNamespace(Namespace.gatherNamespaces(bun2)); Namespace nss=Namespace.gatherNamespaces(doc); doc.setNamespace(nss); return doc; }
public Document makePC1GraphAndSpecialization(ProvFactory pFactory) { Document graph = pFactory.newDocument(); String bName = "b123"; // needs to be generated Bundle bun = makePC1FullGraph(pFactory, bName); graph.getStatementOrBundle().add(bun); bun.setNamespace(Namespace.gatherNamespaces(bun)); Hashtable<String, String> namespaces = new Hashtable<String, String>(); // currently, no prefix used, all qnames map to PC1_NS namespaces.put("_", EX_NS); // new default namespace namespaces.put("xsd", NamespacePrefixMapper.XSD_NS); namespaces.put(EX_PREFIX, EX_NS); namespaces.put(DOT_PREFIX, DOT_NS); Entity bunEntity = pFactory.newEntity(bun.getId()); Entity a = pFactory.newEntity(new org.openprovenance.prov.xml.QualifiedName(EX_NS, globalA1.getId().getLocalPart(),null)); MentionOf ctx = pFactory.newMentionOf(a.getId(), globalA1.getId(), bunEntity.getId()); a.getOther().add(pFactory.newOther(DOT_NS, DOT_PREFIX, "color", "blue", name.XSD_STRING)); graph.getStatementOrBundle().add(bunEntity); graph.getStatementOrBundle().add(a); graph.getStatementOrBundle().add(ctx); graph.setNamespace(Namespace.gatherNamespaces(graph)); graph.getNamespace().extendWith(bun.getNamespace()); return graph; }
public void testBundle2() { Used use1 = pFactory.newUsed(q("use1"), q("a1"), null, q("e1")); Entity e1 = pFactory.newEntity(q("e1")); Activity a1 = pFactory.newActivity(q("a1")); List<Statement> st1 = new LinkedList<Statement>(); st1.add(a1); st1.add(e1); st1.add(use1); Bundle b1 = pFactory.newNamedBundle(q("bundle1"), st1); b1.setNamespace(Namespace.gatherNamespaces(b1,pFactory)); Used use2 = pFactory.newUsed(q("use2"), q("e1"), null, q("a1")); Entity ee1 = pFactory.newEntity(q("a1")); Activity aa1 = pFactory.newActivity(q("e1")); List<Statement> st2 = new LinkedList<Statement>(); st2.add(aa1); st2.add(ee1); st2.add(use2); Bundle b2 = pFactory.newNamedBundle(q("bundle2"), st2); b2.setNamespace(Namespace.gatherNamespaces(b2,pFactory)); Entity eb1 = pFactory.newEntity(q("bundle1")); pFactory.addBundleType(eb1); Entity eb2 = pFactory.newEntity(q("bundle2")); pFactory.addBundleType(eb2); Statement[] statements = new Statement[] { eb1, eb2, }; Bundle[] bundles = new Bundle[] { b1, b2 }; makeDocAndTest(statements, bundles, "target/bundle2", null, true); }
public void testBundle1() { Used use1 = pFactory.newUsed(q("use1"), q("a1"), null, q("e1")); Entity e1 = pFactory.newEntity(q("e1")); Activity a1 = pFactory.newActivity(q("a1")); List<Statement> st1 = new LinkedList<Statement>(); st1.add(a1); st1.add(e1); st1.add(use1); Bundle b1 = pFactory.newNamedBundle(q("bundle1"), st1); Used use2 = pFactory.newUsed(q("use2"), q("aa1"), null, q("ee1")); Entity ee1 = pFactory.newEntity(q("ee1")); Activity aa1 = pFactory.newActivity(q("aa1")); List<Statement> st2 = new LinkedList<Statement>(); st2.add(aa1); st2.add(ee1); st2.add(use2); b1.setNamespace(Namespace.gatherNamespaces(b1,pFactory)); Bundle b2 = pFactory.newNamedBundle(q("bundle2"), st2); Entity eb1 = pFactory.newEntity(q("bundle1")); pFactory.addBundleType(eb1); Entity eb2 = pFactory.newEntity(q("bundle2")); pFactory.addBundleType(eb2); b2.setNamespace(Namespace.gatherNamespaces(b2,pFactory)); Statement[] statements = new Statement[] { eb1, eb2, }; Bundle[] bundles = new Bundle[] { b1, b2 }; makeDocAndTest(statements, bundles, "target/bundle1", null, true); }
/** A small example showing inheritance of namespace from Document. */ public void testBundle3() { Used use1 = pFactory.newUsed(q("use1"), q("a1"), null, q("e1")); Entity e1 = pFactory.newEntity(q("e1")); Activity a1 = pFactory.newActivity(q("a1")); List<Statement> st1 = new LinkedList<Statement>(); st1.add(a1); st1.add(e1); st1.add(use1); Bundle b1 = pFactory.newNamedBundle(q("bundle1"), st1); Used use2 = pFactory.newUsed(q("use2"), q("aa1"), null, q("ee1")); Entity ee1 = pFactory.newEntity(q("ee1")); Activity aa1 = pFactory.newActivity(q("aa1")); List<Statement> st2 = new LinkedList<Statement>(); st2.add(aa1); st2.add(ee1); st2.add(use2); Namespace ns1 = Namespace.gatherNamespaces(b1,pFactory); b1.setNamespace(ns1); Bundle b2 = pFactory.newNamedBundle(q("bundle2"), st2); Entity eb1 = pFactory.newEntity(q("bundle1")); pFactory.addBundleType(eb1); Entity eb2 = pFactory.newEntity(q("bundle2")); pFactory.addBundleType(eb2); Namespace ns2 = Namespace.gatherNamespaces(b2,pFactory); b2.setNamespace(ns2); Statement[] statements = new Statement[] { eb1, eb2, }; Bundle[] bundles = new Bundle[] { b1, b2 }; makeDocAndTest(statements, bundles, "target/bundle3", null, true); }
Bundle b1 = pFactory.newNamedBundle(q("bundle1"), st1); Namespace ns1 = Namespace.gatherNamespaces(b1,pFactory); b1.setNamespace(ns1); Bundle b2 = pFactory.newNamedBundle(another("bundle2"), st2); Namespace ns2 = Namespace.gatherNamespaces(b2,pFactory); b2.setNamespace(ns2);
Bundle namedBundle = pf.getObjectFactory().createNamedBundle(); namedBundle.setId(id); namedBundle.setNamespace(ns); namedBundle.getStatement() .addAll((Collection<? extends Statement>) statements);
Bundle namedBundle = pf.getObjectFactory().createNamedBundle(); namedBundle.setId(id); namedBundle.setNamespace(ns); namedBundle.getStatement() .addAll((Collection<? extends Statement>) statements);
waw1 })); graph.setNamespace(Namespace.gatherNamespaces(graph));