Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Merge pull request #9 from AmericanAirlines/clear-widget-of-deleted-p…
Browse files Browse the repository at this point in the history
…roject

drop sonar project form widget if project deleted
  • Loading branch information
rvema authored Dec 9, 2019
2 parents 10cce08 + 5a08404 commit 846d597
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -186,7 +187,28 @@ private void deleteUnwantedJobs(List<SonarProject> latestProjects, List<SonarPro
if (!collector.getSonarServers().contains(job.getInstanceUrl()) ||
(!job.getCollectorId().equals(collector.getId())) ||
(!latestProjects.contains(job))) {
deleteJobList.add(job);
if(!job.isEnabled()) {
LOG.debug("drop deleted sonar project which is disabled "+job.getProjectName());
deleteJobList.add(job);
} else {
LOG.debug("drop deleted sonar project which is enabled "+job.getProjectName());
// CollectorItem should be removed from components and dashboards first
// then the CollectorItem (sonar proj in this case) can be deleted

List<com.capitalone.dashboard.model.Component> comps = dbComponentRepository
.findByCollectorTypeAndItemIdIn(CollectorType.CodeQuality, Arrays.asList(job.getId()));

for (com.capitalone.dashboard.model.Component c: comps) {
c.getCollectorItems().remove(CollectorType.CodeQuality);
}
dbComponentRepository.save(comps);

// other collectors also delete the widget but not here
// should not remove the code analysis widget
// because it is shared by other collectors

deleteJobList.add(job);
}
}
}
if (!CollectionUtils.isEmpty(deleteJobList)) {
Expand Down

0 comments on commit 846d597

Please sign in to comment.