@@ -48,7 +48,7 @@ import java.util.Set; | |||
public class DefaultDecoratorContext implements DecoratorContext { | |||
private static final String SAVE_MEASURE_METHOD = "saveMeasure"; | |||
private SonarIndex index; | |||
private SonarIndex sonarIndex; | |||
private Resource resource; | |||
private MeasurementFilters measurementFilters; | |||
private boolean readOnly = false; | |||
@@ -63,7 +63,7 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
SonarIndex index, | |||
List<DecoratorContext> childrenContexts, | |||
MeasurementFilters measurementFilters, MeasureCache measureCache, MetricFinder metricFinder) { | |||
this.index = index; | |||
this.sonarIndex = index; | |||
this.resource = resource; | |||
this.childrenContexts = childrenContexts; | |||
this.measurementFilters = measurementFilters; | |||
@@ -88,7 +88,7 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
} | |||
public Project getProject() { | |||
return index.getProject(); | |||
return sonarIndex.getProject(); | |||
} | |||
public List<DecoratorContext> getChildren() { | |||
@@ -181,50 +181,50 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
* {@inheritDoc} | |||
*/ | |||
public List<Violation> getViolations(ViolationQuery violationQuery) { | |||
return index.getViolations(violationQuery); | |||
return sonarIndex.getViolations(violationQuery); | |||
} | |||
/** | |||
* {@inheritDoc} | |||
*/ | |||
public List<Violation> getViolations() { | |||
return index.getViolations(resource); | |||
return sonarIndex.getViolations(resource); | |||
} | |||
public Dependency saveDependency(Dependency dependency) { | |||
checkReadOnly("addDependency"); | |||
return index.addDependency(dependency); | |||
return sonarIndex.addDependency(dependency); | |||
} | |||
public Set<Dependency> getDependencies() { | |||
return index.getDependencies(); | |||
return sonarIndex.getDependencies(); | |||
} | |||
public Collection<Dependency> getIncomingDependencies() { | |||
return index.getIncomingEdges(resource); | |||
return sonarIndex.getIncomingEdges(resource); | |||
} | |||
public Collection<Dependency> getOutgoingDependencies() { | |||
return index.getOutgoingEdges(resource); | |||
return sonarIndex.getOutgoingEdges(resource); | |||
} | |||
public List<Event> getEvents() { | |||
return index.getEvents(resource); | |||
return sonarIndex.getEvents(resource); | |||
} | |||
public Event createEvent(String name, String description, String category, Date date) { | |||
return index.addEvent(resource, name, description, category, date); | |||
return sonarIndex.addEvent(resource, name, description, category, date); | |||
} | |||
public void deleteEvent(Event event) { | |||
index.deleteEvent(event); | |||
sonarIndex.deleteEvent(event); | |||
} | |||
public DefaultDecoratorContext saveViolation(Violation violation, boolean force) { | |||
if (violation.getResource() == null) { | |||
violation.setResource(resource); | |||
} | |||
index.addViolation(violation, force); | |||
sonarIndex.addViolation(violation, force); | |||
return this; | |||
} | |||
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.batch.events; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -183,11 +183,10 @@ public class ResourceKeyMigration implements BatchComponent { | |||
} | |||
private List<ResourceModel> loadEnabledResources(int moduleId, StringBuilder hql) { | |||
List<ResourceModel> resources = session.createQuery(hql.toString()) | |||
return session.createQuery(hql.toString()) | |||
.setParameter("rootId", moduleId) | |||
.setParameter("enabled", true) | |||
.getResultList(); | |||
return resources; | |||
} | |||
private Map<String, ResourceModel> loadDisabledResources(int moduleId, StringBuilder hql) { |
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.batch.index; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.batch.language; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -17,4 +17,5 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@javax.annotation.ParametersAreNonnullByDefault | |||
package org.sonar.batch.languages; |
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.batch; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.batch.phases; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -40,7 +40,7 @@ public class QProfileDecorator implements Decorator { | |||
} | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return project.getModules().size() > 0; | |||
return !project.getModules().isEmpty(); | |||
} | |||
@Override |
@@ -0,0 +1,23 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.batch.scan.maven; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -85,14 +85,8 @@ public class MeasureDataMigration implements DatabaseMigration { | |||
@Override | |||
public boolean update(Connection connection) throws SQLException { | |||
if (ids.size() > 0) { | |||
String deleteSql = new StringBuilder().append("DELETE FROM measure_data WHERE id IN (") | |||
.append(StringUtils.repeat("?", ",", ids.size())).append(")").toString(); | |||
PreparedStatement s = connection.prepareStatement(deleteSql); | |||
int i = 1; | |||
for (Long id : ids) { | |||
s.setLong(i++, id); | |||
} | |||
if (!ids.isEmpty()) { | |||
PreparedStatement s = prepareDeleteQuery(ids, connection); | |||
s.executeUpdate(); | |||
s.close(); | |||
ids.clear(); | |||
@@ -100,9 +94,21 @@ public class MeasureDataMigration implements DatabaseMigration { | |||
} | |||
return false; | |||
} | |||
}); | |||
} | |||
} | |||
); | |||
private PreparedStatement prepareDeleteQuery(final List<Long> ids, Connection connection) throws SQLException { | |||
String deleteSql = new StringBuilder() | |||
.append("DELETE FROM measure_data WHERE id IN (") | |||
.append(StringUtils.repeat("?", ",", ids.size())) | |||
.append(")").toString(); | |||
PreparedStatement s = connection.prepareStatement(deleteSql); | |||
int i = 1; | |||
for (Long id : ids) { | |||
s.setLong(i, id); | |||
i++; | |||
} | |||
return s; | |||
} | |||
private static class Row { |