import org.sonar.api.web.RubyRailsPage;
import org.sonar.api.web.UserRole;
-@RequiredMeasures(mandatory = {CoreMetrics.LCOM4_KEY})
+@RequiredMeasures(allOf = {CoreMetrics.LCOM4_KEY})
@NavigationSection(NavigationSection.RESOURCE_TAB)
@UserRole(UserRole.CODEVIEWER)
@ResourceQualifier(Qualifiers.CLASS)
package org.sonar.plugins.design.ui.dependencies;
import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Resource;
import org.sonar.api.web.DefaultTab;
import org.sonar.api.web.GwtPage;
import org.sonar.api.web.UserRole;
import org.sonar.plugins.design.ui.dependencies.client.DependenciesTab;
-@RequiredMeasures(mandatory = {CoreMetrics.AFFERENT_COUPLINGS_KEY, CoreMetrics.EFFERENT_COUPLINGS_KEY})
-@ResourceQualifier({Resource.QUALIFIER_FILE, Resource.QUALIFIER_CLASS, Resource.QUALIFIER_PACKAGE, Resource.QUALIFIER_PROJECT, Resource.QUALIFIER_MODULE})
+@RequiredMeasures(allOf = {CoreMetrics.AFFERENT_COUPLINGS_KEY, CoreMetrics.EFFERENT_COUPLINGS_KEY})
+@ResourceQualifier({Qualifiers.FILE, Qualifiers.CLASS, Qualifiers.PACKAGE, Qualifiers.PROJECT, Qualifiers.MODULE})
@DefaultTab(metrics = {CoreMetrics.AFFERENT_COUPLINGS_KEY, CoreMetrics.EFFERENT_COUPLINGS_KEY})
@NavigationSection({NavigationSection.RESOURCE_TAB})
@UserRole(UserRole.USER)
*/
package org.sonar.plugins.design.ui.libraries;
+import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Resource;
import org.sonar.api.web.GwtPage;
import org.sonar.api.web.NavigationSection;
import org.sonar.api.web.UserRole;
import org.sonar.plugins.design.ui.libraries.client.LibrariesPage;
-@ResourceQualifier({Resource.QUALIFIER_PROJECT, Resource.QUALIFIER_MODULE})
+@ResourceQualifier({Qualifiers.PROJECT, Qualifiers.MODULE})
@NavigationSection(NavigationSection.RESOURCE)
@UserRole(UserRole.USER)
public class GwtLibrariesPage extends GwtPage {
import org.sonar.api.web.UserRole;
import org.sonar.plugins.design.ui.page.client.DesignPage;
-@RequiredMeasures(mandatory = {CoreMetrics.DEPENDENCY_MATRIX_KEY})
+@RequiredMeasures(allOf = {CoreMetrics.DEPENDENCY_MATRIX_KEY})
@ResourceQualifier({Qualifiers.PROJECT, Qualifiers.MODULE, Qualifiers.PACKAGE, Qualifiers.DIRECTORY})
@DefaultTab(metrics = {
CoreMetrics.DEPENDENCY_MATRIX_KEY, CoreMetrics.PACKAGE_FEEDBACK_EDGES_KEY, CoreMetrics.PACKAGE_CYCLES_KEY,
* </p>
* <p>
* Example: the DesignPage absolutely requires the "dsm" measure to be fed in order to be displayed, whatever the language.
- * The class will define a <code>@RequiredMeasures(mandatory={"dsm"})</code> annotation.
+ * The class will define a <code>@RequiredMeasures(allOf={"dsm"})</code> annotation.
* </p>
*
* @since 2.15
* Lists all the measures that must absolutely to be available on the snapshot in order to display the view.
* @return the list of mandatory measures, identified by their metric key
*/
- String[] mandatory() default {};
+ String[] allOf() default {};
/**
* Lists all needed measures required to display the view. If only one of them is available on the snapshot, then the view
* is displayed.
* @return the list of needed measures, identified by their metric key
*/
- String[] oneOf() default {};
+ String[] anyOf() default {};
}
private void initRequiredMeasures(V view) {
RequiredMeasures requiredMeasuresAnnotation = AnnotationUtils.getClassAnnotation(view, RequiredMeasures.class);
if (requiredMeasuresAnnotation != null) {
- mandatoryMeasures = requiredMeasuresAnnotation.mandatory();
- needOneOfMeasures = requiredMeasuresAnnotation.oneOf();
+ mandatoryMeasures = requiredMeasuresAnnotation.allOf();
+ needOneOfMeasures = requiredMeasuresAnnotation.anyOf();
}
}
*/
package org.sonar.server.ui;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import org.apache.commons.lang.ArrayUtils;
import org.sonar.api.ServerComponent;
import org.sonar.api.web.Page;
import org.sonar.api.web.View;
import org.sonar.api.web.Widget;
-import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
public class Views implements ServerComponent {
- private Map<String, ViewProxy<Page>> pagesPerId = new HashMap<String, ViewProxy<Page>>();
- private Set<ViewProxy<Page>> pages = new TreeSet<ViewProxy<Page>>();
+ private Map<String, ViewProxy<Page>> pagesPerId = Maps.newHashMap();
+ private Set<ViewProxy<Page>> pages = Sets.newTreeSet();
- private Map<String, ViewProxy<Widget>> widgetsPerId = new HashMap<String, ViewProxy<Widget>>();
- private Set<ViewProxy<Widget>> widgets = new TreeSet<ViewProxy<Widget>>();
+ private Map<String, ViewProxy<Widget>> widgetsPerId = Maps.newHashMap();
+ private Set<ViewProxy<Widget>> widgets = Sets.newTreeSet();
public Views() {
}
}
public List<ViewProxy<Page>> getPagesForMetric(String section, String resourceScope, String resourceQualifier, String resourceLanguage,
- String[] availableMeasures, String metric) {
+ String[] availableMeasures, String metric) {
List<ViewProxy<Page>> result = Lists.newArrayList();
for (ViewProxy<Page> proxy : pages) {
if (accept(proxy, section, resourceScope, resourceQualifier, resourceLanguage, availableMeasures) && proxy.supportsMetric(metric)) {
protected static boolean accept(ViewProxy proxy, String section, String resourceScope, String resourceQualifier, String resourceLanguage, String[] availableMeasures) {
return acceptNavigationSection(proxy, section)
- && acceptResourceScope(proxy, resourceScope)
- && acceptResourceQualifier(proxy, resourceQualifier)
- && acceptResourceLanguage(proxy, resourceLanguage)
- && acceptAvailableMeasures(proxy, availableMeasures);
+ && acceptResourceScope(proxy, resourceScope)
+ && acceptResourceQualifier(proxy, resourceQualifier)
+ && acceptResourceLanguage(proxy, resourceLanguage)
+ && acceptAvailableMeasures(proxy, availableMeasures);
}
protected static boolean acceptResourceLanguage(ViewProxy proxy, String resourceLanguage) {
- return resourceLanguage== null || ArrayUtils.isEmpty(proxy.getResourceLanguages()) || ArrayUtils.contains(proxy.getResourceLanguages(), resourceLanguage);
+ return resourceLanguage == null || ArrayUtils.isEmpty(proxy.getResourceLanguages()) || ArrayUtils.contains(proxy.getResourceLanguages(), resourceLanguage);
}
protected static boolean acceptResourceScope(ViewProxy proxy, String resourceScope) {
- return resourceScope== null || ArrayUtils.isEmpty(proxy.getResourceScopes()) || ArrayUtils.contains(proxy.getResourceScopes(), resourceScope);
+ return resourceScope == null || ArrayUtils.isEmpty(proxy.getResourceScopes()) || ArrayUtils.contains(proxy.getResourceScopes(), resourceScope);
}
protected static boolean acceptResourceQualifier(ViewProxy proxy, String resourceQualifier) {
- return resourceQualifier== null || ArrayUtils.isEmpty(proxy.getResourceQualifiers()) || ArrayUtils.contains(proxy.getResourceQualifiers(), resourceQualifier);
+ return resourceQualifier == null || ArrayUtils.isEmpty(proxy.getResourceQualifiers()) || ArrayUtils.contains(proxy.getResourceQualifiers(), resourceQualifier);
}
protected static boolean acceptNavigationSection(ViewProxy proxy, String section) {
@Test
public void shouldAcceptAvailableMeasuresForMandatoryMeasures() throws Exception {
- @RequiredMeasures(mandatory = {"lines", "ncloc"})
+ @RequiredMeasures(allOf = {"lines", "ncloc"})
class MyView extends FakeView {
MyView() {
super("fake");
@Test
public void shouldAcceptAvailableMeasuresForOneOfNeededMeasures() throws Exception {
- @RequiredMeasures(oneOf = {"lines", "ncloc"})
+ @RequiredMeasures(anyOf = {"lines", "ncloc"})
class MyView extends FakeView {
MyView() {
super("fake");
@Test
public void shouldAcceptAvailableMeasuresForMandatoryAndOneOfNeededMeasures() throws Exception {
- @RequiredMeasures(mandatory = {"lines", "ncloc"}, oneOf = {"duplications", "duplictated_blocks"})
+ @RequiredMeasures(allOf = {"lines", "ncloc"}, anyOf = {"duplications", "duplictated_blocks"})
class MyView extends FakeView {
MyView() {
super("fake");