Search in sources :

Example 1 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class CloseIssuesOnRemovedComponentsVisitor method closeIssuesForDeletedComponentUuids.

private void closeIssuesForDeletedComponentUuids(Set<String> deletedComponentUuids) {
    DiskCache<DefaultIssue>.DiskAppender<DefaultIssue> cacheAppender = issueCache.newAppender();
    try {
        for (String deletedComponentUuid : deletedComponentUuids) {
            List<DefaultIssue> issues = baseIssuesLoader.loadForComponentUuid(deletedComponentUuid);
            for (DefaultIssue issue : issues) {
                issue.setBeingClosed(true);
                // TODO should be renamed
                issue.setOnDisabledRule(false);
                issueLifecycle.doAutomaticTransition(issue);
                cacheAppender.append(issue);
            }
        }
    } finally {
        cacheAppender.close();
    }
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) DiskCache(org.sonar.server.util.cache.DiskCache)

Example 2 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class IntegrateIssuesVisitor method fillExistingOpenIssues.

private void fillExistingOpenIssues(Component component, Tracking<DefaultIssue, DefaultIssue> tracking, DiskCache<DefaultIssue>.DiskAppender<DefaultIssue> cacheAppender) {
    for (Map.Entry<DefaultIssue, DefaultIssue> entry : tracking.getMatchedRaws().entrySet()) {
        DefaultIssue raw = entry.getKey();
        DefaultIssue base = entry.getValue();
        issueLifecycle.mergeExistingOpenIssue(raw, base);
        process(component, raw, cacheAppender);
    }
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Map(java.util.Map)

Example 3 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class IntegrateIssuesVisitor method closeUnmatchedBaseIssues.

private void closeUnmatchedBaseIssues(Component component, Tracking<DefaultIssue, DefaultIssue> tracking, DiskCache<DefaultIssue>.DiskAppender<DefaultIssue> cacheAppender) {
    for (DefaultIssue issue : tracking.getUnmatchedBases()) {
        // TODO should replace flag "beingClosed" by express call to transition "automaticClose"
        issue.setBeingClosed(true);
        // TODO manual issues -> was updater.setResolution(newIssue, Issue.RESOLUTION_REMOVED, changeContext);. Is it a problem ?
        process(component, issue, cacheAppender);
    }
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue)

Example 4 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class IssueStorage method insert.

/**
   * @return the keys of the inserted issues
   */
private Collection<String> insert(DbSession session, Iterable<DefaultIssue> issuesToInsert, long now) {
    List<String> inserted = newArrayList();
    int count = 0;
    IssueChangeMapper issueChangeMapper = session.getMapper(IssueChangeMapper.class);
    for (DefaultIssue issue : issuesToInsert) {
        String key = doInsert(session, now, issue);
        inserted.add(key);
        insertChanges(issueChangeMapper, issue);
        if (count > BatchSession.MAX_BATCH_SIZE) {
            session.commit();
        }
        count++;
    }
    session.commit();
    return inserted;
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) IssueChangeMapper(org.sonar.db.issue.IssueChangeMapper)

Example 5 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class TransitionAction method execute.

@Override
public boolean execute(Map<String, Object> properties, Context context) {
    DefaultIssue issue = context.issue();
    String transition = transition(properties);
    return canExecuteTransition(issue, transition) && transitionService.doTransition(context.issue(), context.issueChangeContext(), transition(properties));
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue)

Aggregations

DefaultIssue (org.sonar.core.issue.DefaultIssue)140 Test (org.junit.Test)120 Date (java.util.Date)27 ActiveRule (org.sonar.server.computation.task.projectanalysis.qualityprofile.ActiveRule)15 IssueChangeContext (org.sonar.core.issue.IssueChangeContext)14 DefaultIssueComment (org.sonar.core.issue.DefaultIssueComment)8 IssueDto (org.sonar.db.issue.IssueDto)8 DbSession (org.sonar.db.DbSession)6 ComponentDto (org.sonar.db.component.ComponentDto)5 Issue (org.sonar.api.issue.Issue)4 FieldDiffs (org.sonar.core.issue.FieldDiffs)4 ArrayList (java.util.ArrayList)3 RuleKey (org.sonar.api.rule.RuleKey)3 User (org.sonar.api.user.User)3 IssueChangeMapper (org.sonar.db.issue.IssueChangeMapper)3 IssueMapper (org.sonar.db.issue.IssueMapper)3 RuleDto (org.sonar.db.rule.RuleDto)3 IssueChangeNotification (org.sonar.server.issue.notification.IssueChangeNotification)3 DefaultUser (org.sonar.core.user.DefaultUser)2 RuleTesting.newRuleDto (org.sonar.db.rule.RuleTesting.newRuleDto)2