From: Simon Brandhof Date: Sat, 24 Nov 2012 23:00:50 +0000 (+0100) Subject: SONAR-3825 fix loading of qualifiers in the form X-Git-Tag: 3.4~277 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a38602149510e58a7f2421faa02327feb8236396;p=sonarqube.git SONAR-3825 fix loading of qualifiers in the form --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java index e2b9328d31f..bc3125b2d07 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java @@ -38,15 +38,28 @@ public final class DefaultResourceTypes extends ExtensionProvider implements Bat .setProperty("modifiable_history", true) .setProperty("hasRolePolicy", true) .setProperty("updatable_key", true) + .setProperty("supports_measure_filters", true) .build()) .addType(ResourceType.builder(Qualifiers.MODULE) .setProperty("updatable_key", true) + .setProperty("supports_measure_filters", true) .build()) - .addType(ResourceType.builder(Qualifiers.DIRECTORY).build()) - .addType(ResourceType.builder(Qualifiers.PACKAGE).build()) - .addType(ResourceType.builder(Qualifiers.FILE).hasSourceCode().build()) - .addType(ResourceType.builder(Qualifiers.CLASS).hasSourceCode().build()) - .addType(ResourceType.builder(Qualifiers.UNIT_TEST_FILE).hasSourceCode().build()) + .addType(ResourceType.builder(Qualifiers.DIRECTORY) + .setProperty("supports_measure_filters", true) + .build()) + .addType(ResourceType.builder(Qualifiers.PACKAGE) + .build()) + .addType(ResourceType.builder(Qualifiers.FILE) + .hasSourceCode() + .setProperty("supports_measure_filters", true) + .build()) + .addType(ResourceType.builder(Qualifiers.CLASS) + .hasSourceCode() + .build()) + .addType(ResourceType.builder(Qualifiers.UNIT_TEST_FILE) + .hasSourceCode() + .setProperty("supports_measure_filters", true) + .build()) .addRelations(Qualifiers.PROJECT, Qualifiers.MODULE) .addRelations(Qualifiers.MODULE, Qualifiers.DIRECTORY, Qualifiers.PACKAGE) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index 0a352ace85a..a0a87406463 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -381,6 +381,17 @@ session.flash_notice.logged_out=You have been logged out. # MEASURE FILTERS # #------------------------------------------------------------------------------ +measure_filter.col.date=Date +measure_filter.col.description=Description +measure_filter.col.key=Key +measure_filter.col.language=Language +measure_filter.col.links=Links +measure_filter.col.name=Name +measure_filter.col.short_name=Name +measure_filter.col.version=Version +measure_filter.missing_name=Name is missing +measure_filter.name_too_long=Name is too long + #------------------------------------------------------------------------------ # diff --git a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilter.java b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilter.java index 5c4d247a6d6..41f987dd579 100644 --- a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilter.java +++ b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilter.java @@ -23,8 +23,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.Lists; import org.apache.commons.lang.builder.ReflectionToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; import org.sonar.api.measures.Metric; +import org.sonar.api.resources.Qualifiers; import javax.annotation.Nullable; @@ -76,6 +76,12 @@ public class MeasureFilter { public MeasureFilter setResourceQualifiers(@Nullable List list) { this.resourceQualifiers = sanitize(list); + if (resourceQualifiers.contains(Qualifiers.FILE)) { + resourceQualifiers.add(Qualifiers.CLASS); + } + if (resourceQualifiers.contains(Qualifiers.DIRECTORY)) { + resourceQualifiers.add(Qualifiers.PACKAGE); + } return this; } diff --git a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterExecutor.java b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterExecutor.java index 6b1bf54b3b8..0de8fad5f27 100644 --- a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterExecutor.java +++ b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterExecutor.java @@ -19,6 +19,7 @@ */ package org.sonar.core.measure; +import com.google.common.base.Strings; import org.apache.ibatis.session.SqlSession; import org.sonar.api.ServerComponent; import org.sonar.core.persistence.Database; @@ -75,7 +76,8 @@ public class MeasureFilterExecutor implements ServerComponent { } static boolean isValid(MeasureFilter filter, MeasureFilterContext context) { - boolean valid = !(filter.isOnBaseResourceChildren() && context.getBaseSnapshot() == null); + boolean valid = (Strings.isNullOrEmpty(filter.getBaseResourceKey()) || context.getBaseSnapshot()!=null); + valid &= !(filter.isOnBaseResourceChildren() && context.getBaseSnapshot() == null); valid &= !(filter.isOnFavourites() && context.getUserId() == null); valid &= validateMeasureConditions(filter); valid &= validateSort(filter); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java index fc0d8b0041e..bab797e764b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java @@ -40,7 +40,7 @@ import java.util.Map; *

*