Example #1
0
  @Override
  public Dependency addDependency(Dependency dependency) {
    Dependency existingDep = getEdge(dependency.getFrom(), dependency.getTo());
    if (existingDep != null) {
      return existingDep;
    }

    Dependency parentDependency = dependency.getParent();
    if (parentDependency != null) {
      addDependency(parentDependency);
    }

    if (registerDependency(dependency)) {
      persistence.saveDependency(currentProject, dependency, parentDependency);
    }
    return dependency;
  }
Example #2
0
  @Override
  public Dependency addDependency(Dependency dependency) {
    // Reload resources
    Resource from = getResource(dependency.getFrom());
    Preconditions.checkArgument(from != null, dependency.getFrom() + " is not indexed");
    dependency.setFrom(from);
    Resource to = getResource(dependency.getTo());
    Preconditions.checkArgument(to != null, dependency.getTo() + " is not indexed");
    dependency.setTo(to);

    Dependency existingDep = getEdge(from, to);
    if (existingDep != null) {
      return existingDep;
    }

    Dependency parentDependency = dependency.getParent();
    if (parentDependency != null) {
      addDependency(parentDependency);
    }
    registerDependency(dependency);
    return dependency;
  }