aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-23 15:02:01 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-23 15:09:58 +0200
commitb12c34fb864be99dde7c18190bda01e2c41c58d7 (patch)
tree74df4dd6b767bb0d5b258a8641dc8023f1497b40
parent6a4f6808d2afe98483a5b6b3a1f84c3c62f0860d (diff)
downloadsonarqube-b12c34fb864be99dde7c18190bda01e2c41c58d7.tar.gz
sonarqube-b12c34fb864be99dde7c18190bda01e2c41c58d7.zip
Fix quality flaw
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java47
1 files changed, 25 insertions, 22 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java
index eda2906dfcb..91d5ef962fb 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java
@@ -92,33 +92,36 @@ public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration {
}
for (Component component : components) {
- String snapshotPath = component.getSnapshotPath();
- StringBuilder moduleUuidPath = new StringBuilder();
- Component lastModule = null;
- if (!Strings.isNullOrEmpty(snapshotPath)) {
- for (String s : Splitter.on(".").omitEmptyStrings().split(snapshotPath)) {
- Long snapshotId = Long.valueOf(s);
- Component currentComponent = componentsBySnapshotId.get(snapshotId);
- if (currentComponent.getScope().equals(Scopes.PROJECT)) {
- lastModule = currentComponent;
- moduleUuidPath.append(currentComponent.getUuid()).append(".");
- }
- }
- }
- if (moduleUuidPath.length() > 0) {
- component.setModuleUuidPath(moduleUuidPath.toString());
- }
-
- // Module UUID should contains direct module of a component, but it should be null on the first module
- if (lastModule != null && !lastModule.getId().equals(project.getId())) {
- component.setModuleUuid(getOrCreateUuid(lastModule.getId(), uuidByComponentId));
- }
-
+ updateComponent(component, project, componentsBySnapshotId, uuidByComponentId);
mapper.updateComponentUuids(component);
counter.getAndIncrement();
}
}
+ private void updateComponent(Component component, Component project, Map<Long, Component> componentsBySnapshotId, Map<Long, String> uuidByComponentId){
+ String snapshotPath = component.getSnapshotPath();
+ StringBuilder moduleUuidPath = new StringBuilder();
+ Component lastModule = null;
+ if (!Strings.isNullOrEmpty(snapshotPath)) {
+ for (String s : Splitter.on(".").omitEmptyStrings().split(snapshotPath)) {
+ Long snapshotId = Long.valueOf(s);
+ Component currentComponent = componentsBySnapshotId.get(snapshotId);
+ if (currentComponent.getScope().equals(Scopes.PROJECT)) {
+ lastModule = currentComponent;
+ moduleUuidPath.append(currentComponent.getUuid()).append(".");
+ }
+ }
+ }
+ if (moduleUuidPath.length() > 0) {
+ component.setModuleUuidPath(moduleUuidPath.toString());
+ }
+
+ // Module UUID should contains direct module of a component, but it should be null on the first module
+ if (lastModule != null && !lastModule.getId().equals(project.getId())) {
+ component.setModuleUuid(getOrCreateUuid(lastModule.getId(), uuidByComponentId));
+ }
+ }
+
private void migrateDisabledComponents(DbSession session, Migration50Mapper mapper, Component project, Map<Long, String> uuidByComponentId) {
for (Component component : mapper.selectDisabledComponentChildrenForProjects(project.getId())) {
component.setUuid(getOrCreateUuid(component.getId(), uuidByComponentId));