/******************************************************************************************************************* * * * ******************************************************************************************************************/ @Nonnull public synchronized ModelBuilder with (final @Nonnull Model other) { other.forEach(statement -> model.add(statement)); return this; }
/******************************************************************************************************************* * * * ******************************************************************************************************************/ @Nonnull public synchronized ModelBuilder with (final @Nonnull List<ModelBuilder> others) { others.stream().map(other -> other.toModel()).forEach(m -> m.forEach(statement -> model.add(statement))); return this; } }
@Override public Model apply(Model input) { Model model = new LinkedHashModel(); input.forEach(statement -> expandStatements(model, statement)); return model; }
public static Set<String> getRepositoryIDs(Model model) throws RepositoryException { Set<String> idSet = new LinkedHashSet<String>(); model.filter(null, REPOSITORYID, null).forEach(idStatement -> { if (idStatement.getObject() instanceof Literal) { Literal idLiteral = (Literal)idStatement.getObject(); idSet.add(idLiteral.getLabel()); } }); return idSet; }
public static Set<String> getRepositoryIDs(Model model) throws RepositoryException { Set<String> idSet = new LinkedHashSet<>(); model.filter(null, REPOSITORYID, null).forEach(idStatement -> { if (idStatement.getObject() instanceof Literal) { Literal idLiteral = (Literal)idStatement.getObject(); idSet.add(idLiteral.getLabel()); } }); return idSet; }
@Override public void exportStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts) throws RepositoryException, RDFHandlerException { Model model = committed.filter(subj, pred, obj, contexts); handler.startRDF(); model.getNamespaces().forEach(ns -> { handler.handleNamespace(ns.getPrefix(), ns.getName()); }); model.forEach(st -> { handler.handleStatement(st); }); handler.endRDF(); }
private Model loadModel() { Model model = new TreeModel(); manager.getRepositoryIDs().forEach(id -> { Resource ctx = getContext(id); RepositoryConfig config = manager.getRepositoryConfig(id); Model cfg = new TreeModel(); config.export(cfg, ctx); cfg.getNamespaces().forEach(ns -> { model.setNamespace(ns); }); cfg.forEach(st -> { model.add(st.getSubject(), st.getPredicate(), st.getObject(), ctx); }); }); return model; }
rootNode.getModel().forEach((s) ->{ out.writeTriple(s.getSubject(), s.getPredicate(), s.getObject()); });