/** {@inheritDoc} */
  @Override
  public void buildDependencyGraph(AbstractProject owner, DependencyGraph graph) {
    for (AbstractProject downstream : getChildProjects()) {
      graph.addDependency(new DownstreamDependency(owner, downstream, this));
    }

    // workaround for problems with Matrixprojects
    // see http://issues.hudson-ci.org/browse/HUDSON-5508
    if (!triggerOnlyOnceWhenMatrixEnds) {
      if (owner instanceof MatrixProject) {
        MatrixProject proj = (MatrixProject) owner;
        Collection<MatrixConfiguration> activeConfigurations = proj.getActiveConfigurations();
        for (MatrixConfiguration conf : activeConfigurations) {
          for (AbstractProject downstream : getChildProjects()) {
            graph.addDependency(new DownstreamDependency(conf, downstream, this));
          }
        }
      }
    }
  }