* @since 3.1
*/
abstract class AbstractFilterDashboard extends DashboardTemplate {
- protected abstract String getFilterKey();
-
@Override
public final Dashboard createDashboard() {
Dashboard dashboard = Dashboard.create()
}
/**
- * Override this method to complete dashboard
+ * The key of the filter to display.
+ */
+ protected abstract String getFilterKey();
+
+ /**
+ * Override this method to complete dashboard.
*/
protected void doCompleteDashboard(Dashboard dashboard) {
}
@Override
protected String getFilterKey() {
- return new ProjectFilter().getName();
+ return ProjectFilter.NAME;
}
}
\ No newline at end of file
* @since 2.14
*/
public final class ReviewsDashboard extends DashboardTemplate {
-
@Override
public String getName() {
return "Reviews";
@Override
protected String getFilterKey() {
- return new TreeMapFilter().getName();
+ return TreeMapFilter.NAME;
}
}
\ No newline at end of file
@Override
public Filter createFilter() {
- Filter filter = Filter.create();
- filter.setDisplayAs(Filter.LIST);
- filter.setFavouritesOnly(true);
- filter.add(Criterion.createForQualifier("VW", "SVW", "TRK", "BRC", "DIR", "PAC", "FIL", "CLA", "UTS"));
- filter.add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false));
- filter.add(FilterColumn.create("name", null, FilterColumn.ASC, false));
- filter.add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false));
- filter.add(FilterColumn.create("metric", CoreMetrics.VIOLATIONS_DENSITY_KEY, FilterColumn.DESC, false));
- filter.add(FilterColumn.create("date", null, FilterColumn.DESC, false));
- return filter;
+ return Filter.create()
+ .setDisplayAs(Filter.LIST)
+ .setFavouritesOnly(true)
+ .add(Criterion.createForQualifier("VW", "SVW", "TRK", "BRC", "DIR", "PAC", "FIL", "CLA", "UTS"))
+ .add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false))
+ .add(FilterColumn.create("name", null, FilterColumn.ASC, false))
+ .add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false))
+ .add(FilterColumn.create("metric", CoreMetrics.VIOLATIONS_DENSITY_KEY, FilterColumn.DESC, false))
+ .add(FilterColumn.create("date", null, FilterColumn.DESC, false));
}
}
* @since 3.1
*/
public class ProjectFilter extends FilterTemplate {
+ public static final String NAME = "Projects";
+
@Override
public String getName() {
- return "Projects";
+ return NAME;
}
@Override
public Filter createFilter() {
- Filter filter = Filter.create();
- filter.setDisplayAs(Filter.LIST);
- filter.add(Criterion.createForQualifier(Qualifiers.PROJECT));
- filter.add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false));
- filter.add(FilterColumn.create("name", null, FilterColumn.ASC, false));
- filter.add(FilterColumn.create("version", null, FilterColumn.DESC, false));
- filter.add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false));
- filter.add(FilterColumn.create("metric", CoreMetrics.VIOLATIONS_DENSITY_KEY, FilterColumn.DESC, false));
- filter.add(FilterColumn.create("date", null, FilterColumn.DESC, false));
- filter.add(FilterColumn.create("links", null, FilterColumn.DESC, false));
-
- return filter;
+ return Filter.create()
+ .setDisplayAs(Filter.LIST)
+ .add(Criterion.createForQualifier(Qualifiers.PROJECT))
+ .add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false))
+ .add(FilterColumn.create("name", null, FilterColumn.ASC, false))
+ .add(FilterColumn.create("version", null, FilterColumn.DESC, false))
+ .add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false))
+ .add(FilterColumn.create("metric", CoreMetrics.VIOLATIONS_DENSITY_KEY, FilterColumn.DESC, false))
+ .add(FilterColumn.create("date", null, FilterColumn.DESC, false))
+ .add(FilterColumn.create("links", null, FilterColumn.DESC, false));
}
}
* @since 3.1
*/
public class TreeMapFilter extends FilterTemplate {
+ public static final String NAME = "Treemap";
+
@Override
public String getName() {
- return "Treemap";
+ return NAME;
}
@Override
public Filter createFilter() {
- Filter filter = Filter.create();
- filter.setDisplayAs(Filter.TREEMAP);
- filter.add(Criterion.createForQualifier(Qualifiers.PROJECT));
- filter.add(FilterColumn.create("name", null, FilterColumn.ASC, false));
- filter.add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false));
- filter.add(FilterColumn.create("metric", CoreMetrics.VIOLATIONS_DENSITY_KEY, FilterColumn.DESC, false));
-
- return filter;
+ return Filter.create()
+ .setDisplayAs(Filter.TREEMAP)
+ .add(Criterion.createForQualifier(Qualifiers.PROJECT))
+ .add(FilterColumn.create("name", null, FilterColumn.ASC, false))
+ .add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false))
+ .add(FilterColumn.create("metric", CoreMetrics.VIOLATIONS_DENSITY_KEY, FilterColumn.DESC, false));
}
}
@WidgetCategory({"Filters", "Global"})
@WidgetScope(GLOBAL)
-@WidgetProperties({
+@WidgetProperties(
@WidgetProperty(key = FilterWidget.FILTER, type = WidgetPropertyType.FILTER, optional = false)
-})
+)
public class FilterWidget extends AbstractRubyTemplate implements RubyRailsWidget {
public static final String FILTER = "filter";
import org.sonar.api.web.Dashboard;
import org.sonar.api.web.Dashboard.Widget;
import org.sonar.plugins.core.CorePlugin;
-import org.sonar.plugins.core.filters.MyFavouritesFilter;
-import org.sonar.plugins.core.widgets.FilterWidget;
import static org.fest.assertions.Assertions.assertThat;
assertThat(dashboard.isGlobal()).isTrue();
assertThat(dashboard.isActivated()).isFalse();
- assertThat(widget.getId()).isEqualTo(new FilterWidget().getId());
- assertThat(widget.getProperty("filter")).isEqualTo(new MyFavouritesFilter().getName());
+ assertThat(widget.getId()).isEqualTo("filter");
+ assertThat(widget.getProperty("filter")).isEqualTo("My favourites");
}
}
*/
package org.sonar.plugins.core.dashboards;
-import org.sonar.plugins.core.CorePlugin;
-
import com.google.common.collect.Iterables;
import org.junit.Test;
import org.sonar.api.web.Dashboard;
import org.sonar.api.web.Dashboard.Widget;
-import org.sonar.plugins.core.filters.ProjectFilter;
-import org.sonar.plugins.core.widgets.FilterWidget;
+import org.sonar.plugins.core.CorePlugin;
import static org.fest.assertions.Assertions.assertThat;
Widget widget = Iterables.getOnlyElement(dashboard.getWidgets());
assertThat(dashboard.isGlobal()).isTrue();
- assertThat(widget.getId()).isEqualTo(new FilterWidget().getId());
- assertThat(widget.getProperty("filter")).isEqualTo(new ProjectFilter().getName());
+ assertThat(widget.getId()).isEqualTo("filter");
+ assertThat(widget.getProperty("filter")).isEqualTo("Projects");
}
}
*/
package org.sonar.plugins.core.dashboards;
-import org.sonar.plugins.core.CorePlugin;
-
import com.google.common.collect.Iterables;
import org.junit.Test;
import org.sonar.api.web.Dashboard;
import org.sonar.api.web.Dashboard.Widget;
-import org.sonar.plugins.core.filters.TreeMapFilter;
-import org.sonar.plugins.core.widgets.FilterWidget;
+import org.sonar.plugins.core.CorePlugin;
import static org.fest.assertions.Assertions.assertThat;
Widget widget = Iterables.getOnlyElement(dashboard.getWidgets());
assertThat(dashboard.isGlobal()).isTrue();
- assertThat(widget.getId()).isEqualTo(new FilterWidget().getId());
- assertThat(widget.getProperty("filter")).isEqualTo(new TreeMapFilter().getName());
+ assertThat(widget.getId()).isEqualTo("filter");
+ assertThat(widget.getProperty("filter")).isEqualTo("Treemap");
}
}
import org.sonar.core.review.ReviewMapper;
import org.sonar.core.review.workflow.review.Comment;
import org.sonar.core.review.workflow.review.DefaultReview;
-import org.sonar.core.review.workflow.review.MutableReview;
-
import java.util.Date;
import java.util.List;
import org.sonar.api.config.Settings;
import org.sonar.core.review.workflow.review.DefaultReview;
-import org.sonar.core.review.workflow.review.MutableReview;
-
import java.util.List;
public interface ReviewStore {
import org.sonar.core.review.workflow.function.Function;
import org.sonar.core.review.workflow.review.DefaultReview;
import org.sonar.core.review.workflow.review.DefaultWorkflowContext;
-import org.sonar.core.review.workflow.review.MutableReview;
import org.sonar.core.review.workflow.review.Review;
import org.sonar.core.review.workflow.review.WorkflowContext;
import org.sonar.core.review.workflow.screen.Screen;
Map<String, String> immutableParameters = ImmutableMap.copyOf(parameters);
// TODO execute functions are change state before functions that consume state (like "create-jira-issue")
- Review initialReview = ((DefaultReview) review).cloneImmutable();
+ Review initialReview = review.cloneImmutable();
for (Function function : workflow.getFunctions(commandKey)) {
function.doExecute(review, initialReview, context, immutableParameters);
}
import org.sonar.core.persistence.DaoTestCase;
import org.sonar.core.review.workflow.review.Comment;
import org.sonar.core.review.workflow.review.DefaultReview;
-import org.sonar.core.review.workflow.review.MutableReview;
-
import java.util.Date;
public class ReviewDatabaseStoreTest extends DaoTestCase {
import org.sonar.core.review.workflow.WorkflowEngine;
import org.sonar.core.review.workflow.review.DefaultReview;
import org.sonar.core.review.workflow.review.DefaultWorkflowContext;
-import org.sonar.core.review.workflow.review.MutableReview;
import org.sonar.core.review.workflow.review.Review;
import org.sonar.core.review.workflow.screen.Screen;
import org.sonar.markdown.Markdown;