// Path: rdfagents-core/src/main/java/net/fortytwo/rdfagents/model/Dataset.java
// public class Dataset {
//     public static final String UUID_URN_PREFIX = "urn:uuid:";
// 
//     private final Collection<Statement> statements;
// 
//     public Dataset(Collection<Statement> statements) {
//         this.statements = statements;
//     }
// 
//     public Collection<Statement> getStatements() {
//         return statements;
//     }
// }


import info.aduna.iteration.CloseableIteration;
import net.fortytwo.rdfagents.model.Dataset;
import org.openrdf.model.Resource;
import org.openrdf.model.Statement;
import org.openrdf.model.Value;
import org.openrdf.sail.Sail;
import org.openrdf.sail.SailConnection;
import org.openrdf.sail.SailException;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.stream.Collectors;
package net.fortytwo.rdfagents.data;



/**
 * A simple "describes" query engine which produces a RDF Dataset of graphs describing
 * (containing forward or backward links to) the resource, as well as those describing
 * the graphs, and so on recursively.
 * The purpose of the recursion is to capture the provenance trail of the base description of the the resource.
 *
 * This implementation prevents duplicate statements
 * (i.e. two or more statements with the same subject, predicate, and object in the same graph)
 *
 * @author Joshua Shinavier (http://fortytwo.net)
 */
public class RecursiveDescribeQuery implements DatasetQuery {
    private final Sail sail;
    private final Value resource;

    /**
     * @param resource the resource to describe
     *                 Exactly what constitutes a description is a matter of implementation.
     * @param sail the storage and inference layer against which to evaluate the query
     */
    public RecursiveDescribeQuery(final Value resource,
                                  final Sail sail) {
        this.resource = resource;
        this.sail = sail;
    }

// Path: rdfagents-core/src/main/java/net/fortytwo/rdfagents/model/Dataset.java
// public class Dataset {
//     public static final String UUID_URN_PREFIX = "urn:uuid:";
// 
//     private final Collection<Statement> statements;
// 
//     public Dataset(Collection<Statement> statements) {
//         this.statements = statements;
//     }
// 
//     public Collection<Statement> getStatements() {
//         return statements;
//     }
// }


// Path: rdfagents-core/src/main/java/net/fortytwo/rdfagents/data/RecursiveDescribeQuery.java
import info.aduna.iteration.CloseableIteration;
import net.fortytwo.rdfagents.model.Dataset;
import org.openrdf.model.Resource;
import org.openrdf.model.Statement;
import org.openrdf.model.Value;
import org.openrdf.sail.Sail;
import org.openrdf.sail.SailConnection;
import org.openrdf.sail.SailException;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.stream.Collectors;

package net.fortytwo.rdfagents.data;



/**
 * A simple "describes" query engine which produces a RDF Dataset of graphs describing
 * (containing forward or backward links to) the resource, as well as those describing
 * the graphs, and so on recursively.
 * The purpose of the recursion is to capture the provenance trail of the base description of the the resource.
 *
 * This implementation prevents duplicate statements
 * (i.e. two or more statements with the same subject, predicate, and object in the same graph)
 *
 * @author Joshua Shinavier (http://fortytwo.net)
 */
public class RecursiveDescribeQuery implements DatasetQuery {
    private final Sail sail;
    private final Value resource;

    /**
     * @param resource the resource to describe
     *                 Exactly what constitutes a description is a matter of implementation.
     * @param sail the storage and inference layer against which to evaluate the query
     */
    public RecursiveDescribeQuery(final Value resource,
                                  final Sail sail) {
        this.resource = resource;
        this.sail = sail;
    }

    public Dataset evaluate() throws DatasetQueryException {