/**
  * Get the very first value for a predicate as a string, or null if the predicate is not used
  *
  * @param rdf
  * @param subject
  * @param predicate
  * @return first value for the given predicate or null if not found
  */
 public static String getFirstValueForPredicate(
     final Dataset rdf, final Node subject, final Node predicate) {
   final Iterator<Quad> statements = rdf.asDatasetGraph().find(ANY, subject, predicate, ANY);
   // we'll take the first one we get
   if (statements.hasNext()) {
     final Quad statement = statements.next();
     LOGGER.trace("Checking statement: {}", statement);
     return statement.asTriple().getObject().getLiteral().getLexicalForm();
   }
   LOGGER.trace("No value found for predicate: {}", predicate);
   return null;
 }
 @Override
 public void add(Quad quad) {
   Graph graph;
   if (quad.isDefaultGraph()) {
     graph = getDefaultGraph();
   } else {
     graph = getGraph(quad.getGraph());
   }
   if (graph != null) {
     graph.add(quad.asTriple());
   }
 }
  @Override
  public void compute(Quad quad) {
    logger.debug("Computing : {} ", quad.asTriple().toString());

    String predicate = quad.getPredicate().getURI();

    if (!(predicate.equals(RDF.type))) {
      if ((quad.getObject().isURI()) & (!(quad.getObject().isBlank()))) {
        boolean isAdded = fqurisReservoir.add(quad.getObject().getURI());
        logger.trace(
            "URI found on object: {}, was added to reservoir? {}",
            quad.getObject().getURI(),
            isAdded);
      }
    }
  }
  @Override
  public void compute(Quad quad) {
    logger.debug("Computing : {} ", quad.asTriple().toString());

    Node subject = quad.getSubject();
    Node object = quad.getObject();

    if (quad.getObject().equals(FOAF.Document.asNode())) {
      docs.putIfAbsent(subject.toString(), new DigitalSignature());
    }

    if (quad.getPredicate().equals(ASSURANCE.asNode())) {
      DigitalSignature ds;
      if (endorsements.containsKey(object.getURI())) {
        ds = endorsements.get(object.getURI());
      } else {
        ds = new DigitalSignature();
        ds.endorcement = object.getURI();
      }

      ds.assurance = subject.getURI();

      docs.put(subject.toString(), ds);
      endorsements.put(object.getURI(), ds);
    }

    if (quad.getPredicate().equals(ENDORSER.asNode())) {
      DigitalSignature ds;
      if (endorsements.containsKey(object.getURI())) {
        ds = endorsements.get(object.getURI());
      } else {
        ds = new DigitalSignature();
        ds.endorcement = subject.getURI();
      }

      ds.endorcer = object.getURI();
    }

    if (quad.getObject().equals(ENDORSEMENT.asNode())) {
      DigitalSignature ds = new DigitalSignature();
      ds.endorcement = subject.getURI();

      endorsements.putIfAbsent(subject.getURI(), ds);
    }
  }
  @Override
  public void compute(Quad quad) {
    logger.debug("Assessing {}", quad.asTriple().toString());
    Node predicate = quad.getPredicate();
    Node object = quad.getObject();

    // is it an identification of an Agent?
    if (predicate.hasURI(PROV.wasAttributedTo.getURI())) {
      Entity e = this.getOrPutEntity(quad.getSubject().toString());
      e.agent = quad.getObject().toString();
    }

    // is it an activity in an entity?
    if (predicate.hasURI(PROV.wasGeneratedBy.getURI())) {
      Activity a = this.getOrPutActivity(quad.getObject().toString());
      activityDirectory.put(quad.getSubject().toString(), a);
      Entity e = this.getOrPutEntity(quad.getSubject().toString());
      e.activities.add(a);
    }

    // is it an identification of a datasource in an activity?
    if (predicate.hasURI(PROV.used.getURI())) {
      Activity a = this.getOrPutActivity(quad.getSubject().toString());
      a.datasource = quad.getObject().toString();
    }

    // is it an identification of an agent in an activity?
    if (predicate.hasURI(PROV.wasAssociatedWith.getURI())
        || predicate.hasURI(PROV.actedOnBehalfOf.getURI())) {
      Activity a = null;
      a = this.getOrPutActivity(quad.getSubject().toString());
      a.agent = quad.getObject().getURI();
    }

    // is it an entity?
    if (object.hasURI(PROV.Entity.getURI())) {
      this.getOrPutEntity(quad.getSubject().toString());
    }

    // is it an activity?
    if (object.hasURI(PROV.Activity.getURI())) {
      this.getOrPutActivity(quad.getSubject().toString());
    }
  }
  /**
   * Processes each triple obtained from the dataset to be assessed (instance declarations, that is,
   * triples with predicate rdf:type are ignored). Identifies URIs appearing in both, the subject
   * and object of the triple and adds them to the set of URIs to be evaluated for
   * dereferenceability
   *
   * @param quad Triple (in quad format) to be evaluated
   */
  public void compute(Quad quad) {
    logger.debug("Assessing {}", quad.asTriple().toString());

    // we are currently ignoring triples ?s a ?o
    if (!(quad.getPredicate().getURI().equals(RDF.type.getURI()))) {

      String subject = quad.getSubject().toString();
      if (httpRetriever.isPossibleURL(subject)) {
        logger.trace("URI found on subject: {}", subject);
        addUriToDereference(subject);
      }

      String object = quad.getObject().toString();
      if (httpRetriever.isPossibleURL(object)) {
        logger.trace("URI found on object: {}", object);
        addUriToDereference(object);
      }
    }
  }