diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-07-08 15:46:23 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-07-11 18:32:47 +0200 |
commit | 289dff0fdd23e32a3d326ca69a5337368254878d (patch) | |
tree | f7d60c3f0fc0e95392b5c38e809c2c023ee17976 /sonar-db/src/main/java/org/sonar/db/component | |
parent | 3731d21239bc7fb9faa9fd7e3652a64cdadc24ab (diff) | |
download | sonarqube-289dff0fdd23e32a3d326ca69a5337368254878d.tar.gz sonarqube-289dff0fdd23e32a3d326ca69a5337368254878d.zip |
SONAR-7700 use "B columns" strategy for update of PROJECTS
B columns are used to keep changes in a "functional" transaction
but not a DB transaction
Diffstat (limited to 'sonar-db/src/main/java/org/sonar/db/component')
3 files changed, 195 insertions, 3 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java index 6742bec2cc0..af24457c602 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java @@ -345,8 +345,16 @@ public class ComponentDao implements Dao { insert(session, Lists.asList(item, others)); } - public void update(DbSession session, ComponentDto item) { - mapper(session).update(item); + public void update(DbSession session, ComponentUpdateDto component) { + mapper(session).update(component); + } + + public void applyBChangesForRootComponentUuid(DbSession session, String projectUuid) { + mapper(session).applyBChangesForRootComponentUuid(projectUuid); + } + + public void resetBChangedForRootComponentUuid(DbSession session, String projectUuid) { + mapper(session).resetBChangedForRootComponentUuid(projectUuid); } public void delete(DbSession session, long componentId) { diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java index 9f69872a2fa..74d4b1c92b0 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java @@ -141,7 +141,12 @@ public interface ComponentMapper { void insertBatch(ComponentDto componentDto); - void update(ComponentDto componentDto); + void update(ComponentUpdateDto component); + + void applyBChangesForRootComponentUuid(@Param("projectUuid") String projectUuid); + + void resetBChangedForRootComponentUuid(@Param("projectUuid") String projectUuid); void delete(long componentId); + } diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java new file mode 100644 index 00000000000..7f9af5ab723 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java @@ -0,0 +1,179 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program 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. + * + * This program 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. + */ +package org.sonar.db.component; + +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + +public class ComponentUpdateDto { + private String uuid; + + /** + * if true, the component is being updated + * See https://jira.sonarsource.com/browse/SONAR-7700 + */ + private boolean bChanged; + private String bCopyComponentUuid; + private String bDescription; + private boolean bEnabled; + private String bLanguage; + private String bLongName; + private String bModuleUuid; + private String bModuleUuidPath; + private String bName; + private String bPath; + private String bQualifier; + + public ComponentUpdateDto setUuid(String uuid) { + this.uuid = uuid; + return this; + } + + public String getUuid() { + return uuid; + } + + public boolean isBChanged() { + return bChanged; + } + + @CheckForNull + public String getBCopyComponentUuid() { + return bCopyComponentUuid; + } + + @CheckForNull + public String getBDescription() { + return bDescription; + } + + public boolean isBEnabled() { + return bEnabled; + } + + @CheckForNull + public String getBLanguage() { + return bLanguage; + } + + @CheckForNull + public String getBLongName() { + return bLongName; + } + + @CheckForNull + public String getBModuleUuid() { + return bModuleUuid; + } + + @CheckForNull + public String getBModuleUuidPath() { + return bModuleUuidPath; + } + + @CheckForNull + public String getBName() { + return bName; + } + + @CheckForNull + public String getBPath() { + return bPath; + } + + @CheckForNull + public String getBQualifier() { + return bQualifier; + } + + public ComponentUpdateDto setBChanged(boolean b) { + this.bChanged = b; + return this; + } + + public ComponentUpdateDto setBCopyComponentUuid(@Nullable String s) { + this.bCopyComponentUuid = s; + return this; + } + + public ComponentUpdateDto setBEnabled(boolean b) { + this.bEnabled = b; + return this; + } + + public ComponentUpdateDto setBName(@Nullable String s) { + this.bName = s; + return this; + } + + public ComponentUpdateDto setBLongName(@Nullable String s) { + this.bLongName = s; + return this; + } + + public ComponentUpdateDto setBDescription(@Nullable String s) { + this.bDescription = s; + return this; + } + + public ComponentUpdateDto setBModuleUuid(@Nullable String s) { + this.bModuleUuid = s; + return this; + } + + public ComponentUpdateDto setBModuleUuidPath(@Nullable String s) { + this.bModuleUuidPath = s; + return this; + } + + public ComponentUpdateDto setBPath(@Nullable String s) { + this.bPath = s; + return this; + } + + public ComponentUpdateDto setBLanguage(@Nullable String s) { + this.bLanguage = s; + return this; + } + + public ComponentUpdateDto setBQualifier(@Nullable String s) { + this.bQualifier = s; + return this; + } + + /** + * Copy the A-fields to B-fields. The field bChanged is kept to false. + */ + public static ComponentUpdateDto copyFrom(ComponentDto from) { + return new ComponentUpdateDto() + .setUuid(from.uuid()) + .setBChanged(false) + .setBCopyComponentUuid(from.getCopyResourceUuid()) + .setBDescription(from.description()) + .setBEnabled(from.isEnabled()) + .setBLanguage(from.language()) + .setBLongName(from.longName()) + .setBModuleUuid(from.moduleUuid()) + .setBModuleUuidPath(from.moduleUuidPath()) + .setBName(from.name()) + .setBPath(from.path()) + .setBQualifier(from.qualifier()); + } +} |