How to use the rdflib.BlankNode function in rdflib

To help you get started, we’ve selected a few rdflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inrupt / wac-ldp / src / lib / rdf / setAppModes.ts View on Github external
debug('before patch', store.toNT())

  const originSym = rdflib.sym(origin)
  // remove existing statements on same origin - if it exists
  debug('finding statements about ', origin)
  store.statementsMatching(null, rdflib.sym(ACL['origin'].toString()), originSym).forEach((st: any) => {
    debug('found', st)
    debug('removing trustedApp statements with object ', st.subject)
    store.removeStatements([...store.statementsMatching(null, rdflib.sym(ACL['trustedApp'].toString()), st.subject)])
    debug('removing statements with subject ', st.subject)
    store.removeStatements([...store.statementsMatching(st.subject)])
  })
  debug('after removing', store.toNT())

  // add new triples
  const application = new rdflib.BlankNode()
  store.add(rdflib.sym(webId.toString()), rdflib.sym(ACL['trustedApp'].toString()), application, rdflib.sym(webId.toString()))
  store.add(application, rdflib.sym(ACL['origin'].toString()), originSym, rdflib.sym(webId.toString()))

  modes.forEach(mode => {
    debug('adding', application, ACL['mode'], mode)
    store.add(application, rdflib.sym(ACL['mode'].toString()), rdflib.sym(mode.toString()))
  })
  debug('after patch', store.toNT())
  const turtleDoc: string = rdflib.serialize(undefined, store, webId.toString(), 'text/turtle')
  await blob.setData(await objectToStream(makeResourceData(resourceData.contentType, turtleDoc)))
}
github solid / node-solid-server / lib / requests / sharing-request.js View on Github external
async registerApp (ldp, appOrigin, accessModes, webId) {
    debug(`Registering app (${appOrigin}) with accessModes ${accessModes} for webId ${webId}`)
    const store = await this.getProfileGraph(ldp, webId)
    const origin = $rdf.sym(appOrigin)
    // remove existing statements on same origin - if it exists
    store.statementsMatching(null, ACL('origin'), origin).forEach(st => {
      store.removeStatements([...store.statementsMatching(null, ACL('trustedApp'), st.subject)])
      store.removeStatements([...store.statementsMatching(st.subject)])
    })

    // add new triples
    const application = new $rdf.BlankNode()
    store.add($rdf.sym(webId), ACL('trustedApp'), application, webId)
    store.add(application, ACL('origin'), origin, webId)

    accessModes.forEach(mode => {
      store.add(application, ACL('mode'), ACL(mode))
    })
    await this.saveProfileGraph(ldp, store, webId)
  }
github fletcher91 / link-redux / src / components / __tests__ / Typable.spec.ts View on Github external
it("returns null without onError and registered resource", () => {
            const opts = ctx.empty();
            const resolved = errorComponent({
                subject: new BlankNode(),
                topology: defaultNS.ex("t"),
            }, opts.lrs);

            expect(resolved).toBeNull();
        });
    });
github fletcher91 / link-redux / src / components / __tests__ / LinkedResourceContainer.spec.ts View on Github external
it("renders blank nodes", () => {
        const bn = new BlankNode();
        const opts = ctx.chargeLRS(
            [
                new Statement(bn, defaultNS.rdf("type"), defaultNS.schema("Thing")),
                new Statement(bn, defaultNS.schema("name"), new Literal("title")),
            ],
            bn,
        );

        const comp = createTestElement();
        opts.lrs.registerAll(LinkedRenderStore.registerRenderer(comp, defaultNS.schema("Thing")));
        const elem = mount(
            opts.wrapComponent(createElement(LinkedResourceContainer, {
                loadLinkedObject,
                subject: bn,
            })),
        );
github fletcher91 / link-redux / src / hooks / __tests__ / useDataFetching.spec.ts View on Github external
const comp = () => {
            useDataFetching({ subject: new BlankNode() }, 0, setError);

            return null;
        };
github inrupt / wac-ldp / src / lib / rdf / RdfLibStoreManager.ts View on Github external
export function newBlankNode (): RdfJsTerm {
  return new rdflib.BlankNode()
}
github solid / solid-panes / trustedApplications / service.ts View on Github external
export function getStatementsToAdd (
  origin: NamedNode,
  nodeName: string,
  modes: Mode[],
  person: NamedNode,
  ns: Namespaces
) {
  var application = new $rdf.BlankNode(`bn_${nodeName}`)
  return [
    $rdf.st(person, ns.acl('trustedApp'), application, person.doc()),
    $rdf.st(application, ns.acl('origin'), origin, person.doc()),
    ...modes
      .map(mode => {
        return ns.acl(mode)
      })
      .map(mode => $rdf.st(application, ns.acl('mode'), mode, person.doc()))
  ]
}
github solid / solid-panes / dashboard / trustedApplications / trustedApplicationsUtils.ts View on Github external
export function getStatementsToAdd (
  origin: NamedNode,
  nodeName: string,
  modes: string[],
  person: NamedNode,
  ns: Namespaces
) {
  var application = new BlankNode(`bn_${nodeName}`)
  return [
    st(person, ns.acl('trustedApp'), application, person.doc()),
    st(application, ns.acl('origin'), origin, person.doc()),
    ...modes
      .map(mode => sym(mode))
      .map(mode => st(application, ns.acl('mode'), mode, person.doc()))
  ]
}
github solid / solid-panes / trustedApplications / trustedApplicationsUtils.js View on Github external
function getStatementsToAdd(origin, nodeName, modes, person, ns) {
    var application = new $rdf.BlankNode("bn_" + nodeName);
    return [
        $rdf.st(person, ns.acl('trustedApp'), application, person.doc()),
        $rdf.st(application, ns.acl('origin'), origin, person.doc())
    ].concat(modes
        .map(function (mode) { return $rdf.sym(mode); })
        .map(function (mode) { return $rdf.st(application, ns.acl('mode'), mode, person.doc()); }));
}
exports.getStatementsToAdd = getStatementsToAdd;