diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-12-06 11:15:43 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-12-06 11:15:43 +0000 |
commit | 7f27dc28f2512e81a0fe7e39c89c1f1ad13bbe44 (patch) | |
tree | 6daf91257ae0bce288a96872a9159dc67e67c070 | |
parent | 586297ec105a3b1a5c35d7e0ac52dd8861490955 (diff) | |
download | sonarqube-7f27dc28f2512e81a0fe7e39c89c1f1ad13bbe44.tar.gz sonarqube-7f27dc28f2512e81a0fe7e39c89c1f1ad13bbe44.zip |
* check excluded resources in DefaultIndex#getChildren()
* check exclusion of resources when adding new dependency between resources
* remove the unused method PersistenceManager#saveViolation()
5 files changed, 24 insertions, 21 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java index a0191b39669..cf166a09eb6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java @@ -196,11 +196,16 @@ public final class DefaultIndex extends SonarIndex { } public List<Resource> getChildren(Resource resource) { + return getChildren(resource, false); + } + + public List<Resource> getChildren(Resource resource, boolean includeExcludedResources) { List<Resource> children = Lists.newArrayList(); Bucket bucket = buckets.get(resource); if (bucket != null) { for (Bucket childBucket : bucket.getChildren()) { - children.add(childBucket.getResource()); + if (includeExcludedResources || !childBucket.isExcluded()) + children.add(childBucket.getResource()); } } return children; @@ -279,15 +284,23 @@ public final class DefaultIndex extends SonarIndex { addDependency(parentDependency); } - persistence.saveDependency(currentProject, dependency, parentDependency); - registerDependency(dependency); + if (registerDependency(dependency)) { + persistence.saveDependency(currentProject, dependency, parentDependency); + } return dependency; } - protected void registerDependency(Dependency dependency) { - dependencies.add(dependency); - registerOutgoingDependency(dependency); - registerIncomingDependency(dependency); + boolean registerDependency(Dependency dependency) { + Bucket fromBucket = getOrAddBucket(dependency.getFrom()); + Bucket toBucket = getOrAddBucket(dependency.getTo()); + + if (fromBucket != null && !fromBucket.isExcluded() && toBucket != null && !toBucket.isExcluded()) { + dependencies.add(dependency); + registerOutgoingDependency(dependency); + registerIncomingDependency(dependency); + return true; + } + return false; } private void registerOutgoingDependency(Dependency dependency) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultPersistenceManager.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultPersistenceManager.java index f03147a4ede..ee553ab4868 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultPersistenceManager.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultPersistenceManager.java @@ -86,10 +86,6 @@ public final class DefaultPersistenceManager implements PersistenceManager { dependencyPersister.saveDependency(project, dependency, parentDependency); } - public void saveViolation(Project project, Violation violation) { - violationPersister.saveViolation(project, violation); - } - public void saveLink(Project project, ProjectLink link) { linkPersister.saveLink(project, link); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DependencyPersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/DependencyPersister.java index 5f7648436b4..3b75b3cca1f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DependencyPersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DependencyPersister.java @@ -36,9 +36,9 @@ public final class DependencyPersister { } public void saveDependency(Project project, Dependency dependency, Dependency parentDependency) { - Snapshot fromSnapshot = resourcePersister.saveResource(project, dependency.getFrom()); - Snapshot toSnapshot = resourcePersister.saveResource(project, dependency.getTo()); - Snapshot projectSnapshot = resourcePersister.saveProject(project); + Snapshot fromSnapshot = resourcePersister.getSnapshot(dependency.getFrom()); + Snapshot toSnapshot = resourcePersister.getSnapshot(dependency.getTo()); + Snapshot projectSnapshot = resourcePersister.getSnapshot(project); DependencyDto model = new DependencyDto(); model.setProjectSnapshotId(projectSnapshot.getId()); diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/PersistenceManager.java b/sonar-batch/src/main/java/org/sonar/batch/index/PersistenceManager.java index f53248feff2..f9aebeb5e75 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/PersistenceManager.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/PersistenceManager.java @@ -26,7 +26,6 @@ import org.sonar.api.measures.Measure; import org.sonar.api.resources.Project; import org.sonar.api.resources.ProjectLink; import org.sonar.api.resources.Resource; -import org.sonar.api.rules.Violation; import java.util.List; @@ -47,8 +46,6 @@ public interface PersistenceManager { void saveDependency(Project project, Dependency dependency, Dependency parentDependency); - void saveViolation(Project project, Violation violation); - void saveLink(Project project, ProjectLink link); void deleteLink(Project project, String key); diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ViolationPersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/ViolationPersister.java index 26452f8c148..48c410cc4a6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/ViolationPersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/ViolationPersister.java @@ -39,10 +39,7 @@ public final class ViolationPersister { this.ruleFinder = ruleFinder; } - /** - * @deprecated Use {@link #saveOrUpdateViolation(Project, Violation, RuleFailureModel)} instead. - */ - public void saveViolation(Project project, Violation violation) { + void saveViolation(Project project, Violation violation) { saveOrUpdateViolation(project, violation, null, null); } |