protected void getMetadataProperties(Map<String, Object> metadata, BiConsumer<Object, Object> properties) { // A BdioMetadata instance should effectively be expanded data so we need to compact it using the graph context JsonLdOptions opts = frame().context().jsonLdOptions(); Object expandContext = opts.getExpandContext(); opts.setExpandContext(null); Map<String, Object> metadataNode = JsonLdProcessor.compact(metadata, expandContext, opts); options().metadataLabel().ifPresent(type -> metadataNode.put(JsonLdConsts.TYPE, type)); if (metadata.size() == 1 && metadata.containsKey(JsonLdConsts.ID)) { // JSON-LD compaction will remove the "@id" if it is the only field, put it back metadataNode.put(JsonLdConsts.ID, metadata.get(JsonLdConsts.ID)); } // Use the regular node property extraction logic getNodeProperties(metadataNode, properties); }
options.setExpandContext(context); options.format = JsonLdConsts.APPLICATION_NQUADS; String rdfString = (String)JsonLdProcessor.toRDF(jsonObject, options);
options.setExpandContext(context); final RDF2GoTripleCallback cb = new RDF2GoTripleCallback(); final RepositoryModelSet model = (RepositoryModelSet) JsonLdProcessor.toRDF(jsonObject, cb, options);
options.setExpandContext(context); final RDF2GoTripleCallback cb = new RDF2GoTripleCallback(); final RepositoryModelSet model = (RepositoryModelSet) JsonLdProcessor.toRDF(jsonObject, cb, options);
options.setExpandContext(context); final RDF2GoTripleCallback cb = new RDF2GoTripleCallback(); final RepositoryModelSet model = (RepositoryModelSet) JsonLdProcessor.toRDF(jsonObject, cb, options);
/** * Returns a new (mutable) JSON-LD options instance based on this context. */ public JsonLdOptions jsonLdOptions() { // TODO Technically both the documentLoader and potentially expandContext are mutable JsonLdOptions options = new JsonLdOptions(); options.setDocumentLoader(documentLoader); options.setBase(base); options.setExpandContext(expandContext); options.setOmitDefault(Boolean.TRUE); return options; }
opts.setExpandContext(null); opts.setFrameExpansion(true); final List<Object> expandedFrame = expand(frame, opts); opts.setExpandContext(savedExpandedContext);
opts.setExpandContext(null); opts.setFrameExpansion(true); final List<Object> expandedFrame = expand(frame, opts); opts.setExpandContext(savedExpandedContext);
final InputStream contextStream = cl .getResourceAsStream(TEST_DIR + "/" + test_opts.get("expandContext")); options.setExpandContext(JsonUtils.fromInputStream(contextStream));