use of org.sonar.db.issue.IssueChangeMapper 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;
}
use of org.sonar.db.issue.IssueChangeMapper in project sonarqube by SonarSource.
the class IssueStorage method update.
/**
* @return the keys of the updated issues
*/
private Collection<String> update(List<DefaultIssue> issuesToUpdate, long now) {
Collection<String> updated = new ArrayList<>();
if (!issuesToUpdate.isEmpty()) {
try (DbSession dbSession = dbClient.openSession(false)) {
IssueChangeMapper issueChangeMapper = dbSession.getMapper(IssueChangeMapper.class);
for (DefaultIssue issue : issuesToUpdate) {
String key = doUpdate(dbSession, now, issue);
updated.add(key);
insertChanges(issueChangeMapper, issue);
}
dbSession.commit();
}
}
return updated;
}
use of org.sonar.db.issue.IssueChangeMapper in project sonarqube by SonarSource.
the class PersistIssuesStep method execute.
@Override
public void execute() {
try (DbSession dbSession = dbClient.openSession(true);
CloseableIterator<DefaultIssue> issues = issueCache.traverse()) {
IssueMapper mapper = dbSession.getMapper(IssueMapper.class);
IssueChangeMapper changeMapper = dbSession.getMapper(IssueChangeMapper.class);
while (issues.hasNext()) {
DefaultIssue issue = issues.next();
boolean saved = persistIssueIfRequired(mapper, issue);
if (saved) {
insertChanges(changeMapper, issue);
}
}
dbSession.flushStatements();
dbSession.commit();
}
}
Aggregations