@Override
  public void calculateMetricValue(Entity entity) {

    SortedSet<Version> versions = entity.getVersions();

    Version previousVersion = null;
    Double firstVersionMetricValue = null;

    if (!versions.isEmpty()) {
      previousVersion = versions.first();
      firstVersionMetricValue = entity.getMetricValue(versions.first(), conventionalMetric);
    }

    onNewEntity(entity);

    for (Version version : versions) {
      Double previousMetricValue = entity.getMetricValue(previousVersion, conventionalMetric);
      Double currentMetricValue = entity.getMetricValue(version, conventionalMetric);

      Double value =
          calculateMetricValueForOneVersion(
              firstVersionMetricValue, previousMetricValue, currentMetricValue);

      entity.addMetricValue(version, this, value);

      previousVersion = version;
    }
  }
Ejemplo n.º 2
0
  private Bindings createBindings(Entity entity, Version version) {

    Bindings bindings = engine.createBindings();

    Set<Metric> metrics = entity.getMetrics();
    for (Metric metric : metrics) {
      Double metricValue = entity.getMetricValue(version, metric);
      bindings.put(metric.getNickname(), metricValue);
    }

    return bindings;
  }