How to use the rdflib.lit 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 jolocom / smartwallet-app / src / js / lib / agents / chat.js View on Github external
return [{// this is a message
      subject: id,
      predicate: PRED.type,
      object: PRED.post
    }, { // written by...
      subject: id,
      predicate: PRED.hasCreator,
      object: author
    }, { // with content...
      subject: id,
      predicate: PRED.content,
      object: $rdf.lit(content)
    }, { // with timestamp...
      subject: id,
      predicate: PRED.created,
      object: $rdf.lit(created, undefined, XSD('int'))
    }, { // contained by
      subject: id,
      predicate: PRED.hasContainer,
      object: conversationId
    }, {
      subject: conversationId,
      predicate: PRED.containerOf,
      object: id
    }]
  }
github jolocom / smartwallet-app / src / js / lib / agents / chat.js View on Github external
if (created instanceof Date) {
      created = created.getTime()
    }

    return [{// this is a message
      subject: id,
      predicate: PRED.type,
      object: PRED.post
    }, { // written by...
      subject: id,
      predicate: PRED.hasCreator,
      object: author
    }, { // with content...
      subject: id,
      predicate: PRED.content,
      object: $rdf.lit(content)
    }, { // with timestamp...
      subject: id,
      predicate: PRED.created,
      object: $rdf.lit(created, undefined, XSD('int'))
    }, { // contained by
      subject: id,
      predicate: PRED.hasContainer,
      object: conversationId
    }, {
      subject: conversationId,
      predicate: PRED.containerOf,
      object: id
    }]
  }
github solid / node-solid-server / lib / requests / get-account-info-request.js View on Github external
return err
  }

  // Get object value for solid:storageQuota
  const quotaNode = serverSideGraph.any(storageUrlNode, SOLID('storageQuota'), null)
  if (!quotaNode) {
    return new HTTPError(404, 'Unable to find solid:storageQuota')
  }

  // Get size of user's POD
  const root = ldp.resourceMapper.getFullPath(rootUrl)
  const size = await actualSize(root)

  // Add triples to graph
  const store = $rdf.graph()
  store.add(storageUrlNode, SOLID('storageUsage'), $rdf.lit(size))
  store.add(storageUrlNode, SOLID('storageQuota'), quotaNode)
  return await new Promise((resolve, reject) => {
    $rdf.serialize(null, store, storageUrlNode.value, contentType, (err, result) => {
      if (err) {
        return reject(err)
      }
      resolve(result)
    })
  })
}
github jolocom / smartwallet-app / src / js / lib / agents / solid-wallet.js View on Github external
setIdentityContractAddress(webId, entryValue) {
    if (!webId || !entryValue) {
      console.error('Invalid arguments')
      return
    }

    const g = rdf.graph()
    g.add(
      rdf.sym(webId),
      PRED.identityContractAddress,
      rdf.lit(entryValue)
    )

    return this.http.patch(webId, [], g.statements)
  }
github jolocom / smartwallet-app / src / js / lib / agents / solid-wallet.js View on Github external
addEntryPatch(entryFileUrl, webId, entryId, entryType) {
    const g = rdf.graph()
    const entryNode =
    `${util.getProfFolderUrl(webId)}/card#${entryType}${entryId}`

    const typeToPred = {
      phone: PRED.mobile,
      email: PRED.email,
      passport: PRED.passport,
      idCard: PRED.idCard
    }

    g.add(rdf.sym(webId), typeToPred[entryType], rdf.sym(entryNode))
    g.add(rdf.sym(entryNode), PRED.identifier, rdf.lit(entryId))
    g.add(rdf.sym(entryNode), PRED.seeAlso, rdf.sym(entryFileUrl))
    return g.statements
  },