private Set<Metric> getAllPredictedMetrics() {

    Set<Relationship> relationships =
        inventory.relationships().named(Configuration.PREDICTION_RELATIONSHIP).entities();

    Set<CanonicalPath> metricsCp = new HashSet<>();
    Set<CanonicalPath> metricTypesCp = new HashSet<>();
    Set<CanonicalPath> tenantsCp = new HashSet<>();

    for (Relationship relationship : relationships) {

      predictionRelationships.relationships().put(relationship.getTarget(), relationship);

      if (relationship.getTarget().getSegment().getElementType().equals(Metric.class)) {
        metricsCp.add(relationship.getTarget());
      } else if (relationship.getTarget().getSegment().getElementType().equals(MetricType.class)) {
        metricTypesCp.add(relationship.getTarget());
      } else if (relationship.getTarget().getSegment().getElementType().equals(Tenant.class)) {
        tenantsCp.add(relationship.getTarget());
      }
    }

    Set<Metric> metrics =
        inventory
            .tenants()
            .getAll()
            .feeds()
            .getAll()
            .metrics()
            .getAll(With.paths(metricsCp.toArray(new CanonicalPath[0])))
            .entities();
    Set<Metric> metricsUnderTypes =
        inventory
            .tenants()
            .getAll()
            .feeds()
            .getAll()
            .metricTypes()
            .getAll(With.paths(metricTypesCp.toArray(new CanonicalPath[0])))
            .metrics()
            .getAll()
            .entities();
    Set<Metric> metricsUnderTenant =
        inventory
            .tenants()
            .getAll(With.paths(tenantsCp.toArray(new CanonicalPath[0])))
            .feeds()
            .getAll()
            .metrics()
            .getAll()
            .entities();

    metrics.addAll(metricsUnderTypes);
    metrics.addAll(metricsUnderTenant);

    return metrics;
  }
 @Override
 public void removePredictionRelationship(Relationship relationship) {
   predictionRelationships.relationships().remove(relationship.getTarget());
 }
 @Override
 public void addPredictionRelationship(Relationship relationship) {
   predictionRelationships.relationships().put(relationship.getTarget(), relationship);
 }