Sonar, open source software quality management tool.
-Copyright (C) 2009 SonarSource SA
+Copyright (C) 2008-2011 SonarSource
mailto:contact AT sonarsource DOT com
Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.clover;\r
-\r
-import org.apache.commons.lang.StringUtils;\r
-import org.codehaus.staxmate.in.*;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.sonar.api.batch.SensorContext;\r
-import org.sonar.api.measures.CoreMetrics;\r
-import org.sonar.api.measures.PropertiesBuilder;\r
-import org.sonar.api.resources.JavaFile;\r
-import org.sonar.api.resources.JavaPackage;\r
-import org.sonar.api.resources.Resource;\r
-import org.sonar.api.utils.ParsingUtils;\r
-import static org.sonar.api.utils.ParsingUtils.scaleValue;\r
-import org.sonar.api.utils.StaxParser;\r
-import org.sonar.api.utils.XmlParserException;\r
-\r
-import java.io.File;\r
-import java.text.ParseException;\r
-import javax.xml.stream.XMLStreamException;\r
-\r
-public class XmlReportParser {\r
-\r
- private static final Logger LOG = LoggerFactory.getLogger(XmlReportParser.class);\r
- private SensorContext context;\r
- final PropertiesBuilder<String, Integer> lineHitsBuilder = new PropertiesBuilder<String, Integer>(CoreMetrics.COVERAGE_LINE_HITS_DATA);\r
- final PropertiesBuilder<String, String> branchHitsBuilder = new PropertiesBuilder<String, String>(CoreMetrics.BRANCH_COVERAGE_HITS_DATA);\r
-\r
- public XmlReportParser(SensorContext context) {\r
- this.context = context;\r
- }\r
-\r
- private boolean reportExists(File report) {\r
- return report != null && report.exists() && report.isFile();\r
- }\r
-\r
- protected void collect(File xmlFile) {\r
- try {\r
- if (reportExists(xmlFile)) {\r
- LOG.info("Parsing " + xmlFile.getCanonicalPath());\r
- StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() {\r
- public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {\r
- try {\r
- collectProjectMeasures(rootCursor.advance());\r
- } catch (ParseException e) {\r
- throw new XMLStreamException(e);\r
- }\r
- }\r
- });\r
- parser.parse(xmlFile);\r
- }\r
- } catch (Exception e) {\r
- throw new XmlParserException(e);\r
- }\r
- }\r
-\r
- private void collectProjectMeasures(SMInputCursor rootCursor) throws ParseException, XMLStreamException {\r
- SMInputCursor projectCursor = rootCursor.descendantElementCursor("project");\r
- SMInputCursor projectChildrenCursor = projectCursor.advance().childElementCursor();\r
- projectChildrenCursor.setFilter(new SimpleFilter(SMEvent.START_ELEMENT));\r
-\r
- SMInputCursor metricsCursor = projectChildrenCursor.advance();\r
- analyseMetricsNode(null, metricsCursor);\r
- collectPackageMeasures(projectChildrenCursor);\r
- }\r
-\r
- private void analyseMetricsNode(Resource resource, SMInputCursor metricsCursor) throws ParseException, XMLStreamException {\r
- int elements = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("elements"));\r
- if (elements == 0) {\r
- return;\r
- }\r
-\r
- int statements = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("statements"));\r
- int methods = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("methods"));\r
- int conditionals = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("conditionals"));\r
- int coveredElements = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("coveredelements"));\r
- int coveredStatements = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("coveredstatements"));\r
- int coveredMethods = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("coveredmethods"));\r
- int coveredConditionals = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("coveredconditionals"));\r
-\r
- context.saveMeasure(resource, CoreMetrics.COVERAGE, calculateCoverage(coveredElements, elements));\r
-\r
- context.saveMeasure(resource, CoreMetrics.LINE_COVERAGE, calculateCoverage(coveredMethods + coveredStatements, methods + statements));\r
- context.saveMeasure(resource, CoreMetrics.LINES_TO_COVER, (double) (statements + methods));\r
- context.saveMeasure(resource, CoreMetrics.UNCOVERED_LINES, (double) (statements + methods - coveredStatements - coveredMethods));\r
-\r
- if (conditionals > 0) {\r
- context.saveMeasure(resource, CoreMetrics.BRANCH_COVERAGE, calculateCoverage(coveredConditionals, conditionals));\r
- context.saveMeasure(resource, CoreMetrics.CONDITIONS_TO_COVER, (double) (conditionals));\r
- context.saveMeasure(resource, CoreMetrics.UNCOVERED_CONDITIONS, (double) (conditionals - coveredConditionals));\r
- }\r
- }\r
-\r
- private double calculateCoverage(int coveredElements, int elements) {\r
- if (elements > 0) {\r
- return scaleValue(100.0 * ((double) coveredElements / (double) elements));\r
- }\r
- return 0.0;\r
- }\r
-\r
- private void collectPackageMeasures(SMInputCursor packCursor) throws ParseException, XMLStreamException {\r
- while (packCursor.getNext() != null) {\r
- JavaPackage pack = new JavaPackage(packCursor.getAttrValue("name"));\r
- SMInputCursor packChildrenCursor = packCursor.descendantElementCursor();\r
- packChildrenCursor.setFilter(new SimpleFilter(SMEvent.START_ELEMENT));\r
- SMInputCursor metricsCursor = packChildrenCursor.advance();\r
- analyseMetricsNode(pack, metricsCursor);\r
- collectFileMeasures(packChildrenCursor, pack);\r
- }\r
- }\r
-\r
- private void collectFileMeasures(SMInputCursor fileCursor, JavaPackage pack) throws ParseException, XMLStreamException {\r
- fileCursor.setFilter(SMFilterFactory.getElementOnlyFilter("file"));\r
- while (fileCursor.getNext() != null) {\r
- if (fileCursor.asEvent().isStartElement()) {\r
- String classKey = extractClassName(fileCursor.getAttrValue("name"));\r
- if (classKey != null) {\r
- SMInputCursor fileChildrenCursor = fileCursor.childCursor(new SimpleFilter(SMEvent.START_ELEMENT));\r
- // cursor should be on the metrics element\r
- if (canBeIncludedInFileMetrics(fileChildrenCursor)) {\r
- JavaFile resource = new JavaFile(pack.getKey(), classKey, false);\r
- analyseMetricsNode(resource, fileChildrenCursor);\r
-\r
- // cursor should be now on the line cursor\r
- saveHitsData(resource, fileChildrenCursor);\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- private void saveHitsData(Resource resource, SMInputCursor lineCursor) throws ParseException, XMLStreamException {\r
- lineHitsBuilder.clear();\r
- branchHitsBuilder.clear();\r
- boolean hasBranches = false;\r
-\r
- while (lineCursor.getNext() != null) {\r
- // skip class elements on format 2_3_2\r
- if (lineCursor.getLocalName().equals("class")) {\r
- continue;\r
- }\r
- final String lineId = lineCursor.getAttrValue("num");\r
- int hits;\r
- String count = lineCursor.getAttrValue("count");\r
- if (StringUtils.isBlank(count)) {\r
- int trueCount = (int) ParsingUtils.parseNumber(lineCursor.getAttrValue("truecount"));\r
- int falseCount = (int) ParsingUtils.parseNumber(lineCursor.getAttrValue("falsecount"));\r
- hits = trueCount + falseCount;\r
- String branchHits;\r
- if (trueCount > 0 && falseCount > 0) {\r
- branchHits = "100%";\r
- } else if (trueCount == 0 && falseCount == 0) {\r
- branchHits = "0%";\r
- } else {\r
- branchHits = "50%";\r
- }\r
- branchHitsBuilder.add(lineId, branchHits);\r
- hasBranches = true;\r
-\r
- } else {\r
- hits = (int) ParsingUtils.parseNumber(count);\r
- }\r
- lineHitsBuilder.add(lineId, hits);\r
- }\r
- context.saveMeasure(resource, lineHitsBuilder.build());\r
- if (hasBranches) {\r
- context.saveMeasure(resource, branchHitsBuilder.build());\r
- }\r
- }\r
-\r
- private boolean canBeIncludedInFileMetrics(SMInputCursor metricsCursor) throws ParseException, XMLStreamException {\r
- // skip class elements on 1.x xml format\r
- while (metricsCursor.getNext() != null && metricsCursor.getLocalName().equals("class")) {\r
- }\r
- return ParsingUtils.parseNumber(metricsCursor.getAttrValue("elements")) > 0;\r
- }\r
-\r
- protected String extractClassName(String filename) {\r
- if (filename != null) {\r
- filename = StringUtils.replaceChars(filename, '\\', '/');\r
- filename = StringUtils.substringBeforeLast(filename, ".java");\r
- if (filename.indexOf('/') >= 0) {\r
- filename = StringUtils.substringAfterLast(filename, "/");\r
- }\r
- }\r
- return filename;\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.clover;
+
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.staxmate.in.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.batch.SensorContext;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.PropertiesBuilder;
+import org.sonar.api.resources.JavaFile;
+import org.sonar.api.resources.JavaPackage;
+import org.sonar.api.resources.Resource;
+import org.sonar.api.utils.ParsingUtils;
+import static org.sonar.api.utils.ParsingUtils.scaleValue;
+import org.sonar.api.utils.StaxParser;
+import org.sonar.api.utils.XmlParserException;
+
+import java.io.File;
+import java.text.ParseException;
+import javax.xml.stream.XMLStreamException;
+
+public class XmlReportParser {
+
+ private static final Logger LOG = LoggerFactory.getLogger(XmlReportParser.class);
+ private SensorContext context;
+ final PropertiesBuilder<String, Integer> lineHitsBuilder = new PropertiesBuilder<String, Integer>(CoreMetrics.COVERAGE_LINE_HITS_DATA);
+ final PropertiesBuilder<String, String> branchHitsBuilder = new PropertiesBuilder<String, String>(CoreMetrics.BRANCH_COVERAGE_HITS_DATA);
+
+ public XmlReportParser(SensorContext context) {
+ this.context = context;
+ }
+
+ private boolean reportExists(File report) {
+ return report != null && report.exists() && report.isFile();
+ }
+
+ protected void collect(File xmlFile) {
+ try {
+ if (reportExists(xmlFile)) {
+ LOG.info("Parsing " + xmlFile.getCanonicalPath());
+ StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() {
+ public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
+ try {
+ collectProjectMeasures(rootCursor.advance());
+ } catch (ParseException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+ });
+ parser.parse(xmlFile);
+ }
+ } catch (Exception e) {
+ throw new XmlParserException(e);
+ }
+ }
+
+ private void collectProjectMeasures(SMInputCursor rootCursor) throws ParseException, XMLStreamException {
+ SMInputCursor projectCursor = rootCursor.descendantElementCursor("project");
+ SMInputCursor projectChildrenCursor = projectCursor.advance().childElementCursor();
+ projectChildrenCursor.setFilter(new SimpleFilter(SMEvent.START_ELEMENT));
+
+ SMInputCursor metricsCursor = projectChildrenCursor.advance();
+ analyseMetricsNode(null, metricsCursor);
+ collectPackageMeasures(projectChildrenCursor);
+ }
+
+ private void analyseMetricsNode(Resource resource, SMInputCursor metricsCursor) throws ParseException, XMLStreamException {
+ int elements = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("elements"));
+ if (elements == 0) {
+ return;
+ }
+
+ int statements = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("statements"));
+ int methods = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("methods"));
+ int conditionals = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("conditionals"));
+ int coveredElements = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("coveredelements"));
+ int coveredStatements = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("coveredstatements"));
+ int coveredMethods = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("coveredmethods"));
+ int coveredConditionals = (int) ParsingUtils.parseNumber(metricsCursor.getAttrValue("coveredconditionals"));
+
+ context.saveMeasure(resource, CoreMetrics.COVERAGE, calculateCoverage(coveredElements, elements));
+
+ context.saveMeasure(resource, CoreMetrics.LINE_COVERAGE, calculateCoverage(coveredMethods + coveredStatements, methods + statements));
+ context.saveMeasure(resource, CoreMetrics.LINES_TO_COVER, (double) (statements + methods));
+ context.saveMeasure(resource, CoreMetrics.UNCOVERED_LINES, (double) (statements + methods - coveredStatements - coveredMethods));
+
+ if (conditionals > 0) {
+ context.saveMeasure(resource, CoreMetrics.BRANCH_COVERAGE, calculateCoverage(coveredConditionals, conditionals));
+ context.saveMeasure(resource, CoreMetrics.CONDITIONS_TO_COVER, (double) (conditionals));
+ context.saveMeasure(resource, CoreMetrics.UNCOVERED_CONDITIONS, (double) (conditionals - coveredConditionals));
+ }
+ }
+
+ private double calculateCoverage(int coveredElements, int elements) {
+ if (elements > 0) {
+ return scaleValue(100.0 * ((double) coveredElements / (double) elements));
+ }
+ return 0.0;
+ }
+
+ private void collectPackageMeasures(SMInputCursor packCursor) throws ParseException, XMLStreamException {
+ while (packCursor.getNext() != null) {
+ JavaPackage pack = new JavaPackage(packCursor.getAttrValue("name"));
+ SMInputCursor packChildrenCursor = packCursor.descendantElementCursor();
+ packChildrenCursor.setFilter(new SimpleFilter(SMEvent.START_ELEMENT));
+ SMInputCursor metricsCursor = packChildrenCursor.advance();
+ analyseMetricsNode(pack, metricsCursor);
+ collectFileMeasures(packChildrenCursor, pack);
+ }
+ }
+
+ private void collectFileMeasures(SMInputCursor fileCursor, JavaPackage pack) throws ParseException, XMLStreamException {
+ fileCursor.setFilter(SMFilterFactory.getElementOnlyFilter("file"));
+ while (fileCursor.getNext() != null) {
+ if (fileCursor.asEvent().isStartElement()) {
+ String classKey = extractClassName(fileCursor.getAttrValue("name"));
+ if (classKey != null) {
+ SMInputCursor fileChildrenCursor = fileCursor.childCursor(new SimpleFilter(SMEvent.START_ELEMENT));
+ // cursor should be on the metrics element
+ if (canBeIncludedInFileMetrics(fileChildrenCursor)) {
+ JavaFile resource = new JavaFile(pack.getKey(), classKey, false);
+ analyseMetricsNode(resource, fileChildrenCursor);
+
+ // cursor should be now on the line cursor
+ saveHitsData(resource, fileChildrenCursor);
+ }
+ }
+ }
+ }
+ }
+
+ private void saveHitsData(Resource resource, SMInputCursor lineCursor) throws ParseException, XMLStreamException {
+ lineHitsBuilder.clear();
+ branchHitsBuilder.clear();
+ boolean hasBranches = false;
+
+ while (lineCursor.getNext() != null) {
+ // skip class elements on format 2_3_2
+ if (lineCursor.getLocalName().equals("class")) {
+ continue;
+ }
+ final String lineId = lineCursor.getAttrValue("num");
+ int hits;
+ String count = lineCursor.getAttrValue("count");
+ if (StringUtils.isBlank(count)) {
+ int trueCount = (int) ParsingUtils.parseNumber(lineCursor.getAttrValue("truecount"));
+ int falseCount = (int) ParsingUtils.parseNumber(lineCursor.getAttrValue("falsecount"));
+ hits = trueCount + falseCount;
+ String branchHits;
+ if (trueCount > 0 && falseCount > 0) {
+ branchHits = "100%";
+ } else if (trueCount == 0 && falseCount == 0) {
+ branchHits = "0%";
+ } else {
+ branchHits = "50%";
+ }
+ branchHitsBuilder.add(lineId, branchHits);
+ hasBranches = true;
+
+ } else {
+ hits = (int) ParsingUtils.parseNumber(count);
+ }
+ lineHitsBuilder.add(lineId, hits);
+ }
+ context.saveMeasure(resource, lineHitsBuilder.build());
+ if (hasBranches) {
+ context.saveMeasure(resource, branchHitsBuilder.build());
+ }
+ }
+
+ private boolean canBeIncludedInFileMetrics(SMInputCursor metricsCursor) throws ParseException, XMLStreamException {
+ // skip class elements on 1.x xml format
+ while (metricsCursor.getNext() != null && metricsCursor.getLocalName().equals("class")) {
+ }
+ return ParsingUtils.parseNumber(metricsCursor.getAttrValue("elements")) > 0;
+ }
+
+ protected String extractClassName(String filename) {
+ if (filename != null) {
+ filename = StringUtils.replaceChars(filename, '\\', '/');
+ filename = StringUtils.substringBeforeLast(filename, ".java");
+ if (filename.indexOf('/') >= 0) {
+ filename = StringUtils.substringAfterLast(filename, "/");
+ }
+ }
+ return filename;
+ }
}
\ No newline at end of file
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.clover;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.sonar.api.batch.SensorContext;\r
-import org.sonar.api.measures.CoreMetrics;\r
-import org.sonar.api.resources.JavaFile;\r
-import org.sonar.api.resources.JavaPackage;\r
-import org.sonar.api.resources.Resource;\r
-import org.sonar.api.test.IsMeasure;\r
-import org.sonar.test.TestUtils;\r
-\r
-import java.io.File;\r
-import java.net.URISyntaxException;\r
-import java.text.ParseException;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.mockito.Matchers.anyDouble;\r
-import static org.mockito.Matchers.anyObject;\r
-import static org.mockito.Matchers.argThat;\r
-import static org.mockito.Matchers.eq;\r
-import static org.mockito.Mockito.*;\r
-\r
-public class XmlReportParserTest {\r
-\r
- private XmlReportParser reportParser;\r
- private SensorContext context;\r
- private File xmlFile;\r
-\r
- @Before\r
- public void before() throws URISyntaxException {\r
- xmlFile = TestUtils.getResource(getClass(), "clover.xml");\r
- context = mock(SensorContext.class);\r
- reportParser = new XmlReportParser(context);\r
- }\r
-\r
- @Test\r
- public void collectProjectMeasures() throws Exception {\r
- reportParser.collect(xmlFile);\r
- verify(context).saveMeasure(null, CoreMetrics.COVERAGE, 5.0); // coveredelements / elements\r
-\r
- verify(context).saveMeasure(null, CoreMetrics.LINE_COVERAGE, 6.63); // covered methods + covered statements / methods + statements\r
- verify(context).saveMeasure(null, CoreMetrics.LINES_TO_COVER, 196.0);\r
- verify(context).saveMeasure(null, CoreMetrics.UNCOVERED_LINES, 183.0); // covered methods + covered statements\r
-\r
- verify(context).saveMeasure(null, CoreMetrics.BRANCH_COVERAGE, 0.0); // covered conditionals / conditionals\r
- verify(context).saveMeasure(null, CoreMetrics.CONDITIONS_TO_COVER, 64.0); // covered_conditionals\r
- verify(context).saveMeasure(null, CoreMetrics.UNCOVERED_CONDITIONS, 64.0);\r
- }\r
-\r
- @Test\r
- public void collectPackageMeasures() throws ParseException {\r
- reportParser.collect(xmlFile);\r
- final JavaPackage pac = new JavaPackage("org.sonar.samples");\r
- verify(context).saveMeasure(pac, CoreMetrics.COVERAGE, 28.89);\r
-\r
- // lines\r
- verify(context).saveMeasure(pac, CoreMetrics.LINE_COVERAGE, 28.89);\r
- verify(context).saveMeasure(pac, CoreMetrics.LINES_TO_COVER, 45.0);\r
- verify(context).saveMeasure(pac, CoreMetrics.UNCOVERED_LINES, 32.0);\r
-\r
- // no conditions\r
- verify(context, never()).saveMeasure(eq(pac), eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());\r
- verify(context, never()).saveMeasure(eq(pac), eq(CoreMetrics.CONDITIONS_TO_COVER), anyDouble());\r
- verify(context, never()).saveMeasure(eq(pac), eq(CoreMetrics.UNCOVERED_CONDITIONS), anyDouble());\r
- }\r
-\r
- @Test\r
- public void parseClaver232Format() throws ParseException, URISyntaxException {\r
- reportParser.collect(TestUtils.getResource(getClass(), "clover_2_3_2.xml"));\r
- verify(context).saveMeasure(new JavaPackage("org.sonar.squid.sensors"), CoreMetrics.COVERAGE, 94.87);\r
- }\r
-\r
-// @Test\r
-// public void doNotSaveInnerClassMeasures() throws ParseException, URISyntaxException {\r
-// collector.collect(xmlFile);\r
-//\r
-// verify(context, never()).saveMeasure(\r
-// eq(new JavaFile("ch.hortis.sonar.model.MetricMetaInf.Classes")), eq(CoreMetrics.COVERAGE), anyDouble());\r
-// verify(context).saveMeasure(\r
-// eq(new JavaFile("ch.hortis.sonar.model.MetricMetaInf")), eq(CoreMetrics.COVERAGE), anyDouble());\r
-// }\r
-\r
- @Test\r
- public void collectFileMeasures() throws Exception {\r
- reportParser.collect(xmlFile);\r
-\r
- final JavaFile file = new JavaFile("org.sonar.samples.ClassUnderTest");\r
- verify(context).saveMeasure(file, CoreMetrics.COVERAGE, 100.0);\r
-\r
- verify(context).saveMeasure(file, CoreMetrics.LINE_COVERAGE, 100.0);\r
- verify(context).saveMeasure(file, CoreMetrics.LINES_TO_COVER, 5.0);\r
- verify(context).saveMeasure(file, CoreMetrics.UNCOVERED_LINES, 0.0);\r
-\r
- // no conditions\r
- verify(context, never()).saveMeasure(eq(file), eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());\r
- verify(context, never()).saveMeasure(eq(file), eq(CoreMetrics.CONDITIONS_TO_COVER), anyDouble());\r
- verify(context, never()).saveMeasure(eq(file), eq(CoreMetrics.UNCOVERED_CONDITIONS), anyDouble());\r
- }\r
-\r
- @Test\r
- public void collectFileHitsData() throws Exception {\r
- reportParser.collect(xmlFile);\r
- verify(context).saveMeasure(eq(new JavaFile("org.sonar.samples.ClassUnderTest")), argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA, "4=1;5=1;6=1;8=1;9=1")));\r
- }\r
-\r
- @Test\r
- public void clover1FileNameContainsPath() {\r
- XmlReportParser reportParser = new XmlReportParser(context);\r
- assertEquals("SampleClass", reportParser.extractClassName("C:\\src\\main\\java\\org\\sonar\\samples\\SampleClass.java"));\r
-\r
- assertEquals("SampleClass", reportParser.extractClassName("/src/main/java/org/sonar/samples/SampleClass.java"));\r
- }\r
-\r
- @Test\r
- public void clover2FileNameDoesNotContainPath() {\r
- XmlReportParser reportParser = new XmlReportParser(context);\r
- assertEquals("SampleClass", reportParser.extractClassName("SampleClass.java"));\r
- }\r
-\r
- @Test\r
- public void coverageShouldBeZeroWhenNoElements() throws URISyntaxException {\r
- File xmlFile = TestUtils.getResource(getClass(), "coverageShouldBeZeroWhenNoElements/clover.xml");\r
- context = mock(SensorContext.class);\r
- XmlReportParser reportParser = new XmlReportParser(context);\r
- reportParser.collect(xmlFile);\r
- verify(context, never()).saveMeasure((Resource) anyObject(), eq(CoreMetrics.COVERAGE), anyDouble());\r
- verify(context, never()).saveMeasure((Resource) anyObject(), eq(CoreMetrics.LINE_COVERAGE), anyDouble());\r
- verify(context, never()).saveMeasure((Resource) anyObject(), eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.clover;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.batch.SensorContext;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.resources.JavaFile;
+import org.sonar.api.resources.JavaPackage;
+import org.sonar.api.resources.Resource;
+import org.sonar.api.test.IsMeasure;
+import org.sonar.test.TestUtils;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.text.ParseException;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.anyDouble;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
+
+public class XmlReportParserTest {
+
+ private XmlReportParser reportParser;
+ private SensorContext context;
+ private File xmlFile;
+
+ @Before
+ public void before() throws URISyntaxException {
+ xmlFile = TestUtils.getResource(getClass(), "clover.xml");
+ context = mock(SensorContext.class);
+ reportParser = new XmlReportParser(context);
+ }
+
+ @Test
+ public void collectProjectMeasures() throws Exception {
+ reportParser.collect(xmlFile);
+ verify(context).saveMeasure(null, CoreMetrics.COVERAGE, 5.0); // coveredelements / elements
+
+ verify(context).saveMeasure(null, CoreMetrics.LINE_COVERAGE, 6.63); // covered methods + covered statements / methods + statements
+ verify(context).saveMeasure(null, CoreMetrics.LINES_TO_COVER, 196.0);
+ verify(context).saveMeasure(null, CoreMetrics.UNCOVERED_LINES, 183.0); // covered methods + covered statements
+
+ verify(context).saveMeasure(null, CoreMetrics.BRANCH_COVERAGE, 0.0); // covered conditionals / conditionals
+ verify(context).saveMeasure(null, CoreMetrics.CONDITIONS_TO_COVER, 64.0); // covered_conditionals
+ verify(context).saveMeasure(null, CoreMetrics.UNCOVERED_CONDITIONS, 64.0);
+ }
+
+ @Test
+ public void collectPackageMeasures() throws ParseException {
+ reportParser.collect(xmlFile);
+ final JavaPackage pac = new JavaPackage("org.sonar.samples");
+ verify(context).saveMeasure(pac, CoreMetrics.COVERAGE, 28.89);
+
+ // lines
+ verify(context).saveMeasure(pac, CoreMetrics.LINE_COVERAGE, 28.89);
+ verify(context).saveMeasure(pac, CoreMetrics.LINES_TO_COVER, 45.0);
+ verify(context).saveMeasure(pac, CoreMetrics.UNCOVERED_LINES, 32.0);
+
+ // no conditions
+ verify(context, never()).saveMeasure(eq(pac), eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());
+ verify(context, never()).saveMeasure(eq(pac), eq(CoreMetrics.CONDITIONS_TO_COVER), anyDouble());
+ verify(context, never()).saveMeasure(eq(pac), eq(CoreMetrics.UNCOVERED_CONDITIONS), anyDouble());
+ }
+
+ @Test
+ public void parseClaver232Format() throws ParseException, URISyntaxException {
+ reportParser.collect(TestUtils.getResource(getClass(), "clover_2_3_2.xml"));
+ verify(context).saveMeasure(new JavaPackage("org.sonar.squid.sensors"), CoreMetrics.COVERAGE, 94.87);
+ }
+
+// @Test
+// public void doNotSaveInnerClassMeasures() throws ParseException, URISyntaxException {
+// collector.collect(xmlFile);
+//
+// verify(context, never()).saveMeasure(
+// eq(new JavaFile("ch.hortis.sonar.model.MetricMetaInf.Classes")), eq(CoreMetrics.COVERAGE), anyDouble());
+// verify(context).saveMeasure(
+// eq(new JavaFile("ch.hortis.sonar.model.MetricMetaInf")), eq(CoreMetrics.COVERAGE), anyDouble());
+// }
+
+ @Test
+ public void collectFileMeasures() throws Exception {
+ reportParser.collect(xmlFile);
+
+ final JavaFile file = new JavaFile("org.sonar.samples.ClassUnderTest");
+ verify(context).saveMeasure(file, CoreMetrics.COVERAGE, 100.0);
+
+ verify(context).saveMeasure(file, CoreMetrics.LINE_COVERAGE, 100.0);
+ verify(context).saveMeasure(file, CoreMetrics.LINES_TO_COVER, 5.0);
+ verify(context).saveMeasure(file, CoreMetrics.UNCOVERED_LINES, 0.0);
+
+ // no conditions
+ verify(context, never()).saveMeasure(eq(file), eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());
+ verify(context, never()).saveMeasure(eq(file), eq(CoreMetrics.CONDITIONS_TO_COVER), anyDouble());
+ verify(context, never()).saveMeasure(eq(file), eq(CoreMetrics.UNCOVERED_CONDITIONS), anyDouble());
+ }
+
+ @Test
+ public void collectFileHitsData() throws Exception {
+ reportParser.collect(xmlFile);
+ verify(context).saveMeasure(eq(new JavaFile("org.sonar.samples.ClassUnderTest")), argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA, "4=1;5=1;6=1;8=1;9=1")));
+ }
+
+ @Test
+ public void clover1FileNameContainsPath() {
+ XmlReportParser reportParser = new XmlReportParser(context);
+ assertEquals("SampleClass", reportParser.extractClassName("C:\\src\\main\\java\\org\\sonar\\samples\\SampleClass.java"));
+
+ assertEquals("SampleClass", reportParser.extractClassName("/src/main/java/org/sonar/samples/SampleClass.java"));
+ }
+
+ @Test
+ public void clover2FileNameDoesNotContainPath() {
+ XmlReportParser reportParser = new XmlReportParser(context);
+ assertEquals("SampleClass", reportParser.extractClassName("SampleClass.java"));
+ }
+
+ @Test
+ public void coverageShouldBeZeroWhenNoElements() throws URISyntaxException {
+ File xmlFile = TestUtils.getResource(getClass(), "coverageShouldBeZeroWhenNoElements/clover.xml");
+ context = mock(SensorContext.class);
+ XmlReportParser reportParser = new XmlReportParser(context);
+ reportParser.collect(xmlFile);
+ verify(context, never()).saveMeasure((Resource) anyObject(), eq(CoreMetrics.COVERAGE), anyDouble());
+ verify(context, never()).saveMeasure((Resource) anyObject(), eq(CoreMetrics.LINE_COVERAGE), anyDouble());
+ verify(context, never()).saveMeasure((Resource) anyObject(), eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.clouds;\r
-\r
-import org.sonar.api.resources.Resource;\r
-import org.sonar.api.web.GwtPage;\r
-import org.sonar.api.web.NavigationSection;\r
-import org.sonar.api.web.ResourceScope;\r
-import org.sonar.api.web.UserRole;\r
-import org.sonar.plugins.core.clouds.client.GwtClouds;\r
-\r
-@NavigationSection(NavigationSection.RESOURCE)\r
-@ResourceScope({Resource.SCOPE_SET, Resource.SCOPE_SPACE})\r
-@UserRole(UserRole.USER)\r
-public class Clouds extends GwtPage {\r
-\r
- public String getGwtId() {\r
- return GwtClouds.GWT_ID;\r
- }\r
-\r
- public String getTitle() {\r
- return "Clouds";\r
- }\r
-\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.clouds;
+
+import org.sonar.api.resources.Resource;
+import org.sonar.api.web.GwtPage;
+import org.sonar.api.web.NavigationSection;
+import org.sonar.api.web.ResourceScope;
+import org.sonar.api.web.UserRole;
+import org.sonar.plugins.core.clouds.client.GwtClouds;
+
+@NavigationSection(NavigationSection.RESOURCE)
+@ResourceScope({Resource.SCOPE_SET, Resource.SCOPE_SPACE})
+@UserRole(UserRole.USER)
+public class Clouds extends GwtPage {
+
+ public String getGwtId() {
+ return GwtClouds.GWT_ID;
+ }
+
+ public String getTitle() {
+ return "Clouds";
+ }
+
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.clouds.client;\r
-\r
-import org.sonar.plugins.core.clouds.client.model.Color;\r
-\r
-public class Calculator {\r
-\r
- private Float minValue;\r
- private Float maxValue;\r
- private Float minPercent;\r
- private Float maxPercent;\r
-\r
- public Calculator(Float minPercent, Float maxPercent) {\r
- this.minPercent = minPercent;\r
- this.maxPercent = maxPercent;\r
- }\r
-\r
- public void updateMaxAndMin(Float value){\r
- updateMaxValue(value);\r
- updateMinValue(value);\r
- }\r
- \r
- public Integer getFontSizePercent(Integer value) {\r
- float divisor = getMaxValue() - getMinValue();\r
- float size = getMinPercent();\r
- if (divisor != 0) {\r
- float multiplier = (getMaxPercent() - getMinPercent()) / divisor;\r
- size = getMinPercent() +\r
- ((getMaxValue() - (getMaxValue() - (value - getMinValue()))) * multiplier);\r
- }\r
- return Float.valueOf(size).intValue();\r
- }\r
-\r
- public String getFontColor(float value) {\r
- float interval = (getMaxPercent() - getMinPercent()) / 2f;\r
- float mean = (getMinPercent() + getMaxPercent()) / 2f;\r
-\r
- Color minColor = new Color(191/255f, 0f, 21/255f); // red\r
- Color meanColor = new Color(77/255f, 5/255f, 177/255f); // purple\r
- Color maxColor = new Color(23/255f, 96/255f, 191/255f); // blue\r
-\r
- Color color;\r
- if (value > mean) {\r
- float valuePercent = ((value - mean) / interval) * 100f;\r
- color = mixColorWith(maxColor, meanColor, valuePercent);\r
- } else {\r
- float valuePercent = ((mean - value) / interval) * 100f;\r
- color = mixColorWith(minColor, meanColor, valuePercent);\r
- }\r
-\r
- int r = Float.valueOf(color.getRed()* 255f).intValue();\r
- int g = Float.valueOf(color.getGreen() * 255f).intValue();\r
- int b = Float.valueOf(color.getBlue() * 255f).intValue();\r
-\r
- return ("rgb("+ r +","+ g +","+ b +")");\r
- }\r
-\r
- private Color mixColorWith(Color currentColor, Color mask, float value){\r
- float opacity = value / 100f;\r
-\r
- float r = (currentColor.getRed() * opacity) + (mask.getRed() * (1f - opacity));\r
- float g = (currentColor.getGreen() * opacity) + (mask.getGreen() * (1f - opacity));\r
- float b = (currentColor.getBlue() * opacity) + (mask.getBlue() * (1f - opacity));\r
-\r
- return new Color(r, g, b);\r
- }\r
-\r
-\r
- private void updateMaxValue(Float value) {\r
- if (maxValue == null) {\r
- maxValue = value;\r
- } else if (value > maxValue) {\r
- maxValue = value;\r
- }\r
- }\r
-\r
- private void updateMinValue(Float value) {\r
- if (minValue == null) {\r
- minValue = value;\r
- } else if (value < minValue) {\r
- minValue = value;\r
- }\r
- }\r
-\r
-\r
- public Float getMinValue() {\r
- return minValue;\r
- }\r
-\r
- public Float getMaxValue() {\r
- return maxValue;\r
- }\r
-\r
- public Float getMinPercent() {\r
- return minPercent;\r
- }\r
-\r
- public Float getMaxPercent() {\r
- return maxPercent;\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.clouds.client;
+
+import org.sonar.plugins.core.clouds.client.model.Color;
+
+public class Calculator {
+
+ private Float minValue;
+ private Float maxValue;
+ private Float minPercent;
+ private Float maxPercent;
+
+ public Calculator(Float minPercent, Float maxPercent) {
+ this.minPercent = minPercent;
+ this.maxPercent = maxPercent;
+ }
+
+ public void updateMaxAndMin(Float value){
+ updateMaxValue(value);
+ updateMinValue(value);
+ }
+
+ public Integer getFontSizePercent(Integer value) {
+ float divisor = getMaxValue() - getMinValue();
+ float size = getMinPercent();
+ if (divisor != 0) {
+ float multiplier = (getMaxPercent() - getMinPercent()) / divisor;
+ size = getMinPercent() +
+ ((getMaxValue() - (getMaxValue() - (value - getMinValue()))) * multiplier);
+ }
+ return Float.valueOf(size).intValue();
+ }
+
+ public String getFontColor(float value) {
+ float interval = (getMaxPercent() - getMinPercent()) / 2f;
+ float mean = (getMinPercent() + getMaxPercent()) / 2f;
+
+ Color minColor = new Color(191/255f, 0f, 21/255f); // red
+ Color meanColor = new Color(77/255f, 5/255f, 177/255f); // purple
+ Color maxColor = new Color(23/255f, 96/255f, 191/255f); // blue
+
+ Color color;
+ if (value > mean) {
+ float valuePercent = ((value - mean) / interval) * 100f;
+ color = mixColorWith(maxColor, meanColor, valuePercent);
+ } else {
+ float valuePercent = ((mean - value) / interval) * 100f;
+ color = mixColorWith(minColor, meanColor, valuePercent);
+ }
+
+ int r = Float.valueOf(color.getRed()* 255f).intValue();
+ int g = Float.valueOf(color.getGreen() * 255f).intValue();
+ int b = Float.valueOf(color.getBlue() * 255f).intValue();
+
+ return ("rgb("+ r +","+ g +","+ b +")");
+ }
+
+ private Color mixColorWith(Color currentColor, Color mask, float value){
+ float opacity = value / 100f;
+
+ float r = (currentColor.getRed() * opacity) + (mask.getRed() * (1f - opacity));
+ float g = (currentColor.getGreen() * opacity) + (mask.getGreen() * (1f - opacity));
+ float b = (currentColor.getBlue() * opacity) + (mask.getBlue() * (1f - opacity));
+
+ return new Color(r, g, b);
+ }
+
+
+ private void updateMaxValue(Float value) {
+ if (maxValue == null) {
+ maxValue = value;
+ } else if (value > maxValue) {
+ maxValue = value;
+ }
+ }
+
+ private void updateMinValue(Float value) {
+ if (minValue == null) {
+ minValue = value;
+ } else if (value < minValue) {
+ minValue = value;
+ }
+ }
+
+
+ public Float getMinValue() {
+ return minValue;
+ }
+
+ public Float getMaxValue() {
+ return maxValue;
+ }
+
+ public Float getMinPercent() {
+ return minPercent;
+ }
+
+ public Float getMaxPercent() {
+ return maxPercent;
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.clouds.client.model;\r
-\r
-import org.sonar.api.web.gwt.client.webservices.Resource;\r
-\r
-\r
-public class CloudElement implements Comparable<CloudElement> {\r
-\r
- private Integer fontSize;\r
- private Float fontColor;\r
- private Resource resource;\r
-\r
- public CloudElement(Resource resource, Integer fontSize, Float fontColor) {\r
- this.resource = resource;\r
- this.fontSize = fontSize;\r
- this.fontColor = fontColor;\r
- }\r
-\r
- public Resource getResource() {\r
- return resource;\r
- }\r
-\r
- public Integer getFontSize() {\r
- return fontSize;\r
- }\r
-\r
- public Float getFontColor() {\r
- return fontColor;\r
- }\r
-\r
- public int compareTo(CloudElement cloudElement) {\r
- return resource.getName().compareTo(cloudElement.getResource().getName());\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.clouds.client.model;
+
+import org.sonar.api.web.gwt.client.webservices.Resource;
+
+
+public class CloudElement implements Comparable<CloudElement> {
+
+ private Integer fontSize;
+ private Float fontColor;
+ private Resource resource;
+
+ public CloudElement(Resource resource, Integer fontSize, Float fontColor) {
+ this.resource = resource;
+ this.fontSize = fontSize;
+ this.fontColor = fontColor;
+ }
+
+ public Resource getResource() {
+ return resource;
+ }
+
+ public Integer getFontSize() {
+ return fontSize;
+ }
+
+ public Float getFontColor() {
+ return fontColor;
+ }
+
+ public int compareTo(CloudElement cloudElement) {
+ return resource.getName().compareTo(cloudElement.getResource().getName());
+ }
+
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.clouds.client.model;\r
-\r
-public class Color {\r
-\r
- private float red;\r
- private float green;\r
- private float blue;\r
-\r
- public Color(float red, float green, float blue) {\r
- this.red = red;\r
- this.green = green;\r
- this.blue = blue;\r
- }\r
-\r
- public float getRed() {\r
- return red;\r
- }\r
-\r
- public float getGreen() {\r
- return green;\r
- }\r
-\r
- public float getBlue() {\r
- return blue;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return ("red : "+ red + ", green : "+ green + ", blue : "+ blue );\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.clouds.client.model;
+
+public class Color {
+
+ private float red;
+ private float green;
+ private float blue;
+
+ public Color(float red, float green, float blue) {
+ this.red = red;
+ this.green = green;
+ this.blue = blue;
+ }
+
+ public float getRed() {
+ return red;
+ }
+
+ public float getGreen() {
+ return green;
+ }
+
+ public float getBlue() {
+ return blue;
+ }
+
+ @Override
+ public String toString() {
+ return ("red : "+ red + ", green : "+ green + ", blue : "+ blue );
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.clouds.client.widget;\r
-\r
-import com.google.gwt.event.dom.client.ClickEvent;\r
-import com.google.gwt.event.dom.client.ClickHandler;\r
-import com.google.gwt.user.client.Window;\r
-import com.google.gwt.user.client.ui.*;\r
-import org.sonar.api.web.gwt.client.Utils;\r
-import org.sonar.api.web.gwt.client.webservices.Measure;\r
-import org.sonar.api.web.gwt.client.webservices.Resource;\r
-import org.sonar.api.web.gwt.client.webservices.WSMetrics.Metric;\r
-import org.sonar.api.web.gwt.client.widgets.LoadingLabel;\r
-import org.sonar.plugins.core.clouds.client.Calculator;\r
-import org.sonar.plugins.core.clouds.client.GwtClouds;\r
-import org.sonar.plugins.core.clouds.client.model.CloudElement;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-public class ClassCloudsWidget extends Composite {\r
-\r
- private Panel main;\r
- private Metric sizeMetric;\r
- private List<Resource> resources;\r
- private float minSizePercent = 60f;\r
- private float maxSizePercent = 240f;\r
-\r
- private Calculator sizeCalculator = new Calculator(minSizePercent, maxSizePercent);\r
- private Calculator colorCalculator = new Calculator(0f, 100f);\r
-\r
- public ClassCloudsWidget(List<Resource> resources, Metric sizeMetric) {\r
- this.sizeMetric = sizeMetric;\r
- this.main = new FlowPanel();\r
- this.resources = resources;\r
- initWidget(main);\r
- }\r
-\r
- public Metric getSizeMetric() {\r
- return sizeMetric;\r
- }\r
-\r
- public void generateCloud(Metric colorMetric) {\r
- main.clear();\r
- LoadingLabel loading = new LoadingLabel();\r
- main.add(loading);\r
- if (colorMetric.equals(colorMetric)) {\r
- List<CloudElement> cloudElements = getCloudElements(resources, colorMetric);\r
- createClouds(cloudElements, colorMetric);\r
- }\r
- main.remove(loading);\r
- }\r
-\r
- private List<CloudElement> getCloudElements(List<Resource> resources, Metric colorMetric) {\r
- List<CloudElement> tagList = new ArrayList<CloudElement>();\r
- for (Resource resource : resources) {\r
- Measure sizeMeasure = getMeasure(resource, sizeMetric);\r
- Measure colorMeasure = getMeasure(resource, colorMetric);\r
-\r
- if (sizeMeasure != null && colorMeasure != null) {\r
- Integer size = getMeasureValue(sizeMeasure.getValue());\r
- float color = colorMeasure.getValue().floatValue();\r
- tagList.add(new CloudElement(resource, size, color));\r
- sizeCalculator.updateMaxAndMin(Float.valueOf(size.toString()));\r
- }\r
- }\r
- Collections.sort(tagList);\r
- return tagList;\r
- }\r
-\r
- private Integer getMeasureValue(Double value) {\r
- Float floatValue = (value.floatValue() * 100.0f);\r
- return floatValue.intValue();\r
- }\r
-\r
- private Measure getMeasure(Resource project, Metric metricToFind) {\r
- return project.getMeasure(metricToFind);\r
- }\r
-\r
- private void createClouds(List<CloudElement> cloudElements, Metric colorMetric) {\r
- for (CloudElement tag : cloudElements) {\r
- HTML className = new HTML(\r
- "<span style=\"font-size:" + Integer.toString(sizeCalculator.getFontSizePercent(tag.getFontSize())) +\r
- "%; color:" + colorCalculator.getFontColor(tag.getFontColor()) + "\" >" +\r
- tag.getResource().getName() + "</span>\n");\r
- className.setStyleName("inline");\r
-\r
- Hyperlink link = createLink(tag, colorMetric);\r
- link.setHTML(className.getHTML());\r
- main.add(link);\r
- }\r
- }\r
-\r
- private Hyperlink createLink(CloudElement tag, final Metric colorMetric) {\r
- Hyperlink link = new Hyperlink();\r
- link.setStyleName("tag inline");\r
- String tooltip = getTooltip(tag.getResource(), colorMetric);\r
- link.getElement().setAttribute("title", tooltip);\r
- link.getElement().setAttribute("rel", tooltip);\r
-\r
- String sizeCss = Float.toString(maxSizePercent / 100f) + "em";\r
- link.setHeight(sizeCss);\r
- final Resource clickResource = tag.getResource();\r
- link.addClickHandler(new ClickHandler() {\r
- public void onClick(final ClickEvent event) {\r
- if (clickResource.getCopy() != null) {\r
- Window.Location.assign(Utils.getServerUrl() + "/plugins/resource/" + clickResource.getCopy() + "?page=" + GwtClouds.GWT_ID);\r
- } else {\r
- Utils.openResourcePopup(clickResource, colorMetric.getKey());\r
- }\r
- }\r
- });\r
-\r
- return link;\r
- }\r
-\r
- private String getTooltip(Resource resource, Metric colorMetric) {\r
- Measure sizeMeasure = getMeasure(resource, sizeMetric);\r
- String sizeMetricName = sizeMetric.getName();\r
- String sizeMetricValue = sizeMeasure.getFormattedValue();\r
-\r
- Measure colorMeasure = getMeasure(resource, colorMetric);\r
- String colorMetricName = colorMetric.getName();\r
- String colorMetricValue = colorMeasure.getFormattedValue();\r
-\r
- return resource.getName(true) + ", " + sizeMetricName + " : " + sizeMetricValue + ", " + colorMetricName + " : " + colorMetricValue;\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.clouds.client.widget;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.*;
+import org.sonar.api.web.gwt.client.Utils;
+import org.sonar.api.web.gwt.client.webservices.Measure;
+import org.sonar.api.web.gwt.client.webservices.Resource;
+import org.sonar.api.web.gwt.client.webservices.WSMetrics.Metric;
+import org.sonar.api.web.gwt.client.widgets.LoadingLabel;
+import org.sonar.plugins.core.clouds.client.Calculator;
+import org.sonar.plugins.core.clouds.client.GwtClouds;
+import org.sonar.plugins.core.clouds.client.model.CloudElement;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class ClassCloudsWidget extends Composite {
+
+ private Panel main;
+ private Metric sizeMetric;
+ private List<Resource> resources;
+ private float minSizePercent = 60f;
+ private float maxSizePercent = 240f;
+
+ private Calculator sizeCalculator = new Calculator(minSizePercent, maxSizePercent);
+ private Calculator colorCalculator = new Calculator(0f, 100f);
+
+ public ClassCloudsWidget(List<Resource> resources, Metric sizeMetric) {
+ this.sizeMetric = sizeMetric;
+ this.main = new FlowPanel();
+ this.resources = resources;
+ initWidget(main);
+ }
+
+ public Metric getSizeMetric() {
+ return sizeMetric;
+ }
+
+ public void generateCloud(Metric colorMetric) {
+ main.clear();
+ LoadingLabel loading = new LoadingLabel();
+ main.add(loading);
+ if (colorMetric.equals(colorMetric)) {
+ List<CloudElement> cloudElements = getCloudElements(resources, colorMetric);
+ createClouds(cloudElements, colorMetric);
+ }
+ main.remove(loading);
+ }
+
+ private List<CloudElement> getCloudElements(List<Resource> resources, Metric colorMetric) {
+ List<CloudElement> tagList = new ArrayList<CloudElement>();
+ for (Resource resource : resources) {
+ Measure sizeMeasure = getMeasure(resource, sizeMetric);
+ Measure colorMeasure = getMeasure(resource, colorMetric);
+
+ if (sizeMeasure != null && colorMeasure != null) {
+ Integer size = getMeasureValue(sizeMeasure.getValue());
+ float color = colorMeasure.getValue().floatValue();
+ tagList.add(new CloudElement(resource, size, color));
+ sizeCalculator.updateMaxAndMin(Float.valueOf(size.toString()));
+ }
+ }
+ Collections.sort(tagList);
+ return tagList;
+ }
+
+ private Integer getMeasureValue(Double value) {
+ Float floatValue = (value.floatValue() * 100.0f);
+ return floatValue.intValue();
+ }
+
+ private Measure getMeasure(Resource project, Metric metricToFind) {
+ return project.getMeasure(metricToFind);
+ }
+
+ private void createClouds(List<CloudElement> cloudElements, Metric colorMetric) {
+ for (CloudElement tag : cloudElements) {
+ HTML className = new HTML(
+ "<span style=\"font-size:" + Integer.toString(sizeCalculator.getFontSizePercent(tag.getFontSize())) +
+ "%; color:" + colorCalculator.getFontColor(tag.getFontColor()) + "\" >" +
+ tag.getResource().getName() + "</span>\n");
+ className.setStyleName("inline");
+
+ Hyperlink link = createLink(tag, colorMetric);
+ link.setHTML(className.getHTML());
+ main.add(link);
+ }
+ }
+
+ private Hyperlink createLink(CloudElement tag, final Metric colorMetric) {
+ Hyperlink link = new Hyperlink();
+ link.setStyleName("tag inline");
+ String tooltip = getTooltip(tag.getResource(), colorMetric);
+ link.getElement().setAttribute("title", tooltip);
+ link.getElement().setAttribute("rel", tooltip);
+
+ String sizeCss = Float.toString(maxSizePercent / 100f) + "em";
+ link.setHeight(sizeCss);
+ final Resource clickResource = tag.getResource();
+ link.addClickHandler(new ClickHandler() {
+ public void onClick(final ClickEvent event) {
+ if (clickResource.getCopy() != null) {
+ Window.Location.assign(Utils.getServerUrl() + "/plugins/resource/" + clickResource.getCopy() + "?page=" + GwtClouds.GWT_ID);
+ } else {
+ Utils.openResourcePopup(clickResource, colorMetric.getKey());
+ }
+ }
+ });
+
+ return link;
+ }
+
+ private String getTooltip(Resource resource, Metric colorMetric) {
+ Measure sizeMeasure = getMeasure(resource, sizeMetric);
+ String sizeMetricName = sizeMetric.getName();
+ String sizeMetricValue = sizeMeasure.getFormattedValue();
+
+ Measure colorMeasure = getMeasure(resource, colorMetric);
+ String colorMetricName = colorMetric.getName();
+ String colorMetricValue = colorMeasure.getFormattedValue();
+
+ return resource.getName(true) + ", " + sizeMetricName + " : " + sizeMetricValue + ", " + colorMetricName + " : " + colorMetricValue;
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.clouds.client.widget;\r
-\r
-import com.google.gwt.event.logical.shared.SelectionEvent;\r
-import com.google.gwt.event.logical.shared.SelectionHandler;\r
-import com.google.gwt.user.client.ui.Composite;\r
-import com.google.gwt.user.client.ui.Label;\r
-import com.google.gwt.user.client.ui.TabPanel;\r
-import com.google.gwt.user.client.ui.Widget;\r
-\r
-public class TabWidget extends Composite {\r
-\r
- private TabPanel tab = new TabPanel();\r
-\r
- private Integer nbTab;\r
- private final Integer defaultSelectedTabPosition = 0;\r
- private String selectedTabId;\r
- private int selectedIndex;\r
-\r
- public TabWidget(final SelectionHandler<Integer> selectionListener) {\r
- nbTab = 0;\r
- initWidget(tab);\r
- tab.setWidth("100%");\r
-\r
- tab.addSelectionHandler(new SelectionHandler<Integer>() {\r
- public void onSelection(SelectionEvent<Integer> event) {\r
- selectedTabId = tab.getWidget(event.getSelectedItem()).getElement().getId().replace("_tab_content", "");\r
- selectedIndex = event.getSelectedItem();\r
- selectionListener.onSelection(event);\r
- }\r
- });\r
-\r
- }\r
-\r
- public String getSelectedTabId() {\r
- return selectedTabId;\r
- }\r
-\r
- public Widget getSelectedWidget() {\r
- return tab.getWidget(selectedIndex);\r
- }\r
-\r
- public void addTab(Widget widget, String tabName, String id) {\r
- widget.getElement().setId(id + "_tab_content");\r
- tab.add(widget, createTabLabel(tabName, id));\r
- if (nbTab.equals(defaultSelectedTabPosition)) {\r
- tab.selectTab(defaultSelectedTabPosition);\r
- }\r
- nbTab++;\r
- }\r
-\r
- private Label createTabLabel(String tabName, String id) {\r
- Label tabLabel = new Label(tabName);\r
- tabLabel.getElement().setId(id + "_tab_title");\r
- tabLabel.addStyleName("tab_title");\r
- return tabLabel;\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.clouds.client.widget;
+
+import com.google.gwt.event.logical.shared.SelectionEvent;
+import com.google.gwt.event.logical.shared.SelectionHandler;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.TabPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+public class TabWidget extends Composite {
+
+ private TabPanel tab = new TabPanel();
+
+ private Integer nbTab;
+ private final Integer defaultSelectedTabPosition = 0;
+ private String selectedTabId;
+ private int selectedIndex;
+
+ public TabWidget(final SelectionHandler<Integer> selectionListener) {
+ nbTab = 0;
+ initWidget(tab);
+ tab.setWidth("100%");
+
+ tab.addSelectionHandler(new SelectionHandler<Integer>() {
+ public void onSelection(SelectionEvent<Integer> event) {
+ selectedTabId = tab.getWidget(event.getSelectedItem()).getElement().getId().replace("_tab_content", "");
+ selectedIndex = event.getSelectedItem();
+ selectionListener.onSelection(event);
+ }
+ });
+
+ }
+
+ public String getSelectedTabId() {
+ return selectedTabId;
+ }
+
+ public Widget getSelectedWidget() {
+ return tab.getWidget(selectedIndex);
+ }
+
+ public void addTab(Widget widget, String tabName, String id) {
+ widget.getElement().setId(id + "_tab_content");
+ tab.add(widget, createTabLabel(tabName, id));
+ if (nbTab.equals(defaultSelectedTabPosition)) {
+ tab.selectTab(defaultSelectedTabPosition);
+ }
+ nbTab++;
+ }
+
+ private Label createTabLabel(String tabName, String id) {
+ Label tabLabel = new Label(tabName);
+ tabLabel.getElement().setId(id + "_tab_title");
+ tabLabel.addStyleName("tab_title");
+ return tabLabel;
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.timemachine;\r
-\r
-import java.util.List;\r
-\r
-public class TendencyAnalyser {\r
-\r
- public final static Integer TENDENCY_BIG_UP = 2;\r
- public final static Integer TENDENCY_UP = 1;\r
- public final static Integer TENDENCY_NEUTRAL = 0;\r
- public final static Integer TENDENCY_DOWN = -1;\r
- public final static Integer TENDENCY_BIG_DOWN = -2;\r
-\r
- public Integer analyseLevel(List<Double> values) {\r
- TendencyAnalyser.SlopeData slopeData = analyse(values);\r
- if (slopeData != null) {\r
- return slopeData.getLevel();\r
- }\r
- return null;\r
- }\r
-\r
- public SlopeData analyse(List<Double> values) {\r
- double sumY = 0.0;\r
- double sumX = 0.0;\r
- double sumYPower2 = 0.0;\r
- double sumXY = 0.0;\r
- double sumXPower2 = 0.0;\r
- int nbrPoints = 0;\r
- boolean nullValuesYList = true;\r
- int i = 0;\r
- for (Double p : values) {\r
- if (p != null) {\r
- nullValuesYList = false;\r
- //SumY calculation\r
- sumY += p;\r
- // sumYPower2 calculation\r
- sumYPower2 += p * p;\r
- //sumXY calculation\r
- sumXY += p * (i + 1);\r
- //SumX calculation\r
- sumX += (i + 1);\r
- //sumXPower2 calculation\r
- sumXPower2 += (i + 1) * (i + 1);\r
- //Point number calculation\r
- nbrPoints++;\r
- }\r
- i++;\r
- }\r
- // no tendency if null values or only 1 value\r
- if (nullValuesYList || nbrPoints == 1) {\r
- return null;\r
- }\r
- double n0 = (((nbrPoints) * (sumXY)) - ((sumX) * (sumY)));\r
- double d = (((nbrPoints) * (sumXPower2)) - ((sumX) * (sumX)));\r
- double n1 = (((sumY) * (sumXPower2)) - ((sumX) * (sumXY)));\r
-\r
- SlopeData result = new SlopeData();\r
-\r
- //yIntercept Calculation the value when X equals zero\r
- result.setYIntercept(n1 / d);\r
- // Slope Calculation\r
- if (n0 == 0d && d == 0d) {\r
- result.setSlope(0.0);\r
- } else {\r
- Double slope = n0 / d;\r
- if (Double.isNaN(slope) || Double.isInfinite(slope)) {\r
- result.setSlope(null);\r
- } else {\r
- result.setSlope(slope);\r
- }\r
- }\r
- result.setSumXPower2(sumXPower2);\r
- result.setSumXY(sumXY);\r
- result.setSumYPower2(sumYPower2);\r
-\r
- if (sumXPower2 == 0 || sumYPower2 == 0) {\r
- result.setCorrelationRate(0.0);\r
- } else {\r
- result.setCorrelationRate((sumXY) / (Math.sqrt(sumXPower2 * sumYPower2)));\r
- }\r
-\r
- return result;\r
- }\r
-\r
-\r
- static class SlopeData {\r
- private double sumXPower2;\r
- private double sumYPower2;\r
- private double sumXY;\r
- private double yIntercept; // not used today\r
- private Double slope;\r
- private Double correlationRate;\r
-\r
- public double getSumXPower2() {\r
- return sumXPower2;\r
- }\r
-\r
- public void setSumXPower2(double sumXPower2) {\r
- this.sumXPower2 = sumXPower2;\r
- }\r
-\r
- public double getSumYPower2() {\r
- return sumYPower2;\r
- }\r
-\r
- public void setSumYPower2(double sumYPower2) {\r
- this.sumYPower2 = sumYPower2;\r
- }\r
-\r
- public double getSumXY() {\r
- return sumXY;\r
- }\r
-\r
- public void setSumXY(double sumXY) {\r
- this.sumXY = sumXY;\r
- }\r
-\r
- public double getYIntercept() {\r
- return yIntercept;\r
- }\r
-\r
- public void setYIntercept(double yIntercept) {\r
- this.yIntercept = yIntercept;\r
- }\r
-\r
- public Double getSlope() {\r
- return slope;\r
- }\r
-\r
- public void setSlope(Double slope) {\r
- this.slope = slope;\r
- }\r
-\r
- public Double getCorrelationRate() {\r
- return correlationRate;\r
- }\r
-\r
- public void setCorrelationRate(Double correlationRate) {\r
- this.correlationRate = correlationRate;\r
- }\r
-\r
- public Integer getLevel() {\r
- double hSlope = 0.8;\r
- double nSlope = 0.2;\r
-\r
- double vHighCorcoef = 1.0;\r
- double modCorcoef = 0.69;\r
- Double correlationCoeff = getCorrelationRate();\r
- boolean vHCorCoefPos = (correlationCoeff > modCorcoef) && (correlationCoeff <= vHighCorcoef);\r
- boolean vHCorCoefNeg = (correlationCoeff < -modCorcoef) && (correlationCoeff >= -vHighCorcoef);\r
-\r
- if ((vHCorCoefPos || vHCorCoefNeg) && (slope >= hSlope)) {\r
- return TENDENCY_BIG_UP;\r
-\r
- } else if ((vHCorCoefPos || vHCorCoefNeg) && (slope <= -hSlope)) {\r
- return TENDENCY_BIG_DOWN;\r
-\r
- } else if ((vHCorCoefPos || vHCorCoefNeg) && ((slope >= nSlope) && (slope < hSlope))) {\r
- return TENDENCY_UP;\r
-\r
- } else if ((vHCorCoefPos || vHCorCoefNeg) && ((slope <= -nSlope) && (slope > -hSlope))) {\r
- return TENDENCY_DOWN;\r
-\r
- } else if ((vHCorCoefPos || vHCorCoefNeg) && ((slope < nSlope) || (slope > -nSlope))) {\r
- return TENDENCY_NEUTRAL;\r
-\r
- } else if (correlationCoeff == 0 && slope == 0 && !vHCorCoefPos && !vHCorCoefNeg) {\r
- return TENDENCY_NEUTRAL;\r
- }\r
- return null;\r
- }\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.timemachine;
+
+import java.util.List;
+
+public class TendencyAnalyser {
+
+ public final static Integer TENDENCY_BIG_UP = 2;
+ public final static Integer TENDENCY_UP = 1;
+ public final static Integer TENDENCY_NEUTRAL = 0;
+ public final static Integer TENDENCY_DOWN = -1;
+ public final static Integer TENDENCY_BIG_DOWN = -2;
+
+ public Integer analyseLevel(List<Double> values) {
+ TendencyAnalyser.SlopeData slopeData = analyse(values);
+ if (slopeData != null) {
+ return slopeData.getLevel();
+ }
+ return null;
+ }
+
+ public SlopeData analyse(List<Double> values) {
+ double sumY = 0.0;
+ double sumX = 0.0;
+ double sumYPower2 = 0.0;
+ double sumXY = 0.0;
+ double sumXPower2 = 0.0;
+ int nbrPoints = 0;
+ boolean nullValuesYList = true;
+ int i = 0;
+ for (Double p : values) {
+ if (p != null) {
+ nullValuesYList = false;
+ //SumY calculation
+ sumY += p;
+ // sumYPower2 calculation
+ sumYPower2 += p * p;
+ //sumXY calculation
+ sumXY += p * (i + 1);
+ //SumX calculation
+ sumX += (i + 1);
+ //sumXPower2 calculation
+ sumXPower2 += (i + 1) * (i + 1);
+ //Point number calculation
+ nbrPoints++;
+ }
+ i++;
+ }
+ // no tendency if null values or only 1 value
+ if (nullValuesYList || nbrPoints == 1) {
+ return null;
+ }
+ double n0 = (((nbrPoints) * (sumXY)) - ((sumX) * (sumY)));
+ double d = (((nbrPoints) * (sumXPower2)) - ((sumX) * (sumX)));
+ double n1 = (((sumY) * (sumXPower2)) - ((sumX) * (sumXY)));
+
+ SlopeData result = new SlopeData();
+
+ //yIntercept Calculation the value when X equals zero
+ result.setYIntercept(n1 / d);
+ // Slope Calculation
+ if (n0 == 0d && d == 0d) {
+ result.setSlope(0.0);
+ } else {
+ Double slope = n0 / d;
+ if (Double.isNaN(slope) || Double.isInfinite(slope)) {
+ result.setSlope(null);
+ } else {
+ result.setSlope(slope);
+ }
+ }
+ result.setSumXPower2(sumXPower2);
+ result.setSumXY(sumXY);
+ result.setSumYPower2(sumYPower2);
+
+ if (sumXPower2 == 0 || sumYPower2 == 0) {
+ result.setCorrelationRate(0.0);
+ } else {
+ result.setCorrelationRate((sumXY) / (Math.sqrt(sumXPower2 * sumYPower2)));
+ }
+
+ return result;
+ }
+
+
+ static class SlopeData {
+ private double sumXPower2;
+ private double sumYPower2;
+ private double sumXY;
+ private double yIntercept; // not used today
+ private Double slope;
+ private Double correlationRate;
+
+ public double getSumXPower2() {
+ return sumXPower2;
+ }
+
+ public void setSumXPower2(double sumXPower2) {
+ this.sumXPower2 = sumXPower2;
+ }
+
+ public double getSumYPower2() {
+ return sumYPower2;
+ }
+
+ public void setSumYPower2(double sumYPower2) {
+ this.sumYPower2 = sumYPower2;
+ }
+
+ public double getSumXY() {
+ return sumXY;
+ }
+
+ public void setSumXY(double sumXY) {
+ this.sumXY = sumXY;
+ }
+
+ public double getYIntercept() {
+ return yIntercept;
+ }
+
+ public void setYIntercept(double yIntercept) {
+ this.yIntercept = yIntercept;
+ }
+
+ public Double getSlope() {
+ return slope;
+ }
+
+ public void setSlope(Double slope) {
+ this.slope = slope;
+ }
+
+ public Double getCorrelationRate() {
+ return correlationRate;
+ }
+
+ public void setCorrelationRate(Double correlationRate) {
+ this.correlationRate = correlationRate;
+ }
+
+ public Integer getLevel() {
+ double hSlope = 0.8;
+ double nSlope = 0.2;
+
+ double vHighCorcoef = 1.0;
+ double modCorcoef = 0.69;
+ Double correlationCoeff = getCorrelationRate();
+ boolean vHCorCoefPos = (correlationCoeff > modCorcoef) && (correlationCoeff <= vHighCorcoef);
+ boolean vHCorCoefNeg = (correlationCoeff < -modCorcoef) && (correlationCoeff >= -vHighCorcoef);
+
+ if ((vHCorCoefPos || vHCorCoefNeg) && (slope >= hSlope)) {
+ return TENDENCY_BIG_UP;
+
+ } else if ((vHCorCoefPos || vHCorCoefNeg) && (slope <= -hSlope)) {
+ return TENDENCY_BIG_DOWN;
+
+ } else if ((vHCorCoefPos || vHCorCoefNeg) && ((slope >= nSlope) && (slope < hSlope))) {
+ return TENDENCY_UP;
+
+ } else if ((vHCorCoefPos || vHCorCoefNeg) && ((slope <= -nSlope) && (slope > -hSlope))) {
+ return TENDENCY_DOWN;
+
+ } else if ((vHCorCoefPos || vHCorCoefNeg) && ((slope < nSlope) || (slope > -nSlope))) {
+ return TENDENCY_NEUTRAL;
+
+ } else if (correlationCoeff == 0 && slope == 0 && !vHCorCoefPos && !vHCorCoefNeg) {
+ return TENDENCY_NEUTRAL;
+ }
+ return null;
+ }
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.widgets;\r
-\r
-import org.sonar.api.web.*;\r
-\r
-@WidgetLayout(WidgetLayoutType.NONE)\r
-@Description("Display current alerts on the project.")\r
-public class AlertsWidget extends AbstractRubyTemplate implements RubyRailsWidget {\r
- public String getId() {\r
- return "alerts";\r
- }\r
-\r
- public String getTitle() {\r
- return "Alerts";\r
- }\r
-\r
- @Override\r
- protected String getTemplatePath() {\r
- return "/org/sonar/plugins/core/widgets/alerts.html.erb";\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.web.*;
+
+@WidgetLayout(WidgetLayoutType.NONE)
+@Description("Display current alerts on the project.")
+public class AlertsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ public String getId() {
+ return "alerts";
+ }
+
+ public String getTitle() {
+ return "Alerts";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/org/sonar/plugins/core/widgets/alerts.html.erb";
+ }
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.widgets;\r
-\r
-import org.sonar.api.web.AbstractRubyTemplate;\r
-import org.sonar.api.web.Description;\r
-import org.sonar.api.web.RubyRailsWidget;\r
-import org.sonar.api.web.WidgetCategory;\r
-\r
-@WidgetCategory({"Tests"})\r
-@Description("Reports on units tests and code coverage by unit tests.")\r
-public class CodeCoverageWidget extends AbstractRubyTemplate implements RubyRailsWidget {\r
- public String getId() {\r
- return "code_coverage";\r
- }\r
-\r
- public String getTitle() {\r
- return "Code coverage";\r
- }\r
-\r
- @Override\r
- protected String getTemplatePath() {\r
- return "/org/sonar/plugins/core/widgets/code_coverage.html.erb";\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.web.AbstractRubyTemplate;
+import org.sonar.api.web.Description;
+import org.sonar.api.web.RubyRailsWidget;
+import org.sonar.api.web.WidgetCategory;
+
+@WidgetCategory({"Tests"})
+@Description("Reports on units tests and code coverage by unit tests.")
+public class CodeCoverageWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ public String getId() {
+ return "code_coverage";
+ }
+
+ public String getTitle() {
+ return "Code coverage";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/org/sonar/plugins/core/widgets/code_coverage.html.erb";
+ }
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.widgets;\r
-\r
-import org.sonar.api.web.AbstractRubyTemplate;\r
-import org.sonar.api.web.Description;\r
-import org.sonar.api.web.RubyRailsWidget;\r
-\r
-@Description("Reports on copy/paste and documentation")\r
-public class CommentsDuplicationsWidget extends AbstractRubyTemplate implements RubyRailsWidget {\r
- public String getId() {\r
- return "comments_duplications";\r
- }\r
-\r
- public String getTitle() {\r
- return "Comments & Duplications";\r
- }\r
-\r
- @Override\r
- protected String getTemplatePath() {\r
- return "/org/sonar/plugins/core/widgets/comments_duplications.html.erb";\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.web.AbstractRubyTemplate;
+import org.sonar.api.web.Description;
+import org.sonar.api.web.RubyRailsWidget;
+
+@Description("Reports on copy/paste and documentation")
+public class CommentsDuplicationsWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ public String getId() {
+ return "comments_duplications";
+ }
+
+ public String getTitle() {
+ return "Comments & Duplications";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/org/sonar/plugins/core/widgets/comments_duplications.html.erb";
+ }
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.widgets;\r
-\r
-import org.sonar.api.web.AbstractRubyTemplate;\r
-import org.sonar.api.web.Description;\r
-import org.sonar.api.web.RubyRailsWidget;\r
-\r
-@Description("Reports on complexity, average complexity and complexity distribution.")\r
-public class ComplexityWidget extends AbstractRubyTemplate implements RubyRailsWidget {\r
- public String getId() {\r
- return "complexity";\r
- }\r
-\r
- public String getTitle() {\r
- return "Complexity";\r
- }\r
-\r
- @Override\r
- protected String getTemplatePath() {\r
- return "/org/sonar/plugins/core/widgets/complexity.html.erb";\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.web.AbstractRubyTemplate;
+import org.sonar.api.web.Description;
+import org.sonar.api.web.RubyRailsWidget;
+
+@Description("Reports on complexity, average complexity and complexity distribution.")
+public class ComplexityWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ public String getId() {
+ return "complexity";
+ }
+
+ public String getTitle() {
+ return "Complexity";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/org/sonar/plugins/core/widgets/complexity.html.erb";
+ }
}
\ No newline at end of file
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.widgets;\r
-\r
-import org.sonar.api.web.*;\r
-\r
-@WidgetLayout(WidgetLayoutType.NONE)\r
-@Description("Displays general project information taken from the pom.xml")\r
-public class DescriptionWidget extends AbstractRubyTemplate implements RubyRailsWidget {\r
- public String getId() {\r
- return "description";\r
- }\r
-\r
- public String getTitle() {\r
- return "Description";\r
- }\r
-\r
- @Override\r
- protected String getTemplatePath() {\r
- return "/org/sonar/plugins/core/widgets/description.html.erb";\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.web.*;
+
+@WidgetLayout(WidgetLayoutType.NONE)
+@Description("Displays general project information taken from the pom.xml")
+public class DescriptionWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ public String getId() {
+ return "description";
+ }
+
+ public String getTitle() {
+ return "Description";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/org/sonar/plugins/core/widgets/description.html.erb";
+ }
}
\ No newline at end of file
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.widgets;\r
-\r
-import org.sonar.api.web.*;\r
-\r
-@WidgetCategory({"Rules"})\r
-@Description("Reports violations and compliance index on coding standards.")\r
-public class RulesWidget extends AbstractRubyTemplate implements RubyRailsWidget {\r
- public String getId() {\r
- return "rules";\r
- }\r
-\r
- public String getTitle() {\r
- return "Rules Compliance";\r
- }\r
-\r
- @Override\r
- protected String getTemplatePath() {\r
- return "/org/sonar/plugins/core/widgets/rules.html.erb";\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.web.*;
+
+@WidgetCategory({"Rules"})
+@Description("Reports violations and compliance index on coding standards.")
+public class RulesWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ public String getId() {
+ return "rules";
+ }
+
+ public String getTitle() {
+ return "Rules Compliance";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/org/sonar/plugins/core/widgets/rules.html.erb";
+ }
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.widgets;\r
-\r
-import org.sonar.api.web.AbstractRubyTemplate;\r
-import org.sonar.api.web.Description;\r
-import org.sonar.api.web.RubyRailsWidget;\r
-\r
-@Description("Reports general metrics on the size of the project.")\r
-public class SizeWidget extends AbstractRubyTemplate implements RubyRailsWidget {\r
- public String getId() {\r
- return "size";\r
- }\r
-\r
- public String getTitle() {\r
- return "Size metrics";\r
- }\r
-\r
- @Override\r
- protected String getTemplatePath() {\r
- return "/org/sonar/plugins/core/widgets/size.html.erb";\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.widgets;
+
+import org.sonar.api.web.AbstractRubyTemplate;
+import org.sonar.api.web.Description;
+import org.sonar.api.web.RubyRailsWidget;
+
+@Description("Reports general metrics on the size of the project.")
+public class SizeWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+ public String getId() {
+ return "size";
+ }
+
+ public String getTitle() {
+ return "Size metrics";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/org/sonar/plugins/core/widgets/size.html.erb";
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.core.timemachine;\r
-\r
-import org.junit.Test;\r
-\r
-import java.util.Arrays;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import static org.hamcrest.CoreMatchers.nullValue;\r
-import static org.junit.Assert.*;\r
-\r
-public class TendencyAnalyserTest {\r
- private TendencyAnalyser analyser = new TendencyAnalyser();\r
-\r
- private List<Double> getValues(Double[] array) {\r
- return Arrays.asList(array);\r
- }\r
-\r
-\r
- protected void assertBetween(String typeLabel, Double value, Double min, Double max) {\r
- assertTrue(typeLabel + " " + value + "<" + min, value >= min);\r
- assertTrue(typeLabel + "=" + value + ">" + max, value <= max);\r
- }\r
-\r
- @Test\r
- public void testNoData() {\r
- assertThat(analyser.analyse(Collections.<Double>emptyList()), nullValue());\r
- }\r
-\r
- @Test\r
- public void testNotEnoughData() {\r
- assertThat(analyser.analyseLevel(Arrays.asList(10.0)), nullValue());\r
- }\r
-\r
- @Test\r
- public void testTendencyOnThreeDays() {\r
- Double[] doubles = new Double[]{10.0, null, 9.9};\r
- TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));\r
- assertBetween("slope", slopeData.getSlope(), -0.5, 0.5);\r
- assertEquals(TendencyAnalyser.TENDENCY_NEUTRAL, slopeData.getLevel());\r
- }\r
-\r
- @Test\r
- public void testTendencyOnTwoZeroDays() {\r
- Double[] doubles = new Double[]{0.0, 0.0};\r
- TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));\r
- assertBetween("slope", slopeData.getSlope(), -0.0, 0.0);\r
- assertEquals(TendencyAnalyser.TENDENCY_NEUTRAL, slopeData.getLevel());\r
- }\r
-\r
- @Test\r
- public void testTendencyOnThreeZeroDays() {\r
- Double[] doubles = new Double[]{0.0, 0.0, 0.0};\r
- TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));\r
- assertBetween("slope", slopeData.getSlope(), -0.0, 0.0);\r
- assertEquals(TendencyAnalyser.TENDENCY_NEUTRAL, slopeData.getLevel());\r
- }\r
-\r
- @Test\r
- public void testBigDownOnThreeDays() {\r
- Double[] doubles = new Double[]{90.0, 91.0, 50.0};\r
- TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));\r
- assertTrue("slope", slopeData.getSlope() < -2.0);\r
- assertEquals(TendencyAnalyser.TENDENCY_BIG_DOWN, slopeData.getLevel());\r
- }\r
-\r
- @Test\r
- public void testFlatTendency() {\r
- Double[] doubles = new Double[]{10.0, 10.2, 9.9};\r
- TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));\r
- assertBetween("slope", slopeData.getSlope(), -0.5, 0.5);\r
- assertEquals(TendencyAnalyser.TENDENCY_NEUTRAL, slopeData.getLevel());\r
- }\r
-\r
- @Test\r
- public void testFlatTendencyWithPeak() {\r
- Double[] doubles = new Double[]{10.0, 15.0, 10.0};\r
- TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));\r
- assertBetween("slope", slopeData.getSlope(), -0.5, 0.5);\r
- assertEquals(TendencyAnalyser.TENDENCY_NEUTRAL, slopeData.getLevel());\r
- }\r
-\r
- @Test\r
- public void testBigUpTendencyOnThreeValues() {\r
- Double[] doubles = new Double[]{10.0, 12.0, 15.5};\r
- TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));\r
- assertBetween("slope", slopeData.getSlope(), 2.5, 3.0);\r
- assertEquals(TendencyAnalyser.TENDENCY_BIG_UP, slopeData.getLevel());\r
- }\r
-\r
- @Test\r
- public void testBigUpTendencyOnTenValues() {\r
- Double[] doubles = new Double[]{45.0, 60.0, 57.0, 65.0, 58.0, 68.0, 59.0, 66.0, 76.0, 80.0};\r
- TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));\r
- assertBetween("slope", slopeData.getSlope(), 2.5, 3.0);\r
- assertEquals(TendencyAnalyser.TENDENCY_BIG_UP, slopeData.getLevel());\r
- }\r
-\r
- @Test\r
- public void testMediumUpTendency() {\r
- Double[] doubles = new Double[]{5.0, 4.5, 5.1, 5.5, 5.3, 6.4, 6.3, 6.6, 6.8, 6.5};\r
- TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));\r
- assertBetween("slope", slopeData.getSlope(), 0.0, 1.0);\r
- assertEquals(TendencyAnalyser.TENDENCY_UP, slopeData.getLevel());\r
- }\r
-\r
- @Test\r
- public void testAsymetricAlgorithm() {\r
- TendencyAnalyser.SlopeData slopeData1 = analyser.analyse(getValues(new Double[]{45.0, 47.0, 95.0}));\r
- TendencyAnalyser.SlopeData slopeData2 = analyser.analyse(getValues(new Double[]{95.0, 45.0, 47.0}));\r
- assertTrue(slopeData1.getSlope() != slopeData2.getSlope());\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.core.timemachine;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.*;
+
+public class TendencyAnalyserTest {
+ private TendencyAnalyser analyser = new TendencyAnalyser();
+
+ private List<Double> getValues(Double[] array) {
+ return Arrays.asList(array);
+ }
+
+
+ protected void assertBetween(String typeLabel, Double value, Double min, Double max) {
+ assertTrue(typeLabel + " " + value + "<" + min, value >= min);
+ assertTrue(typeLabel + "=" + value + ">" + max, value <= max);
+ }
+
+ @Test
+ public void testNoData() {
+ assertThat(analyser.analyse(Collections.<Double>emptyList()), nullValue());
+ }
+
+ @Test
+ public void testNotEnoughData() {
+ assertThat(analyser.analyseLevel(Arrays.asList(10.0)), nullValue());
+ }
+
+ @Test
+ public void testTendencyOnThreeDays() {
+ Double[] doubles = new Double[]{10.0, null, 9.9};
+ TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));
+ assertBetween("slope", slopeData.getSlope(), -0.5, 0.5);
+ assertEquals(TendencyAnalyser.TENDENCY_NEUTRAL, slopeData.getLevel());
+ }
+
+ @Test
+ public void testTendencyOnTwoZeroDays() {
+ Double[] doubles = new Double[]{0.0, 0.0};
+ TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));
+ assertBetween("slope", slopeData.getSlope(), -0.0, 0.0);
+ assertEquals(TendencyAnalyser.TENDENCY_NEUTRAL, slopeData.getLevel());
+ }
+
+ @Test
+ public void testTendencyOnThreeZeroDays() {
+ Double[] doubles = new Double[]{0.0, 0.0, 0.0};
+ TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));
+ assertBetween("slope", slopeData.getSlope(), -0.0, 0.0);
+ assertEquals(TendencyAnalyser.TENDENCY_NEUTRAL, slopeData.getLevel());
+ }
+
+ @Test
+ public void testBigDownOnThreeDays() {
+ Double[] doubles = new Double[]{90.0, 91.0, 50.0};
+ TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));
+ assertTrue("slope", slopeData.getSlope() < -2.0);
+ assertEquals(TendencyAnalyser.TENDENCY_BIG_DOWN, slopeData.getLevel());
+ }
+
+ @Test
+ public void testFlatTendency() {
+ Double[] doubles = new Double[]{10.0, 10.2, 9.9};
+ TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));
+ assertBetween("slope", slopeData.getSlope(), -0.5, 0.5);
+ assertEquals(TendencyAnalyser.TENDENCY_NEUTRAL, slopeData.getLevel());
+ }
+
+ @Test
+ public void testFlatTendencyWithPeak() {
+ Double[] doubles = new Double[]{10.0, 15.0, 10.0};
+ TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));
+ assertBetween("slope", slopeData.getSlope(), -0.5, 0.5);
+ assertEquals(TendencyAnalyser.TENDENCY_NEUTRAL, slopeData.getLevel());
+ }
+
+ @Test
+ public void testBigUpTendencyOnThreeValues() {
+ Double[] doubles = new Double[]{10.0, 12.0, 15.5};
+ TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));
+ assertBetween("slope", slopeData.getSlope(), 2.5, 3.0);
+ assertEquals(TendencyAnalyser.TENDENCY_BIG_UP, slopeData.getLevel());
+ }
+
+ @Test
+ public void testBigUpTendencyOnTenValues() {
+ Double[] doubles = new Double[]{45.0, 60.0, 57.0, 65.0, 58.0, 68.0, 59.0, 66.0, 76.0, 80.0};
+ TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));
+ assertBetween("slope", slopeData.getSlope(), 2.5, 3.0);
+ assertEquals(TendencyAnalyser.TENDENCY_BIG_UP, slopeData.getLevel());
+ }
+
+ @Test
+ public void testMediumUpTendency() {
+ Double[] doubles = new Double[]{5.0, 4.5, 5.1, 5.5, 5.3, 6.4, 6.3, 6.6, 6.8, 6.5};
+ TendencyAnalyser.SlopeData slopeData = analyser.analyse(getValues(doubles));
+ assertBetween("slope", slopeData.getSlope(), 0.0, 1.0);
+ assertEquals(TendencyAnalyser.TENDENCY_UP, slopeData.getLevel());
+ }
+
+ @Test
+ public void testAsymetricAlgorithm() {
+ TendencyAnalyser.SlopeData slopeData1 = analyser.analyse(getValues(new Double[]{45.0, 47.0, 95.0}));
+ TendencyAnalyser.SlopeData slopeData2 = analyser.analyse(getValues(new Double[]{95.0, 45.0, 47.0}));
+ assertTrue(slopeData1.getSlope() != slopeData2.getSlope());
+ }
}
\ No newline at end of file
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.dbcleaner;\r
-\r
-import org.sonar.api.Plugin;\r
-import org.sonar.api.Properties;\r
-import org.sonar.api.Property;\r
-import org.sonar.plugins.dbcleaner.api.DbCleanerConstants;\r
-import org.sonar.plugins.dbcleaner.period.DefaultPeriodCleaner;\r
-import org.sonar.plugins.dbcleaner.period.PeriodPurge;\r
-import org.sonar.plugins.dbcleaner.purges.*;\r
-import org.sonar.plugins.dbcleaner.runner.PurgeRunner;\r
-\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-@Properties({\r
- @Property(key = DbCleanerConstants.MONTHS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_WEEK,\r
- defaultValue = DbCleanerConstants.ONE_MONTH, name = "Number of months before starting to keep only one snapshot by week",\r
- description = "After this number of months, if there are several snapshots during the same week, "\r
- + "the DbCleaner keeps the first one and fully delete the other ones.", global = true, project = true),\r
- @Property(key = DbCleanerConstants.MONTHS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_MONTH,\r
- defaultValue = DbCleanerConstants.ONE_YEAR, name = "Number of months before starting to keep only one snapshot by month",\r
- description = "After this number of months, if there are several snapshots during the same month, "\r
- + "the DbCleaner keeps the first one and fully delete the other ones.", global = true, project = true),\r
- @Property(key = DbCleanerConstants.MONTHS_BEFORE_DELETING_ALL_SNAPSHOTS, defaultValue = DbCleanerConstants.FIVE_YEARS,\r
- name = "Number of months before starting to delete all remaining snapshots",\r
- description = "After this number of months, all snapshots are fully deleted.", global = true, project = true)})\r
-public final class DbCleanerPlugin implements Plugin {\r
-\r
- @Override\r
- public String toString() {\r
- return DbCleanerConstants.PLUGIN_NAME;\r
- }\r
-\r
- public String getKey() {\r
- return DbCleanerConstants.PLUGIN_KEY;\r
- }\r
-\r
- public String getName() {\r
- return DbCleanerConstants.PLUGIN_NAME;\r
- }\r
-\r
- public String getDescription() {\r
- return "The DbCleaner optimizes the Sonar DB performances by removing old and useless quality snapshots.";\r
- }\r
-\r
- public List getExtensions() {\r
- return Arrays.asList(\r
- // shared components\r
- DefaultPeriodCleaner.class,\r
-\r
- // purges\r
- PurgeOrphanResources.class, PurgeEntities.class, PurgeRuleMeasures.class, PurgeUnprocessed.class,\r
- PurgeDeletedResources.class, PurgeDeprecatedLast.class, UnflagLastDoublons.class, PurgeDisabledResources.class,\r
- PurgeResourceRoles.class, PurgeEventOrphans.class, PurgePropertyOrphans.class, PeriodPurge.class, PurgeDependencies.class,\r
-\r
- // post-job\r
- PurgeRunner.class);\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.dbcleaner;
+
+import org.sonar.api.Plugin;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.plugins.dbcleaner.api.DbCleanerConstants;
+import org.sonar.plugins.dbcleaner.period.DefaultPeriodCleaner;
+import org.sonar.plugins.dbcleaner.period.PeriodPurge;
+import org.sonar.plugins.dbcleaner.purges.*;
+import org.sonar.plugins.dbcleaner.runner.PurgeRunner;
+
+import java.util.Arrays;
+import java.util.List;
+
+@Properties({
+ @Property(key = DbCleanerConstants.MONTHS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_WEEK,
+ defaultValue = DbCleanerConstants.ONE_MONTH, name = "Number of months before starting to keep only one snapshot by week",
+ description = "After this number of months, if there are several snapshots during the same week, "
+ + "the DbCleaner keeps the first one and fully delete the other ones.", global = true, project = true),
+ @Property(key = DbCleanerConstants.MONTHS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_MONTH,
+ defaultValue = DbCleanerConstants.ONE_YEAR, name = "Number of months before starting to keep only one snapshot by month",
+ description = "After this number of months, if there are several snapshots during the same month, "
+ + "the DbCleaner keeps the first one and fully delete the other ones.", global = true, project = true),
+ @Property(key = DbCleanerConstants.MONTHS_BEFORE_DELETING_ALL_SNAPSHOTS, defaultValue = DbCleanerConstants.FIVE_YEARS,
+ name = "Number of months before starting to delete all remaining snapshots",
+ description = "After this number of months, all snapshots are fully deleted.", global = true, project = true)})
+public final class DbCleanerPlugin implements Plugin {
+
+ @Override
+ public String toString() {
+ return DbCleanerConstants.PLUGIN_NAME;
+ }
+
+ public String getKey() {
+ return DbCleanerConstants.PLUGIN_KEY;
+ }
+
+ public String getName() {
+ return DbCleanerConstants.PLUGIN_NAME;
+ }
+
+ public String getDescription() {
+ return "The DbCleaner optimizes the Sonar DB performances by removing old and useless quality snapshots.";
+ }
+
+ public List getExtensions() {
+ return Arrays.asList(
+ // shared components
+ DefaultPeriodCleaner.class,
+
+ // purges
+ PurgeOrphanResources.class, PurgeEntities.class, PurgeRuleMeasures.class, PurgeUnprocessed.class,
+ PurgeDeletedResources.class, PurgeDeprecatedLast.class, UnflagLastDoublons.class, PurgeDisabledResources.class,
+ PurgeResourceRoles.class, PurgeEventOrphans.class, PurgePropertyOrphans.class, PeriodPurge.class, PurgeDependencies.class,
+
+ // post-job
+ PurgeRunner.class);
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.dbcleaner.period;\r
-\r
-import org.sonar.api.batch.Event;\r
-import org.sonar.api.database.DatabaseSession;\r
-import org.sonar.api.database.model.Snapshot;\r
-\r
-import javax.persistence.Query;\r
-import java.util.List;\r
-\r
-final class SQLRequests {\r
-\r
- private final DatabaseSession session;\r
-\r
- SQLRequests(DatabaseSession session) {\r
- this.session = session;\r
- }\r
-\r
- List<Snapshot> getProjectSnapshotsOrderedByCreatedAt(int oneProjectSnapshotId) {\r
- Query query = session.createQuery("FROM " + Snapshot.class.getSimpleName()\r
- + " sp1 WHERE sp1.resourceId = (select sp2.resourceId FROM " + Snapshot.class.getSimpleName()\r
- + " sp2 WHERE sp2.id = :id) and sp1.rootId= null and not exists (from " + Event.class.getSimpleName() + " e where e.snapshot=sp1) order by sp1.createdAt");\r
- query.setParameter("id", oneProjectSnapshotId);\r
- return query.getResultList();\r
- }\r
-\r
- List<Integer> getChildIds(Snapshot parentSnapshot) {\r
- Query query = session.createQuery("select sp.id FROM " + Snapshot.class.getSimpleName()\r
- + " sp WHERE sp.rootId = :rootId or id = :rootId");\r
- query.setParameter("rootId", parentSnapshot.getId());\r
- return query.getResultList();\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.dbcleaner.period;
+
+import org.sonar.api.batch.Event;
+import org.sonar.api.database.DatabaseSession;
+import org.sonar.api.database.model.Snapshot;
+
+import javax.persistence.Query;
+import java.util.List;
+
+final class SQLRequests {
+
+ private final DatabaseSession session;
+
+ SQLRequests(DatabaseSession session) {
+ this.session = session;
+ }
+
+ List<Snapshot> getProjectSnapshotsOrderedByCreatedAt(int oneProjectSnapshotId) {
+ Query query = session.createQuery("FROM " + Snapshot.class.getSimpleName()
+ + " sp1 WHERE sp1.resourceId = (select sp2.resourceId FROM " + Snapshot.class.getSimpleName()
+ + " sp2 WHERE sp2.id = :id) and sp1.rootId= null and not exists (from " + Event.class.getSimpleName() + " e where e.snapshot=sp1) order by sp1.createdAt");
+ query.setParameter("id", oneProjectSnapshotId);
+ return query.getResultList();
+ }
+
+ List<Integer> getChildIds(Snapshot parentSnapshot) {
+ Query query = session.createQuery("select sp.id FROM " + Snapshot.class.getSimpleName()
+ + " sp WHERE sp.rootId = :rootId or id = :rootId");
+ query.setParameter("rootId", parentSnapshot.getId());
+ return query.getResultList();
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
<!--
~ Sonar, open source software quality management tool.
- ~ Copyright (C) 2009 SonarSource SA
+ ~ Copyright (C) 2008-2011 SonarSource
~ mailto:contact AT sonarsource DOT com
~
~ Sonar is free software; you can redistribute it and/or
<!--
~ Sonar, open source software quality management tool.
- ~ Copyright (C) 2009 SonarSource SA
+ ~ Copyright (C) 2008-2011 SonarSource
~ mailto:contact AT sonarsource DOT com
~
~ Sonar is free software; you can redistribute it and/or
<!--
~ Sonar, open source software quality management tool.
- ~ Copyright (C) 2009 SonarSource SA
+ ~ Copyright (C) 2008-2011 SonarSource
~ mailto:contact AT sonarsource DOT com
~
~ Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.findbugs;\r
-\r
-import java.io.File;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.xml.stream.XMLInputFactory;\r
-import javax.xml.stream.XMLStreamException;\r
-\r
-import org.codehaus.staxmate.SMInputFactory;\r
-import org.codehaus.staxmate.in.SMInputCursor;\r
-import org.sonar.api.utils.SonarException;\r
-import org.sonar.api.utils.XmlParserException;\r
-\r
-class FindbugsXmlReportParser {\r
-\r
- private final File findbugsXmlReport;\r
- private final String findbugsXmlReportPath;\r
-\r
- public FindbugsXmlReportParser(File findbugsXmlReport) {\r
- this.findbugsXmlReport = findbugsXmlReport;\r
- findbugsXmlReportPath = findbugsXmlReport.getAbsolutePath();\r
- if ( !findbugsXmlReport.exists()) {\r
- throw new SonarException("The findbugs XML report can't be found at '" + findbugsXmlReportPath + "'");\r
- }\r
- }\r
-\r
- public List<Violation> getViolations() {\r
- List<Violation> violations = new ArrayList<Violation>();\r
- try {\r
- SMInputFactory inf = new SMInputFactory(XMLInputFactory.newInstance());\r
- SMInputCursor cursor = inf.rootElementCursor(findbugsXmlReport).advance();\r
- SMInputCursor bugInstanceCursor = cursor.childElementCursor("BugInstance").advance();\r
- while (bugInstanceCursor.asEvent() != null) {\r
- String type = bugInstanceCursor.getAttrValue("type");\r
- String longMessage = "";\r
- SMInputCursor bugInstanceChildCursor = bugInstanceCursor.childElementCursor().advance();\r
- while (bugInstanceChildCursor.asEvent() != null) {\r
- String nodeName = bugInstanceChildCursor.getLocalName();\r
- if ("LongMessage".equals(nodeName)) {\r
- longMessage = bugInstanceChildCursor.collectDescendantText();\r
- } else if ("SourceLine".equals(nodeName)) {\r
- Violation fbViolation = new Violation();\r
- fbViolation.type = type;\r
- fbViolation.longMessage = longMessage;\r
- fbViolation.parseStart(bugInstanceChildCursor.getAttrValue("start"));\r
- fbViolation.parseEnd(bugInstanceChildCursor.getAttrValue("end"));\r
- fbViolation.className = bugInstanceChildCursor.getAttrValue("classname");\r
- fbViolation.sourcePath = bugInstanceChildCursor.getAttrValue("sourcepath");\r
- violations.add(fbViolation);\r
- }\r
- bugInstanceChildCursor.advance();\r
- }\r
- bugInstanceCursor.advance();\r
- }\r
- cursor.getStreamReader().closeCompletely();\r
- } catch (XMLStreamException e) {\r
- throw new XmlParserException("Unable to parse the Findbugs XML Report '" + findbugsXmlReportPath + "'", e);\r
- }\r
- return violations;\r
- }\r
-\r
- public static class Violation {\r
-\r
- private String type;\r
- private String longMessage;\r
- private Integer start;\r
- private Integer end;\r
- protected String className;\r
- protected String sourcePath;\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void parseStart(String attrValue) {\r
- try {\r
- start = Integer.parseInt(attrValue);\r
- } catch (NumberFormatException e) {\r
- start = null;\r
- }\r
- }\r
-\r
- public void parseEnd(String attrValue) {\r
- try {\r
- end = Integer.parseInt(attrValue);\r
- } catch (NumberFormatException e) {\r
- end = null;\r
- }\r
- }\r
-\r
- public String getLongMessage() {\r
- return longMessage;\r
- }\r
-\r
- public Integer getStart() {\r
- return start;\r
- }\r
-\r
- public Integer getEnd() {\r
- return end;\r
- }\r
-\r
- public String getClassName() {\r
- return className;\r
- }\r
-\r
- public String getSourcePath() {\r
- return sourcePath;\r
- }\r
-\r
- public String getSonarJavaFileKey() {\r
- if (className.indexOf('$') > -1) {\r
- return className.substring(0, className.indexOf('$'));\r
- }\r
- return className;\r
- }\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+
+import org.codehaus.staxmate.SMInputFactory;
+import org.codehaus.staxmate.in.SMInputCursor;
+import org.sonar.api.utils.SonarException;
+import org.sonar.api.utils.XmlParserException;
+
+class FindbugsXmlReportParser {
+
+ private final File findbugsXmlReport;
+ private final String findbugsXmlReportPath;
+
+ public FindbugsXmlReportParser(File findbugsXmlReport) {
+ this.findbugsXmlReport = findbugsXmlReport;
+ findbugsXmlReportPath = findbugsXmlReport.getAbsolutePath();
+ if ( !findbugsXmlReport.exists()) {
+ throw new SonarException("The findbugs XML report can't be found at '" + findbugsXmlReportPath + "'");
+ }
+ }
+
+ public List<Violation> getViolations() {
+ List<Violation> violations = new ArrayList<Violation>();
+ try {
+ SMInputFactory inf = new SMInputFactory(XMLInputFactory.newInstance());
+ SMInputCursor cursor = inf.rootElementCursor(findbugsXmlReport).advance();
+ SMInputCursor bugInstanceCursor = cursor.childElementCursor("BugInstance").advance();
+ while (bugInstanceCursor.asEvent() != null) {
+ String type = bugInstanceCursor.getAttrValue("type");
+ String longMessage = "";
+ SMInputCursor bugInstanceChildCursor = bugInstanceCursor.childElementCursor().advance();
+ while (bugInstanceChildCursor.asEvent() != null) {
+ String nodeName = bugInstanceChildCursor.getLocalName();
+ if ("LongMessage".equals(nodeName)) {
+ longMessage = bugInstanceChildCursor.collectDescendantText();
+ } else if ("SourceLine".equals(nodeName)) {
+ Violation fbViolation = new Violation();
+ fbViolation.type = type;
+ fbViolation.longMessage = longMessage;
+ fbViolation.parseStart(bugInstanceChildCursor.getAttrValue("start"));
+ fbViolation.parseEnd(bugInstanceChildCursor.getAttrValue("end"));
+ fbViolation.className = bugInstanceChildCursor.getAttrValue("classname");
+ fbViolation.sourcePath = bugInstanceChildCursor.getAttrValue("sourcepath");
+ violations.add(fbViolation);
+ }
+ bugInstanceChildCursor.advance();
+ }
+ bugInstanceCursor.advance();
+ }
+ cursor.getStreamReader().closeCompletely();
+ } catch (XMLStreamException e) {
+ throw new XmlParserException("Unable to parse the Findbugs XML Report '" + findbugsXmlReportPath + "'", e);
+ }
+ return violations;
+ }
+
+ public static class Violation {
+
+ private String type;
+ private String longMessage;
+ private Integer start;
+ private Integer end;
+ protected String className;
+ protected String sourcePath;
+
+ public String getType() {
+ return type;
+ }
+
+ public void parseStart(String attrValue) {
+ try {
+ start = Integer.parseInt(attrValue);
+ } catch (NumberFormatException e) {
+ start = null;
+ }
+ }
+
+ public void parseEnd(String attrValue) {
+ try {
+ end = Integer.parseInt(attrValue);
+ } catch (NumberFormatException e) {
+ end = null;
+ }
+ }
+
+ public String getLongMessage() {
+ return longMessage;
+ }
+
+ public Integer getStart() {
+ return start;
+ }
+
+ public Integer getEnd() {
+ return end;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getSourcePath() {
+ return sourcePath;
+ }
+
+ public String getSonarJavaFileKey() {
+ if (className.indexOf('$') > -1) {
+ return className.substring(0, className.indexOf('$'));
+ }
+ return className;
+ }
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.googleanalytics;\r
-\r
-import org.apache.commons.configuration.Configuration;\r
-import org.sonar.api.CoreProperties;\r
-import org.sonar.api.web.Footer;\r
-\r
-public class GoogleAnalyticsWebFooter implements Footer {\r
-\r
- private Configuration configuration;\r
-\r
- public GoogleAnalyticsWebFooter(Configuration configuration) {\r
- this.configuration = configuration;\r
- }\r
-\r
- protected String getIdAccount() {\r
- return configuration.getString(CoreProperties.GOOGLE_ANALYTICS_ACCOUNT_PROPERTY, "");\r
- }\r
-\r
- public String getKey() {\r
- return "webfooter_" + CoreProperties.GOOGLE_ANALYTICS_PLUGIN;\r
- }\r
-\r
- public String getHtml() {\r
- String id = getIdAccount();\r
- if (id != null && !"".equals(id)) {\r
- return "<script type=\"text/javascript\">\n" +\r
- "var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\n" +\r
- "document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));\n" +\r
- "</script>\n" +\r
- "<script type=\"text/javascript\">\n" +\r
- "var pageTracker = _gat._getTracker(\"" + id + "\");\n" +\r
- "pageTracker._initData();\n" +\r
- "pageTracker._trackPageview();\n" +\r
- "</script>";\r
- }\r
- return null;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return getKey();\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.googleanalytics;
+
+import org.apache.commons.configuration.Configuration;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.web.Footer;
+
+public class GoogleAnalyticsWebFooter implements Footer {
+
+ private Configuration configuration;
+
+ public GoogleAnalyticsWebFooter(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ protected String getIdAccount() {
+ return configuration.getString(CoreProperties.GOOGLE_ANALYTICS_ACCOUNT_PROPERTY, "");
+ }
+
+ public String getKey() {
+ return "webfooter_" + CoreProperties.GOOGLE_ANALYTICS_PLUGIN;
+ }
+
+ public String getHtml() {
+ String id = getIdAccount();
+ if (id != null && !"".equals(id)) {
+ return "<script type=\"text/javascript\">\n" +
+ "var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\n" +
+ "document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));\n" +
+ "</script>\n" +
+ "<script type=\"text/javascript\">\n" +
+ "var pageTracker = _gat._getTracker(\"" + id + "\");\n" +
+ "pageTracker._initData();\n" +
+ "pageTracker._trackPageview();\n" +
+ "</script>";
+ }
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return getKey();
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.pmd;\r
-\r
-import org.apache.commons.lang.StringUtils;\r
-import org.codehaus.staxmate.in.SMInputCursor;\r
-import org.sonar.api.CoreProperties;\r
-import org.sonar.api.batch.AbstractViolationsStaxParser;\r
-import org.sonar.api.batch.SensorContext;\r
-import org.sonar.api.profiles.RulesProfile;\r
-import org.sonar.api.resources.JavaFile;\r
-import org.sonar.api.resources.Project;\r
-import org.sonar.api.resources.Resource;\r
-import org.sonar.api.rules.RulesManager;\r
-\r
-import javax.xml.stream.XMLStreamException;\r
-\r
-class PmdViolationsXmlParser extends AbstractViolationsStaxParser {\r
-\r
- private Project project;\r
-\r
- PmdViolationsXmlParser(Project project, SensorContext context, RulesManager rulesManager, RulesProfile profile) {\r
- super(context, rulesManager, profile);\r
- this.project = project;\r
- }\r
-\r
- @Override\r
- protected String keyForPlugin() {\r
- return CoreProperties.PMD_PLUGIN;\r
- }\r
-\r
- @Override\r
- protected SMInputCursor cursorForResources(SMInputCursor rootCursor) throws XMLStreamException {\r
- return rootCursor.descendantElementCursor("file");\r
- }\r
-\r
- @Override\r
- protected SMInputCursor cursorForViolations(SMInputCursor resourcesCursor) throws XMLStreamException {\r
- return resourcesCursor.descendantElementCursor("violation");\r
- }\r
-\r
- @Override\r
- protected String lineNumberForViolation(SMInputCursor violationCursor) throws XMLStreamException {\r
- return violationCursor.getAttrValue("beginline");\r
- }\r
-\r
- @Override\r
- protected String messageFor(SMInputCursor violationCursor) throws XMLStreamException {\r
- return StringUtils.trim(violationCursor.collectDescendantText());\r
- }\r
-\r
- @Override\r
- protected String ruleKey(SMInputCursor violationCursor) throws XMLStreamException {\r
- return violationCursor.getAttrValue("rule");\r
- }\r
-\r
- @Override\r
- protected Resource toResource(SMInputCursor resourcesCursor) throws XMLStreamException {\r
- return JavaFile.fromAbsolutePath(resourcesCursor.getAttrValue("name"), project.getFileSystem().getSourceDirs(), false);\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.pmd;
+
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.staxmate.in.SMInputCursor;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.batch.AbstractViolationsStaxParser;
+import org.sonar.api.batch.SensorContext;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.resources.JavaFile;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Resource;
+import org.sonar.api.rules.RulesManager;
+
+import javax.xml.stream.XMLStreamException;
+
+class PmdViolationsXmlParser extends AbstractViolationsStaxParser {
+
+ private Project project;
+
+ PmdViolationsXmlParser(Project project, SensorContext context, RulesManager rulesManager, RulesProfile profile) {
+ super(context, rulesManager, profile);
+ this.project = project;
+ }
+
+ @Override
+ protected String keyForPlugin() {
+ return CoreProperties.PMD_PLUGIN;
+ }
+
+ @Override
+ protected SMInputCursor cursorForResources(SMInputCursor rootCursor) throws XMLStreamException {
+ return rootCursor.descendantElementCursor("file");
+ }
+
+ @Override
+ protected SMInputCursor cursorForViolations(SMInputCursor resourcesCursor) throws XMLStreamException {
+ return resourcesCursor.descendantElementCursor("violation");
+ }
+
+ @Override
+ protected String lineNumberForViolation(SMInputCursor violationCursor) throws XMLStreamException {
+ return violationCursor.getAttrValue("beginline");
+ }
+
+ @Override
+ protected String messageFor(SMInputCursor violationCursor) throws XMLStreamException {
+ return StringUtils.trim(violationCursor.collectDescendantText());
+ }
+
+ @Override
+ protected String ruleKey(SMInputCursor violationCursor) throws XMLStreamException {
+ return violationCursor.getAttrValue("rule");
+ }
+
+ @Override
+ protected Resource toResource(SMInputCursor resourcesCursor) throws XMLStreamException {
+ return JavaFile.fromAbsolutePath(resourcesCursor.getAttrValue("name"), project.getFileSystem().getSourceDirs(), false);
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.pmd.xml;\r
-\r
-public class PmdProperty {\r
-\r
- private String name;\r
-\r
- private String value;\r
- \r
- private String cdataValue;\r
-\r
- public PmdProperty(String name, String value) {\r
- this.name = name;\r
- this.value = value;\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- public String getValue() {\r
- return value;\r
- }\r
- \r
- public String getCdataValue() {\r
- return cdataValue;\r
- }\r
- \r
- public boolean isCdataValue(){\r
- return cdataValue != null;\r
- }\r
-\r
- public void setValue(String value) {\r
- this.value = value;\r
- }\r
- \r
- public void setCdataValue(String cdataValue) {\r
- this.cdataValue = cdataValue;\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.pmd.xml;
+
+public class PmdProperty {
+
+ private String name;
+
+ private String value;
+
+ private String cdataValue;
+
+ public PmdProperty(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getCdataValue() {
+ return cdataValue;
+ }
+
+ public boolean isCdataValue(){
+ return cdataValue != null;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public void setCdataValue(String cdataValue) {
+ this.cdataValue = cdataValue;
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.pmd.xml;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-public class PmdRule implements Comparable<String> {\r
-\r
- private String ref;\r
-\r
- private String priority;\r
-\r
- private String name;\r
-\r
- private String message;\r
-\r
- private List<PmdProperty> properties = new ArrayList<PmdProperty>();\r
-\r
- private String clazz;// NOSONAR unused private field\r
-\r
- public PmdRule(String ref) {\r
- this(ref, null);\r
- }\r
-\r
- public PmdRule(String ref, String priority) {\r
- this.ref = ref;\r
- this.priority = priority;\r
- }\r
-\r
- public String getRef() {\r
- return ref;\r
- }\r
-\r
- public void setProperties(List<PmdProperty> properties) {\r
- this.properties = properties;\r
- }\r
-\r
- public List<PmdProperty> getProperties() {\r
- return properties;\r
- }\r
-\r
- public PmdProperty getProperty(String propertyName) {\r
- for (PmdProperty prop : properties) {\r
- if (propertyName.equals(prop.getName())) {\r
- return prop;\r
- }\r
- }\r
- return null;\r
- }\r
-\r
- public int compareTo(String o) {\r
- return o.compareTo(ref);\r
- }\r
-\r
- public String getPriority() {\r
- return priority;\r
- }\r
-\r
- public void setPriority(String priority) {\r
- this.priority = priority;\r
- }\r
-\r
- public void addProperty(PmdProperty property) {\r
- if (properties == null) {\r
- properties = new ArrayList<PmdProperty>();\r
- }\r
- properties.add(property);\r
- }\r
-\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
-\r
- public void setMessage(String message) {\r
- this.message = message;\r
- }\r
-\r
- public String getMessage() {\r
- return message;\r
- }\r
-\r
- public String getClazz() {\r
- return clazz;\r
- }\r
-\r
- public void setRef(String ref) {\r
- this.ref = ref;\r
- }\r
-\r
- public void removeProperty(String propertyName) {\r
- PmdProperty prop = getProperty(propertyName);\r
- properties.remove(prop);\r
- }\r
-\r
- public void setClazz(String clazz) {\r
- this.clazz = clazz;\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- public boolean hasProperties() {\r
- return properties != null && !properties.isEmpty();\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.pmd.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PmdRule implements Comparable<String> {
+
+ private String ref;
+
+ private String priority;
+
+ private String name;
+
+ private String message;
+
+ private List<PmdProperty> properties = new ArrayList<PmdProperty>();
+
+ private String clazz;// NOSONAR unused private field
+
+ public PmdRule(String ref) {
+ this(ref, null);
+ }
+
+ public PmdRule(String ref, String priority) {
+ this.ref = ref;
+ this.priority = priority;
+ }
+
+ public String getRef() {
+ return ref;
+ }
+
+ public void setProperties(List<PmdProperty> properties) {
+ this.properties = properties;
+ }
+
+ public List<PmdProperty> getProperties() {
+ return properties;
+ }
+
+ public PmdProperty getProperty(String propertyName) {
+ for (PmdProperty prop : properties) {
+ if (propertyName.equals(prop.getName())) {
+ return prop;
+ }
+ }
+ return null;
+ }
+
+ public int compareTo(String o) {
+ return o.compareTo(ref);
+ }
+
+ public String getPriority() {
+ return priority;
+ }
+
+ public void setPriority(String priority) {
+ this.priority = priority;
+ }
+
+ public void addProperty(PmdProperty property) {
+ if (properties == null) {
+ properties = new ArrayList<PmdProperty>();
+ }
+ properties.add(property);
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getClazz() {
+ return clazz;
+ }
+
+ public void setRef(String ref) {
+ this.ref = ref;
+ }
+
+ public void removeProperty(String propertyName) {
+ PmdProperty prop = getProperty(propertyName);
+ properties.remove(prop);
+ }
+
+ public void setClazz(String clazz) {
+ this.clazz = clazz;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean hasProperties() {
+ return properties != null && !properties.isEmpty();
+ }
}
\ No newline at end of file
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.plugins.squid.bridges;\r
-\r
-import org.sonar.api.measures.CoreMetrics;\r
-import org.sonar.api.measures.Measure;\r
-import org.sonar.api.resources.Resource;\r
-import org.sonar.squid.Squid;\r
-import org.sonar.squid.api.SourceClass;\r
-import org.sonar.squid.api.SourceCode;\r
-import org.sonar.squid.api.SourcePackage;\r
-import org.sonar.squid.indexer.QueryByParent;\r
-import org.sonar.squid.indexer.QueryByType;\r
-import org.sonar.squid.math.MeasuresDistribution;\r
-import org.sonar.squid.measures.Metric;\r
-\r
-import java.util.Map;\r
-\r
-public class ClassComplexityDistributionBridge extends Bridge {\r
-\r
- public static final int[] CLASSES_DISTRIB_BOTTOM_LIMITS = {0, 5, 10, 20, 30, 60, 90};\r
-\r
- protected ClassComplexityDistributionBridge() {\r
- super(false);\r
- }\r
-\r
- @Override\r
- public final void onPackage(SourcePackage squidPackage, Resource sonarPackage) {\r
- if (squidPackage.getDouble(Metric.METHODS) > 0) {\r
- context.saveMeasure(sonarPackage, new Measure(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, getClassesComplexityDistribution(squidPackage, squid)));\r
- }\r
- }\r
-\r
- private String getClassesComplexityDistribution(SourceCode unit, Squid squid) {\r
- MeasuresDistribution distribution = new MeasuresDistribution(squid.search(new QueryByParent(unit), new QueryByType(SourceClass.class)));\r
- Map<Integer, Integer> distrib = distribution.distributeAccordingTo(Metric.COMPLEXITY, CLASSES_DISTRIB_BOTTOM_LIMITS);\r
- StringBuilder distribString = new StringBuilder(32);\r
- for (Map.Entry<Integer, Integer> entry : distrib.entrySet()) {\r
- distribString.append(entry.getKey()).append('=').append(entry.getValue().toString()).append(';');\r
- }\r
- distribString.setLength(distribString.length() - 1);\r
- return distribString.toString();\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.squid.bridges;
+
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.Measure;
+import org.sonar.api.resources.Resource;
+import org.sonar.squid.Squid;
+import org.sonar.squid.api.SourceClass;
+import org.sonar.squid.api.SourceCode;
+import org.sonar.squid.api.SourcePackage;
+import org.sonar.squid.indexer.QueryByParent;
+import org.sonar.squid.indexer.QueryByType;
+import org.sonar.squid.math.MeasuresDistribution;
+import org.sonar.squid.measures.Metric;
+
+import java.util.Map;
+
+public class ClassComplexityDistributionBridge extends Bridge {
+
+ public static final int[] CLASSES_DISTRIB_BOTTOM_LIMITS = {0, 5, 10, 20, 30, 60, 90};
+
+ protected ClassComplexityDistributionBridge() {
+ super(false);
+ }
+
+ @Override
+ public final void onPackage(SourcePackage squidPackage, Resource sonarPackage) {
+ if (squidPackage.getDouble(Metric.METHODS) > 0) {
+ context.saveMeasure(sonarPackage, new Measure(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, getClassesComplexityDistribution(squidPackage, squid)));
+ }
+ }
+
+ private String getClassesComplexityDistribution(SourceCode unit, Squid squid) {
+ MeasuresDistribution distribution = new MeasuresDistribution(squid.search(new QueryByParent(unit), new QueryByType(SourceClass.class)));
+ Map<Integer, Integer> distrib = distribution.distributeAccordingTo(Metric.COMPLEXITY, CLASSES_DISTRIB_BOTTOM_LIMITS);
+ StringBuilder distribString = new StringBuilder(32);
+ for (Map.Entry<Integer, Integer> entry : distrib.entrySet()) {
+ distribString.append(entry.getKey()).append('=').append(entry.getValue().toString()).append(';');
+ }
+ distribString.setLength(distribString.length() - 1);
+ return distribString.toString();
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-@echo off\r
+@echo off
-rem Copyright (C) 2009 SonarSource SA
+rem Copyright (C) 2008-2011 SonarSource
rem mailto:contact AT sonarsource DOT com
rem
rem Sonar is free software; you can redistribute it and/or
#! /bin/sh
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
<!--
-Copyright (C) 2009 SonarSource SA
+Copyright (C) 2008-2011 SonarSource
mailto:contact AT sonarsource DOT com
Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.application;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.net.URISyntaxException;\r
-import java.util.Properties;\r
-\r
-public final class StartServer {\r
- private static final String DEFAULT_WEB_HOST = "0.0.0.0";\r
- private static final int DEFAULT_WEB_PORT = 9000;\r
- private static final String DEFAULT_WEB_CONTEXT = "/";\r
- private static final int DEFAULT_AJP13_PORT = -1;\r
-\r
- private StartServer() {\r
- }\r
-\r
- public static void main(String[] args) throws Exception {\r
- configureLogback();\r
- configureHome();\r
-\r
- Properties configuration = getConfiguration();\r
- String host = configuration.getProperty("sonar.web.host", DEFAULT_WEB_HOST);\r
- int port = Integer.parseInt(configuration.getProperty("sonar.web.port", "" + DEFAULT_WEB_PORT));\r
- String context = configuration.getProperty("sonar.web.context", DEFAULT_WEB_CONTEXT);\r
- int ajp13Port = Integer.parseInt(configuration.getProperty("sonar.ajp13.port", "" + DEFAULT_AJP13_PORT));\r
- JettyEmbedder jetty = new JettyEmbedder(host, port, context, ajp13Port, StartServer.class.getResource("/jetty.xml"));\r
- configureRequestLogs(jetty, configuration);\r
-\r
- jetty.start();\r
- Thread.currentThread().join();\r
- }\r
-\r
- private static void configureRequestLogs(JettyEmbedder jetty, Properties configuration) {\r
- String filenamePattern = configuration.getProperty("sonar.web.jettyRequestLogs");\r
- if (filenamePattern!=null) {\r
- jetty.configureRequestLogs(filenamePattern);\r
- }\r
- }\r
-\r
- private static Properties getConfiguration() throws IOException {\r
- Properties properties = new Properties();\r
- properties.load(StartServer.class.getResourceAsStream("/conf/sonar.properties"));\r
- return properties;\r
- }\r
-\r
- private static void configureHome() throws URISyntaxException {\r
- File confFile = new File(StartServer.class.getResource("/conf/sonar.properties").toURI());\r
- System.setProperty("sonar.home", confFile.getParentFile().getParentFile().getAbsolutePath());\r
- }\r
-\r
- private static void configureLogback() throws URISyntaxException {\r
- File confFile = new File(StartServer.class.getResource("/conf/logback.xml").toURI());\r
- System.setProperty("logback.configurationFile", confFile.getAbsolutePath()); \r
- System.setProperty("logback.ContextSelector", "JNDI");\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.application;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.Properties;
+
+public final class StartServer {
+ private static final String DEFAULT_WEB_HOST = "0.0.0.0";
+ private static final int DEFAULT_WEB_PORT = 9000;
+ private static final String DEFAULT_WEB_CONTEXT = "/";
+ private static final int DEFAULT_AJP13_PORT = -1;
+
+ private StartServer() {
+ }
+
+ public static void main(String[] args) throws Exception {
+ configureLogback();
+ configureHome();
+
+ Properties configuration = getConfiguration();
+ String host = configuration.getProperty("sonar.web.host", DEFAULT_WEB_HOST);
+ int port = Integer.parseInt(configuration.getProperty("sonar.web.port", "" + DEFAULT_WEB_PORT));
+ String context = configuration.getProperty("sonar.web.context", DEFAULT_WEB_CONTEXT);
+ int ajp13Port = Integer.parseInt(configuration.getProperty("sonar.ajp13.port", "" + DEFAULT_AJP13_PORT));
+ JettyEmbedder jetty = new JettyEmbedder(host, port, context, ajp13Port, StartServer.class.getResource("/jetty.xml"));
+ configureRequestLogs(jetty, configuration);
+
+ jetty.start();
+ Thread.currentThread().join();
+ }
+
+ private static void configureRequestLogs(JettyEmbedder jetty, Properties configuration) {
+ String filenamePattern = configuration.getProperty("sonar.web.jettyRequestLogs");
+ if (filenamePattern!=null) {
+ jetty.configureRequestLogs(filenamePattern);
+ }
+ }
+
+ private static Properties getConfiguration() throws IOException {
+ Properties properties = new Properties();
+ properties.load(StartServer.class.getResourceAsStream("/conf/sonar.properties"));
+ return properties;
+ }
+
+ private static void configureHome() throws URISyntaxException {
+ File confFile = new File(StartServer.class.getResource("/conf/sonar.properties").toURI());
+ System.setProperty("sonar.home", confFile.getParentFile().getParentFile().getAbsolutePath());
+ }
+
+ private static void configureLogback() throws URISyntaxException {
+ File confFile = new File(StartServer.class.getResource("/conf/logback.xml").toURI());
+ System.setProperty("logback.configurationFile", confFile.getAbsolutePath());
+ System.setProperty("logback.ContextSelector", "JNDI");
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package org.sonar.channel;\r
-\r
-import java.util.List;\r
-\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-public class ChannelDispatcher<OUTPUT> extends Channel<OUTPUT> {\r
-\r
- private static final Logger logger = LoggerFactory.getLogger(ChannelDispatcher.class);\r
- private final boolean failIfNoChannelToConsumeOneCharacter;\r
-\r
- @SuppressWarnings("rawtypes")\r
- private final Channel[] channels;\r
-\r
- @SuppressWarnings("rawtypes")\r
- public ChannelDispatcher(List<Channel> tokenizers) {\r
- this(tokenizers, false);\r
- }\r
-\r
- @SuppressWarnings("rawtypes")\r
- public ChannelDispatcher(List<Channel> tokenizers, boolean failIfNoChannelToConsumeOneCharacter) {\r
- this.channels = tokenizers.toArray(new Channel[0]); // NOSONAR, lack of performance is not an issue here\r
- this.failIfNoChannelToConsumeOneCharacter = failIfNoChannelToConsumeOneCharacter;\r
- }\r
-\r
- public boolean consume(CodeReader code, OUTPUT output) {\r
- int nextChar = code.peek();\r
- while (nextChar != -1) {\r
- boolean channelConsumed = false;\r
- for (Channel<OUTPUT> channel : channels) {\r
- if (channel.consume(code, output)) {\r
- channelConsumed = true;\r
- break;\r
- }\r
- }\r
- if ( !channelConsumed) {\r
- String message = "None of the channel has been able to handle character '" + (char) code.peek() + "' (decimal value " + code.peek()\r
- + ") at line " + code.getLinePosition() + ", column " + code.getColumnPosition();\r
- if (failIfNoChannelToConsumeOneCharacter) {\r
- throw new IllegalStateException(message);\r
- }\r
- logger.debug(message);\r
- code.pop();\r
- }\r
- nextChar = code.peek();\r
- }\r
- return true;\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package org.sonar.channel;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ChannelDispatcher<OUTPUT> extends Channel<OUTPUT> {
+
+ private static final Logger logger = LoggerFactory.getLogger(ChannelDispatcher.class);
+ private final boolean failIfNoChannelToConsumeOneCharacter;
+
+ @SuppressWarnings("rawtypes")
+ private final Channel[] channels;
+
+ @SuppressWarnings("rawtypes")
+ public ChannelDispatcher(List<Channel> tokenizers) {
+ this(tokenizers, false);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public ChannelDispatcher(List<Channel> tokenizers, boolean failIfNoChannelToConsumeOneCharacter) {
+ this.channels = tokenizers.toArray(new Channel[0]); // NOSONAR, lack of performance is not an issue here
+ this.failIfNoChannelToConsumeOneCharacter = failIfNoChannelToConsumeOneCharacter;
+ }
+
+ public boolean consume(CodeReader code, OUTPUT output) {
+ int nextChar = code.peek();
+ while (nextChar != -1) {
+ boolean channelConsumed = false;
+ for (Channel<OUTPUT> channel : channels) {
+ if (channel.consume(code, output)) {
+ channelConsumed = true;
+ break;
+ }
+ }
+ if ( !channelConsumed) {
+ String message = "None of the channel has been able to handle character '" + (char) code.peek() + "' (decimal value " + code.peek()
+ + ") at line " + code.getLinePosition() + ", column " + code.getColumnPosition();
+ if (failIfNoChannelToConsumeOneCharacter) {
+ throw new IllegalStateException(message);
+ }
+ logger.debug(message);
+ code.pop();
+ }
+ nextChar = code.peek();
+ }
+ return true;
+ }
}
\ No newline at end of file
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package org.sonar.colorizer;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.sonar.channel.CodeReader;\r
-\r
-import static org.hamcrest.MatcherAssert.assertThat;\r
-import static org.hamcrest.Matchers.is;\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-public class MultilinesDocTokenizerTest {\r
-\r
- private HtmlCodeBuilder codeBuilder;\r
-\r
- @Before\r
- public void init() {\r
- codeBuilder = new HtmlCodeBuilder();\r
- }\r
-\r
- @Test\r
- public void testStandardComment() {\r
- MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("{[||", "");\r
- assertThat(tokenizer.hasNextToken(new CodeReader("{[|| And here is strange multi-line comment"), new HtmlCodeBuilder()), is(true));\r
- assertThat(tokenizer.hasNextToken(new CodeReader("// this is not a strange multi-line comment"), new HtmlCodeBuilder()), is(false));\r
- }\r
-\r
- @Test\r
- public void testLongStartToken() {\r
- MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/***", "**/");\r
- assertTrue(tokenizer.consume(new CodeReader("/*** multi-line comment**/ private part"), codeBuilder));\r
- assertEquals("/*** multi-line comment**/", codeBuilder.toString());\r
- }\r
- \r
- @Test\r
- public void testStartTokenEndTokenOverlapping() {\r
- MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/*", "*/");\r
- assertTrue(tokenizer.consume(new CodeReader("/*// multi-line comment*/ private part"), codeBuilder));\r
- assertEquals("/*// multi-line comment*/", codeBuilder.toString());\r
- }\r
- \r
- @Test\r
- public void testMultilinesComment() {\r
- CodeReader reader = new CodeReader("/* multi-line comment\n*/ private part");\r
- MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/*", "*/");\r
- assertTrue(tokenizer.consume(reader, codeBuilder));\r
- assertEquals("/* multi-line comment", codeBuilder.toString());\r
- reader.pop();\r
- assertTrue(tokenizer.consume(reader, codeBuilder));\r
- assertEquals("/* multi-line comment*/", codeBuilder.toString());\r
- }\r
-\r
- public class MultiLineDocTokenizerImpl extends MultilinesDocTokenizer {\r
-\r
- public MultiLineDocTokenizerImpl(String startToken, String endToken) {\r
- super(startToken, endToken, "", "");\r
- }\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package org.sonar.colorizer;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.channel.CodeReader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class MultilinesDocTokenizerTest {
+
+ private HtmlCodeBuilder codeBuilder;
+
+ @Before
+ public void init() {
+ codeBuilder = new HtmlCodeBuilder();
+ }
+
+ @Test
+ public void testStandardComment() {
+ MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("{[||", "");
+ assertThat(tokenizer.hasNextToken(new CodeReader("{[|| And here is strange multi-line comment"), new HtmlCodeBuilder()), is(true));
+ assertThat(tokenizer.hasNextToken(new CodeReader("// this is not a strange multi-line comment"), new HtmlCodeBuilder()), is(false));
+ }
+
+ @Test
+ public void testLongStartToken() {
+ MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/***", "**/");
+ assertTrue(tokenizer.consume(new CodeReader("/*** multi-line comment**/ private part"), codeBuilder));
+ assertEquals("/*** multi-line comment**/", codeBuilder.toString());
+ }
+
+ @Test
+ public void testStartTokenEndTokenOverlapping() {
+ MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/*", "*/");
+ assertTrue(tokenizer.consume(new CodeReader("/*// multi-line comment*/ private part"), codeBuilder));
+ assertEquals("/*// multi-line comment*/", codeBuilder.toString());
+ }
+
+ @Test
+ public void testMultilinesComment() {
+ CodeReader reader = new CodeReader("/* multi-line comment\n*/ private part");
+ MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/*", "*/");
+ assertTrue(tokenizer.consume(reader, codeBuilder));
+ assertEquals("/* multi-line comment", codeBuilder.toString());
+ reader.pop();
+ assertTrue(tokenizer.consume(reader, codeBuilder));
+ assertEquals("/* multi-line comment*/", codeBuilder.toString());
+ }
+
+ public class MultiLineDocTokenizerImpl extends MultilinesDocTokenizer {
+
+ public MultiLineDocTokenizerImpl(String startToken, String endToken) {
+ super(startToken, endToken, "", "");
+ }
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.jpa.dao;\r
-\r
-import org.sonar.api.database.DatabaseSession;\r
-import org.sonar.api.database.model.AsyncMeasureSnapshot;\r
-import org.sonar.api.database.model.MeasureModel;\r
-import org.sonar.api.database.model.ResourceModel;\r
-import org.sonar.api.database.model.Snapshot;\r
-\r
-import javax.persistence.NoResultException;\r
-import javax.persistence.Query;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-public class AsyncMeasuresDao extends BaseDao {\r
-\r
- public AsyncMeasuresDao(DatabaseSession session) {\r
- super(session);\r
- }\r
-\r
- public MeasureModel getAsyncMeasure(Long asyncMeasureId) {\r
- return getSession().getEntityManager().find(MeasureModel.class, asyncMeasureId);\r
- }\r
-\r
- public void deleteAsyncMeasure(MeasureModel asyncMeasure) {\r
- deleteAsyncMeasureSnapshots(asyncMeasure.getId());\r
- getSession().remove(asyncMeasure);\r
- }\r
-\r
- public Snapshot getPreviousSnapshot(Snapshot s) {\r
- try {\r
- return (Snapshot) getSession().createQuery(\r
- "SELECT s FROM Snapshot s " +\r
- "WHERE s.createdAt<:date " +\r
- "AND s.scope=:scope " +\r
- "AND s.resourceId=:resourceId " +\r
- "ORDER BY s.createdAt DESC")\r
- .setParameter("date", s.getCreatedAt())\r
- .setParameter("scope", s.getScope())\r
- .setParameter("resourceId", s.getResourceId())\r
- .setMaxResults(1)\r
- .getSingleResult();\r
- } catch (NoResultException ex) {\r
- return null;\r
- }\r
- }\r
-\r
- public List<Snapshot> getNextSnapshotsUntilDate(MeasureModel measure, Date date) {\r
- Query query = getSession().createQuery(\r
- "SELECT s FROM Snapshot s " +\r
- "WHERE s.resourceId=:projectId " +\r
- "AND s.createdAt>=:beginDate " +\r
- (date != null ? "AND s.createdAt<:endDate " : "") +\r
- "AND s.scope=:scope " +\r
- "ORDER BY s.createdAt ASC ")\r
- .setParameter("projectId", measure.getProjectId())\r
- .setParameter("beginDate", measure.getMeasureDate())\r
- .setParameter("scope", ResourceModel.SCOPE_PROJECT);\r
- if (date != null) {\r
- query.setParameter("endDate", date);\r
- }\r
- return query.getResultList();\r
- }\r
-\r
- public AsyncMeasureSnapshot createAsyncMeasureSnapshot(Long asyncMeasureId, Integer snapshotId, Date AsyncMeasureDate, Date snapshotDate, Integer metricId, Integer projectId) {\r
- AsyncMeasureSnapshot asyncMeasureSnapshot = new AsyncMeasureSnapshot(asyncMeasureId, snapshotId, AsyncMeasureDate, snapshotDate, metricId, projectId);\r
- getSession().save(asyncMeasureSnapshot);\r
- return asyncMeasureSnapshot;\r
- }\r
-\r
- public void updateAsyncMeasureSnapshot(AsyncMeasureSnapshot asyncMeasureSnapshot, Snapshot snapshot) {\r
- if (snapshot != null) {\r
- asyncMeasureSnapshot.setSnapshotId(snapshot.getId());\r
- asyncMeasureSnapshot.setSnapshotDate(snapshot.getCreatedAt());\r
- } else {\r
- asyncMeasureSnapshot.setSnapshotId(null);\r
- asyncMeasureSnapshot.setSnapshotDate(null);\r
- }\r
- getSession().merge(asyncMeasureSnapshot);\r
- }\r
-\r
- public void removeSnapshotFromAsyncMeasureSnapshot(AsyncMeasureSnapshot asyncMeasureSnapshot) {\r
- asyncMeasureSnapshot.setSnapshotId(null);\r
- asyncMeasureSnapshot.setSnapshotDate(null);\r
- getSession().merge(asyncMeasureSnapshot);\r
- }\r
-\r
-\r
- public AsyncMeasureSnapshot getNextAsyncMeasureSnapshot(Integer projetcId, Integer metricId, Date date) {\r
- try {\r
- return (AsyncMeasureSnapshot) getSession().createQuery(\r
- "SELECT ams FROM AsyncMeasureSnapshot ams " +\r
- "WHERE ams.projectId=:projectId " +\r
- "AND ams.metricId=:metricId " +\r
- "AND ams.measureDate>:date " +\r
- "ORDER BY ams.measureDate ASC")\r
- .setParameter("projectId", projetcId)\r
- .setParameter("metricId", metricId)\r
- .setParameter("date", date)\r
- .setMaxResults(1)\r
- .getSingleResult();\r
- } catch (NoResultException ex) {\r
- return null;\r
- }\r
- }\r
-\r
- public List<AsyncMeasureSnapshot> getNextAsyncMeasureSnapshotsUntilDate(MeasureModel asyncMeasure, Date endDate) {\r
- Query query = getSession().createQuery(\r
- "SELECT ams FROM AsyncMeasureSnapshot ams " +\r
- "WHERE ams.projectId=:projectId " +\r
- "AND ams.metricId=:metricId " +\r
- (endDate != null ? "AND ams.measureDate<:endDate " : "") +\r
- "AND ams.snapshotDate>=:measureDate " +\r
- "ORDER BY ams.snapshotDate ASC ")\r
- .setParameter("projectId", asyncMeasure.getProjectId())\r
- .setParameter("metricId", asyncMeasure.getMetricId())\r
- .setParameter("measureDate", asyncMeasure.getMeasureDate());\r
- if (endDate != null) {\r
- query.setParameter("endDate", endDate);\r
- }\r
- return query.getResultList();\r
- }\r
-\r
- public List<AsyncMeasureSnapshot> getPreviousAsyncMeasureSnapshots(Integer projectId, Date beginDate, Date endDate) {\r
- Query query = getSession().createQuery(\r
- "SELECT ams FROM AsyncMeasureSnapshot ams " +\r
- "WHERE ams.projectId=:projectId " +\r
- "AND ams.measureDate<=:endDate " +\r
- (beginDate != null ? "AND ams.measureDate>:beginDate " : "") +\r
- "AND ams.snapshotId IS NULL " +\r
- "ORDER BY ams.measureDate ASC")\r
- .setParameter("projectId", projectId)\r
- .setParameter("endDate", endDate);\r
- if (beginDate != null) {\r
- query.setParameter("beginDate", beginDate);\r
- }\r
- return query.getResultList();\r
- }\r
-\r
- public List<AsyncMeasureSnapshot> getAsyncMeasureSnapshotsFromSnapshotId(Integer snapshotId, List<Integer> metricIdsToExclude) {\r
- Query query = getSession().createQuery(\r
- "SELECT ams FROM AsyncMeasureSnapshot ams " +\r
- "WHERE ams.snapshotId=:snapshotId " +\r
- (!metricIdsToExclude.isEmpty() ? "AND ams.metricId NOT IN (:metricIdsToExclude) " : "") +\r
- "ORDER BY ams.measureDate ASC")\r
- .setParameter("snapshotId", snapshotId);\r
- if (!metricIdsToExclude.isEmpty()) {\r
- query.setParameter("metricIdsToExclude", metricIdsToExclude);\r
- }\r
- return query.getResultList();\r
- }\r
-\r
- public AsyncMeasureSnapshot getLastAsyncMeasureSnapshot(Integer projetcId, Integer metricId, Date date) {\r
- try {\r
- return (AsyncMeasureSnapshot) getSession().createQuery(\r
- "SELECT ams FROM AsyncMeasureSnapshot ams " +\r
- "WHERE ams.projectId=:projectId " +\r
- "AND ams.metricId=:metricId " +\r
- "AND ams.measureDate<:date " +\r
- "ORDER BY ams.measureDate DESC")\r
- .setParameter("projectId", projetcId)\r
- .setParameter("metricId", metricId)\r
- .setParameter("date", date)\r
- .setMaxResults(1)\r
- .getSingleResult();\r
- } catch (NoResultException ex) {\r
- return null;\r
- }\r
- }\r
-\r
- public void deleteAsyncMeasureSnapshots(Long asyncMeasureId) {\r
- getSession().createQuery(\r
- "DELETE FROM AsyncMeasureSnapshot ams WHERE ams.measureId=:measureId")\r
- .setParameter("measureId", asyncMeasureId)\r
- .executeUpdate();\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.jpa.dao;
+
+import org.sonar.api.database.DatabaseSession;
+import org.sonar.api.database.model.AsyncMeasureSnapshot;
+import org.sonar.api.database.model.MeasureModel;
+import org.sonar.api.database.model.ResourceModel;
+import org.sonar.api.database.model.Snapshot;
+
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import java.util.Date;
+import java.util.List;
+
+public class AsyncMeasuresDao extends BaseDao {
+
+ public AsyncMeasuresDao(DatabaseSession session) {
+ super(session);
+ }
+
+ public MeasureModel getAsyncMeasure(Long asyncMeasureId) {
+ return getSession().getEntityManager().find(MeasureModel.class, asyncMeasureId);
+ }
+
+ public void deleteAsyncMeasure(MeasureModel asyncMeasure) {
+ deleteAsyncMeasureSnapshots(asyncMeasure.getId());
+ getSession().remove(asyncMeasure);
+ }
+
+ public Snapshot getPreviousSnapshot(Snapshot s) {
+ try {
+ return (Snapshot) getSession().createQuery(
+ "SELECT s FROM Snapshot s " +
+ "WHERE s.createdAt<:date " +
+ "AND s.scope=:scope " +
+ "AND s.resourceId=:resourceId " +
+ "ORDER BY s.createdAt DESC")
+ .setParameter("date", s.getCreatedAt())
+ .setParameter("scope", s.getScope())
+ .setParameter("resourceId", s.getResourceId())
+ .setMaxResults(1)
+ .getSingleResult();
+ } catch (NoResultException ex) {
+ return null;
+ }
+ }
+
+ public List<Snapshot> getNextSnapshotsUntilDate(MeasureModel measure, Date date) {
+ Query query = getSession().createQuery(
+ "SELECT s FROM Snapshot s " +
+ "WHERE s.resourceId=:projectId " +
+ "AND s.createdAt>=:beginDate " +
+ (date != null ? "AND s.createdAt<:endDate " : "") +
+ "AND s.scope=:scope " +
+ "ORDER BY s.createdAt ASC ")
+ .setParameter("projectId", measure.getProjectId())
+ .setParameter("beginDate", measure.getMeasureDate())
+ .setParameter("scope", ResourceModel.SCOPE_PROJECT);
+ if (date != null) {
+ query.setParameter("endDate", date);
+ }
+ return query.getResultList();
+ }
+
+ public AsyncMeasureSnapshot createAsyncMeasureSnapshot(Long asyncMeasureId, Integer snapshotId, Date AsyncMeasureDate, Date snapshotDate, Integer metricId, Integer projectId) {
+ AsyncMeasureSnapshot asyncMeasureSnapshot = new AsyncMeasureSnapshot(asyncMeasureId, snapshotId, AsyncMeasureDate, snapshotDate, metricId, projectId);
+ getSession().save(asyncMeasureSnapshot);
+ return asyncMeasureSnapshot;
+ }
+
+ public void updateAsyncMeasureSnapshot(AsyncMeasureSnapshot asyncMeasureSnapshot, Snapshot snapshot) {
+ if (snapshot != null) {
+ asyncMeasureSnapshot.setSnapshotId(snapshot.getId());
+ asyncMeasureSnapshot.setSnapshotDate(snapshot.getCreatedAt());
+ } else {
+ asyncMeasureSnapshot.setSnapshotId(null);
+ asyncMeasureSnapshot.setSnapshotDate(null);
+ }
+ getSession().merge(asyncMeasureSnapshot);
+ }
+
+ public void removeSnapshotFromAsyncMeasureSnapshot(AsyncMeasureSnapshot asyncMeasureSnapshot) {
+ asyncMeasureSnapshot.setSnapshotId(null);
+ asyncMeasureSnapshot.setSnapshotDate(null);
+ getSession().merge(asyncMeasureSnapshot);
+ }
+
+
+ public AsyncMeasureSnapshot getNextAsyncMeasureSnapshot(Integer projetcId, Integer metricId, Date date) {
+ try {
+ return (AsyncMeasureSnapshot) getSession().createQuery(
+ "SELECT ams FROM AsyncMeasureSnapshot ams " +
+ "WHERE ams.projectId=:projectId " +
+ "AND ams.metricId=:metricId " +
+ "AND ams.measureDate>:date " +
+ "ORDER BY ams.measureDate ASC")
+ .setParameter("projectId", projetcId)
+ .setParameter("metricId", metricId)
+ .setParameter("date", date)
+ .setMaxResults(1)
+ .getSingleResult();
+ } catch (NoResultException ex) {
+ return null;
+ }
+ }
+
+ public List<AsyncMeasureSnapshot> getNextAsyncMeasureSnapshotsUntilDate(MeasureModel asyncMeasure, Date endDate) {
+ Query query = getSession().createQuery(
+ "SELECT ams FROM AsyncMeasureSnapshot ams " +
+ "WHERE ams.projectId=:projectId " +
+ "AND ams.metricId=:metricId " +
+ (endDate != null ? "AND ams.measureDate<:endDate " : "") +
+ "AND ams.snapshotDate>=:measureDate " +
+ "ORDER BY ams.snapshotDate ASC ")
+ .setParameter("projectId", asyncMeasure.getProjectId())
+ .setParameter("metricId", asyncMeasure.getMetricId())
+ .setParameter("measureDate", asyncMeasure.getMeasureDate());
+ if (endDate != null) {
+ query.setParameter("endDate", endDate);
+ }
+ return query.getResultList();
+ }
+
+ public List<AsyncMeasureSnapshot> getPreviousAsyncMeasureSnapshots(Integer projectId, Date beginDate, Date endDate) {
+ Query query = getSession().createQuery(
+ "SELECT ams FROM AsyncMeasureSnapshot ams " +
+ "WHERE ams.projectId=:projectId " +
+ "AND ams.measureDate<=:endDate " +
+ (beginDate != null ? "AND ams.measureDate>:beginDate " : "") +
+ "AND ams.snapshotId IS NULL " +
+ "ORDER BY ams.measureDate ASC")
+ .setParameter("projectId", projectId)
+ .setParameter("endDate", endDate);
+ if (beginDate != null) {
+ query.setParameter("beginDate", beginDate);
+ }
+ return query.getResultList();
+ }
+
+ public List<AsyncMeasureSnapshot> getAsyncMeasureSnapshotsFromSnapshotId(Integer snapshotId, List<Integer> metricIdsToExclude) {
+ Query query = getSession().createQuery(
+ "SELECT ams FROM AsyncMeasureSnapshot ams " +
+ "WHERE ams.snapshotId=:snapshotId " +
+ (!metricIdsToExclude.isEmpty() ? "AND ams.metricId NOT IN (:metricIdsToExclude) " : "") +
+ "ORDER BY ams.measureDate ASC")
+ .setParameter("snapshotId", snapshotId);
+ if (!metricIdsToExclude.isEmpty()) {
+ query.setParameter("metricIdsToExclude", metricIdsToExclude);
+ }
+ return query.getResultList();
+ }
+
+ public AsyncMeasureSnapshot getLastAsyncMeasureSnapshot(Integer projetcId, Integer metricId, Date date) {
+ try {
+ return (AsyncMeasureSnapshot) getSession().createQuery(
+ "SELECT ams FROM AsyncMeasureSnapshot ams " +
+ "WHERE ams.projectId=:projectId " +
+ "AND ams.metricId=:metricId " +
+ "AND ams.measureDate<:date " +
+ "ORDER BY ams.measureDate DESC")
+ .setParameter("projectId", projetcId)
+ .setParameter("metricId", metricId)
+ .setParameter("date", date)
+ .setMaxResults(1)
+ .getSingleResult();
+ } catch (NoResultException ex) {
+ return null;
+ }
+ }
+
+ public void deleteAsyncMeasureSnapshots(Long asyncMeasureId) {
+ getSession().createQuery(
+ "DELETE FROM AsyncMeasureSnapshot ams WHERE ams.measureId=:measureId")
+ .setParameter("measureId", asyncMeasureId)
+ .executeUpdate();
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.jpa.dao;\r
-\r
-import org.apache.commons.collections.CollectionUtils;\r
-import org.apache.commons.collections.Predicate;\r
-import org.sonar.api.database.DatabaseSession;\r
-import org.sonar.api.measures.Metric;\r
-\r
-import java.util.*;\r
-\r
-public class MeasuresDao extends BaseDao {\r
-\r
- private final Map<String, Metric> metricsByName = new HashMap<String, Metric>();\r
-\r
- public MeasuresDao(DatabaseSession session) {\r
- super(session);\r
- }\r
-\r
- public Metric getMetric(Metric metric) {\r
- return getMetricsByName().get(metric.getKey());\r
- }\r
-\r
- public List<Metric> getMetrics(List<Metric> metrics) {\r
- List<Metric> result = new ArrayList<Metric>();\r
- for (Metric metric : metrics) {\r
- result.add(getMetric(metric));\r
- }\r
- return result;\r
- }\r
-\r
- public Metric getMetric(String metricName) {\r
- return getMetricsByName().get(metricName);\r
- }\r
-\r
- public Collection<Metric> getMetrics() {\r
- return getMetricsByName().values();\r
- }\r
-\r
- public Collection<Metric> getEnabledMetrics() {\r
- return CollectionUtils.select(getMetricsByName().values(), new Predicate() {\r
- public boolean evaluate(Object o) {\r
- return ((Metric) o).getEnabled();\r
- }\r
- });\r
- }\r
-\r
- public Collection<Metric> getUserDefinedMetrics() {\r
- return CollectionUtils.select(getMetricsByName().values(), new Predicate() {\r
- public boolean evaluate(Object o) {\r
- Metric m = (Metric) o;\r
- return (m.getEnabled() && m.getOrigin() != Metric.Origin.JAV);\r
- }\r
- });\r
- }\r
-\r
- public void disableAutomaticMetrics() {\r
- getSession().createQuery("update " + Metric.class.getSimpleName() + " m set m.enabled=false where m.userManaged=false").executeUpdate();\r
- getSession().commit();\r
- metricsByName.clear();\r
- }\r
-\r
- public void registerMetrics(Collection<Metric> metrics) {\r
- if (metrics != null) {\r
- for (Metric metric : metrics) {\r
- metric.setEnabled(Boolean.TRUE);\r
- persistMetric(metric);\r
- }\r
- getSession().commit();\r
- }\r
- }\r
-\r
- public void persistMetric(Metric metric) {\r
- Metric dbMetric = getMetric(metric);\r
- if (dbMetric != null) {\r
- dbMetric.merge(metric);\r
- getSession().getEntityManager().merge(dbMetric);\r
-\r
- } else {\r
- getSession().getEntityManager().persist(metric);\r
- }\r
-\r
- metricsByName.clear();\r
- }\r
-\r
- public void disabledMetrics(Collection<Metric> metrics) {\r
- for (Metric metric : metrics) {\r
- metric.setEnabled(Boolean.FALSE);\r
- getSession().getEntityManager().persist(metric);\r
- metricsByName.put(metric.getName(), metric);\r
- }\r
- }\r
-\r
- private Map<String, Metric> getMetricsByName() {\r
- if (metricsByName.isEmpty()) {\r
- List<Metric> metrics = getSession().getResults(Metric.class);\r
- for (Metric metric : metrics) {\r
- metricsByName.put(metric.getKey(), metric);\r
- }\r
- }\r
- return metricsByName;\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.jpa.dao;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+import org.sonar.api.database.DatabaseSession;
+import org.sonar.api.measures.Metric;
+
+import java.util.*;
+
+public class MeasuresDao extends BaseDao {
+
+ private final Map<String, Metric> metricsByName = new HashMap<String, Metric>();
+
+ public MeasuresDao(DatabaseSession session) {
+ super(session);
+ }
+
+ public Metric getMetric(Metric metric) {
+ return getMetricsByName().get(metric.getKey());
+ }
+
+ public List<Metric> getMetrics(List<Metric> metrics) {
+ List<Metric> result = new ArrayList<Metric>();
+ for (Metric metric : metrics) {
+ result.add(getMetric(metric));
+ }
+ return result;
+ }
+
+ public Metric getMetric(String metricName) {
+ return getMetricsByName().get(metricName);
+ }
+
+ public Collection<Metric> getMetrics() {
+ return getMetricsByName().values();
+ }
+
+ public Collection<Metric> getEnabledMetrics() {
+ return CollectionUtils.select(getMetricsByName().values(), new Predicate() {
+ public boolean evaluate(Object o) {
+ return ((Metric) o).getEnabled();
+ }
+ });
+ }
+
+ public Collection<Metric> getUserDefinedMetrics() {
+ return CollectionUtils.select(getMetricsByName().values(), new Predicate() {
+ public boolean evaluate(Object o) {
+ Metric m = (Metric) o;
+ return (m.getEnabled() && m.getOrigin() != Metric.Origin.JAV);
+ }
+ });
+ }
+
+ public void disableAutomaticMetrics() {
+ getSession().createQuery("update " + Metric.class.getSimpleName() + " m set m.enabled=false where m.userManaged=false").executeUpdate();
+ getSession().commit();
+ metricsByName.clear();
+ }
+
+ public void registerMetrics(Collection<Metric> metrics) {
+ if (metrics != null) {
+ for (Metric metric : metrics) {
+ metric.setEnabled(Boolean.TRUE);
+ persistMetric(metric);
+ }
+ getSession().commit();
+ }
+ }
+
+ public void persistMetric(Metric metric) {
+ Metric dbMetric = getMetric(metric);
+ if (dbMetric != null) {
+ dbMetric.merge(metric);
+ getSession().getEntityManager().merge(dbMetric);
+
+ } else {
+ getSession().getEntityManager().persist(metric);
+ }
+
+ metricsByName.clear();
+ }
+
+ public void disabledMetrics(Collection<Metric> metrics) {
+ for (Metric metric : metrics) {
+ metric.setEnabled(Boolean.FALSE);
+ getSession().getEntityManager().persist(metric);
+ metricsByName.put(metric.getName(), metric);
+ }
+ }
+
+ private Map<String, Metric> getMetricsByName() {
+ if (metricsByName.isEmpty()) {
+ List<Metric> metrics = getSession().getResults(Metric.class);
+ for (Metric metric : metrics) {
+ metricsByName.put(metric.getKey(), metric);
+ }
+ }
+ return metricsByName;
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.jpa.dao;\r
-\r
-import org.sonar.api.database.DatabaseSession;\r
-import org.sonar.api.database.model.RuleFailureModel;\r
-import org.sonar.api.database.model.Snapshot;\r
-import org.sonar.api.profiles.RulesProfile;\r
-import org.sonar.api.rules.ActiveRule;\r
-import org.sonar.api.rules.ActiveRuleParam;\r
-import org.sonar.api.rules.Rule;\r
-import org.sonar.api.rules.RuleParam;\r
-\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-public class RulesDao extends BaseDao {\r
-\r
- public RulesDao(DatabaseSession session) {\r
- super(session);\r
- }\r
-\r
- public List<Rule> getRules() {\r
- return getSession().getResults(Rule.class, "enabled", true);\r
- }\r
-\r
- public List<Rule> getRulesByRepository(String repositoryKey) {\r
- return getSession().getResults(Rule.class, "pluginName", repositoryKey, "enabled", true);\r
- }\r
-\r
- /**\r
- * @deprecated since 2.5 use {@link #getRulesByRepository(String)} instead.\r
- */\r
- @Deprecated\r
- public List<Rule> getRulesByPlugin(String pluginKey) {\r
- return getRulesByRepository(pluginKey);\r
- }\r
-\r
- public Rule getRuleByKey(String repositoryKey, String ruleKey) {\r
- return getSession().getSingleResult(Rule.class, "key", ruleKey, "pluginName", repositoryKey, "enabled", true);\r
- }\r
-\r
-\r
- public RuleParam getRuleParam(Rule rule, String paramKey) {\r
- return getSession().getSingleResult(RuleParam.class, "rule", rule, "key", paramKey);\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.jpa.dao;
+
+import org.sonar.api.database.DatabaseSession;
+import org.sonar.api.database.model.RuleFailureModel;
+import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.rules.ActiveRule;
+import org.sonar.api.rules.ActiveRuleParam;
+import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RuleParam;
+
+import java.util.Iterator;
+import java.util.List;
+
+public class RulesDao extends BaseDao {
+
+ public RulesDao(DatabaseSession session) {
+ super(session);
+ }
+
+ public List<Rule> getRules() {
+ return getSession().getResults(Rule.class, "enabled", true);
+ }
+
+ public List<Rule> getRulesByRepository(String repositoryKey) {
+ return getSession().getResults(Rule.class, "pluginName", repositoryKey, "enabled", true);
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #getRulesByRepository(String)} instead.
+ */
+ @Deprecated
+ public List<Rule> getRulesByPlugin(String pluginKey) {
+ return getRulesByRepository(pluginKey);
+ }
+
+ public Rule getRuleByKey(String repositoryKey, String ruleKey) {
+ return getSession().getSingleResult(Rule.class, "key", ruleKey, "pluginName", repositoryKey, "enabled", true);
+ }
+
+
+ public RuleParam getRuleParam(Rule rule, String paramKey) {
+ return getSession().getSingleResult(RuleParam.class, "rule", rule, "key", paramKey);
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.jpa.dao;\r
-\r
-import org.junit.Test;\r
-import org.sonar.api.database.model.AsyncMeasureSnapshot;\r
-import org.sonar.api.database.model.MeasureModel;\r
-import org.sonar.api.database.model.ResourceModel;\r
-import org.sonar.api.database.model.Snapshot;\r
-import org.sonar.jpa.test.AbstractDbUnitTestCase;\r
-\r
-import java.text.ParseException;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Arrays;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import static org.hamcrest.CoreMatchers.is;\r
-import static org.junit.Assert.assertThat;\r
-\r
-public class AsyncMeasuresDaoTest extends AbstractDbUnitTestCase {\r
-\r
- private static final int PROJECT_ID = 1;\r
- private static final int METRIC_ID = 1;\r
-\r
- @Test\r
- public void testGetNextAsyncMeasureSnapshot() {\r
- setupData("sharedFixture", "testGetNextAsyncMeasureSnapshot");\r
-\r
- AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());\r
- AsyncMeasureSnapshot asyncMeasure = asyncMeasuresDao.getNextAsyncMeasureSnapshot(\r
- PROJECT_ID, METRIC_ID, stringToDate("2008-12-04 08:00:00.00"));\r
-\r
- assertThat(asyncMeasure.getId(), is(3));\r
- }\r
-\r
- @Test\r
- public void testGetNextSnapshotsUntilDate() {\r
- setupData("sharedFixture", "testGetNextSnapshotsUntilDate");\r
-\r
- AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());\r
- MeasureModel asyncMeasure = getSession().getEntityManager().find(MeasureModel.class, 1l);\r
- List<Snapshot> snapshotIds = asyncMeasuresDao.getNextSnapshotsUntilDate(\r
- asyncMeasure, stringToDate("2008-12-06 12:00:00.00"));\r
-\r
- assertThat(snapshotIds.size(), is(2));\r
- assertThat(snapshotIds.get(0).getId(), is(2));\r
- assertThat(snapshotIds.get(1).getId(), is(4));\r
- }\r
-\r
- @Test\r
- public void testGetPreviousSnapshot() {\r
- setupData("sharedFixture", "testGetPreviousSnapshot");\r
- AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());\r
- Snapshot s = new Snapshot();\r
- s.setCreatedAt(stringToDate("2008-12-04 08:00:00.00"));\r
- s.setScope(ResourceModel.SCOPE_PROJECT);\r
- ResourceModel resource1 = getSession().getEntity(ResourceModel.class, 1);\r
- ResourceModel resource2 = getSession().getEntity(ResourceModel.class, 2);\r
-\r
- s.setResource(resource1);\r
- assertThat(asyncMeasuresDao.getPreviousSnapshot(s).getId(), is(1));\r
-\r
- s.setResource(resource2);\r
- assertThat(asyncMeasuresDao.getPreviousSnapshot(s).getId(), is(5));\r
- }\r
-\r
- @Test\r
- public void testGetNextAsyncMeasureSnapshotsUntilDate() {\r
- setupData("sharedFixture", "testGetNextAsyncMeasureSnapshotsUntilDate");\r
-\r
- AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());\r
- MeasureModel asyncMeasure = getSession().getEntityManager().find(MeasureModel.class, 3l);\r
- List<AsyncMeasureSnapshot> asyncMeasureSnapshots = asyncMeasuresDao.getNextAsyncMeasureSnapshotsUntilDate(\r
- asyncMeasure, stringToDate("2008-12-06 08:00:00.00"));\r
-\r
- assertThat(asyncMeasureSnapshots.size(), is(2));\r
- assertThat(asyncMeasureSnapshots.get(0).getId(), is(2));\r
- assertThat(asyncMeasureSnapshots.get(1).getId(), is(3));\r
- }\r
-\r
- @Test\r
- public void testDeleteAsyncMeasure() {\r
- setupData("sharedFixture", "testDeleteAsyncMeasure");\r
-\r
- AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());\r
- MeasureModel asyncMeasure = getSession().getEntityManager().find(MeasureModel.class, 1l);\r
- asyncMeasuresDao.deleteAsyncMeasure(asyncMeasure);\r
-\r
- getSession().commit();\r
- checkTables("testDeleteAsyncMeasure", "project_measures", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void testGetAsyncMeasureSnapshotsFromSnapshotId() {\r
- setupData("sharedFixture", "testGetAsyncMeasureSnapshotsFromSnapshotId");\r
-\r
- AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());\r
- Integer snapshotId = 1;\r
- List<AsyncMeasureSnapshot> asyncMeasureSnapshots = asyncMeasuresDao.getAsyncMeasureSnapshotsFromSnapshotId(\r
- snapshotId, Arrays.asList(1));\r
- assertThat(asyncMeasureSnapshots.size(), is(1));\r
- assertThat(asyncMeasureSnapshots.get(0).getId(), is(2));\r
- }\r
-\r
- @Test\r
- public void testGetLastAsyncMeasureSnapshot() {\r
- setupData("sharedFixture", "testGetLastAsyncMeasureSnapshot");\r
-\r
- AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());\r
- AsyncMeasureSnapshot asyncMeasureSnapshot = asyncMeasuresDao.getLastAsyncMeasureSnapshot(\r
- PROJECT_ID, METRIC_ID, stringToDate("2008-12-04 12:00:00.00"));\r
- assertThat(asyncMeasureSnapshot.getId(), is(2));\r
- }\r
-\r
- @Test\r
- public void testDeleteAsyncMeasureSnapshots() {\r
- setupData("sharedFixture", "testDeleteAsyncMeasureSnapshots");\r
-\r
- AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());\r
- asyncMeasuresDao.deleteAsyncMeasureSnapshots(1l);\r
-\r
- checkTables("testDeleteAsyncMeasureSnapshots", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void testGetPreviousAsyncMeasureSnapshots() {\r
- setupData("sharedFixture", "testGetPreviousAsyncMeasureSnapshots");\r
-\r
- AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());\r
- List<AsyncMeasureSnapshot> asyncMeasureSnapshots = asyncMeasuresDao.getPreviousAsyncMeasureSnapshots(\r
- PROJECT_ID, stringToDate("2008-12-04 08:00:00.00"), stringToDate("2008-12-08 08:00:00.00"));\r
- assertThat(asyncMeasureSnapshots.size(), is(2));\r
- assertThat(asyncMeasureSnapshots.get(0).getId(), is(5));\r
- assertThat(asyncMeasureSnapshots.get(1).getId(), is(6));\r
- }\r
-\r
-\r
- private static Date stringToDate(String sDate) {\r
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS");\r
- try {\r
- return sdf.parse(sDate);\r
- } catch (ParseException e) {\r
- throw new RuntimeException("Bad date format.");\r
- }\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.jpa.dao;
+
+import org.junit.Test;
+import org.sonar.api.database.model.AsyncMeasureSnapshot;
+import org.sonar.api.database.model.MeasureModel;
+import org.sonar.api.database.model.ResourceModel;
+import org.sonar.api.database.model.Snapshot;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class AsyncMeasuresDaoTest extends AbstractDbUnitTestCase {
+
+ private static final int PROJECT_ID = 1;
+ private static final int METRIC_ID = 1;
+
+ @Test
+ public void testGetNextAsyncMeasureSnapshot() {
+ setupData("sharedFixture", "testGetNextAsyncMeasureSnapshot");
+
+ AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());
+ AsyncMeasureSnapshot asyncMeasure = asyncMeasuresDao.getNextAsyncMeasureSnapshot(
+ PROJECT_ID, METRIC_ID, stringToDate("2008-12-04 08:00:00.00"));
+
+ assertThat(asyncMeasure.getId(), is(3));
+ }
+
+ @Test
+ public void testGetNextSnapshotsUntilDate() {
+ setupData("sharedFixture", "testGetNextSnapshotsUntilDate");
+
+ AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());
+ MeasureModel asyncMeasure = getSession().getEntityManager().find(MeasureModel.class, 1l);
+ List<Snapshot> snapshotIds = asyncMeasuresDao.getNextSnapshotsUntilDate(
+ asyncMeasure, stringToDate("2008-12-06 12:00:00.00"));
+
+ assertThat(snapshotIds.size(), is(2));
+ assertThat(snapshotIds.get(0).getId(), is(2));
+ assertThat(snapshotIds.get(1).getId(), is(4));
+ }
+
+ @Test
+ public void testGetPreviousSnapshot() {
+ setupData("sharedFixture", "testGetPreviousSnapshot");
+ AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());
+ Snapshot s = new Snapshot();
+ s.setCreatedAt(stringToDate("2008-12-04 08:00:00.00"));
+ s.setScope(ResourceModel.SCOPE_PROJECT);
+ ResourceModel resource1 = getSession().getEntity(ResourceModel.class, 1);
+ ResourceModel resource2 = getSession().getEntity(ResourceModel.class, 2);
+
+ s.setResource(resource1);
+ assertThat(asyncMeasuresDao.getPreviousSnapshot(s).getId(), is(1));
+
+ s.setResource(resource2);
+ assertThat(asyncMeasuresDao.getPreviousSnapshot(s).getId(), is(5));
+ }
+
+ @Test
+ public void testGetNextAsyncMeasureSnapshotsUntilDate() {
+ setupData("sharedFixture", "testGetNextAsyncMeasureSnapshotsUntilDate");
+
+ AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());
+ MeasureModel asyncMeasure = getSession().getEntityManager().find(MeasureModel.class, 3l);
+ List<AsyncMeasureSnapshot> asyncMeasureSnapshots = asyncMeasuresDao.getNextAsyncMeasureSnapshotsUntilDate(
+ asyncMeasure, stringToDate("2008-12-06 08:00:00.00"));
+
+ assertThat(asyncMeasureSnapshots.size(), is(2));
+ assertThat(asyncMeasureSnapshots.get(0).getId(), is(2));
+ assertThat(asyncMeasureSnapshots.get(1).getId(), is(3));
+ }
+
+ @Test
+ public void testDeleteAsyncMeasure() {
+ setupData("sharedFixture", "testDeleteAsyncMeasure");
+
+ AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());
+ MeasureModel asyncMeasure = getSession().getEntityManager().find(MeasureModel.class, 1l);
+ asyncMeasuresDao.deleteAsyncMeasure(asyncMeasure);
+
+ getSession().commit();
+ checkTables("testDeleteAsyncMeasure", "project_measures", "async_measure_snapshots");
+ }
+
+ @Test
+ public void testGetAsyncMeasureSnapshotsFromSnapshotId() {
+ setupData("sharedFixture", "testGetAsyncMeasureSnapshotsFromSnapshotId");
+
+ AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());
+ Integer snapshotId = 1;
+ List<AsyncMeasureSnapshot> asyncMeasureSnapshots = asyncMeasuresDao.getAsyncMeasureSnapshotsFromSnapshotId(
+ snapshotId, Arrays.asList(1));
+ assertThat(asyncMeasureSnapshots.size(), is(1));
+ assertThat(asyncMeasureSnapshots.get(0).getId(), is(2));
+ }
+
+ @Test
+ public void testGetLastAsyncMeasureSnapshot() {
+ setupData("sharedFixture", "testGetLastAsyncMeasureSnapshot");
+
+ AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());
+ AsyncMeasureSnapshot asyncMeasureSnapshot = asyncMeasuresDao.getLastAsyncMeasureSnapshot(
+ PROJECT_ID, METRIC_ID, stringToDate("2008-12-04 12:00:00.00"));
+ assertThat(asyncMeasureSnapshot.getId(), is(2));
+ }
+
+ @Test
+ public void testDeleteAsyncMeasureSnapshots() {
+ setupData("sharedFixture", "testDeleteAsyncMeasureSnapshots");
+
+ AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());
+ asyncMeasuresDao.deleteAsyncMeasureSnapshots(1l);
+
+ checkTables("testDeleteAsyncMeasureSnapshots", "async_measure_snapshots");
+ }
+
+ @Test
+ public void testGetPreviousAsyncMeasureSnapshots() {
+ setupData("sharedFixture", "testGetPreviousAsyncMeasureSnapshots");
+
+ AsyncMeasuresDao asyncMeasuresDao = new AsyncMeasuresDao(getSession());
+ List<AsyncMeasureSnapshot> asyncMeasureSnapshots = asyncMeasuresDao.getPreviousAsyncMeasureSnapshots(
+ PROJECT_ID, stringToDate("2008-12-04 08:00:00.00"), stringToDate("2008-12-08 08:00:00.00"));
+ assertThat(asyncMeasureSnapshots.size(), is(2));
+ assertThat(asyncMeasureSnapshots.get(0).getId(), is(5));
+ assertThat(asyncMeasureSnapshots.get(1).getId(), is(6));
+ }
+
+
+ private static Date stringToDate(String sDate) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS");
+ try {
+ return sdf.parse(sDate);
+ } catch (ParseException e) {
+ throw new RuntimeException("Bad date format.");
+ }
+ }
+
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.jpa.dao;\r
-\r
-import org.junit.Test;\r
-import org.sonar.api.database.model.Snapshot;\r
-import org.sonar.jpa.test.AbstractDbUnitTestCase;\r
-\r
-public class AsyncMeasuresServiceTest extends AbstractDbUnitTestCase {\r
-\r
- @Test\r
- public void assignLatestMeasuresToLastSnapshot() {\r
- setupData("sharedFixture", "assignLatestMeasuresToLastSnapshot");\r
-\r
- AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());\r
- Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 2);\r
- asyncMeasuresService.refresh(snapshot);\r
-\r
- checkTables("assignLatestMeasuresToLastSnapshot", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void assignNewMeasuresToLastSnapshot() {\r
- setupData("sharedFixture", "assignNewMeasuresToLastSnapshot");\r
-\r
- AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());\r
- Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 2);\r
- asyncMeasuresService.refresh(snapshot);\r
-\r
- checkTables("assignNewMeasuresToLastSnapshot", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void assignMeasuresWhenNoPreviousSnapshot() {\r
- setupData("sharedFixture", "assignMeasuresWhenNoPreviousSnapshot");\r
-\r
- AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());\r
- Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 1);\r
- asyncMeasuresService.refresh(snapshot);\r
-\r
- checkTables("assignMeasuresWhenNoPreviousSnapshot", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void assignLatestMeasuresWhenNoPreviousSnapshot() {\r
- setupData("sharedFixture", "assignLatestMeasuresWhenNoPreviousSnapshot");\r
-\r
- AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());\r
- Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 1);\r
- asyncMeasuresService.refresh(snapshot);\r
-\r
- checkTables("assignLatestMeasuresWhenNoPreviousSnapshot", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void assignPastMeasuresToPastSnapshot() {\r
- setupData("sharedFixture", "assignPastMeasuresToPastSnapshot");\r
-\r
- AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());\r
- Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 3);\r
- asyncMeasuresService.refresh(snapshot);\r
-\r
- checkTables("assignPastMeasuresToPastSnapshot", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void assignNewMeasureToFutureSnapshots() {\r
- setupData("sharedFixture", "assignNewMeasureToFutureSnapshots");\r
-\r
- AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());\r
- asyncMeasuresService.registerMeasure(2l);\r
-\r
- checkTables("assignNewMeasureToFutureSnapshots", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void assignMeasureToFutureSnapshotsWithDifferentMetric() {\r
- setupData("sharedFixture", "assignMeasureToFutureSnapshotsWithDifferentMetric");\r
-\r
- AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());\r
- asyncMeasureService.registerMeasure(3l);\r
-\r
- checkTables("assignMeasureToFutureSnapshotsWithDifferentMetric", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void assignAPastMeasureToNextSnapshotsWithDifferentMetric() {\r
- setupData("sharedFixture", "assignAPastMeasureToNextSnapshotsWithDifferentMetric");\r
-\r
- AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());\r
- asyncMeasureService.registerMeasure(2l);\r
-\r
- checkTables("assignAPastMeasureToNextSnapshotsWithDifferentMetric", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void addFutureSnapshot() {\r
- setupData("sharedFixture", "addFutureSnapshot");\r
-\r
- AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());\r
- asyncMeasureService.registerMeasure(2l);\r
-\r
- checkTables("addFutureSnapshot", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void addInvisibleMeasure() {\r
- setupData("sharedFixture", "addInvisibleMeasure");\r
-\r
- AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());\r
- asyncMeasureService.registerMeasure(2l);\r
-\r
- checkTables("addInvisibleMeasure", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void deleteMeasure() {\r
- setupData("sharedFixture", "deleteMeasure");\r
-\r
- AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());\r
- asyncMeasureService.deleteMeasure(2l);\r
-\r
- checkTables("deleteMeasure", "async_measure_snapshots");\r
- }\r
-\r
- @Test\r
- public void deleteLastMeasure() {\r
- setupData("sharedFixture", "deleteLastMeasure");\r
-\r
- AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());\r
- asyncMeasureService.deleteMeasure(1l);\r
-\r
- checkTables("deleteLastMeasure", "async_measure_snapshots");\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.jpa.dao;
+
+import org.junit.Test;
+import org.sonar.api.database.model.Snapshot;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+public class AsyncMeasuresServiceTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void assignLatestMeasuresToLastSnapshot() {
+ setupData("sharedFixture", "assignLatestMeasuresToLastSnapshot");
+
+ AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());
+ Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 2);
+ asyncMeasuresService.refresh(snapshot);
+
+ checkTables("assignLatestMeasuresToLastSnapshot", "async_measure_snapshots");
+ }
+
+ @Test
+ public void assignNewMeasuresToLastSnapshot() {
+ setupData("sharedFixture", "assignNewMeasuresToLastSnapshot");
+
+ AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());
+ Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 2);
+ asyncMeasuresService.refresh(snapshot);
+
+ checkTables("assignNewMeasuresToLastSnapshot", "async_measure_snapshots");
+ }
+
+ @Test
+ public void assignMeasuresWhenNoPreviousSnapshot() {
+ setupData("sharedFixture", "assignMeasuresWhenNoPreviousSnapshot");
+
+ AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());
+ Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 1);
+ asyncMeasuresService.refresh(snapshot);
+
+ checkTables("assignMeasuresWhenNoPreviousSnapshot", "async_measure_snapshots");
+ }
+
+ @Test
+ public void assignLatestMeasuresWhenNoPreviousSnapshot() {
+ setupData("sharedFixture", "assignLatestMeasuresWhenNoPreviousSnapshot");
+
+ AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());
+ Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 1);
+ asyncMeasuresService.refresh(snapshot);
+
+ checkTables("assignLatestMeasuresWhenNoPreviousSnapshot", "async_measure_snapshots");
+ }
+
+ @Test
+ public void assignPastMeasuresToPastSnapshot() {
+ setupData("sharedFixture", "assignPastMeasuresToPastSnapshot");
+
+ AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());
+ Snapshot snapshot = getSession().getEntityManager().find(Snapshot.class, 3);
+ asyncMeasuresService.refresh(snapshot);
+
+ checkTables("assignPastMeasuresToPastSnapshot", "async_measure_snapshots");
+ }
+
+ @Test
+ public void assignNewMeasureToFutureSnapshots() {
+ setupData("sharedFixture", "assignNewMeasureToFutureSnapshots");
+
+ AsyncMeasuresService asyncMeasuresService = new AsyncMeasuresService(getSession());
+ asyncMeasuresService.registerMeasure(2l);
+
+ checkTables("assignNewMeasureToFutureSnapshots", "async_measure_snapshots");
+ }
+
+ @Test
+ public void assignMeasureToFutureSnapshotsWithDifferentMetric() {
+ setupData("sharedFixture", "assignMeasureToFutureSnapshotsWithDifferentMetric");
+
+ AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());
+ asyncMeasureService.registerMeasure(3l);
+
+ checkTables("assignMeasureToFutureSnapshotsWithDifferentMetric", "async_measure_snapshots");
+ }
+
+ @Test
+ public void assignAPastMeasureToNextSnapshotsWithDifferentMetric() {
+ setupData("sharedFixture", "assignAPastMeasureToNextSnapshotsWithDifferentMetric");
+
+ AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());
+ asyncMeasureService.registerMeasure(2l);
+
+ checkTables("assignAPastMeasureToNextSnapshotsWithDifferentMetric", "async_measure_snapshots");
+ }
+
+ @Test
+ public void addFutureSnapshot() {
+ setupData("sharedFixture", "addFutureSnapshot");
+
+ AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());
+ asyncMeasureService.registerMeasure(2l);
+
+ checkTables("addFutureSnapshot", "async_measure_snapshots");
+ }
+
+ @Test
+ public void addInvisibleMeasure() {
+ setupData("sharedFixture", "addInvisibleMeasure");
+
+ AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());
+ asyncMeasureService.registerMeasure(2l);
+
+ checkTables("addInvisibleMeasure", "async_measure_snapshots");
+ }
+
+ @Test
+ public void deleteMeasure() {
+ setupData("sharedFixture", "deleteMeasure");
+
+ AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());
+ asyncMeasureService.deleteMeasure(2l);
+
+ checkTables("deleteMeasure", "async_measure_snapshots");
+ }
+
+ @Test
+ public void deleteLastMeasure() {
+ setupData("sharedFixture", "deleteLastMeasure");
+
+ AsyncMeasuresService asyncMeasureService = new AsyncMeasuresService(getSession());
+ asyncMeasureService.deleteMeasure(1l);
+
+ checkTables("deleteLastMeasure", "async_measure_snapshots");
+ }
+
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.jpa.dao;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.sonar.api.database.model.ResourceModel;\r
-import org.sonar.api.measures.Metric;\r
-import org.sonar.jpa.test.AbstractDbUnitTestCase;\r
-\r
-import java.util.Arrays;\r
-import java.util.Collection;\r
-\r
-import static org.hamcrest.Matchers.is;\r
-import static org.hamcrest.Matchers.not;\r
-import static org.junit.Assert.assertThat;\r
-\r
-public class MeasuresDaoTest extends AbstractDbUnitTestCase {\r
-\r
- private MeasuresDao service;\r
- private ResourceModel project;\r
-\r
- @Before\r
- public void before() throws Exception {\r
- service = new MeasuresDao(getSession());\r
- project = new ResourceModel(ResourceModel.SCOPE_PROJECT, "foo:bar", ResourceModel.QUALIFIER_PROJECT_TRUNK, null, "Foo");\r
- project.setName("project name");\r
- getSession().save(project);\r
- }\r
-\r
- @Test\r
- public void shouldReturnUserDefinedMetrics() {\r
- for (Metric metric : createMetrics()) {\r
- getSession().save(metric);\r
- }\r
-\r
- Collection<Metric> metrics = service.getUserDefinedMetrics();\r
- assertThat(metrics.size(), is(2));\r
- for (Metric metric : metrics) {\r
- assertThat(metric.getOrigin(), not(Metric.Origin.JAV));\r
- }\r
- }\r
-\r
- @Test\r
- public void shouldRegisterMetrics() {\r
- Collection<Metric> newMetrics = createMetrics();\r
- service.registerMetrics(newMetrics);\r
-\r
- Collection<Metric> metrics = service.getEnabledMetrics();\r
- assertThat(metrics.size(), is(newMetrics.size()));\r
- }\r
-\r
- @Test\r
- public void shouldDisabledMetrics() {\r
- Collection<Metric> newMetrics = createMetrics();\r
-\r
- service.disabledMetrics(newMetrics);\r
-\r
- Collection<Metric> allMetrics = service.getMetrics();\r
- assertThat(allMetrics.size(), is(newMetrics.size()));\r
-\r
- Collection<Metric> disabledMetrics = service.getEnabledMetrics();\r
- assertThat(disabledMetrics.size(), is(0));\r
- }\r
-\r
-\r
- private Collection<Metric> createMetrics() {\r
- Metric m1 = new Metric("metric1");\r
- m1.setEnabled(false);\r
- m1.setOrigin(Metric.Origin.JAV);\r
-\r
- Metric m2 = new Metric("metric2");\r
- m2.setEnabled(true);\r
- m2.setOrigin(Metric.Origin.JAV);\r
-\r
- Metric m3 = new Metric("metric3");\r
- m3.setEnabled(false);\r
- m3.setOrigin(Metric.Origin.GUI);\r
-\r
- Metric m4 = new Metric("metric4");\r
- m4.setEnabled(true);\r
- m4.setOrigin(Metric.Origin.GUI);\r
-\r
- Metric m5 = new Metric("metric5");\r
- m5.setEnabled(true);\r
- m5.setOrigin(Metric.Origin.WS);\r
-\r
- return Arrays.asList(m1, m2, m3, m4, m5);\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.jpa.dao;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.database.model.ResourceModel;
+import org.sonar.api.measures.Metric;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+
+public class MeasuresDaoTest extends AbstractDbUnitTestCase {
+
+ private MeasuresDao service;
+ private ResourceModel project;
+
+ @Before
+ public void before() throws Exception {
+ service = new MeasuresDao(getSession());
+ project = new ResourceModel(ResourceModel.SCOPE_PROJECT, "foo:bar", ResourceModel.QUALIFIER_PROJECT_TRUNK, null, "Foo");
+ project.setName("project name");
+ getSession().save(project);
+ }
+
+ @Test
+ public void shouldReturnUserDefinedMetrics() {
+ for (Metric metric : createMetrics()) {
+ getSession().save(metric);
+ }
+
+ Collection<Metric> metrics = service.getUserDefinedMetrics();
+ assertThat(metrics.size(), is(2));
+ for (Metric metric : metrics) {
+ assertThat(metric.getOrigin(), not(Metric.Origin.JAV));
+ }
+ }
+
+ @Test
+ public void shouldRegisterMetrics() {
+ Collection<Metric> newMetrics = createMetrics();
+ service.registerMetrics(newMetrics);
+
+ Collection<Metric> metrics = service.getEnabledMetrics();
+ assertThat(metrics.size(), is(newMetrics.size()));
+ }
+
+ @Test
+ public void shouldDisabledMetrics() {
+ Collection<Metric> newMetrics = createMetrics();
+
+ service.disabledMetrics(newMetrics);
+
+ Collection<Metric> allMetrics = service.getMetrics();
+ assertThat(allMetrics.size(), is(newMetrics.size()));
+
+ Collection<Metric> disabledMetrics = service.getEnabledMetrics();
+ assertThat(disabledMetrics.size(), is(0));
+ }
+
+
+ private Collection<Metric> createMetrics() {
+ Metric m1 = new Metric("metric1");
+ m1.setEnabled(false);
+ m1.setOrigin(Metric.Origin.JAV);
+
+ Metric m2 = new Metric("metric2");
+ m2.setEnabled(true);
+ m2.setOrigin(Metric.Origin.JAV);
+
+ Metric m3 = new Metric("metric3");
+ m3.setEnabled(false);
+ m3.setOrigin(Metric.Origin.GUI);
+
+ Metric m4 = new Metric("metric4");
+ m4.setEnabled(true);
+ m4.setOrigin(Metric.Origin.GUI);
+
+ Metric m5 = new Metric("metric5");
+ m5.setEnabled(true);
+ m5.setOrigin(Metric.Origin.WS);
+
+ return Arrays.asList(m1, m2, m3, m4, m5);
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.jpa.dao;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.sonar.api.database.model.ResourceModel;\r
-import org.sonar.api.profiles.RulesProfile;\r
-import org.sonar.jpa.test.AbstractDbUnitTestCase;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertNull;\r
-\r
-public class ProfilesDaoTest extends AbstractDbUnitTestCase {\r
-\r
- private ProfilesDao profilesDao;\r
-\r
- @Before\r
- public void setup() {\r
- profilesDao = new ProfilesDao(getSession());\r
- }\r
-\r
-\r
- @Test\r
- public void testGetActiveProfile() {\r
- RulesProfile testDefaultProfile = new RulesProfile("default", "java", true, true);\r
- RulesProfile testProfile = new RulesProfile("not default", "java", false, false);\r
- getSession().save(testDefaultProfile, testProfile);\r
-\r
- ResourceModel testResourceWithProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withProfile", "qual", null, "test");\r
- testResourceWithProfile.setRulesProfile(testProfile);\r
- ResourceModel testResourceWithNoProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withoutProfile", "qual", null, "test");\r
- getSession().save(testResourceWithProfile, testResourceWithNoProfile);\r
-\r
- assertNull(profilesDao.getActiveProfile("wrongLanguage", "withoutProfile"));\r
- assertEquals(testDefaultProfile.getId(), profilesDao.getActiveProfile("java", "wrongKey").getId());\r
- assertEquals(testDefaultProfile.getId(), profilesDao.getActiveProfile("java", "withoutProfile").getId());\r
- assertEquals(testProfile.getId(), profilesDao.getActiveProfile("java", "withProfile").getId());\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.jpa.dao;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.database.model.ResourceModel;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ProfilesDaoTest extends AbstractDbUnitTestCase {
+
+ private ProfilesDao profilesDao;
+
+ @Before
+ public void setup() {
+ profilesDao = new ProfilesDao(getSession());
+ }
+
+
+ @Test
+ public void testGetActiveProfile() {
+ RulesProfile testDefaultProfile = new RulesProfile("default", "java", true, true);
+ RulesProfile testProfile = new RulesProfile("not default", "java", false, false);
+ getSession().save(testDefaultProfile, testProfile);
+
+ ResourceModel testResourceWithProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withProfile", "qual", null, "test");
+ testResourceWithProfile.setRulesProfile(testProfile);
+ ResourceModel testResourceWithNoProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withoutProfile", "qual", null, "test");
+ getSession().save(testResourceWithProfile, testResourceWithNoProfile);
+
+ assertNull(profilesDao.getActiveProfile("wrongLanguage", "withoutProfile"));
+ assertEquals(testDefaultProfile.getId(), profilesDao.getActiveProfile("java", "wrongKey").getId());
+ assertEquals(testDefaultProfile.getId(), profilesDao.getActiveProfile("java", "withoutProfile").getId());
+ assertEquals(testProfile.getId(), profilesDao.getActiveProfile("java", "withProfile").getId());
+ }
+
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.jpa.dao;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.sonar.api.profiles.RulesProfile;\r
-import org.sonar.api.rules.*;\r
-import org.sonar.jpa.test.AbstractDbUnitTestCase;\r
-\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-import static org.hamcrest.CoreMatchers.*;\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertThat;\r
-\r
-public class RulesDaoTest extends AbstractDbUnitTestCase {\r
-\r
- private RulesDao rulesDao;\r
-\r
- @Before\r
- public void setup() {\r
- rulesDao = new RulesDao(getSession());\r
- }\r
-\r
- @Test\r
- public void shouldGetRules() {\r
- setupData("shouldGetRules");\r
-\r
- List<Rule> rules = rulesDao.getRules();\r
- assertThat(rules, notNullValue());\r
- assertThat(rules.size(), is(2));\r
-\r
- assertEquals("rule_one", rules.get(0).getKey());\r
- assertEquals(1, rules.get(0).getParams().size());\r
- }\r
-\r
- @Test\r
- public void shouldGetRuleWithRuleKeyAndPluginKey() {\r
- setupData("shouldGetRuleWithRuleKeyAndPluginKey");\r
-\r
- Rule rule = rulesDao.getRuleByKey("plugin", "checkstyle.rule1");\r
- assertThat(rule, notNullValue());\r
- assertThat(rule.getId(), notNullValue());\r
-\r
- Rule rule2 = rulesDao.getRuleByKey("plugin", "key not found");\r
- assertThat(rule2, nullValue());\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.jpa.dao;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.rules.*;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+public class RulesDaoTest extends AbstractDbUnitTestCase {
+
+ private RulesDao rulesDao;
+
+ @Before
+ public void setup() {
+ rulesDao = new RulesDao(getSession());
+ }
+
+ @Test
+ public void shouldGetRules() {
+ setupData("shouldGetRules");
+
+ List<Rule> rules = rulesDao.getRules();
+ assertThat(rules, notNullValue());
+ assertThat(rules.size(), is(2));
+
+ assertEquals("rule_one", rules.get(0).getKey());
+ assertEquals(1, rules.get(0).getParams().size());
+ }
+
+ @Test
+ public void shouldGetRuleWithRuleKeyAndPluginKey() {
+ setupData("shouldGetRuleWithRuleKeyAndPluginKey");
+
+ Rule rule = rulesDao.getRuleByKey("plugin", "checkstyle.rule1");
+ assertThat(rule, notNullValue());
+ assertThat(rule.getId(), notNullValue());
+
+ Rule rule2 = rulesDao.getRuleByKey("plugin", "key not found");
+ assertThat(rule2, nullValue());
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.jpa.session;\r
-\r
-import org.hamcrest.Matchers;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.internal.matchers.IsCollectionContaining;\r
-import org.sonar.api.database.model.MeasureModel;\r
-import org.sonar.api.database.model.ResourceModel;\r
-import org.sonar.api.database.model.Snapshot;\r
-import org.sonar.api.measures.CoreMetrics;\r
-import org.sonar.api.measures.Metric;\r
-import org.sonar.jpa.dao.MeasuresDao;\r
-import org.sonar.jpa.test.AbstractDbUnitTestCase;\r
-\r
-import javax.persistence.NonUniqueResultException;\r
-import java.sql.Date;\r
-import java.util.List;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-public class DatabaseSessionTest extends AbstractDbUnitTestCase {\r
- private static final Long NB_INSERTS = 20000l;\r
-\r
- private ResourceModel project1;\r
- private ResourceModel project2;\r
-\r
- @Before\r
- public void setup() {\r
- project1 = new ResourceModel(ResourceModel.SCOPE_PROJECT, "mygroup:myartifact", "JAV", null, "my name");\r
- project2 = new ResourceModel(ResourceModel.SCOPE_PROJECT, "mygroup:myartifact1", "JAV", null, "my name 2");\r
- }\r
-\r
- @Test\r
- public void performaceTestOnBatchInserts() throws Exception {\r
-\r
- Snapshot snapshot = new Snapshot(project1, true, "", new Date(1));\r
- getSession().save(project1, snapshot);\r
- getSession().save(CoreMetrics.CLASSES);\r
- getSession().commit();\r
-\r
- Metric metric = new MeasuresDao(getSession()).getMetric(CoreMetrics.CLASSES_KEY);\r
- for (int i = 0; i < NB_INSERTS; i++) {\r
- MeasureModel pm = new MeasureModel(metric.getId(), 1.0).setSnapshotId(snapshot.getId());\r
- getSession().save(pm);\r
- }\r
-\r
- getSession().commit();\r
- assertEquals(NB_INSERTS, getHQLCount(MeasureModel.class));\r
-\r
- }\r
-\r
- @Test\r
- public void testGetSingleResultWithNoResults() {\r
- assertNull(getSession().getSingleResult(ResourceModel.class, "name", "test"));\r
- }\r
-\r
- @Test\r
- public void testGetSingleResultWithNoCriterias() {\r
- try {\r
- assertNull(getSession().getSingleResult(ResourceModel.class, (Object[]) null));\r
- fail("No IllegalStateException raised");\r
- } catch (IllegalStateException ex) {\r
- // error raised correctly\r
- }\r
- }\r
-\r
- @Test\r
- public void testGetSingleResultWithOneResult() {\r
- getSession().save(project1);\r
- ResourceModel hit = getSession().getSingleResult(ResourceModel.class, "name", "my name");\r
- assertNotNull(hit);\r
- assertEquals(project1, hit);\r
- }\r
-\r
- @Test\r
- public void testGetSingleResultWithTwoResults() {\r
- getSession().save(project1, project2);\r
- try {\r
- getSession().getSingleResult(ResourceModel.class, "qualifier", "JAV");\r
- fail("No NonUniqueResultException raised");\r
- } catch (NonUniqueResultException ex) {\r
- // error raised correctly\r
- }\r
- }\r
-\r
- @Test\r
- public void testGetResultsWithNoResults() {\r
- List<ResourceModel> hits = getSession().getResults(ResourceModel.class, "name", "foo");\r
- assertTrue(hits.isEmpty());\r
- }\r
-\r
- @Test\r
- public void testGetResultsWithMultipleResults() {\r
- ResourceModel project3 = new ResourceModel(ResourceModel.SCOPE_PROJECT, "mygroup:myartifact3", "TEST", null, "my name 3");\r
- getSession().save(project1, project2, project3);\r
-\r
- List<ResourceModel> hits = getSession().getResults(ResourceModel.class, "qualifier", "JAV");\r
- assertFalse(hits.isEmpty());\r
- assertThat(hits, IsCollectionContaining.hasItems(project1, project2));\r
- assertThat(hits, Matchers.not(IsCollectionContaining.hasItem(project3)));\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.jpa.session;
+
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.internal.matchers.IsCollectionContaining;
+import org.sonar.api.database.model.MeasureModel;
+import org.sonar.api.database.model.ResourceModel;
+import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.Metric;
+import org.sonar.jpa.dao.MeasuresDao;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import javax.persistence.NonUniqueResultException;
+import java.sql.Date;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+public class DatabaseSessionTest extends AbstractDbUnitTestCase {
+ private static final Long NB_INSERTS = 20000l;
+
+ private ResourceModel project1;
+ private ResourceModel project2;
+
+ @Before
+ public void setup() {
+ project1 = new ResourceModel(ResourceModel.SCOPE_PROJECT, "mygroup:myartifact", "JAV", null, "my name");
+ project2 = new ResourceModel(ResourceModel.SCOPE_PROJECT, "mygroup:myartifact1", "JAV", null, "my name 2");
+ }
+
+ @Test
+ public void performaceTestOnBatchInserts() throws Exception {
+
+ Snapshot snapshot = new Snapshot(project1, true, "", new Date(1));
+ getSession().save(project1, snapshot);
+ getSession().save(CoreMetrics.CLASSES);
+ getSession().commit();
+
+ Metric metric = new MeasuresDao(getSession()).getMetric(CoreMetrics.CLASSES_KEY);
+ for (int i = 0; i < NB_INSERTS; i++) {
+ MeasureModel pm = new MeasureModel(metric.getId(), 1.0).setSnapshotId(snapshot.getId());
+ getSession().save(pm);
+ }
+
+ getSession().commit();
+ assertEquals(NB_INSERTS, getHQLCount(MeasureModel.class));
+
+ }
+
+ @Test
+ public void testGetSingleResultWithNoResults() {
+ assertNull(getSession().getSingleResult(ResourceModel.class, "name", "test"));
+ }
+
+ @Test
+ public void testGetSingleResultWithNoCriterias() {
+ try {
+ assertNull(getSession().getSingleResult(ResourceModel.class, (Object[]) null));
+ fail("No IllegalStateException raised");
+ } catch (IllegalStateException ex) {
+ // error raised correctly
+ }
+ }
+
+ @Test
+ public void testGetSingleResultWithOneResult() {
+ getSession().save(project1);
+ ResourceModel hit = getSession().getSingleResult(ResourceModel.class, "name", "my name");
+ assertNotNull(hit);
+ assertEquals(project1, hit);
+ }
+
+ @Test
+ public void testGetSingleResultWithTwoResults() {
+ getSession().save(project1, project2);
+ try {
+ getSession().getSingleResult(ResourceModel.class, "qualifier", "JAV");
+ fail("No NonUniqueResultException raised");
+ } catch (NonUniqueResultException ex) {
+ // error raised correctly
+ }
+ }
+
+ @Test
+ public void testGetResultsWithNoResults() {
+ List<ResourceModel> hits = getSession().getResults(ResourceModel.class, "name", "foo");
+ assertTrue(hits.isEmpty());
+ }
+
+ @Test
+ public void testGetResultsWithMultipleResults() {
+ ResourceModel project3 = new ResourceModel(ResourceModel.SCOPE_PROJECT, "mygroup:myartifact3", "TEST", null, "my name 3");
+ getSession().save(project1, project2, project3);
+
+ List<ResourceModel> hits = getSession().getResults(ResourceModel.class, "qualifier", "JAV");
+ assertFalse(hits.isEmpty());
+ assertThat(hits, IsCollectionContaining.hasItems(project1, project2));
+ assertThat(hits, Matchers.not(IsCollectionContaining.hasItem(project3)));
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.rules;\r
-\r
-import org.sonar.api.profiles.RulesProfile;\r
-\r
-@Deprecated\r
-public interface ConfigurationExportable {\r
-\r
- String exportConfiguration(RulesProfile profile);\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.rules;
+
+import org.sonar.api.profiles.RulesProfile;
+
+@Deprecated
+public interface ConfigurationExportable {
+
+ String exportConfiguration(RulesProfile profile);
+
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.rules;\r
-\r
-import java.util.List;\r
-import org.sonar.api.rules.Rule;\r
-\r
-@Deprecated\r
-public interface ConfigurationImportable {\r
-\r
- List<ActiveRule> importConfiguration(String configuration, List<Rule> rules);\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.rules;
+
+import java.util.List;
+import org.sonar.api.rules.Rule;
+
+@Deprecated
+public interface ConfigurationImportable {
+
+ List<ActiveRule> importConfiguration(String configuration, List<Rule> rules);
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.rules;\r
-\r
-import org.sonar.api.BatchExtension;\r
-import org.sonar.api.ServerExtension;\r
-import org.sonar.api.profiles.RulesProfile;\r
-import org.sonar.api.resources.Language;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * @deprecated since 2.3\r
- */\r
-@Deprecated\r
-public interface RulesRepository<LANG extends Language> extends BatchExtension, ServerExtension {\r
-\r
- /**\r
- * @return the language the repository is associated\r
- */\r
- LANG getLanguage();\r
-\r
- /**\r
- * @return the list of rules of the repository\r
- */\r
- List<Rule> getInitialReferential();\r
-\r
- /**\r
- * The method to parse the base referential of rules and return a list of rules\r
- *\r
- * @param fileContent the initial referential\r
- * @return a list of rules\r
- */\r
- List<Rule> parseReferential(String fileContent);\r
-\r
- /**\r
- * @return a list of profiles that are provided with the referential\r
- */\r
- List<RulesProfile> getProvidedProfiles();\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.rules;
+
+import org.sonar.api.BatchExtension;
+import org.sonar.api.ServerExtension;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.resources.Language;
+
+import java.util.List;
+
+/**
+ * @deprecated since 2.3
+ */
+@Deprecated
+public interface RulesRepository<LANG extends Language> extends BatchExtension, ServerExtension {
+
+ /**
+ * @return the language the repository is associated
+ */
+ LANG getLanguage();
+
+ /**
+ * @return the list of rules of the repository
+ */
+ List<Rule> getInitialReferential();
+
+ /**
+ * The method to parse the base referential of rules and return a list of rules
+ *
+ * @param fileContent the initial referential
+ * @return a list of rules
+ */
+ List<Rule> parseReferential(String fileContent);
+
+ /**
+ * @return a list of profiles that are provided with the referential
+ */
+ List<RulesProfile> getProvidedProfiles();
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.rules.xml;\r
-\r
-import com.thoughtworks.xstream.annotations.XStreamAlias;\r
-import com.thoughtworks.xstream.annotations.XStreamAsAttribute;\r
-\r
-@Deprecated\r
-@XStreamAlias("property")\r
-public class Property {\r
-\r
- @XStreamAsAttribute\r
- private String name;\r
-\r
- @XStreamAsAttribute\r
- private String value;\r
-\r
- public Property(String name, String value) {\r
- this.name = name;\r
- this.value = value;\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- public String getValue() {\r
- return value;\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.rules.xml;
+
+import com.thoughtworks.xstream.annotations.XStreamAlias;
+import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
+
+@Deprecated
+@XStreamAlias("property")
+public class Property {
+
+ @XStreamAsAttribute
+ private String name;
+
+ @XStreamAsAttribute
+ private String value;
+
+ public Property(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.rules.xml;\r
-\r
-import com.thoughtworks.xstream.annotations.XStreamAlias;\r
-import com.thoughtworks.xstream.annotations.XStreamAsAttribute;\r
-import com.thoughtworks.xstream.annotations.XStreamImplicit;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-@Deprecated\r
-@XStreamAlias("rule")\r
-public class Rule implements Comparable<String> {\r
-\r
- @XStreamAsAttribute\r
- private String key;\r
-\r
- @XStreamAsAttribute\r
- private String priority;\r
-\r
- @XStreamImplicit\r
- private List<Property> properties;\r
-\r
- public Rule(String ref) {\r
- this(ref, null);\r
- }\r
-\r
- public Rule(String ref, String priority) {\r
- this.key = ref;\r
- this.priority = priority;\r
- }\r
-\r
- public String getKey() {\r
- return key;\r
- }\r
-\r
- public void setProperties(List<Property> properties) {\r
- this.properties = properties;\r
- }\r
-\r
- public List<Property> getProperties() {\r
- return properties;\r
- }\r
-\r
- public int compareTo(String o) {\r
- return o.compareTo(key);\r
- }\r
-\r
- public String getPriority() {\r
- return priority;\r
- }\r
-\r
- public void setPriority(String priority) {\r
- this.priority = priority;\r
- }\r
-\r
- public void addProperty(Property property) {\r
- if (properties == null) {\r
- properties = new ArrayList<Property>();\r
- }\r
- properties.add(property);\r
- }\r
-\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.rules.xml;
+
+import com.thoughtworks.xstream.annotations.XStreamAlias;
+import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
+import com.thoughtworks.xstream.annotations.XStreamImplicit;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Deprecated
+@XStreamAlias("rule")
+public class Rule implements Comparable<String> {
+
+ @XStreamAsAttribute
+ private String key;
+
+ @XStreamAsAttribute
+ private String priority;
+
+ @XStreamImplicit
+ private List<Property> properties;
+
+ public Rule(String ref) {
+ this(ref, null);
+ }
+
+ public Rule(String ref, String priority) {
+ this.key = ref;
+ this.priority = priority;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setProperties(List<Property> properties) {
+ this.properties = properties;
+ }
+
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ public int compareTo(String o) {
+ return o.compareTo(key);
+ }
+
+ public String getPriority() {
+ return priority;
+ }
+
+ public void setPriority(String priority) {
+ this.priority = priority;
+ }
+
+ public void addProperty(Property property) {
+ if (properties == null) {
+ properties = new ArrayList<Property>();
+ }
+ properties.add(property);
+ }
+
}
\ No newline at end of file
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package org.sonar.api.batch;\r
-\r
-import static junit.framework.Assert.assertNull;\r
-import static org.hamcrest.MatcherAssert.assertThat;\r
-import static org.hamcrest.Matchers.is;\r
-import static org.mockito.Mockito.mock;\r
-\r
-import java.io.StringReader;\r
-\r
-import javax.xml.stream.XMLStreamException;\r
-\r
-import org.codehaus.staxmate.in.SMInputCursor;\r
-import org.hibernate.lob.ReaderInputStream;\r
-import org.junit.Test;\r
-import org.sonar.api.resources.JavaFile;\r
-import org.sonar.api.resources.Resource;\r
-import org.sonar.api.rules.RulesManager;\r
-\r
-public class AbstractViolationsStaxParserTest {\r
-\r
- @Test\r
- public void testParseLineIndex() {\r
-\r
- assertThat(AbstractViolationsStaxParser.parseLineIndex("4"), is(4));\r
- assertNull(AbstractViolationsStaxParser.parseLineIndex("toto"));\r
- assertNull(AbstractViolationsStaxParser.parseLineIndex(""));\r
- assertNull(AbstractViolationsStaxParser.parseLineIndex(null));\r
- assertNull(AbstractViolationsStaxParser.parseLineIndex("-1"));\r
- }\r
-\r
- @Test\r
- public void testDoNotSaveViolationsOnUnexistedResource() throws XMLStreamException {\r
- SensorContext context = mock(SensorContext.class);\r
- MyViolationParser violationParser = new MyViolationParser(context, null);\r
- violationParser.setDoSaveViolationsOnUnexistedResource(false);\r
- violationParser.parse(new ReaderInputStream(new StringReader("<root><file/></root>")));\r
- }\r
-\r
- @Test(expected = CursorForViolationsMethodHasBeenCalled.class)\r
- public void testDoSaveViolationsOnUnexistedResource() throws XMLStreamException {\r
- SensorContext context = mock(SensorContext.class);\r
- MyViolationParser violationParser = new MyViolationParser(context, null);\r
- violationParser.parse(new ReaderInputStream(new StringReader("<root><file/></root>")));\r
- }\r
-\r
- private class MyViolationParser extends AbstractViolationsStaxParser {\r
-\r
- protected MyViolationParser(SensorContext context, RulesManager rulesManager) {\r
- super(context, rulesManager);\r
- }\r
-\r
- protected SMInputCursor cursorForResources(SMInputCursor rootCursor) throws XMLStreamException {\r
- return rootCursor.descendantElementCursor("file");\r
- }\r
-\r
- protected SMInputCursor cursorForViolations(SMInputCursor resourcesCursor) throws XMLStreamException {\r
- throw new CursorForViolationsMethodHasBeenCalled();\r
- }\r
-\r
- protected Resource toResource(SMInputCursor resourceCursor) throws XMLStreamException {\r
- return new JavaFile("org.sonar.MyClass");\r
- }\r
-\r
- protected String messageFor(SMInputCursor violationCursor) throws XMLStreamException {\r
- return null;\r
- }\r
-\r
- protected String ruleKey(SMInputCursor violationCursor) throws XMLStreamException {\r
- return null;\r
- }\r
-\r
- protected String keyForPlugin() {\r
- return null;\r
- }\r
-\r
- protected String lineNumberForViolation(SMInputCursor violationCursor) throws XMLStreamException {\r
- return null;\r
- }\r
- }\r
-\r
- private class CursorForViolationsMethodHasBeenCalled extends RuntimeException {\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package org.sonar.api.batch;
+
+import static junit.framework.Assert.assertNull;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.codehaus.staxmate.in.SMInputCursor;
+import org.hibernate.lob.ReaderInputStream;
+import org.junit.Test;
+import org.sonar.api.resources.JavaFile;
+import org.sonar.api.resources.Resource;
+import org.sonar.api.rules.RulesManager;
+
+public class AbstractViolationsStaxParserTest {
+
+ @Test
+ public void testParseLineIndex() {
+
+ assertThat(AbstractViolationsStaxParser.parseLineIndex("4"), is(4));
+ assertNull(AbstractViolationsStaxParser.parseLineIndex("toto"));
+ assertNull(AbstractViolationsStaxParser.parseLineIndex(""));
+ assertNull(AbstractViolationsStaxParser.parseLineIndex(null));
+ assertNull(AbstractViolationsStaxParser.parseLineIndex("-1"));
+ }
+
+ @Test
+ public void testDoNotSaveViolationsOnUnexistedResource() throws XMLStreamException {
+ SensorContext context = mock(SensorContext.class);
+ MyViolationParser violationParser = new MyViolationParser(context, null);
+ violationParser.setDoSaveViolationsOnUnexistedResource(false);
+ violationParser.parse(new ReaderInputStream(new StringReader("<root><file/></root>")));
+ }
+
+ @Test(expected = CursorForViolationsMethodHasBeenCalled.class)
+ public void testDoSaveViolationsOnUnexistedResource() throws XMLStreamException {
+ SensorContext context = mock(SensorContext.class);
+ MyViolationParser violationParser = new MyViolationParser(context, null);
+ violationParser.parse(new ReaderInputStream(new StringReader("<root><file/></root>")));
+ }
+
+ private class MyViolationParser extends AbstractViolationsStaxParser {
+
+ protected MyViolationParser(SensorContext context, RulesManager rulesManager) {
+ super(context, rulesManager);
+ }
+
+ protected SMInputCursor cursorForResources(SMInputCursor rootCursor) throws XMLStreamException {
+ return rootCursor.descendantElementCursor("file");
+ }
+
+ protected SMInputCursor cursorForViolations(SMInputCursor resourcesCursor) throws XMLStreamException {
+ throw new CursorForViolationsMethodHasBeenCalled();
+ }
+
+ protected Resource toResource(SMInputCursor resourceCursor) throws XMLStreamException {
+ return new JavaFile("org.sonar.MyClass");
+ }
+
+ protected String messageFor(SMInputCursor violationCursor) throws XMLStreamException {
+ return null;
+ }
+
+ protected String ruleKey(SMInputCursor violationCursor) throws XMLStreamException {
+ return null;
+ }
+
+ protected String keyForPlugin() {
+ return null;
+ }
+
+ protected String lineNumberForViolation(SMInputCursor violationCursor) throws XMLStreamException {
+ return null;
+ }
+ }
+
+ private class CursorForViolationsMethodHasBeenCalled extends RuntimeException {
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.cpd;\r
-\r
-import net.sourceforge.pmd.util.filter.Filters;\r
-\r
-import java.io.FilenameFilter;\r
-\r
-public abstract class AbstractLanguage implements Language {\r
- private final Tokenizer tokenizer;\r
- private final FilenameFilter fileFilter;\r
-\r
- public AbstractLanguage(Tokenizer tokenizer, String... extensions) {\r
- this.tokenizer = tokenizer;\r
- fileFilter = net.sourceforge.pmd.util.filter.Filters.toFilenameFilter(Filters.getFileExtensionOrDirectoryFilter(extensions));\r
- }\r
-\r
- public FilenameFilter getFileFilter() {\r
- return fileFilter;\r
- }\r
-\r
- public Tokenizer getTokenizer() {\r
- return tokenizer;\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.cpd;
+
+import net.sourceforge.pmd.util.filter.Filters;
+
+import java.io.FilenameFilter;
+
+public abstract class AbstractLanguage implements Language {
+ private final Tokenizer tokenizer;
+ private final FilenameFilter fileFilter;
+
+ public AbstractLanguage(Tokenizer tokenizer, String... extensions) {
+ this.tokenizer = tokenizer;
+ fileFilter = net.sourceforge.pmd.util.filter.Filters.toFilenameFilter(Filters.getFileExtensionOrDirectoryFilter(extensions));
+ }
+
+ public FilenameFilter getFileFilter() {
+ return fileFilter;
+ }
+
+ public Tokenizer getTokenizer() {
+ return tokenizer;
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util;\r
-\r
-import java.io.File;\r
-import java.io.FilenameFilter;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-/**\r
- * A utility class for finding files within a directory.\r
- */\r
-public class FileFinder {\r
-\r
- private FilenameFilter filter;\r
- private static final String FILE_SEP = System.getProperty("file.separator");\r
-\r
- public List<File> findFilesFrom(String dir, FilenameFilter filter, boolean recurse) {\r
- this.filter = filter;\r
- List<File> files = new ArrayList<File>();\r
- scanDirectory(new File(dir), files, recurse);\r
- return files;\r
- }\r
-\r
- /**\r
- * Implements a tail recursive file scanner\r
- */\r
- private void scanDirectory(File dir, List<File> list, boolean recurse) {\r
- String[] candidates = dir.list(filter);\r
- if (candidates == null) {\r
- return;\r
- }\r
- for (int i = 0; i < candidates.length; i++) {\r
- File tmp = new File(dir + FILE_SEP + candidates[i]);\r
- if (tmp.isDirectory()) {\r
- if (recurse) {\r
- scanDirectory(tmp, list, true);\r
- }\r
- } else {\r
- list.add(new File(dir + FILE_SEP + candidates[i]));\r
- }\r
- }\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A utility class for finding files within a directory.
+ */
+public class FileFinder {
+
+ private FilenameFilter filter;
+ private static final String FILE_SEP = System.getProperty("file.separator");
+
+ public List<File> findFilesFrom(String dir, FilenameFilter filter, boolean recurse) {
+ this.filter = filter;
+ List<File> files = new ArrayList<File>();
+ scanDirectory(new File(dir), files, recurse);
+ return files;
+ }
+
+ /**
+ * Implements a tail recursive file scanner
+ */
+ private void scanDirectory(File dir, List<File> list, boolean recurse) {
+ String[] candidates = dir.list(filter);
+ if (candidates == null) {
+ return;
+ }
+ for (int i = 0; i < candidates.length; i++) {
+ File tmp = new File(dir + FILE_SEP + candidates[i]);
+ if (tmp.isDirectory()) {
+ if (recurse) {
+ scanDirectory(tmp, list, true);
+ }
+ } else {
+ list.add(new File(dir + FILE_SEP + candidates[i]));
+ }
+ }
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util.filter;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-/**\r
- * A base class for Filters which implements behavior using a List of other\r
- * Filters.\r
- * \r
- * @param <T>\r
- * The underlying type on which the filter applies.\r
- */\r
-public abstract class AbstractCompoundFilter<T> implements Filter<T> {\r
-\r
- protected List<Filter<T>> filters;\r
-\r
- public AbstractCompoundFilter() {\r
- filters = new ArrayList<Filter<T>>(2);\r
- }\r
-\r
- public AbstractCompoundFilter(Filter<T>... filters) {\r
- this.filters = new ArrayList<Filter<T>>(filters.length);\r
- for (Filter<T> filter : filters) {\r
- this.filters.add(filter);\r
- }\r
- }\r
-\r
- public List<Filter<T>> getFilters() {\r
- return filters;\r
- }\r
-\r
- public void setFilters(List<Filter<T>> filters) {\r
- this.filters = filters;\r
- }\r
-\r
- public void addFilter(Filter<T> filter) {\r
- filters.add(filter);\r
- }\r
-\r
- protected abstract String getOperator();\r
-\r
- public String toString() {\r
- StringBuilder builder = new StringBuilder();\r
- builder.append("(");\r
- for (int i = 0; i < filters.size(); i++) {\r
- if (i > 0) {\r
- builder.append(" ");\r
- builder.append(getOperator());\r
- builder.append(" ");\r
- }\r
- builder.append(filters.get(i));\r
- }\r
- builder.append(")");\r
- return builder.toString();\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util.filter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A base class for Filters which implements behavior using a List of other
+ * Filters.
+ *
+ * @param <T>
+ * The underlying type on which the filter applies.
+ */
+public abstract class AbstractCompoundFilter<T> implements Filter<T> {
+
+ protected List<Filter<T>> filters;
+
+ public AbstractCompoundFilter() {
+ filters = new ArrayList<Filter<T>>(2);
+ }
+
+ public AbstractCompoundFilter(Filter<T>... filters) {
+ this.filters = new ArrayList<Filter<T>>(filters.length);
+ for (Filter<T> filter : filters) {
+ this.filters.add(filter);
+ }
+ }
+
+ public List<Filter<T>> getFilters() {
+ return filters;
+ }
+
+ public void setFilters(List<Filter<T>> filters) {
+ this.filters = filters;
+ }
+
+ public void addFilter(Filter<T> filter) {
+ filters.add(filter);
+ }
+
+ protected abstract String getOperator();
+
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("(");
+ for (int i = 0; i < filters.size(); i++) {
+ if (i > 0) {
+ builder.append(" ");
+ builder.append(getOperator());
+ builder.append(" ");
+ }
+ builder.append(filters.get(i));
+ }
+ builder.append(")");
+ return builder.toString();
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util.filter;\r
-\r
-/**\r
- * A base class for Filters which implements behavior using delegation\r
- * to an underlying filter.\r
- * \r
- * @param <T>\r
- * The underlying type on which the filter applies.\r
- */\r
-public abstract class AbstractDelegateFilter<T> implements Filter<T> {\r
- protected Filter<T> filter;\r
-\r
- public AbstractDelegateFilter() {\r
- }\r
-\r
- public AbstractDelegateFilter(Filter<T> filter) {\r
- this.filter = filter;\r
- }\r
-\r
- public Filter<T> getFilter() {\r
- return filter;\r
- }\r
-\r
- public void setFilter(Filter<T> filter) {\r
- this.filter = filter;\r
- }\r
-\r
- // Subclass should override to do something other the simply delegate.\r
- public boolean filter(T obj) {\r
- return filter.filter(obj);\r
- }\r
-\r
- // Subclass should override to do something other the simply delegate.\r
- public String toString() {\r
- return filter.toString();\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util.filter;
+
+/**
+ * A base class for Filters which implements behavior using delegation
+ * to an underlying filter.
+ *
+ * @param <T>
+ * The underlying type on which the filter applies.
+ */
+public abstract class AbstractDelegateFilter<T> implements Filter<T> {
+ protected Filter<T> filter;
+
+ public AbstractDelegateFilter() {
+ }
+
+ public AbstractDelegateFilter(Filter<T> filter) {
+ this.filter = filter;
+ }
+
+ public Filter<T> getFilter() {
+ return filter;
+ }
+
+ public void setFilter(Filter<T> filter) {
+ this.filter = filter;
+ }
+
+ // Subclass should override to do something other the simply delegate.
+ public boolean filter(T obj) {
+ return filter.filter(obj);
+ }
+
+ // Subclass should override to do something other the simply delegate.
+ public String toString() {
+ return filter.toString();
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util.filter;\r
-\r
-/**\r
- * A logical AND of a list of Filters. This implementation is short circuiting.\r
- * \r
- * @param <T>\r
- * The underlying type on which the filter applies.\r
- */\r
-public class AndFilter<T> extends AbstractCompoundFilter<T> {\r
-\r
- public AndFilter() {\r
- super();\r
- }\r
-\r
- public AndFilter(Filter<T>... filters) {\r
- super(filters);\r
- }\r
-\r
- public boolean filter(T obj) {\r
- boolean match = true;\r
- for (Filter<T> filter : filters) {\r
- if (!filter.filter(obj)) {\r
- match = false;\r
- break;\r
- }\r
- }\r
- return match;\r
- }\r
-\r
- @Override\r
- protected String getOperator() {\r
- return "and";\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util.filter;
+
+/**
+ * A logical AND of a list of Filters. This implementation is short circuiting.
+ *
+ * @param <T>
+ * The underlying type on which the filter applies.
+ */
+public class AndFilter<T> extends AbstractCompoundFilter<T> {
+
+ public AndFilter() {
+ super();
+ }
+
+ public AndFilter(Filter<T>... filters) {
+ super(filters);
+ }
+
+ public boolean filter(T obj) {
+ boolean match = true;
+ for (Filter<T> filter : filters) {
+ if (!filter.filter(obj)) {
+ match = false;
+ break;
+ }
+ }
+ return match;
+ }
+
+ @Override
+ protected String getOperator() {
+ return "and";
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util.filter;\r
-\r
-import java.io.File;\r
-\r
-/**\r
- * Directory filter.\r
- */\r
-public class DirectoryFilter implements Filter<File> {\r
- public static final DirectoryFilter INSTANCE = new DirectoryFilter();\r
-\r
- private DirectoryFilter() {\r
- }\r
-\r
- public boolean filter(File file) {\r
- return file.isDirectory();\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util.filter;
+
+import java.io.File;
+
+/**
+ * Directory filter.
+ */
+public class DirectoryFilter implements Filter<File> {
+ public static final DirectoryFilter INSTANCE = new DirectoryFilter();
+
+ private DirectoryFilter() {
+ }
+
+ public boolean filter(File file) {
+ return file.isDirectory();
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util.filter;\r
-\r
-import java.io.File;\r
-\r
-public class FileExtensionFilter implements Filter<File> {\r
- protected final String[] extensions;\r
- protected final boolean ignoreCase;\r
-\r
- /**\r
- * Matches any files with the given extensions, ignoring case\r
- */\r
- public FileExtensionFilter(String... extensions) {\r
- this(true, extensions);\r
- }\r
-\r
- /**\r
- * Matches any files with the given extensions, optionally ignoring case.\r
- */\r
- public FileExtensionFilter(boolean ignoreCase, String... extensions) {\r
- this.extensions = extensions;\r
- this.ignoreCase = ignoreCase;\r
- if (ignoreCase) {\r
- for (int i = 0; i < this.extensions.length; i++) {\r
- this.extensions[i] = this.extensions[i].toUpperCase();\r
- }\r
- }\r
- }\r
-\r
- public boolean filter(File file) {\r
- boolean accept = extensions == null;\r
- if (!accept) {\r
- for (String extension : extensions) {\r
- String name = file.getName();\r
- if (ignoreCase ? name.toUpperCase().endsWith(extension) : name.endsWith(extension)) {\r
- accept = true;\r
- break;\r
- }\r
- }\r
- }\r
- return accept;\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util.filter;
+
+import java.io.File;
+
+public class FileExtensionFilter implements Filter<File> {
+ protected final String[] extensions;
+ protected final boolean ignoreCase;
+
+ /**
+ * Matches any files with the given extensions, ignoring case
+ */
+ public FileExtensionFilter(String... extensions) {
+ this(true, extensions);
+ }
+
+ /**
+ * Matches any files with the given extensions, optionally ignoring case.
+ */
+ public FileExtensionFilter(boolean ignoreCase, String... extensions) {
+ this.extensions = extensions;
+ this.ignoreCase = ignoreCase;
+ if (ignoreCase) {
+ for (int i = 0; i < this.extensions.length; i++) {
+ this.extensions[i] = this.extensions[i].toUpperCase();
+ }
+ }
+ }
+
+ public boolean filter(File file) {
+ boolean accept = extensions == null;
+ if (!accept) {
+ for (String extension : extensions) {
+ String name = file.getName();
+ if (ignoreCase ? name.toUpperCase().endsWith(extension) : name.endsWith(extension)) {
+ accept = true;
+ break;
+ }
+ }
+ }
+ return accept;
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util.filter;\r
-\r
-/**\r
- * A Filter interface, used for filtering arbitrary objects.\r
- * \r
- * @param <T>\r
- * The underlying type on which the filter applies.\r
- */\r
-public interface Filter<T> {\r
- boolean filter(T obj);\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util.filter;
+
+/**
+ * A Filter interface, used for filtering arbitrary objects.
+ *
+ * @param <T>
+ * The underlying type on which the filter applies.
+ */
+public interface Filter<T> {
+ boolean filter(T obj);
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util.filter;\r
-\r
-import java.io.File;\r
-import java.io.FilenameFilter;\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.List;\r
-\r
-/**\r
- * Utility class for working with Filters. Contains builder style methods,\r
- * apply methods, as well as mechanisms for adapting Filters and FilenameFilters.\r
- */\r
-public class Filters {\r
-\r
- /**\r
- * Filter a given Collection.\r
- * @param <T> Type of the Collection.\r
- * @param filter A Filter upon the Type of objects in the Collection.\r
- * @param collection The Collection to filter.\r
- * @return A List containing only those objects for which the Filter returned <code>true</code>.\r
- */\r
- public static <T> List<T> filter(Filter<T> filter, Collection<T> collection) {\r
- List<T> list = new ArrayList<T>();\r
- for (T obj : collection) {\r
- if (filter.filter(obj)) {\r
- list.add(obj);\r
- }\r
- }\r
- return list;\r
- }\r
-\r
- /**\r
- * Get a File Filter for files with the given extensions, ignoring case.\r
- * @param extensions The extensions to filter.\r
- * @return A File Filter.\r
- */\r
- public static Filter<File> getFileExtensionFilter(String... extensions) {\r
- return new FileExtensionFilter(extensions);\r
- }\r
-\r
- /**\r
- * Get a File Filter for directories.\r
- * @return A File Filter.\r
- */\r
- public static Filter<File> getDirectoryFilter() {\r
- return DirectoryFilter.INSTANCE;\r
- }\r
-\r
- /**\r
- * Get a File Filter for directories or for files with the given extensions, ignoring case.\r
- * @param extensions The extensions to filter.\r
- * @return A File Filter.\r
- */\r
- public static Filter<File> getFileExtensionOrDirectoryFilter(String... extensions) {\r
- return new OrFilter<File>(getFileExtensionFilter(extensions), getDirectoryFilter());\r
- }\r
-\r
- /**\r
- * Given a String Filter, expose as a File Filter. The File paths are\r
- * normalized to a standard pattern using <code>/</code> as a path separator\r
- * which can be used cross platform easily in a regular expression based\r
- * String Filter.\r
- * \r
- * @param filter A String Filter.\r
- * @return A File Filter.\r
- */\r
- public static Filter<File> toNormalizedFileFilter(final Filter<String> filter) {\r
- return new Filter<File>() {\r
- public boolean filter(File file) {\r
- String path = file.getPath();\r
- path = path.replace('\\', '/');\r
- return filter.filter(path);\r
- }\r
-\r
- public String toString() {\r
- return filter.toString();\r
- }\r
- };\r
- }\r
-\r
- /**\r
- * Given a String Filter, expose as a Filter on another type. The\r
- * <code>toString()</code> method is called on the objects of the other\r
- * type and delegated to the String Filter.\r
- * @param <T> The desired type.\r
- * @param filter The existing String Filter.\r
- * @return A Filter on the desired type.\r
- */\r
- public static <T> Filter<T> fromStringFilter(final Filter<String> filter) {\r
- return new Filter<T>() {\r
- public boolean filter(T obj) {\r
- return filter.filter(obj.toString());\r
- }\r
-\r
- public String toString() {\r
- return filter.toString();\r
- }\r
- };\r
- }\r
-\r
- /**\r
- * Given a File Filter, expose as a FilenameFilter.\r
- * @param filter The File Filter.\r
- * @return A FilenameFilter.\r
- */\r
- public static FilenameFilter toFilenameFilter(final Filter<File> filter) {\r
- return new FilenameFilter() {\r
- public boolean accept(File dir, String name) {\r
- return filter.filter(new File(dir, name));\r
- }\r
-\r
- public String toString() {\r
- return filter.toString();\r
- }\r
- };\r
- }\r
-\r
- /**\r
- * Given a FilenameFilter, expose as a File Filter.\r
- * @param filter The FilenameFilter.\r
- * @return A File Filter.\r
- */\r
- public static Filter<File> toFileFilter(final FilenameFilter filter) {\r
- return new Filter<File>() {\r
- public boolean filter(File file) {\r
- return filter.accept(file.getParentFile(), file.getName());\r
- }\r
-\r
- public String toString() {\r
- return filter.toString();\r
- }\r
- };\r
- }\r
-\r
- /**\r
- * Construct a String Filter using set of include and exclude regular\r
- * expressions. If there are no include regular expressions provide, then\r
- * a regular expression is added which matches every String by default.\r
- * A String is included as long as it matches an include regular expression\r
- * and does not match an exclude regular expression.\r
- * <p>\r
- * In other words, exclude patterns override include patterns.\r
- * \r
- * @param includeRegexes The include regular expressions. May be <code>null</code>.\r
- * @param excludeRegexes The exclude regular expressions. May be <code>null</code>.\r
- * @return A String Filter.\r
- */\r
- public static Filter<String> buildRegexFilterExcludeOverInclude(List<String> includeRegexes,\r
- List<String> excludeRegexes) {\r
- OrFilter<String> includeFilter = new OrFilter<String>();\r
- if (includeRegexes == null || includeRegexes.size() == 0) {\r
- includeFilter.addFilter(new RegexStringFilter(".*"));\r
- } else {\r
- for (String includeRegex : includeRegexes) {\r
- includeFilter.addFilter(new RegexStringFilter(includeRegex));\r
- }\r
- }\r
-\r
- OrFilter<String> excludeFilter = new OrFilter<String>();\r
- if (excludeRegexes != null) {\r
- for (String excludeRegex : excludeRegexes) {\r
- excludeFilter.addFilter(new RegexStringFilter(excludeRegex));\r
- }\r
- }\r
-\r
- return new AndFilter<String>(includeFilter, new NotFilter<String>(excludeFilter));\r
- }\r
-\r
- /**\r
- * Construct a String Filter using set of include and exclude regular\r
- * expressions. If there are no include regular expressions provide, then\r
- * a regular expression is added which matches every String by default.\r
- * A String is included as long as the case that there is an include which\r
- * matches or there is not an exclude which matches.\r
- * <p>\r
- * In other words, include patterns override exclude patterns.\r
- * \r
- * @param includeRegexes The include regular expressions. May be <code>null</code>.\r
- * @param excludeRegexes The exclude regular expressions. May be <code>null</code>.\r
- * @return A String Filter.\r
- */\r
- public static Filter<String> buildRegexFilterIncludeOverExclude(List<String> includeRegexes,\r
- List<String> excludeRegexes) {\r
- OrFilter<String> includeFilter = new OrFilter<String>();\r
- if (includeRegexes != null) {\r
- for (String includeRegex : includeRegexes) {\r
- includeFilter.addFilter(new RegexStringFilter(includeRegex));\r
- }\r
- }\r
-\r
- OrFilter<String> excludeFilter = new OrFilter<String>();\r
- if (excludeRegexes != null) {\r
- for (String excludeRegex : excludeRegexes) {\r
- excludeFilter.addFilter(new RegexStringFilter(excludeRegex));\r
- }\r
- }\r
-\r
- return new OrFilter<String>(includeFilter, new NotFilter<String>(excludeFilter));\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util.filter;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Utility class for working with Filters. Contains builder style methods,
+ * apply methods, as well as mechanisms for adapting Filters and FilenameFilters.
+ */
+public class Filters {
+
+ /**
+ * Filter a given Collection.
+ * @param <T> Type of the Collection.
+ * @param filter A Filter upon the Type of objects in the Collection.
+ * @param collection The Collection to filter.
+ * @return A List containing only those objects for which the Filter returned <code>true</code>.
+ */
+ public static <T> List<T> filter(Filter<T> filter, Collection<T> collection) {
+ List<T> list = new ArrayList<T>();
+ for (T obj : collection) {
+ if (filter.filter(obj)) {
+ list.add(obj);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Get a File Filter for files with the given extensions, ignoring case.
+ * @param extensions The extensions to filter.
+ * @return A File Filter.
+ */
+ public static Filter<File> getFileExtensionFilter(String... extensions) {
+ return new FileExtensionFilter(extensions);
+ }
+
+ /**
+ * Get a File Filter for directories.
+ * @return A File Filter.
+ */
+ public static Filter<File> getDirectoryFilter() {
+ return DirectoryFilter.INSTANCE;
+ }
+
+ /**
+ * Get a File Filter for directories or for files with the given extensions, ignoring case.
+ * @param extensions The extensions to filter.
+ * @return A File Filter.
+ */
+ public static Filter<File> getFileExtensionOrDirectoryFilter(String... extensions) {
+ return new OrFilter<File>(getFileExtensionFilter(extensions), getDirectoryFilter());
+ }
+
+ /**
+ * Given a String Filter, expose as a File Filter. The File paths are
+ * normalized to a standard pattern using <code>/</code> as a path separator
+ * which can be used cross platform easily in a regular expression based
+ * String Filter.
+ *
+ * @param filter A String Filter.
+ * @return A File Filter.
+ */
+ public static Filter<File> toNormalizedFileFilter(final Filter<String> filter) {
+ return new Filter<File>() {
+ public boolean filter(File file) {
+ String path = file.getPath();
+ path = path.replace('\\', '/');
+ return filter.filter(path);
+ }
+
+ public String toString() {
+ return filter.toString();
+ }
+ };
+ }
+
+ /**
+ * Given a String Filter, expose as a Filter on another type. The
+ * <code>toString()</code> method is called on the objects of the other
+ * type and delegated to the String Filter.
+ * @param <T> The desired type.
+ * @param filter The existing String Filter.
+ * @return A Filter on the desired type.
+ */
+ public static <T> Filter<T> fromStringFilter(final Filter<String> filter) {
+ return new Filter<T>() {
+ public boolean filter(T obj) {
+ return filter.filter(obj.toString());
+ }
+
+ public String toString() {
+ return filter.toString();
+ }
+ };
+ }
+
+ /**
+ * Given a File Filter, expose as a FilenameFilter.
+ * @param filter The File Filter.
+ * @return A FilenameFilter.
+ */
+ public static FilenameFilter toFilenameFilter(final Filter<File> filter) {
+ return new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return filter.filter(new File(dir, name));
+ }
+
+ public String toString() {
+ return filter.toString();
+ }
+ };
+ }
+
+ /**
+ * Given a FilenameFilter, expose as a File Filter.
+ * @param filter The FilenameFilter.
+ * @return A File Filter.
+ */
+ public static Filter<File> toFileFilter(final FilenameFilter filter) {
+ return new Filter<File>() {
+ public boolean filter(File file) {
+ return filter.accept(file.getParentFile(), file.getName());
+ }
+
+ public String toString() {
+ return filter.toString();
+ }
+ };
+ }
+
+ /**
+ * Construct a String Filter using set of include and exclude regular
+ * expressions. If there are no include regular expressions provide, then
+ * a regular expression is added which matches every String by default.
+ * A String is included as long as it matches an include regular expression
+ * and does not match an exclude regular expression.
+ * <p>
+ * In other words, exclude patterns override include patterns.
+ *
+ * @param includeRegexes The include regular expressions. May be <code>null</code>.
+ * @param excludeRegexes The exclude regular expressions. May be <code>null</code>.
+ * @return A String Filter.
+ */
+ public static Filter<String> buildRegexFilterExcludeOverInclude(List<String> includeRegexes,
+ List<String> excludeRegexes) {
+ OrFilter<String> includeFilter = new OrFilter<String>();
+ if (includeRegexes == null || includeRegexes.size() == 0) {
+ includeFilter.addFilter(new RegexStringFilter(".*"));
+ } else {
+ for (String includeRegex : includeRegexes) {
+ includeFilter.addFilter(new RegexStringFilter(includeRegex));
+ }
+ }
+
+ OrFilter<String> excludeFilter = new OrFilter<String>();
+ if (excludeRegexes != null) {
+ for (String excludeRegex : excludeRegexes) {
+ excludeFilter.addFilter(new RegexStringFilter(excludeRegex));
+ }
+ }
+
+ return new AndFilter<String>(includeFilter, new NotFilter<String>(excludeFilter));
+ }
+
+ /**
+ * Construct a String Filter using set of include and exclude regular
+ * expressions. If there are no include regular expressions provide, then
+ * a regular expression is added which matches every String by default.
+ * A String is included as long as the case that there is an include which
+ * matches or there is not an exclude which matches.
+ * <p>
+ * In other words, include patterns override exclude patterns.
+ *
+ * @param includeRegexes The include regular expressions. May be <code>null</code>.
+ * @param excludeRegexes The exclude regular expressions. May be <code>null</code>.
+ * @return A String Filter.
+ */
+ public static Filter<String> buildRegexFilterIncludeOverExclude(List<String> includeRegexes,
+ List<String> excludeRegexes) {
+ OrFilter<String> includeFilter = new OrFilter<String>();
+ if (includeRegexes != null) {
+ for (String includeRegex : includeRegexes) {
+ includeFilter.addFilter(new RegexStringFilter(includeRegex));
+ }
+ }
+
+ OrFilter<String> excludeFilter = new OrFilter<String>();
+ if (excludeRegexes != null) {
+ for (String excludeRegex : excludeRegexes) {
+ excludeFilter.addFilter(new RegexStringFilter(excludeRegex));
+ }
+ }
+
+ return new OrFilter<String>(includeFilter, new NotFilter<String>(excludeFilter));
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util.filter;\r
-\r
-/**\r
- * A logical NEGATION of a Filter.\r
- * \r
- * @param <T>\r
- * The underlying type on which the filter applies.\r
- */\r
-public class NotFilter<T> extends AbstractDelegateFilter<T> {\r
- public NotFilter() {\r
- super();\r
- }\r
-\r
- public NotFilter(Filter<T> filter) {\r
- super(filter);\r
- }\r
-\r
- public boolean filter(T obj) {\r
- return !filter.filter(obj);\r
- }\r
-\r
- public String toString() {\r
- return "not (" + filter + ")";\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util.filter;
+
+/**
+ * A logical NEGATION of a Filter.
+ *
+ * @param <T>
+ * The underlying type on which the filter applies.
+ */
+public class NotFilter<T> extends AbstractDelegateFilter<T> {
+ public NotFilter() {
+ super();
+ }
+
+ public NotFilter(Filter<T> filter) {
+ super(filter);
+ }
+
+ public boolean filter(T obj) {
+ return !filter.filter(obj);
+ }
+
+ public String toString() {
+ return "not (" + filter + ")";
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util.filter;\r
-\r
-/**\r
- * A logical OR of a list of Filters. This implementation is short circuiting.\r
- * \r
- * @param <T>\r
- * The underlying type on which the filter applies.\r
- */\r
-public class OrFilter<T> extends AbstractCompoundFilter<T> {\r
-\r
- public OrFilter() {\r
- super();\r
- }\r
-\r
- public OrFilter(Filter<T>... filters) {\r
- super(filters);\r
- }\r
-\r
- public boolean filter(T obj) {\r
- boolean match = false;\r
- for (Filter<T> filter : filters) {\r
- if (filter.filter(obj)) {\r
- match = true;\r
- break;\r
- }\r
- }\r
- return match;\r
- }\r
-\r
- @Override\r
- protected String getOperator() {\r
- return "or";\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util.filter;
+
+/**
+ * A logical OR of a list of Filters. This implementation is short circuiting.
+ *
+ * @param <T>
+ * The underlying type on which the filter applies.
+ */
+public class OrFilter<T> extends AbstractCompoundFilter<T> {
+
+ public OrFilter() {
+ super();
+ }
+
+ public OrFilter(Filter<T>... filters) {
+ super(filters);
+ }
+
+ public boolean filter(T obj) {
+ boolean match = false;
+ for (Filter<T> filter : filters) {
+ if (filter.filter(obj)) {
+ match = true;
+ break;
+ }
+ }
+ return match;
+ }
+
+ @Override
+ protected String getOperator() {
+ return "or";
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package net.sourceforge.pmd.util.filter;\r
-\r
-import java.util.regex.Pattern;\r
-\r
-/**\r
- * A filter to which uses a regular expression to match upon Strings.\r
- */\r
-public class RegexStringFilter implements Filter<String> {\r
-\r
- protected String regex;\r
-\r
- protected Pattern pattern;\r
-\r
- public RegexStringFilter() {\r
- }\r
-\r
- public RegexStringFilter(String regex) {\r
- this.regex = regex;\r
- }\r
-\r
- public String getRegex() {\r
- return regex;\r
- }\r
-\r
- public void setRegex(String regex) {\r
- this.regex = regex;\r
- this.pattern = null;\r
- }\r
-\r
- public boolean filter(String obj) {\r
- if (pattern == null) {\r
- pattern = Pattern.compile(regex);\r
- }\r
- return pattern.matcher(obj).matches();\r
- }\r
-\r
- public String toString() {\r
- return "matches " + regex;\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package net.sourceforge.pmd.util.filter;
+
+import java.util.regex.Pattern;
+
+/**
+ * A filter to which uses a regular expression to match upon Strings.
+ */
+public class RegexStringFilter implements Filter<String> {
+
+ protected String regex;
+
+ protected Pattern pattern;
+
+ public RegexStringFilter() {
+ }
+
+ public RegexStringFilter(String regex) {
+ this.regex = regex;
+ }
+
+ public String getRegex() {
+ return regex;
+ }
+
+ public void setRegex(String regex) {
+ this.regex = regex;
+ this.pattern = null;
+ }
+
+ public boolean filter(String obj) {
+ if (pattern == null) {
+ pattern = Pattern.compile(regex);
+ }
+ return pattern.matcher(obj).matches();
+ }
+
+ public String toString() {
+ return "matches " + regex;
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package org.sonar.graph;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import com.google.common.collect.HashMultiset;\r
-import com.google.common.collect.Multiset;\r
-\r
-public final class FeedbackCycle implements Iterable<FeedbackEdge>, Comparable<FeedbackCycle> {\r
-\r
- private List<FeedbackEdge> orderedFeedbackEdges;\r
- private int totalOccurrencesOfEdgesInCycle;\r
- private final Cycle cycle;\r
-\r
- private FeedbackCycle(Cycle cycle) {\r
- orderedFeedbackEdges = new ArrayList<FeedbackEdge>();\r
- totalOccurrencesOfEdgesInCycle = 0;\r
- this.cycle = cycle;\r
- }\r
-\r
- private void add(FeedbackEdge feedbackEdge) {\r
- orderedFeedbackEdges.add(feedbackEdge);\r
- }\r
-\r
- public static List<FeedbackCycle> buildFeedbackCycles(Set<Cycle> cycles) {\r
- Multiset<Edge> edgesBag = createBagWithAllEdgesOfCycles(cycles);\r
-\r
- List<FeedbackCycle> feedbackCycles = new ArrayList<FeedbackCycle>();\r
- for (Cycle cycle : cycles) {\r
- FeedbackCycle feedbackCycle = new FeedbackCycle(cycle);\r
- int totalOccurrences = 0;\r
- for (Edge edge : cycle.getEdges()) {\r
- FeedbackEdge feedbackEdge = new FeedbackEdge(edge, edgesBag.count(edge));\r
- feedbackCycle.add(feedbackEdge);\r
- totalOccurrences += feedbackEdge.getOccurences();\r
- }\r
- feedbackCycle.setTotalOccurrencesOfEdgesInCycle(totalOccurrences);\r
- Collections.sort(feedbackCycle.orderedFeedbackEdges);\r
- feedbackCycles.add(feedbackCycle);\r
- }\r
- Collections.sort(feedbackCycles);\r
-\r
- return feedbackCycles;\r
- }\r
-\r
- private static Multiset<Edge> createBagWithAllEdgesOfCycles(Set<Cycle> cycles) {\r
- Multiset<Edge> edgesBag = HashMultiset.create();\r
- for (Cycle cycle : cycles) {\r
- for (Edge edge : cycle.getEdges()) {\r
- edgesBag.add(edge);\r
- }\r
- }\r
- return edgesBag;\r
- }\r
-\r
- private void setTotalOccurrencesOfEdgesInCycle(int totalOccurrencesOfEdgesInCycle) {\r
- this.totalOccurrencesOfEdgesInCycle = totalOccurrencesOfEdgesInCycle;\r
- }\r
-\r
- public int getTotalOccurrencesOfEdgesInCycle() {\r
- return totalOccurrencesOfEdgesInCycle;\r
- }\r
-\r
- public Iterator<FeedbackEdge> iterator() {\r
- return orderedFeedbackEdges.iterator();\r
- }\r
-\r
- public int compareTo(FeedbackCycle feedbackCycle) {\r
- if (getTotalOccurrencesOfEdgesInCycle() < feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {\r
- return -1;\r
- }\r
- if (getTotalOccurrencesOfEdgesInCycle() == feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {\r
- if (cycle.size() == feedbackCycle.cycle.size()) {\r
- return orderedFeedbackEdges.get(0).compareTo(feedbackCycle.orderedFeedbackEdges.get(0));\r
- }\r
- return cycle.size() - feedbackCycle.cycle.size();\r
- }\r
- return 1;\r
- }\r
-\r
- public Cycle getCycle() {\r
- return cycle;\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package org.sonar.graph;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import com.google.common.collect.HashMultiset;
+import com.google.common.collect.Multiset;
+
+public final class FeedbackCycle implements Iterable<FeedbackEdge>, Comparable<FeedbackCycle> {
+
+ private List<FeedbackEdge> orderedFeedbackEdges;
+ private int totalOccurrencesOfEdgesInCycle;
+ private final Cycle cycle;
+
+ private FeedbackCycle(Cycle cycle) {
+ orderedFeedbackEdges = new ArrayList<FeedbackEdge>();
+ totalOccurrencesOfEdgesInCycle = 0;
+ this.cycle = cycle;
+ }
+
+ private void add(FeedbackEdge feedbackEdge) {
+ orderedFeedbackEdges.add(feedbackEdge);
+ }
+
+ public static List<FeedbackCycle> buildFeedbackCycles(Set<Cycle> cycles) {
+ Multiset<Edge> edgesBag = createBagWithAllEdgesOfCycles(cycles);
+
+ List<FeedbackCycle> feedbackCycles = new ArrayList<FeedbackCycle>();
+ for (Cycle cycle : cycles) {
+ FeedbackCycle feedbackCycle = new FeedbackCycle(cycle);
+ int totalOccurrences = 0;
+ for (Edge edge : cycle.getEdges()) {
+ FeedbackEdge feedbackEdge = new FeedbackEdge(edge, edgesBag.count(edge));
+ feedbackCycle.add(feedbackEdge);
+ totalOccurrences += feedbackEdge.getOccurences();
+ }
+ feedbackCycle.setTotalOccurrencesOfEdgesInCycle(totalOccurrences);
+ Collections.sort(feedbackCycle.orderedFeedbackEdges);
+ feedbackCycles.add(feedbackCycle);
+ }
+ Collections.sort(feedbackCycles);
+
+ return feedbackCycles;
+ }
+
+ private static Multiset<Edge> createBagWithAllEdgesOfCycles(Set<Cycle> cycles) {
+ Multiset<Edge> edgesBag = HashMultiset.create();
+ for (Cycle cycle : cycles) {
+ for (Edge edge : cycle.getEdges()) {
+ edgesBag.add(edge);
+ }
+ }
+ return edgesBag;
+ }
+
+ private void setTotalOccurrencesOfEdgesInCycle(int totalOccurrencesOfEdgesInCycle) {
+ this.totalOccurrencesOfEdgesInCycle = totalOccurrencesOfEdgesInCycle;
+ }
+
+ public int getTotalOccurrencesOfEdgesInCycle() {
+ return totalOccurrencesOfEdgesInCycle;
+ }
+
+ public Iterator<FeedbackEdge> iterator() {
+ return orderedFeedbackEdges.iterator();
+ }
+
+ public int compareTo(FeedbackCycle feedbackCycle) {
+ if (getTotalOccurrencesOfEdgesInCycle() < feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {
+ return -1;
+ }
+ if (getTotalOccurrencesOfEdgesInCycle() == feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {
+ if (cycle.size() == feedbackCycle.cycle.size()) {
+ return orderedFeedbackEdges.get(0).compareTo(feedbackCycle.orderedFeedbackEdges.get(0));
+ }
+ return cycle.size() - feedbackCycle.cycle.size();
+ }
+ return 1;
+ }
+
+ public Cycle getCycle() {
+ return cycle;
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.graph;\r
-\r
-public class FeedbackEdge implements Comparable<FeedbackEdge> {\r
-\r
- private Edge edge;\r
- private double relativeWeight;\r
- private int occurences;\r
- private final int hashcode;\r
-\r
- public FeedbackEdge(Edge edge, int occurences) {\r
- this.edge = edge;\r
- this.hashcode = edge.hashCode();\r
- this.occurences = occurences;\r
- this.relativeWeight = (double) edge.getWeight() / occurences;\r
- }\r
-\r
- protected Edge getEdge() {\r
- return edge;\r
- }\r
-\r
- protected int getWeight() {\r
- return edge.getWeight();\r
- }\r
-\r
- protected double getRelativeWeight() {\r
- return relativeWeight;\r
- }\r
-\r
- protected int getOccurences() {\r
- return occurences;\r
- }\r
-\r
- public int compareTo(FeedbackEdge feedbackEdge) {\r
- if (this.getRelativeWeight() < feedbackEdge.getRelativeWeight()) {\r
- return -1;\r
- }\r
- if (this.getRelativeWeight() == feedbackEdge.getRelativeWeight()) {\r
- return this.getEdge().getFrom().toString().compareTo(feedbackEdge.getEdge().getFrom().toString());\r
- }\r
- return 1;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (!(obj instanceof FeedbackEdge) || this.hashCode() != obj.hashCode()) {\r
- return false;\r
- }\r
- FeedbackEdge otherEdge = (FeedbackEdge) obj;\r
- return edge.equals(otherEdge.edge);\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return hashcode;\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.graph;
+
+public class FeedbackEdge implements Comparable<FeedbackEdge> {
+
+ private Edge edge;
+ private double relativeWeight;
+ private int occurences;
+ private final int hashcode;
+
+ public FeedbackEdge(Edge edge, int occurences) {
+ this.edge = edge;
+ this.hashcode = edge.hashCode();
+ this.occurences = occurences;
+ this.relativeWeight = (double) edge.getWeight() / occurences;
+ }
+
+ protected Edge getEdge() {
+ return edge;
+ }
+
+ protected int getWeight() {
+ return edge.getWeight();
+ }
+
+ protected double getRelativeWeight() {
+ return relativeWeight;
+ }
+
+ protected int getOccurences() {
+ return occurences;
+ }
+
+ public int compareTo(FeedbackEdge feedbackEdge) {
+ if (this.getRelativeWeight() < feedbackEdge.getRelativeWeight()) {
+ return -1;
+ }
+ if (this.getRelativeWeight() == feedbackEdge.getRelativeWeight()) {
+ return this.getEdge().getFrom().toString().compareTo(feedbackEdge.getEdge().getFrom().toString());
+ }
+ return 1;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof FeedbackEdge) || this.hashCode() != obj.hashCode()) {
+ return false;
+ }
+ FeedbackEdge otherEdge = (FeedbackEdge) obj;
+ return edge.equals(otherEdge.edge);
+ }
+
+ @Override
+ public int hashCode() {
+ return hashcode;
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.graph;\r
-\r
-import org.junit.Test;\r
-\r
-import static org.hamcrest.MatcherAssert.assertThat;\r
-import static org.hamcrest.Matchers.greaterThan;\r
-import static org.hamcrest.Matchers.is;\r
-\r
-public class FeedbackEdgeTest {\r
-\r
- @Test\r
- public void testWeights() {\r
- FeedbackEdge fEdge = mockFeedbackEdge(14, 2);\r
- assertThat(fEdge.getWeight(), is(14));\r
- assertThat(fEdge.getRelativeWeight(), is(7.0));\r
- assertThat(fEdge.getOccurences(), is(2));\r
- }\r
-\r
- @Test\r
- public void testCompareTo() {\r
- FeedbackEdge feedbackEdge1;\r
- FeedbackEdge feedbackEdge2;\r
- FeedbackEdge feedbackEdge3;\r
-\r
- feedbackEdge1 = mockFeedbackEdge(14, 2);\r
- feedbackEdge2 = mockFeedbackEdge(10, 2);\r
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(1));\r
-\r
- feedbackEdge1 = mockFeedbackEdge(10, 2);\r
- feedbackEdge2 = mockFeedbackEdge(14, 2);\r
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));\r
-\r
- feedbackEdge1 = mockFeedbackEdge(14, 2);\r
- feedbackEdge2 = mockFeedbackEdge(14, 2);\r
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(0));\r
-\r
- feedbackEdge1 = mockFeedbackEdge(14, 2);\r
- feedbackEdge2 = mockFeedbackEdge(13, 2);\r
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(1));\r
-\r
- feedbackEdge1 = mockFeedbackEdge(13, 2);\r
- feedbackEdge2 = mockFeedbackEdge(14, 2);\r
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));\r
-\r
- feedbackEdge1 = mockFeedbackEdge("A", "B", 14, 2);\r
- feedbackEdge2 = mockFeedbackEdge("B", "C", 14, 2);\r
- feedbackEdge3 = mockFeedbackEdge("C", "A", 14, 2);\r
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));\r
- assertThat(feedbackEdge2.compareTo(feedbackEdge3), is(-1));\r
- assertThat(feedbackEdge3.compareTo(feedbackEdge1), greaterThan(1));\r
- }\r
-\r
- private FeedbackEdge mockFeedbackEdge(int weight, int occurrences) {\r
- return mockFeedbackEdge("from", "to", weight, occurrences);\r
- }\r
-\r
- private FeedbackEdge mockFeedbackEdge(String from, String to, int weight, int occurrences) {\r
- Edge edge = new StringEdge(from, to, weight);\r
- return new FeedbackEdge(edge, occurrences);\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.graph;
+
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+
+public class FeedbackEdgeTest {
+
+ @Test
+ public void testWeights() {
+ FeedbackEdge fEdge = mockFeedbackEdge(14, 2);
+ assertThat(fEdge.getWeight(), is(14));
+ assertThat(fEdge.getRelativeWeight(), is(7.0));
+ assertThat(fEdge.getOccurences(), is(2));
+ }
+
+ @Test
+ public void testCompareTo() {
+ FeedbackEdge feedbackEdge1;
+ FeedbackEdge feedbackEdge2;
+ FeedbackEdge feedbackEdge3;
+
+ feedbackEdge1 = mockFeedbackEdge(14, 2);
+ feedbackEdge2 = mockFeedbackEdge(10, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(1));
+
+ feedbackEdge1 = mockFeedbackEdge(10, 2);
+ feedbackEdge2 = mockFeedbackEdge(14, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));
+
+ feedbackEdge1 = mockFeedbackEdge(14, 2);
+ feedbackEdge2 = mockFeedbackEdge(14, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(0));
+
+ feedbackEdge1 = mockFeedbackEdge(14, 2);
+ feedbackEdge2 = mockFeedbackEdge(13, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(1));
+
+ feedbackEdge1 = mockFeedbackEdge(13, 2);
+ feedbackEdge2 = mockFeedbackEdge(14, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));
+
+ feedbackEdge1 = mockFeedbackEdge("A", "B", 14, 2);
+ feedbackEdge2 = mockFeedbackEdge("B", "C", 14, 2);
+ feedbackEdge3 = mockFeedbackEdge("C", "A", 14, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));
+ assertThat(feedbackEdge2.compareTo(feedbackEdge3), is(-1));
+ assertThat(feedbackEdge3.compareTo(feedbackEdge1), greaterThan(1));
+ }
+
+ private FeedbackEdge mockFeedbackEdge(int weight, int occurrences) {
+ return mockFeedbackEdge("from", "to", weight, occurrences);
+ }
+
+ private FeedbackEdge mockFeedbackEdge(String from, String to, int weight, int occurrences) {
+ Edge edge = new StringEdge(from, to, weight);
+ return new FeedbackEdge(edge, occurrences);
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * A plugin is a group of extensions. See <code>org.sonar.api.Extension</code> interface to get all extension points.\r
- * <p/>\r
- * <p>The manifest property <code>Plugin-Class</code> must declare the name of the implementation class.\r
- * See META-INF/MANIFEST.MF.</p>\r
- *\r
- * @see org.sonar.api.Extension\r
- * @since 1.10\r
- */\r
-public interface Plugin {\r
-\r
- /**\r
- * Unique key within sonar plugins\r
- * @deprecated since 2.2. The key must be set in the manifest.\r
- */\r
- @Deprecated\r
- String getKey();\r
-\r
- /**\r
- * Descriptive name\r
- * @deprecated since 2.2. The name must be set in the manifest.\r
- */\r
- @Deprecated\r
- String getName();\r
-\r
- /**\r
- * description of the plugin, can contains html or ruby code\r
- * @deprecated since 2.2. The description must be set in the manifest.\r
- */\r
- @Deprecated\r
- String getDescription();\r
-\r
- /**\r
- * Classes of the implemented extensions.\r
- */\r
- List getExtensions();\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api;
+
+import java.util.List;
+
+/**
+ * A plugin is a group of extensions. See <code>org.sonar.api.Extension</code> interface to get all extension points.
+ * <p/>
+ * <p>The manifest property <code>Plugin-Class</code> must declare the name of the implementation class.
+ * See META-INF/MANIFEST.MF.</p>
+ *
+ * @see org.sonar.api.Extension
+ * @since 1.10
+ */
+public interface Plugin {
+
+ /**
+ * Unique key within sonar plugins
+ * @deprecated since 2.2. The key must be set in the manifest.
+ */
+ @Deprecated
+ String getKey();
+
+ /**
+ * Descriptive name
+ * @deprecated since 2.2. The name must be set in the manifest.
+ */
+ @Deprecated
+ String getName();
+
+ /**
+ * description of the plugin, can contains html or ruby code
+ * @deprecated since 2.2. The description must be set in the manifest.
+ */
+ @Deprecated
+ String getDescription();
+
+ /**
+ * Classes of the implemented extensions.
+ */
+ List getExtensions();
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.batch;\r
-\r
-import org.sonar.api.measures.CoreMetrics;\r
-import org.sonar.api.measures.MeasureUtils;\r
-import org.sonar.api.measures.Metric;\r
-import org.sonar.api.resources.Language;\r
-import org.sonar.api.resources.Project;\r
-import org.sonar.api.resources.Resource;\r
-\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-/**\r
- * @deprecated since 2.1, a formula has been implemented on the metric, so no need to have decorator anymore\r
- * @since 1.13\r
- */\r
-@Deprecated\r
-public abstract class AbstractFunctionComplexityDecorator implements Decorator {\r
-\r
- private Language language;\r
-\r
- /**\r
- * @param language this will be use to defined whether the decorator should be executed on a project\r
- */\r
- public AbstractFunctionComplexityDecorator(Language language) {\r
- this.language = language;\r
- }\r
-\r
- /**\r
- * {@inheritDoc}\r
- */\r
- public boolean shouldExecuteOnProject(Project project) {\r
- return language.equals(project.getLanguage());\r
- }\r
-\r
- /**\r
- * Used to define upstream dependencies\r
- */\r
- @DependsUpon\r
- public List<Metric> dependsUponFileAndComplexityMetrics() {\r
- return Arrays.asList(CoreMetrics.FUNCTIONS, CoreMetrics.COMPLEXITY);\r
- }\r
-\r
- /**\r
- * Used to define downstream dependencies\r
- */\r
- @DependedUpon\r
- public Metric generateFileComplexityMetric() {\r
- return CoreMetrics.FUNCTION_COMPLEXITY;\r
- }\r
-\r
- /**\r
- * {@inheritDoc}\r
- */\r
- public void decorate(Resource resource, DecoratorContext context) {\r
- if (!shouldDecorateResource(resource, context)) {\r
- return;\r
- }\r
- Double functions = MeasureUtils.getValue(context.getMeasure(CoreMetrics.FUNCTIONS), null);\r
- Double complexity = MeasureUtils.getValue(context.getMeasure(CoreMetrics.COMPLEXITY), null);\r
- if (complexity != null && functions != null && functions > 0.0) {\r
- context.saveMeasure(CoreMetrics.FUNCTION_COMPLEXITY, complexity / functions);\r
- }\r
- }\r
-\r
- private boolean shouldDecorateResource(Resource resource, DecoratorContext context) {\r
- return !MeasureUtils.hasValue(context.getMeasure(CoreMetrics.FUNCTION_COMPLEXITY));\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.batch;
+
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.MeasureUtils;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.resources.Language;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Resource;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @deprecated since 2.1, a formula has been implemented on the metric, so no need to have decorator anymore
+ * @since 1.13
+ */
+@Deprecated
+public abstract class AbstractFunctionComplexityDecorator implements Decorator {
+
+ private Language language;
+
+ /**
+ * @param language this will be use to defined whether the decorator should be executed on a project
+ */
+ public AbstractFunctionComplexityDecorator(Language language) {
+ this.language = language;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean shouldExecuteOnProject(Project project) {
+ return language.equals(project.getLanguage());
+ }
+
+ /**
+ * Used to define upstream dependencies
+ */
+ @DependsUpon
+ public List<Metric> dependsUponFileAndComplexityMetrics() {
+ return Arrays.asList(CoreMetrics.FUNCTIONS, CoreMetrics.COMPLEXITY);
+ }
+
+ /**
+ * Used to define downstream dependencies
+ */
+ @DependedUpon
+ public Metric generateFileComplexityMetric() {
+ return CoreMetrics.FUNCTION_COMPLEXITY;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void decorate(Resource resource, DecoratorContext context) {
+ if (!shouldDecorateResource(resource, context)) {
+ return;
+ }
+ Double functions = MeasureUtils.getValue(context.getMeasure(CoreMetrics.FUNCTIONS), null);
+ Double complexity = MeasureUtils.getValue(context.getMeasure(CoreMetrics.COMPLEXITY), null);
+ if (complexity != null && functions != null && functions > 0.0) {
+ context.saveMeasure(CoreMetrics.FUNCTION_COMPLEXITY, complexity / functions);
+ }
+ }
+
+ private boolean shouldDecorateResource(Resource resource, DecoratorContext context) {
+ return !MeasureUtils.hasValue(context.getMeasure(CoreMetrics.FUNCTION_COMPLEXITY));
+ }
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-\r
-package org.sonar.api.batch;\r
-\r
-import org.sonar.api.measures.CoreMetrics;\r
-import org.sonar.api.measures.CountDistributionBuilder;\r
-import org.sonar.api.measures.Measure;\r
-import org.sonar.api.measures.Metric;\r
-import org.sonar.api.resources.Language;\r
-import org.sonar.api.resources.Project;\r
-import org.sonar.api.resources.Resource;\r
-\r
-/**\r
- * @deprecated since 2.1, a formula has been implemented on the metric, so no need to have decorator anymore\r
- * @since 2.0\r
- */\r
-@Deprecated\r
-public abstract class AbstractFunctionComplexityDistributionDecorator implements Decorator {\r
-\r
- private CountDistributionBuilder builder = new CountDistributionBuilder(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);\r
- private Language language;\r
-\r
- public AbstractFunctionComplexityDistributionDecorator(Language language) {\r
- this.language = language;\r
- }\r
-\r
- @DependedUpon\r
- public Metric generatesMetrics() {\r
- return CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION;\r
- }\r
-\r
- public boolean shouldExecuteOnProject(Project project) {\r
- return language.equals(project.getLanguage());\r
- }\r
-\r
- public void decorate(Resource resource, DecoratorContext context) {\r
- if (shouldDecorateResource(context)) {\r
- reset();\r
- saveDistribution(context);\r
- }\r
- }\r
-\r
- private void saveDistribution(DecoratorContext context) {\r
- for (Measure childMeasure : context.getChildrenMeasures(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION)) {\r
- builder.add(childMeasure);\r
- }\r
-\r
- if (!builder.isEmpty()) {\r
- context.saveMeasure(builder.build());\r
- }\r
- }\r
-\r
- private void reset() {\r
- builder.clear();\r
- }\r
-\r
- private boolean shouldDecorateResource(DecoratorContext context) {\r
- return context.getMeasure(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION) == null;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return getClass().getSimpleName();\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package org.sonar.api.batch;
+
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.CountDistributionBuilder;
+import org.sonar.api.measures.Measure;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.resources.Language;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Resource;
+
+/**
+ * @deprecated since 2.1, a formula has been implemented on the metric, so no need to have decorator anymore
+ * @since 2.0
+ */
+@Deprecated
+public abstract class AbstractFunctionComplexityDistributionDecorator implements Decorator {
+
+ private CountDistributionBuilder builder = new CountDistributionBuilder(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
+ private Language language;
+
+ public AbstractFunctionComplexityDistributionDecorator(Language language) {
+ this.language = language;
+ }
+
+ @DependedUpon
+ public Metric generatesMetrics() {
+ return CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION;
+ }
+
+ public boolean shouldExecuteOnProject(Project project) {
+ return language.equals(project.getLanguage());
+ }
+
+ public void decorate(Resource resource, DecoratorContext context) {
+ if (shouldDecorateResource(context)) {
+ reset();
+ saveDistribution(context);
+ }
+ }
+
+ private void saveDistribution(DecoratorContext context) {
+ for (Measure childMeasure : context.getChildrenMeasures(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION)) {
+ builder.add(childMeasure);
+ }
+
+ if (!builder.isEmpty()) {
+ context.saveMeasure(builder.build());
+ }
+ }
+
+ private void reset() {
+ builder.clear();
+ }
+
+ private boolean shouldDecorateResource(DecoratorContext context) {
+ return context.getMeasure(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION) == null;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.database.model;\r
-\r
-import org.apache.commons.lang.builder.EqualsBuilder;\r
-import org.apache.commons.lang.builder.HashCodeBuilder;\r
-import org.apache.commons.lang.builder.ToStringBuilder;\r
-import org.sonar.api.database.BaseIdentifiable;\r
-\r
-import java.util.Date;\r
-import javax.persistence.*;\r
-\r
-/**\r
- * Class to map an aysync measure with hibernate model\r
- */\r
-@Entity\r
-@Table(name = "async_measure_snapshots")\r
-public class AsyncMeasureSnapshot extends BaseIdentifiable {\r
-\r
- @Column(name = "project_measure_id", updatable = true, nullable = true)\r
- private Long measureId;\r
-\r
- @Temporal(TemporalType.TIMESTAMP)\r
- @Column(name = "measure_date", updatable = true, nullable = true)\r
- private Date measureDate;\r
-\r
- @Column(name = "snapshot_id", updatable = true, nullable = true)\r
- private Integer snapshotId;\r
-\r
- @Temporal(TemporalType.TIMESTAMP)\r
- @Column(name = "snapshot_date", updatable = true, nullable = true)\r
- private Date snapshotDate;\r
-\r
- @Column(name = "metric_id", updatable = true, nullable = true)\r
- private Integer metricId;\r
-\r
- @Column(name = "project_id", updatable = true, nullable = true)\r
- private Integer projectId;\r
-\r
- /**\r
- * This is the constructor to use\r
- *\r
- * @param measureId\r
- * @param snapshotId the snapshot id to which the measure is attached\r
- * @param measureDate the date of the measure\r
- * @param snapshotDate the snapshot date\r
- * @param metricId the metric the measure is attached to\r
- * @param projectId the id of the project\r
- */\r
- public AsyncMeasureSnapshot(Long measureId, Integer snapshotId, Date measureDate, Date snapshotDate, Integer metricId, Integer projectId) {\r
- this.measureId = measureId;\r
- this.measureDate = measureDate;\r
- this.snapshotId = snapshotId;\r
- this.snapshotDate = snapshotDate;\r
- this.projectId = projectId;\r
- this.metricId = metricId;\r
- }\r
-\r
- /**\r
- * Default constructor\r
- */\r
- public AsyncMeasureSnapshot() {\r
- }\r
-\r
- public Long getMeasureId() {\r
- return measureId;\r
- }\r
-\r
- public void setMeasureId(Long measureId) {\r
- this.measureId = measureId;\r
- }\r
-\r
- public Integer getSnapshotId() {\r
- return snapshotId;\r
- }\r
-\r
- public void setSnapshotId(Integer snapshotId) {\r
- this.snapshotId = snapshotId;\r
- }\r
-\r
- public Date getMeasureDate() {\r
- return measureDate;\r
- }\r
-\r
- public void setMeasureDate(Date measureDate) {\r
- this.measureDate = measureDate;\r
- }\r
-\r
- public Date getSnapshotDate() {\r
- return snapshotDate;\r
- }\r
-\r
- public void setSnapshotDate(Date snapshotDate) {\r
- this.snapshotDate = snapshotDate;\r
- }\r
-\r
- public Integer getMetricId() {\r
- return metricId;\r
- }\r
-\r
- public void setMetricId(Integer metricId) {\r
- this.metricId = metricId;\r
- }\r
-\r
- public Integer getProjectId() {\r
- return projectId;\r
- }\r
-\r
- public void setProjectId(Integer projectId) {\r
- this.projectId = projectId;\r
- }\r
-\r
- public void setMeasure(MeasureModel measure) {\r
- setMeasureId(measure.getId());\r
- setMeasureDate(measure.getMeasureDate());\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (!(obj instanceof AsyncMeasureSnapshot)) {\r
- return false;\r
- }\r
- if (this == obj) {\r
- return true;\r
- }\r
- AsyncMeasureSnapshot other = (AsyncMeasureSnapshot) obj;\r
- return new EqualsBuilder()\r
- .append(measureId, other.getMeasureId())\r
- .append(measureDate, other.getMeasureDate())\r
- .append(snapshotId, other.getSnapshotId())\r
- .append(snapshotDate, other.getSnapshotDate())\r
- .isEquals();\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return new HashCodeBuilder(17, 37)\r
- .append(measureId)\r
- .append(measureDate)\r
- .append(snapshotDate)\r
- .append(snapshotId)\r
- .toHashCode();\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return new ToStringBuilder(this)\r
- .append("id", getId())\r
- .append("measureId", measureId)\r
- .append("measureDate", measureDate)\r
- .append("snapshotId", snapshotId)\r
- .append("snapshotDate", snapshotDate)\r
- .toString();\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.database.model;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.sonar.api.database.BaseIdentifiable;
+
+import java.util.Date;
+import javax.persistence.*;
+
+/**
+ * Class to map an aysync measure with hibernate model
+ */
+@Entity
+@Table(name = "async_measure_snapshots")
+public class AsyncMeasureSnapshot extends BaseIdentifiable {
+
+ @Column(name = "project_measure_id", updatable = true, nullable = true)
+ private Long measureId;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "measure_date", updatable = true, nullable = true)
+ private Date measureDate;
+
+ @Column(name = "snapshot_id", updatable = true, nullable = true)
+ private Integer snapshotId;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "snapshot_date", updatable = true, nullable = true)
+ private Date snapshotDate;
+
+ @Column(name = "metric_id", updatable = true, nullable = true)
+ private Integer metricId;
+
+ @Column(name = "project_id", updatable = true, nullable = true)
+ private Integer projectId;
+
+ /**
+ * This is the constructor to use
+ *
+ * @param measureId
+ * @param snapshotId the snapshot id to which the measure is attached
+ * @param measureDate the date of the measure
+ * @param snapshotDate the snapshot date
+ * @param metricId the metric the measure is attached to
+ * @param projectId the id of the project
+ */
+ public AsyncMeasureSnapshot(Long measureId, Integer snapshotId, Date measureDate, Date snapshotDate, Integer metricId, Integer projectId) {
+ this.measureId = measureId;
+ this.measureDate = measureDate;
+ this.snapshotId = snapshotId;
+ this.snapshotDate = snapshotDate;
+ this.projectId = projectId;
+ this.metricId = metricId;
+ }
+
+ /**
+ * Default constructor
+ */
+ public AsyncMeasureSnapshot() {
+ }
+
+ public Long getMeasureId() {
+ return measureId;
+ }
+
+ public void setMeasureId(Long measureId) {
+ this.measureId = measureId;
+ }
+
+ public Integer getSnapshotId() {
+ return snapshotId;
+ }
+
+ public void setSnapshotId(Integer snapshotId) {
+ this.snapshotId = snapshotId;
+ }
+
+ public Date getMeasureDate() {
+ return measureDate;
+ }
+
+ public void setMeasureDate(Date measureDate) {
+ this.measureDate = measureDate;
+ }
+
+ public Date getSnapshotDate() {
+ return snapshotDate;
+ }
+
+ public void setSnapshotDate(Date snapshotDate) {
+ this.snapshotDate = snapshotDate;
+ }
+
+ public Integer getMetricId() {
+ return metricId;
+ }
+
+ public void setMetricId(Integer metricId) {
+ this.metricId = metricId;
+ }
+
+ public Integer getProjectId() {
+ return projectId;
+ }
+
+ public void setProjectId(Integer projectId) {
+ this.projectId = projectId;
+ }
+
+ public void setMeasure(MeasureModel measure) {
+ setMeasureId(measure.getId());
+ setMeasureDate(measure.getMeasureDate());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof AsyncMeasureSnapshot)) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ AsyncMeasureSnapshot other = (AsyncMeasureSnapshot) obj;
+ return new EqualsBuilder()
+ .append(measureId, other.getMeasureId())
+ .append(measureDate, other.getMeasureDate())
+ .append(snapshotId, other.getSnapshotId())
+ .append(snapshotDate, other.getSnapshotDate())
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37)
+ .append(measureId)
+ .append(measureDate)
+ .append(snapshotDate)
+ .append(snapshotId)
+ .toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("id", getId())
+ .append("measureId", measureId)
+ .append("measureDate", measureDate)
+ .append("snapshotId", snapshotId)
+ .append("snapshotDate", snapshotDate)
+ .toString();
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.measures;\r
-\r
-import org.sonar.api.resources.Scopes;\r
-\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-/**\r
- * @since 2.0\r
- *\r
- * Used to consolidate a distribution measure throughout the resource tree\r
- */\r
-public class SumChildDistributionFormula implements Formula {\r
-\r
- private String minimumScopeToPersist= Scopes.FILE;\r
-\r
- public List<Metric> dependsUponMetrics() {\r
- return Collections.emptyList();\r
- }\r
-\r
- public String getMinimumScopeToPersist() {\r
- return minimumScopeToPersist;\r
- }\r
-\r
- public SumChildDistributionFormula setMinimumScopeToPersist(String s) {\r
- this.minimumScopeToPersist = s;\r
- return this;\r
- }\r
-\r
- public Measure calculate(FormulaData data, FormulaContext context) {\r
- Collection<Measure> measures = data.getChildrenMeasures(context.getTargetMetric());\r
- if (measures == null || measures.isEmpty()) {\r
- return null;\r
- }\r
- else {\r
- RangeDistributionBuilder distribution = new RangeDistributionBuilder(context.getTargetMetric());\r
- for (Measure measure : measures) {\r
- distribution.add(measure);\r
- }\r
- Measure measure = distribution.build();\r
- if (!Scopes.isHigherThanOrEquals(context.getResource().getScope(), minimumScopeToPersist)) {\r
- measure.setPersistenceMode(PersistenceMode.MEMORY);\r
- }\r
- return measure;\r
- }\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.measures;
+
+import org.sonar.api.resources.Scopes;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @since 2.0
+ *
+ * Used to consolidate a distribution measure throughout the resource tree
+ */
+public class SumChildDistributionFormula implements Formula {
+
+ private String minimumScopeToPersist= Scopes.FILE;
+
+ public List<Metric> dependsUponMetrics() {
+ return Collections.emptyList();
+ }
+
+ public String getMinimumScopeToPersist() {
+ return minimumScopeToPersist;
+ }
+
+ public SumChildDistributionFormula setMinimumScopeToPersist(String s) {
+ this.minimumScopeToPersist = s;
+ return this;
+ }
+
+ public Measure calculate(FormulaData data, FormulaContext context) {
+ Collection<Measure> measures = data.getChildrenMeasures(context.getTargetMetric());
+ if (measures == null || measures.isEmpty()) {
+ return null;
+ }
+ else {
+ RangeDistributionBuilder distribution = new RangeDistributionBuilder(context.getTargetMetric());
+ for (Measure measure : measures) {
+ distribution.add(measure);
+ }
+ Measure measure = distribution.build();
+ if (!Scopes.isHigherThanOrEquals(context.getResource().getScope(), minimumScopeToPersist)) {
+ measure.setPersistenceMode(PersistenceMode.MEMORY);
+ }
+ return measure;
+ }
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.rules;\r
-\r
-import org.apache.commons.lang.builder.EqualsBuilder;\r
-import org.apache.commons.lang.builder.HashCodeBuilder;\r
-\r
-import javax.persistence.*;\r
-\r
-@Entity\r
-@Table(name = "active_rule_parameters")\r
-public class ActiveRuleParam implements Cloneable {\r
-\r
-\r
- @Id\r
- @Column(name = "id")\r
- @GeneratedValue\r
- private Integer id;\r
-\r
- @ManyToOne(fetch = FetchType.LAZY)\r
- @JoinColumn(name = "active_rule_id")\r
- private ActiveRule activeRule;\r
-\r
- @ManyToOne(fetch = FetchType.LAZY, optional = true)\r
- @JoinColumn(name = "rules_parameter_id")\r
- private RuleParam ruleParam;\r
-\r
- @Column(name = "value", updatable = false, nullable = true, length = 4000)\r
- private String value;\r
-\r
- public Integer getId() {\r
- return id;\r
- }\r
-\r
- /**\r
- * @deprecated visibility should be decreased to protected or package\r
- */\r
- @Deprecated\r
- void setId(Integer id) {\r
- this.id = id;\r
- }\r
-\r
- /**\r
- * @deprecated visibility should be decreased to protected or package\r
- */\r
- @Deprecated\r
- public ActiveRuleParam() {\r
- }\r
-\r
- /**\r
- * @deprecated visibility should be decreased to protected or package\r
- */\r
- @Deprecated\r
- public ActiveRuleParam(ActiveRule activeRule, RuleParam ruleParam, String value) {\r
- this.activeRule = activeRule;\r
- this.ruleParam = ruleParam;\r
- this.value = value;\r
- }\r
-\r
- public ActiveRule getActiveRule() {\r
- return activeRule;\r
- }\r
-\r
- /**\r
- * @deprecated visibility should be decreased to protected or package\r
- */\r
- @Deprecated\r
- public void setActiveRule(ActiveRule activeRule) {\r
- this.activeRule = activeRule;\r
- }\r
-\r
- public RuleParam getRuleParam() {\r
- return ruleParam;\r
- }\r
-\r
- /**\r
- * @deprecated visibility should be decreased to protected or package\r
- */\r
- @Deprecated\r
- public void setRuleParam(RuleParam ruleParam) {\r
- this.ruleParam = ruleParam;\r
- }\r
-\r
- public String getValue() {\r
- return value;\r
- }\r
-\r
- public void setValue(String value) {\r
- this.value = value;\r
- }\r
-\r
- public String getKey() {\r
- return ruleParam.getKey();\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (!(obj instanceof RuleParam)) {\r
- return false;\r
- }\r
- if (this == obj) {\r
- return true;\r
- }\r
- RuleParam other = (RuleParam) obj;\r
- return new EqualsBuilder()\r
- .append(getId(), other.getKey()).isEquals();\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return new HashCodeBuilder(17, 37)\r
- .append(getId())\r
- .toHashCode();\r
- }\r
-\r
- @Override\r
- public Object clone() {\r
- return new ActiveRuleParam(getActiveRule(), getRuleParam(), getValue());\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.rules;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "active_rule_parameters")
+public class ActiveRuleParam implements Cloneable {
+
+
+ @Id
+ @Column(name = "id")
+ @GeneratedValue
+ private Integer id;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "active_rule_id")
+ private ActiveRule activeRule;
+
+ @ManyToOne(fetch = FetchType.LAZY, optional = true)
+ @JoinColumn(name = "rules_parameter_id")
+ private RuleParam ruleParam;
+
+ @Column(name = "value", updatable = false, nullable = true, length = 4000)
+ private String value;
+
+ public Integer getId() {
+ return id;
+ }
+
+ /**
+ * @deprecated visibility should be decreased to protected or package
+ */
+ @Deprecated
+ void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * @deprecated visibility should be decreased to protected or package
+ */
+ @Deprecated
+ public ActiveRuleParam() {
+ }
+
+ /**
+ * @deprecated visibility should be decreased to protected or package
+ */
+ @Deprecated
+ public ActiveRuleParam(ActiveRule activeRule, RuleParam ruleParam, String value) {
+ this.activeRule = activeRule;
+ this.ruleParam = ruleParam;
+ this.value = value;
+ }
+
+ public ActiveRule getActiveRule() {
+ return activeRule;
+ }
+
+ /**
+ * @deprecated visibility should be decreased to protected or package
+ */
+ @Deprecated
+ public void setActiveRule(ActiveRule activeRule) {
+ this.activeRule = activeRule;
+ }
+
+ public RuleParam getRuleParam() {
+ return ruleParam;
+ }
+
+ /**
+ * @deprecated visibility should be decreased to protected or package
+ */
+ @Deprecated
+ public void setRuleParam(RuleParam ruleParam) {
+ this.ruleParam = ruleParam;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getKey() {
+ return ruleParam.getKey();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof RuleParam)) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ RuleParam other = (RuleParam) obj;
+ return new EqualsBuilder()
+ .append(getId(), other.getKey()).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37)
+ .append(getId())
+ .toHashCode();
+ }
+
+ @Override
+ public Object clone() {
+ return new ActiveRuleParam(getActiveRule(), getRuleParam(), getValue());
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.rules;\r
-\r
-import org.apache.commons.lang.StringUtils;\r
-import org.apache.commons.lang.builder.EqualsBuilder;\r
-import org.apache.commons.lang.builder.HashCodeBuilder;\r
-import org.apache.commons.lang.builder.ToStringBuilder;\r
-import org.sonar.api.database.DatabaseProperties;\r
-import org.sonar.check.Cardinality;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.persistence.*;\r
-\r
-@Entity\r
-@Table(name = "rules")\r
-public final class Rule {\r
-\r
- private final static RulesCategory NONE = new RulesCategory("none");\r
- \r
- @Id\r
- @Column(name = "id")\r
- @GeneratedValue\r
- private Integer id;\r
-\r
- /**\r
- * The default priority given to a rule if not explicitly set\r
- */\r
- public static final RulePriority DEFAULT_PRIORITY = RulePriority.MAJOR;\r
-\r
- @Column(name = "name", updatable = true, nullable = false)\r
- private String name;\r
-\r
- @Column(name = "plugin_rule_key", updatable = false, nullable = true, length = 200)\r
- private String key;\r
-\r
- @Column(name = "enabled", updatable = true, nullable = true)\r
- private Boolean enabled = Boolean.TRUE;\r
-\r
- @Column(name = "plugin_config_key", updatable = true, nullable = true, length = 500)\r
- private String configKey;\r
-\r
- // Godin: This field should be named priority, otherwise StandardRulesXmlParserTest fails\r
- @Column(name = "priority", updatable = true, nullable = true)\r
- @Enumerated(EnumType.ORDINAL)\r
- private RulePriority priority = DEFAULT_PRIORITY;\r
-\r
- @Column(name = "description", updatable = true, nullable = true, length = DatabaseProperties.MAX_TEXT_SIZE)\r
- private String description;\r
-\r
- @Column(name = "plugin_name", updatable = true, nullable = false)\r
- private String pluginName;\r
-\r
- @Enumerated(EnumType.STRING)\r
- @Column(name = "cardinality", updatable = true, nullable = false)\r
- private Cardinality cardinality = Cardinality.SINGLE;\r
-\r
- @ManyToOne(fetch = FetchType.EAGER)\r
- @JoinColumn(name = "parent_id", updatable = true, nullable = true)\r
- private Rule parent = null;\r
-\r
- @org.hibernate.annotations.Cascade({ org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })\r
- @OneToMany(mappedBy = "rule")\r
- private List<RuleParam> params = new ArrayList<RuleParam>();\r
-\r
- /**\r
- * @deprecated since 2.3. Use the factory method {@link #create()}\r
- */\r
- @Deprecated\r
- public Rule() {\r
- // TODO reduce visibility to package\r
- }\r
-\r
- /**\r
- * Creates rule with minimum set of info\r
- * \r
- * @param pluginName the plugin name indicates which plugin the rule belongs to\r
- * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique across the\r
- * application\r
- * @deprecated since 2.3. Use the factory method {@link #create()}\r
- */\r
- @Deprecated\r
- public Rule(String pluginName, String key) {\r
- this.pluginName = pluginName;\r
- this.key = key;\r
- this.configKey = key;\r
- }\r
-\r
- /**\r
- * Creates a fully qualified rule\r
- * \r
- * @param pluginKey the plugin the rule belongs to\r
- * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique across the\r
- * application\r
- * @param name the name displayed in the UI\r
- * @param rulesCategory the ISO category the rule belongs to\r
- * @param severity this is the severity associated to the rule\r
- * @deprecated since 2.3. Use the factory method {@link #create()}\r
- */\r
- @Deprecated\r
- public Rule(String pluginKey, String key, String name, RulesCategory rulesCategory, RulePriority severity) {\r
- setName(name);\r
- this.key = key;\r
- this.configKey = key;\r
- this.priority = severity;\r
- this.pluginName = pluginKey;\r
- }\r
-\r
- /**\r
- * @deprecated since 2.3. Use the factory method {@link #create()}\r
- */\r
- @Deprecated\r
- public Rule(String name, String key, RulesCategory rulesCategory, String pluginName, String description) {\r
- this();\r
- setName(name);\r
- this.key = key;\r
- this.configKey = key;\r
- this.pluginName = pluginName;\r
- this.description = description;\r
- }\r
-\r
- /**\r
- * @deprecated since 2.3. Use the factory method {@link #create()}\r
- */\r
- @Deprecated\r
- public Rule(String name, String key, String configKey, RulesCategory rulesCategory, String pluginName, String description) {\r
- this();\r
- setName(name);\r
- this.key = key;\r
- this.configKey = configKey;\r
- this.pluginName = pluginName;\r
- this.description = description;\r
- }\r
-\r
- public Integer getId() {\r
- return id;\r
- }\r
-\r
- /**\r
- * @deprecated since 2.3. visibility should be decreased to protected or package\r
- */\r
- @Deprecated\r
- public void setId(Integer id) {\r
- this.id = id;\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- /**\r
- * Sets the rule name\r
- */\r
- public Rule setName(String name) {\r
- this.name = removeNewLineCharacters(name);\r
- return this;\r
- }\r
-\r
- public String getKey() {\r
- return key;\r
- }\r
-\r
- /**\r
- * Sets the rule key\r
- */\r
- public Rule setKey(String key) {\r
- this.key = key;\r
- return this;\r
- }\r
-\r
- /**\r
- * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007\r
- */\r
- @Deprecated\r
- public RulesCategory getRulesCategory() {\r
- return NONE;\r
- }\r
-\r
- /**\r
- * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007\r
- */\r
- @Deprecated\r
- public Rule setRulesCategory(RulesCategory rulesCategory) {\r
- return this;\r
- }\r
-\r
- /**\r
- * @deprecated since 2.5 use {@link #getRepositoryKey()} instead\r
- */\r
- @Deprecated\r
- public String getPluginName() {\r
- return pluginName;\r
- }\r
-\r
- /**\r
- * @deprecated since 2.5 use {@link #setRepositoryKey(String)} instead\r
- */\r
- @Deprecated\r
- public Rule setPluginName(String pluginName) {\r
- this.pluginName = pluginName;\r
- return this;\r
- }\r
-\r
- public String getConfigKey() {\r
- return configKey;\r
- }\r
-\r
- /**\r
- * Sets the configuration key\r
- */\r
- public Rule setConfigKey(String configKey) {\r
- this.configKey = configKey;\r
- return this;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- /**\r
- * Sets the rule description\r
- */\r
- public Rule setDescription(String description) {\r
- this.description = StringUtils.strip(description);\r
- return this;\r
- }\r
-\r
- public Boolean isEnabled() {\r
- return enabled;\r
- }\r
-\r
- /**\r
- * Do not call. Used only by sonar.\r
- */\r
- public Rule setEnabled(Boolean b) {\r
- this.enabled = b;\r
- return this;\r
- }\r
-\r
- public List<RuleParam> getParams() {\r
- return params;\r
- }\r
-\r
- public RuleParam getParam(String key) {\r
- for (RuleParam param : params) {\r
- if (StringUtils.equals(key, param.getKey())) {\r
- return param;\r
- }\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * Sets the rule parameters\r
- */\r
- public Rule setParams(List<RuleParam> params) {\r
- this.params.clear();\r
- for (RuleParam param : params) {\r
- param.setRule(this);\r
- this.params.add(param);\r
- }\r
- return this;\r
- }\r
-\r
- public RuleParam createParameter() {\r
- RuleParam parameter = new RuleParam()\r
- .setRule(this);\r
- params.add(parameter);\r
- return parameter;\r
- }\r
-\r
- public RuleParam createParameter(String key) {\r
- RuleParam parameter = new RuleParam()\r
- .setKey(key)\r
- .setRule(this);\r
- params.add(parameter);\r
- return parameter;\r
- }\r
-\r
- /**\r
- * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007\r
- */\r
- @Deprecated\r
- public Integer getCategoryId() {\r
- return null;\r
- }\r
-\r
- /**\r
- * @since 2.5\r
- */\r
- public RulePriority getSeverity() {\r
- return priority;\r
- }\r
-\r
- /**\r
- * @param severity severity to set, if null, uses the default priority.\r
- * @since 2.5\r
- */\r
- public Rule setSeverity(RulePriority severity) {\r
- if (severity == null) {\r
- this.priority = DEFAULT_PRIORITY;\r
- } else {\r
- this.priority = severity;\r
- }\r
- return this;\r
- }\r
-\r
- /**\r
- * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829\r
- */\r
- @Deprecated\r
- public RulePriority getPriority() {\r
- return priority;\r
- }\r
-\r
- /**\r
- * Sets the rule priority. If null, uses the default priority\r
- * \r
- * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.codehaus.org/browse/SONAR-1829\r
- */\r
- @Deprecated\r
- public Rule setPriority(RulePriority priority) {\r
- return setSeverity(priority);\r
- }\r
-\r
- public String getRepositoryKey() {\r
- return pluginName;\r
- }\r
-\r
- public Rule setRepositoryKey(String s) {\r
- this.pluginName = s;\r
- return this;\r
- }\r
-\r
- public Rule setUniqueKey(String repositoryKey, String key) {\r
- return setRepositoryKey(repositoryKey).setKey(key).setConfigKey(key);\r
- }\r
-\r
- public Cardinality getCardinality() {\r
- return cardinality;\r
- }\r
-\r
- public Rule setCardinality(Cardinality c) {\r
- this.cardinality = c;\r
- return this;\r
- }\r
-\r
- public Rule getParent() {\r
- return parent;\r
- }\r
-\r
- public Rule setParent(Rule parent) {\r
- this.parent = parent;\r
- return this;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (!(obj instanceof Rule)) {\r
- return false;\r
- }\r
- if (this == obj) {\r
- return true;\r
- }\r
- Rule other = (Rule) obj;\r
- return new EqualsBuilder()\r
- .append(pluginName, other.getRepositoryKey())\r
- .append(key, other.getKey())\r
- .isEquals();\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return new HashCodeBuilder(17, 37)\r
- .append(pluginName)\r
- .append(key)\r
- .toHashCode();\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return new ToStringBuilder(this)\r
- .append("id", getId())\r
- .append("name", name)\r
- .append("key", key)\r
- .append("configKey", configKey)\r
- .append("plugin", pluginName)\r
- .toString();\r
- }\r
-\r
- private String removeNewLineCharacters(String text) {\r
- String removedCRLF = StringUtils.remove(text, "\n");\r
- removedCRLF = StringUtils.remove(removedCRLF, "\r");\r
- removedCRLF = StringUtils.remove(removedCRLF, "\n\r");\r
- removedCRLF = StringUtils.remove(removedCRLF, "\r\n");\r
- return removedCRLF;\r
- }\r
-\r
- public static Rule create() {\r
- return new Rule();\r
- }\r
-\r
- /**\r
- * Create with all required fields\r
- */\r
- public static Rule create(String repositoryKey, String key, String name) {\r
- return new Rule().setUniqueKey(repositoryKey, key).setName(name);\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.rules;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.sonar.api.database.DatabaseProperties;
+import org.sonar.check.Cardinality;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "rules")
+public final class Rule {
+
+ private final static RulesCategory NONE = new RulesCategory("none");
+
+ @Id
+ @Column(name = "id")
+ @GeneratedValue
+ private Integer id;
+
+ /**
+ * The default priority given to a rule if not explicitly set
+ */
+ public static final RulePriority DEFAULT_PRIORITY = RulePriority.MAJOR;
+
+ @Column(name = "name", updatable = true, nullable = false)
+ private String name;
+
+ @Column(name = "plugin_rule_key", updatable = false, nullable = true, length = 200)
+ private String key;
+
+ @Column(name = "enabled", updatable = true, nullable = true)
+ private Boolean enabled = Boolean.TRUE;
+
+ @Column(name = "plugin_config_key", updatable = true, nullable = true, length = 500)
+ private String configKey;
+
+ // Godin: This field should be named priority, otherwise StandardRulesXmlParserTest fails
+ @Column(name = "priority", updatable = true, nullable = true)
+ @Enumerated(EnumType.ORDINAL)
+ private RulePriority priority = DEFAULT_PRIORITY;
+
+ @Column(name = "description", updatable = true, nullable = true, length = DatabaseProperties.MAX_TEXT_SIZE)
+ private String description;
+
+ @Column(name = "plugin_name", updatable = true, nullable = false)
+ private String pluginName;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "cardinality", updatable = true, nullable = false)
+ private Cardinality cardinality = Cardinality.SINGLE;
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "parent_id", updatable = true, nullable = true)
+ private Rule parent = null;
+
+ @org.hibernate.annotations.Cascade({ org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
+ @OneToMany(mappedBy = "rule")
+ private List<RuleParam> params = new ArrayList<RuleParam>();
+
+ /**
+ * @deprecated since 2.3. Use the factory method {@link #create()}
+ */
+ @Deprecated
+ public Rule() {
+ // TODO reduce visibility to package
+ }
+
+ /**
+ * Creates rule with minimum set of info
+ *
+ * @param pluginName the plugin name indicates which plugin the rule belongs to
+ * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique across the
+ * application
+ * @deprecated since 2.3. Use the factory method {@link #create()}
+ */
+ @Deprecated
+ public Rule(String pluginName, String key) {
+ this.pluginName = pluginName;
+ this.key = key;
+ this.configKey = key;
+ }
+
+ /**
+ * Creates a fully qualified rule
+ *
+ * @param pluginKey the plugin the rule belongs to
+ * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique across the
+ * application
+ * @param name the name displayed in the UI
+ * @param rulesCategory the ISO category the rule belongs to
+ * @param severity this is the severity associated to the rule
+ * @deprecated since 2.3. Use the factory method {@link #create()}
+ */
+ @Deprecated
+ public Rule(String pluginKey, String key, String name, RulesCategory rulesCategory, RulePriority severity) {
+ setName(name);
+ this.key = key;
+ this.configKey = key;
+ this.priority = severity;
+ this.pluginName = pluginKey;
+ }
+
+ /**
+ * @deprecated since 2.3. Use the factory method {@link #create()}
+ */
+ @Deprecated
+ public Rule(String name, String key, RulesCategory rulesCategory, String pluginName, String description) {
+ this();
+ setName(name);
+ this.key = key;
+ this.configKey = key;
+ this.pluginName = pluginName;
+ this.description = description;
+ }
+
+ /**
+ * @deprecated since 2.3. Use the factory method {@link #create()}
+ */
+ @Deprecated
+ public Rule(String name, String key, String configKey, RulesCategory rulesCategory, String pluginName, String description) {
+ this();
+ setName(name);
+ this.key = key;
+ this.configKey = configKey;
+ this.pluginName = pluginName;
+ this.description = description;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ /**
+ * @deprecated since 2.3. visibility should be decreased to protected or package
+ */
+ @Deprecated
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the rule name
+ */
+ public Rule setName(String name) {
+ this.name = removeNewLineCharacters(name);
+ return this;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Sets the rule key
+ */
+ public Rule setKey(String key) {
+ this.key = key;
+ return this;
+ }
+
+ /**
+ * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
+ */
+ @Deprecated
+ public RulesCategory getRulesCategory() {
+ return NONE;
+ }
+
+ /**
+ * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
+ */
+ @Deprecated
+ public Rule setRulesCategory(RulesCategory rulesCategory) {
+ return this;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #getRepositoryKey()} instead
+ */
+ @Deprecated
+ public String getPluginName() {
+ return pluginName;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #setRepositoryKey(String)} instead
+ */
+ @Deprecated
+ public Rule setPluginName(String pluginName) {
+ this.pluginName = pluginName;
+ return this;
+ }
+
+ public String getConfigKey() {
+ return configKey;
+ }
+
+ /**
+ * Sets the configuration key
+ */
+ public Rule setConfigKey(String configKey) {
+ this.configKey = configKey;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the rule description
+ */
+ public Rule setDescription(String description) {
+ this.description = StringUtils.strip(description);
+ return this;
+ }
+
+ public Boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * Do not call. Used only by sonar.
+ */
+ public Rule setEnabled(Boolean b) {
+ this.enabled = b;
+ return this;
+ }
+
+ public List<RuleParam> getParams() {
+ return params;
+ }
+
+ public RuleParam getParam(String key) {
+ for (RuleParam param : params) {
+ if (StringUtils.equals(key, param.getKey())) {
+ return param;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Sets the rule parameters
+ */
+ public Rule setParams(List<RuleParam> params) {
+ this.params.clear();
+ for (RuleParam param : params) {
+ param.setRule(this);
+ this.params.add(param);
+ }
+ return this;
+ }
+
+ public RuleParam createParameter() {
+ RuleParam parameter = new RuleParam()
+ .setRule(this);
+ params.add(parameter);
+ return parameter;
+ }
+
+ public RuleParam createParameter(String key) {
+ RuleParam parameter = new RuleParam()
+ .setKey(key)
+ .setRule(this);
+ params.add(parameter);
+ return parameter;
+ }
+
+ /**
+ * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
+ */
+ @Deprecated
+ public Integer getCategoryId() {
+ return null;
+ }
+
+ /**
+ * @since 2.5
+ */
+ public RulePriority getSeverity() {
+ return priority;
+ }
+
+ /**
+ * @param severity severity to set, if null, uses the default priority.
+ * @since 2.5
+ */
+ public Rule setSeverity(RulePriority severity) {
+ if (severity == null) {
+ this.priority = DEFAULT_PRIORITY;
+ } else {
+ this.priority = severity;
+ }
+ return this;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
+ public RulePriority getPriority() {
+ return priority;
+ }
+
+ /**
+ * Sets the rule priority. If null, uses the default priority
+ *
+ * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
+ public Rule setPriority(RulePriority priority) {
+ return setSeverity(priority);
+ }
+
+ public String getRepositoryKey() {
+ return pluginName;
+ }
+
+ public Rule setRepositoryKey(String s) {
+ this.pluginName = s;
+ return this;
+ }
+
+ public Rule setUniqueKey(String repositoryKey, String key) {
+ return setRepositoryKey(repositoryKey).setKey(key).setConfigKey(key);
+ }
+
+ public Cardinality getCardinality() {
+ return cardinality;
+ }
+
+ public Rule setCardinality(Cardinality c) {
+ this.cardinality = c;
+ return this;
+ }
+
+ public Rule getParent() {
+ return parent;
+ }
+
+ public Rule setParent(Rule parent) {
+ this.parent = parent;
+ return this;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Rule)) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ Rule other = (Rule) obj;
+ return new EqualsBuilder()
+ .append(pluginName, other.getRepositoryKey())
+ .append(key, other.getKey())
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37)
+ .append(pluginName)
+ .append(key)
+ .toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("id", getId())
+ .append("name", name)
+ .append("key", key)
+ .append("configKey", configKey)
+ .append("plugin", pluginName)
+ .toString();
+ }
+
+ private String removeNewLineCharacters(String text) {
+ String removedCRLF = StringUtils.remove(text, "\n");
+ removedCRLF = StringUtils.remove(removedCRLF, "\r");
+ removedCRLF = StringUtils.remove(removedCRLF, "\n\r");
+ removedCRLF = StringUtils.remove(removedCRLF, "\r\n");
+ return removedCRLF;
+ }
+
+ public static Rule create() {
+ return new Rule();
+ }
+
+ /**
+ * Create with all required fields
+ */
+ public static Rule create(String repositoryKey, String key, String name) {
+ return new Rule().setUniqueKey(repositoryKey, key).setName(name);
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.rules;\r
-\r
-import org.apache.commons.lang.StringUtils;\r
-import org.apache.commons.lang.builder.EqualsBuilder;\r
-import org.apache.commons.lang.builder.HashCodeBuilder;\r
-import org.apache.commons.lang.builder.ToStringBuilder;\r
-\r
-import javax.persistence.*;\r
-\r
-@Entity\r
-@Table(name = "rules_parameters")\r
-public class RuleParam {\r
-\r
- @Id\r
- @Column(name = "id")\r
- @GeneratedValue\r
- private Integer id;\r
-\r
- @ManyToOne(fetch = FetchType.EAGER)\r
- @JoinColumn(name = "rule_id")\r
- private Rule rule;\r
-\r
- @Column(name = "name", updatable = true, nullable = false, length = 128)\r
- private String key;\r
-\r
- @Column(name = "description", updatable = true, nullable = true, length = 4000)\r
- private String description;\r
-\r
- @Column(name = "param_type", updatable = true, nullable = true, length = 512)\r
- private String type = "s";\r
-\r
- @Column(name = "default_value", updatable = true, nullable = true, length = 4000)\r
- private String defaultValue;\r
-\r
- /**\r
- * @deprecated since 2.3 use the factory method Rule.setParameter()\r
- */\r
- @Deprecated\r
- public RuleParam() {\r
- }\r
-\r
- /**\r
- * @deprecated since 2.3 use the factory method setParameter()\r
- */\r
- @Deprecated\r
- public RuleParam(Rule rule, String key, String description, String type) {\r
- this.rule = rule;\r
- this.key = key;\r
- this.description = description;\r
- this.type = type;\r
- }\r
-\r
- public Rule getRule() {\r
- return rule;\r
- }\r
-\r
- RuleParam setRule(Rule rule) {\r
- this.rule = rule;\r
- return this;\r
- }\r
-\r
- public String getKey() {\r
- return key;\r
- }\r
-\r
- public RuleParam setKey(String key) {\r
- this.key = key;\r
- return this;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public RuleParam setDescription(String s) {\r
- this.description = StringUtils.defaultString(s, "");\r
- return this;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public RuleParam setType(String type) {\r
- this.type = type;\r
- return this;\r
- }\r
-\r
- public String getDefaultValue() {\r
- return defaultValue;\r
- }\r
-\r
- public Boolean getDefaultValueAsBoolean() {\r
- if (defaultValue!=null) {\r
- return Boolean.parseBoolean(defaultValue);\r
- }\r
- return null;\r
- }\r
-\r
- public Integer getDefaultValueAsInteger() {\r
- if (defaultValue!=null) {\r
- return Integer.parseInt(defaultValue);\r
- }\r
- return null;\r
- }\r
-\r
- public RuleParam setDefaultValue(String s) {\r
- this.defaultValue = s;\r
- return this;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (!(obj instanceof RuleParam)) {\r
- return false;\r
- }\r
- if (this == obj) {\r
- return true;\r
- }\r
- RuleParam other = (RuleParam) obj;\r
- return new EqualsBuilder()\r
- //.append(rule, other.getRule())\r
- .append(key, other.getKey()).isEquals();\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return new HashCodeBuilder(17, 37)\r
- //.append(rule)\r
- .append(key)\r
- .toHashCode();\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return new ToStringBuilder(this)\r
- .append("id", id)\r
- .append("key", key)\r
- .append("desc", description)\r
- .append("type", type)\r
- .toString();\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.rules;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "rules_parameters")
+public class RuleParam {
+
+ @Id
+ @Column(name = "id")
+ @GeneratedValue
+ private Integer id;
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "rule_id")
+ private Rule rule;
+
+ @Column(name = "name", updatable = true, nullable = false, length = 128)
+ private String key;
+
+ @Column(name = "description", updatable = true, nullable = true, length = 4000)
+ private String description;
+
+ @Column(name = "param_type", updatable = true, nullable = true, length = 512)
+ private String type = "s";
+
+ @Column(name = "default_value", updatable = true, nullable = true, length = 4000)
+ private String defaultValue;
+
+ /**
+ * @deprecated since 2.3 use the factory method Rule.setParameter()
+ */
+ @Deprecated
+ public RuleParam() {
+ }
+
+ /**
+ * @deprecated since 2.3 use the factory method setParameter()
+ */
+ @Deprecated
+ public RuleParam(Rule rule, String key, String description, String type) {
+ this.rule = rule;
+ this.key = key;
+ this.description = description;
+ this.type = type;
+ }
+
+ public Rule getRule() {
+ return rule;
+ }
+
+ RuleParam setRule(Rule rule) {
+ this.rule = rule;
+ return this;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public RuleParam setKey(String key) {
+ this.key = key;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public RuleParam setDescription(String s) {
+ this.description = StringUtils.defaultString(s, "");
+ return this;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public RuleParam setType(String type) {
+ this.type = type;
+ return this;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public Boolean getDefaultValueAsBoolean() {
+ if (defaultValue!=null) {
+ return Boolean.parseBoolean(defaultValue);
+ }
+ return null;
+ }
+
+ public Integer getDefaultValueAsInteger() {
+ if (defaultValue!=null) {
+ return Integer.parseInt(defaultValue);
+ }
+ return null;
+ }
+
+ public RuleParam setDefaultValue(String s) {
+ this.defaultValue = s;
+ return this;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof RuleParam)) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ RuleParam other = (RuleParam) obj;
+ return new EqualsBuilder()
+ //.append(rule, other.getRule())
+ .append(key, other.getKey()).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37)
+ //.append(rule)
+ .append(key)
+ .toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("id", id)
+ .append("key", key)
+ .append("desc", description)
+ .append("type", type)
+ .toString();
+ }
}
\ No newline at end of file
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.rules;\r
-\r
-import org.apache.commons.lang.builder.EqualsBuilder;\r
-import org.apache.commons.lang.builder.HashCodeBuilder;\r
-import org.apache.commons.lang.builder.ToStringBuilder;\r
-import org.hibernate.annotations.Cache;\r
-import org.hibernate.annotations.CacheConcurrencyStrategy;\r
-import org.hibernate.annotations.Immutable;\r
-import org.sonar.api.database.BaseIdentifiable;\r
-import org.sonar.check.IsoCategory;\r
-\r
-import javax.persistence.Column;\r
-import javax.persistence.Entity;\r
-import javax.persistence.Table;\r
-\r
-/**\r
- * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007\r
- */\r
-@Deprecated\r
-@Immutable\r
-@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)\r
-@Entity\r
-@Table(name = "rules_categories")\r
-public class RulesCategory extends BaseIdentifiable {\r
-\r
- @Column(name = "name", updatable = false, nullable = false)\r
- private String name;\r
-\r
- @Column(name = "description", updatable = false, nullable = true)\r
- private String description;\r
-\r
- /**\r
- * Creates a RuleCategory based on the category name\r
- *\r
- * @param name the category name\r
- */\r
- public RulesCategory(String name) {\r
- this.name = name;\r
- }\r
-\r
- /**\r
- * Creates a category based on the category name and description\r
- *\r
- * @param name the category name\r
- * @param description the category description\r
- */\r
- public RulesCategory(String name, String description) {\r
- this.name = name;\r
- this.description = description;\r
- }\r
-\r
- /**\r
- * Creates an empty category\r
- */\r
- public RulesCategory() {\r
- }\r
-\r
- /**\r
- * @return the category name\r
- */\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- /**\r
- * Sets the category name\r
- *\r
- * @param name the name\r
- */\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
-\r
- /**\r
- * @return the category description\r
- */\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- /**\r
- * Sets the cay description\r
- *\r
- * @param description the description\r
- */\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (!(obj instanceof RulesCategory)) {\r
- return false;\r
- }\r
- if (this == obj) {\r
- return true;\r
- }\r
- RulesCategory other = (RulesCategory) obj;\r
- return new EqualsBuilder()\r
- .append(name, other.getName()).isEquals();\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return new HashCodeBuilder(17, 37)\r
- .append(name)\r
- .toHashCode();\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return new ToStringBuilder(this)\r
- .append("id", getId())\r
- .append("name", name)\r
- .append("desc", description)\r
- .toString();\r
- }\r
-\r
- public IsoCategory toIsoCategory() {\r
- if (name.equals(Iso9126RulesCategories.EFFICIENCY.getName())) {\r
- return IsoCategory.Efficiency;\r
- }\r
- if (name.equals(Iso9126RulesCategories.MAINTAINABILITY.getName())) {\r
- return IsoCategory.Maintainability;\r
- }\r
- if (name.equals(Iso9126RulesCategories.PORTABILITY.getName())) {\r
- return IsoCategory.Portability;\r
- }\r
- if (name.equals(Iso9126RulesCategories.RELIABILITY.getName())) {\r
- return IsoCategory.Reliability;\r
- }\r
- if (name.equals(Iso9126RulesCategories.USABILITY.getName())) {\r
- return IsoCategory.Usability;\r
- }\r
- return null;\r
- }\r
-\r
- public static RulesCategory fromIsoCategory(IsoCategory iso) {\r
- if (iso == IsoCategory.Efficiency) {\r
- return Iso9126RulesCategories.EFFICIENCY;\r
- }\r
- if (iso == IsoCategory.Maintainability) {\r
- return Iso9126RulesCategories.MAINTAINABILITY;\r
- }\r
- if (iso == IsoCategory.Portability) {\r
- return Iso9126RulesCategories.PORTABILITY;\r
- }\r
- if (iso == IsoCategory.Reliability) {\r
- return Iso9126RulesCategories.RELIABILITY;\r
- }\r
- if (iso == IsoCategory.Usability) {\r
- return Iso9126RulesCategories.USABILITY;\r
- }\r
- return null;\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.rules;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.hibernate.annotations.Cache;
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+import org.hibernate.annotations.Immutable;
+import org.sonar.api.database.BaseIdentifiable;
+import org.sonar.check.IsoCategory;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
+ */
+@Deprecated
+@Immutable
+@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
+@Entity
+@Table(name = "rules_categories")
+public class RulesCategory extends BaseIdentifiable {
+
+ @Column(name = "name", updatable = false, nullable = false)
+ private String name;
+
+ @Column(name = "description", updatable = false, nullable = true)
+ private String description;
+
+ /**
+ * Creates a RuleCategory based on the category name
+ *
+ * @param name the category name
+ */
+ public RulesCategory(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Creates a category based on the category name and description
+ *
+ * @param name the category name
+ * @param description the category description
+ */
+ public RulesCategory(String name, String description) {
+ this.name = name;
+ this.description = description;
+ }
+
+ /**
+ * Creates an empty category
+ */
+ public RulesCategory() {
+ }
+
+ /**
+ * @return the category name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the category name
+ *
+ * @param name the name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the category description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the cay description
+ *
+ * @param description the description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof RulesCategory)) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ RulesCategory other = (RulesCategory) obj;
+ return new EqualsBuilder()
+ .append(name, other.getName()).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37)
+ .append(name)
+ .toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("id", getId())
+ .append("name", name)
+ .append("desc", description)
+ .toString();
+ }
+
+ public IsoCategory toIsoCategory() {
+ if (name.equals(Iso9126RulesCategories.EFFICIENCY.getName())) {
+ return IsoCategory.Efficiency;
+ }
+ if (name.equals(Iso9126RulesCategories.MAINTAINABILITY.getName())) {
+ return IsoCategory.Maintainability;
+ }
+ if (name.equals(Iso9126RulesCategories.PORTABILITY.getName())) {
+ return IsoCategory.Portability;
+ }
+ if (name.equals(Iso9126RulesCategories.RELIABILITY.getName())) {
+ return IsoCategory.Reliability;
+ }
+ if (name.equals(Iso9126RulesCategories.USABILITY.getName())) {
+ return IsoCategory.Usability;
+ }
+ return null;
+ }
+
+ public static RulesCategory fromIsoCategory(IsoCategory iso) {
+ if (iso == IsoCategory.Efficiency) {
+ return Iso9126RulesCategories.EFFICIENCY;
+ }
+ if (iso == IsoCategory.Maintainability) {
+ return Iso9126RulesCategories.MAINTAINABILITY;
+ }
+ if (iso == IsoCategory.Portability) {
+ return Iso9126RulesCategories.PORTABILITY;
+ }
+ if (iso == IsoCategory.Reliability) {
+ return Iso9126RulesCategories.RELIABILITY;
+ }
+ if (iso == IsoCategory.Usability) {
+ return Iso9126RulesCategories.USABILITY;
+ }
+ return null;
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.web;\r
-\r
-import java.lang.annotation.ElementType;\r
-import java.lang.annotation.Retention;\r
-import java.lang.annotation.RetentionPolicy;\r
-import java.lang.annotation.Target;\r
-\r
-@Retention(RetentionPolicy.RUNTIME)\r
-@Target(ElementType.TYPE)\r
-public @interface Description {\r
- String value();\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.web;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Description {
+ String value();
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.web;\r
-\r
-import org.sonar.api.ServerExtension;\r
-\r
-/**\r
- * @since 1.10\r
- */\r
-public interface Footer extends ServerExtension {\r
-\r
- /**\r
- * Static HTML (no Ruby on Rails nor GWT)\r
- */\r
- String getHtml();\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.web;
+
+import org.sonar.api.ServerExtension;
+
+/**
+ * @since 1.10
+ */
+public interface Footer extends ServerExtension {
+
+ /**
+ * Static HTML (no Ruby on Rails nor GWT)
+ */
+ String getHtml();
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.web;\r
-\r
-import java.lang.annotation.Retention;\r
-import java.lang.annotation.RetentionPolicy;\r
-\r
-@Retention(RetentionPolicy.RUNTIME)\r
-public @interface WidgetProperties {\r
- WidgetProperty[] value() default {};\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.web;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface WidgetProperties {
+ WidgetProperty[] value() default {};
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.web;\r
-\r
-import java.lang.annotation.ElementType;\r
-import java.lang.annotation.Retention;\r
-import java.lang.annotation.RetentionPolicy;\r
-import java.lang.annotation.Target;\r
-\r
-@Retention(RetentionPolicy.RUNTIME)\r
-@Target(ElementType.TYPE)\r
-public @interface WidgetProperty {\r
-\r
- String key();\r
-\r
- WidgetPropertyType type() default WidgetPropertyType.STRING;\r
-\r
- String defaultValue() default "";\r
-\r
- String description() default "";\r
-\r
- boolean optional() default true;\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.web;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface WidgetProperty {
+
+ String key();
+
+ WidgetPropertyType type() default WidgetPropertyType.STRING;
+
+ String defaultValue() default "";
+
+ String description() default "";
+
+ boolean optional() default true;
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.web.gwt.client;\r
-\r
-import com.google.gwt.i18n.client.Dictionary;\r
-\r
-public final class ResourceDictionary {\r
-\r
- public final static String CONF_PERMALINK_BASE = "permalink_url_base";\r
- public final static String CONF_RESOURCE_KEY = "resource_key";\r
- public final static String CONF_V_RESOURCE_KEY = "viewer_resource_key";\r
- public final static String CONF_V_PLUGIN_KEY = "viewer_plugin_key";\r
- public final static String CONF_V_METRIC_KEY = "metric";\r
-\r
- private ResourceDictionary() {\r
- }\r
-\r
- public static String getPermaLinkURLBase() {\r
- return Utils.getConfiguration(CONF_PERMALINK_BASE);\r
- }\r
-\r
- public static String getResourceKey() {\r
- return Utils.getConfiguration(CONF_RESOURCE_KEY);\r
- }\r
-\r
- public static String getViewerResourceKey() {\r
- return Utils.getConfiguration(CONF_V_RESOURCE_KEY);\r
- }\r
-\r
- public static String getViewerPluginKey() {\r
- return Utils.getConfiguration(CONF_V_PLUGIN_KEY);\r
- }\r
-\r
- public static String getViewerMetricKey() {\r
- return Utils.getConfiguration(CONF_V_METRIC_KEY);\r
- }\r
-\r
- public static Dictionary getResourceViewers() {\r
- return Dictionary.getDictionary("resource_viewers");\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.web.gwt.client;
+
+import com.google.gwt.i18n.client.Dictionary;
+
+public final class ResourceDictionary {
+
+ public final static String CONF_PERMALINK_BASE = "permalink_url_base";
+ public final static String CONF_RESOURCE_KEY = "resource_key";
+ public final static String CONF_V_RESOURCE_KEY = "viewer_resource_key";
+ public final static String CONF_V_PLUGIN_KEY = "viewer_plugin_key";
+ public final static String CONF_V_METRIC_KEY = "metric";
+
+ private ResourceDictionary() {
+ }
+
+ public static String getPermaLinkURLBase() {
+ return Utils.getConfiguration(CONF_PERMALINK_BASE);
+ }
+
+ public static String getResourceKey() {
+ return Utils.getConfiguration(CONF_RESOURCE_KEY);
+ }
+
+ public static String getViewerResourceKey() {
+ return Utils.getConfiguration(CONF_V_RESOURCE_KEY);
+ }
+
+ public static String getViewerPluginKey() {
+ return Utils.getConfiguration(CONF_V_PLUGIN_KEY);
+ }
+
+ public static String getViewerMetricKey() {
+ return Utils.getConfiguration(CONF_V_METRIC_KEY);
+ }
+
+ public static Dictionary getResourceViewers() {
+ return Dictionary.getDictionary("resource_viewers");
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.batch;\r
-\r
-import org.junit.Test;\r
-import static org.mockito.Mockito.*;\r
-import org.sonar.api.measures.CoreMetrics;\r
-import org.sonar.api.measures.Measure;\r
-import org.sonar.api.resources.Directory;\r
-import org.sonar.api.resources.File;\r
-import org.sonar.api.resources.Java;\r
-import org.sonar.api.resources.Resource;\r
-\r
-public class AbstractFunctionComplexityDecoratorTest {\r
-\r
- @Test\r
- public void calculateFunctionComplexity() {\r
-\r
- Resource directory = new Directory("fake");\r
- DecoratorContext context = mock(DecoratorContext.class);\r
- when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 200.0));\r
- when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 500.0));\r
-\r
- new AbstractFunctionComplexityDecorator(Java.INSTANCE) {\r
- }.decorate(directory, context);\r
-\r
- verify(context).saveMeasure(CoreMetrics.FUNCTION_COMPLEXITY, 2.5);\r
- }\r
-\r
- @Test\r
- public void noAverageIfMissingData() {\r
-\r
- DecoratorContext context = mock(DecoratorContext.class);\r
- when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 20.0));\r
- Resource directory = new Directory("fake");\r
-\r
- new AbstractFunctionComplexityDecorator(Java.INSTANCE) {\r
- }.decorate(directory, context);\r
-\r
- verify(context, never()).saveMeasure(eq(CoreMetrics.FUNCTION_COMPLEXITY), anyDouble());\r
- }\r
-\r
- @Test\r
- public void noAverageIfZeroFiles() {\r
- AbstractFunctionComplexityDecorator decorator = new AbstractFunctionComplexityDecorator(Java.INSTANCE) {\r
- };\r
-\r
- Resource directory = new Directory("fake");\r
- DecoratorContext context = mock(DecoratorContext.class);\r
- when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 0.0));\r
- when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 500.0));\r
-\r
- decorator.decorate(directory, context);\r
-\r
- verify(context, never()).saveMeasure(eq(CoreMetrics.FUNCTION_COMPLEXITY), anyDouble());\r
- }\r
-\r
- @Test\r
- public void doNotCalculateOnFiles() {\r
-\r
- Resource file = new File("fake");\r
- DecoratorContext context = mock(DecoratorContext.class);\r
- when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 1.0));\r
- when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 25.0));\r
-\r
- new AbstractFunctionComplexityDecorator(Java.INSTANCE) {\r
- }.decorate(file, context);\r
-\r
- verify(context).saveMeasure(eq(CoreMetrics.FUNCTION_COMPLEXITY), anyDouble());\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.batch;
+
+import org.junit.Test;
+import static org.mockito.Mockito.*;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.Measure;
+import org.sonar.api.resources.Directory;
+import org.sonar.api.resources.File;
+import org.sonar.api.resources.Java;
+import org.sonar.api.resources.Resource;
+
+public class AbstractFunctionComplexityDecoratorTest {
+
+ @Test
+ public void calculateFunctionComplexity() {
+
+ Resource directory = new Directory("fake");
+ DecoratorContext context = mock(DecoratorContext.class);
+ when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 200.0));
+ when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 500.0));
+
+ new AbstractFunctionComplexityDecorator(Java.INSTANCE) {
+ }.decorate(directory, context);
+
+ verify(context).saveMeasure(CoreMetrics.FUNCTION_COMPLEXITY, 2.5);
+ }
+
+ @Test
+ public void noAverageIfMissingData() {
+
+ DecoratorContext context = mock(DecoratorContext.class);
+ when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 20.0));
+ Resource directory = new Directory("fake");
+
+ new AbstractFunctionComplexityDecorator(Java.INSTANCE) {
+ }.decorate(directory, context);
+
+ verify(context, never()).saveMeasure(eq(CoreMetrics.FUNCTION_COMPLEXITY), anyDouble());
+ }
+
+ @Test
+ public void noAverageIfZeroFiles() {
+ AbstractFunctionComplexityDecorator decorator = new AbstractFunctionComplexityDecorator(Java.INSTANCE) {
+ };
+
+ Resource directory = new Directory("fake");
+ DecoratorContext context = mock(DecoratorContext.class);
+ when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 0.0));
+ when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 500.0));
+
+ decorator.decorate(directory, context);
+
+ verify(context, never()).saveMeasure(eq(CoreMetrics.FUNCTION_COMPLEXITY), anyDouble());
+ }
+
+ @Test
+ public void doNotCalculateOnFiles() {
+
+ Resource file = new File("fake");
+ DecoratorContext context = mock(DecoratorContext.class);
+ when(context.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 1.0));
+ when(context.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 25.0));
+
+ new AbstractFunctionComplexityDecorator(Java.INSTANCE) {
+ }.decorate(file, context);
+
+ verify(context).saveMeasure(eq(CoreMetrics.FUNCTION_COMPLEXITY), anyDouble());
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.measures;\r
-\r
-import com.google.common.collect.Lists;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.sonar.api.resources.JavaFile;\r
-\r
-import java.util.List;\r
-\r
-import static junit.framework.Assert.assertNull;\r
-import static org.hamcrest.CoreMatchers.is;\r
-import static org.junit.Assert.assertThat;\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.when;\r
-\r
-public class AverageComplexityFormulaTest {\r
-\r
- private FormulaContext context;\r
- private FormulaData data;\r
-\r
- @Before\r
- public void before() {\r
- context = mock(FormulaContext.class);\r
- when(context.getTargetMetric()).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY);\r
- data = mock(FormulaData.class);\r
- }\r
-\r
- @Test\r
- public void testAverageCalculation() {\r
- List<FormulaData> childrenData = Lists.newArrayList();\r
- FormulaData data1 = mock(FormulaData.class);\r
- childrenData.add(data1);\r
- when(data1.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 43.0));\r
- when(data1.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 107.0));\r
-\r
- FormulaData data2 = mock(FormulaData.class);\r
- childrenData.add(data2);\r
- when(data2.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 127.0));\r
- when(data2.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 233.0));\r
-\r
- when(data.getChildren()).thenReturn(childrenData);\r
-\r
- Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);\r
-\r
- assertThat(measure.getValue(), is(2.0));\r
- }\r
-\r
- @Test\r
- public void testWhenNoChildrenMesaures() {\r
- List<FormulaData> childrenData = Lists.newArrayList();\r
- when(data.getChildren()).thenReturn(childrenData);\r
- Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);\r
- assertNull(measure);\r
- }\r
-\r
- @Test\r
- public void testWhenNoComplexityMesaures() {\r
- List<FormulaData> childrenData = Lists.newArrayList();\r
- FormulaData data1 = mock(FormulaData.class);\r
- childrenData.add(data1);\r
- when(data1.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 43.0));\r
-\r
- when(data.getChildren()).thenReturn(childrenData);\r
- Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);\r
-\r
- assertNull(measure);\r
- }\r
-\r
- @Test\r
- public void testWhenNoByMetricMesaures() {\r
- List<FormulaData> childrenData = Lists.newArrayList();\r
- FormulaData data1 = mock(FormulaData.class);\r
- childrenData.add(data1);\r
- when(data1.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 43.0));\r
-\r
- when(data.getChildren()).thenReturn(childrenData);\r
- Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);\r
-\r
- assertNull(measure);\r
- }\r
-\r
- @Test\r
- public void testWhenMixedMetrics() {\r
- List<FormulaData> childrenData = Lists.newArrayList();\r
- FormulaData data1 = mock(FormulaData.class);\r
- childrenData.add(data1);\r
- when(data1.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 43.0));\r
- when(data1.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 107.0));\r
-\r
- FormulaData data2 = mock(FormulaData.class);\r
- childrenData.add(data2);\r
- when(data2.getMeasure(CoreMetrics.PARAGRAPHS)).thenReturn(new Measure(CoreMetrics.PARAGRAPHS, 127.0));\r
- when(data2.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 233.0));\r
-\r
- when(data.getChildren()).thenReturn(childrenData);\r
-\r
- Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);\r
-\r
- assertThat(measure.getValue(), is(2.5));\r
- }\r
-\r
- @Test\r
- public void testCalculationForFIle() {\r
- when(data.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 60.0));\r
- when(data.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 20.0));\r
- when(context.getResource()).thenReturn(new JavaFile("foo"));\r
-\r
- Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);\r
- assertThat(measure.getValue(), is(3.0));\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.measures;
+
+import com.google.common.collect.Lists;
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.resources.JavaFile;
+
+import java.util.List;
+
+import static junit.framework.Assert.assertNull;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AverageComplexityFormulaTest {
+
+ private FormulaContext context;
+ private FormulaData data;
+
+ @Before
+ public void before() {
+ context = mock(FormulaContext.class);
+ when(context.getTargetMetric()).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY);
+ data = mock(FormulaData.class);
+ }
+
+ @Test
+ public void testAverageCalculation() {
+ List<FormulaData> childrenData = Lists.newArrayList();
+ FormulaData data1 = mock(FormulaData.class);
+ childrenData.add(data1);
+ when(data1.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 43.0));
+ when(data1.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 107.0));
+
+ FormulaData data2 = mock(FormulaData.class);
+ childrenData.add(data2);
+ when(data2.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 127.0));
+ when(data2.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 233.0));
+
+ when(data.getChildren()).thenReturn(childrenData);
+
+ Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);
+
+ assertThat(measure.getValue(), is(2.0));
+ }
+
+ @Test
+ public void testWhenNoChildrenMesaures() {
+ List<FormulaData> childrenData = Lists.newArrayList();
+ when(data.getChildren()).thenReturn(childrenData);
+ Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);
+ assertNull(measure);
+ }
+
+ @Test
+ public void testWhenNoComplexityMesaures() {
+ List<FormulaData> childrenData = Lists.newArrayList();
+ FormulaData data1 = mock(FormulaData.class);
+ childrenData.add(data1);
+ when(data1.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 43.0));
+
+ when(data.getChildren()).thenReturn(childrenData);
+ Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);
+
+ assertNull(measure);
+ }
+
+ @Test
+ public void testWhenNoByMetricMesaures() {
+ List<FormulaData> childrenData = Lists.newArrayList();
+ FormulaData data1 = mock(FormulaData.class);
+ childrenData.add(data1);
+ when(data1.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 43.0));
+
+ when(data.getChildren()).thenReturn(childrenData);
+ Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);
+
+ assertNull(measure);
+ }
+
+ @Test
+ public void testWhenMixedMetrics() {
+ List<FormulaData> childrenData = Lists.newArrayList();
+ FormulaData data1 = mock(FormulaData.class);
+ childrenData.add(data1);
+ when(data1.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 43.0));
+ when(data1.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 107.0));
+
+ FormulaData data2 = mock(FormulaData.class);
+ childrenData.add(data2);
+ when(data2.getMeasure(CoreMetrics.PARAGRAPHS)).thenReturn(new Measure(CoreMetrics.PARAGRAPHS, 127.0));
+ when(data2.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 233.0));
+
+ when(data.getChildren()).thenReturn(childrenData);
+
+ Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);
+
+ assertThat(measure.getValue(), is(2.5));
+ }
+
+ @Test
+ public void testCalculationForFIle() {
+ when(data.getMeasure(CoreMetrics.COMPLEXITY)).thenReturn(new Measure(CoreMetrics.COMPLEXITY, 60.0));
+ when(data.getMeasure(CoreMetrics.FUNCTIONS)).thenReturn(new Measure(CoreMetrics.FUNCTIONS, 20.0));
+ when(context.getResource()).thenReturn(new JavaFile("foo"));
+
+ Measure measure = new AverageComplexityFormula(CoreMetrics.FUNCTIONS).calculate(data, context);
+ assertThat(measure.getValue(), is(3.0));
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.api.measures;\r
-\r
-import com.google.common.collect.Lists;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.sonar.api.resources.File;\r
-import org.sonar.api.resources.JavaFile;\r
-import org.sonar.api.resources.JavaPackage;\r
-import org.sonar.api.resources.Scopes;\r
-\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import static junit.framework.Assert.assertNull;\r
-import static org.hamcrest.CoreMatchers.is;\r
-import static org.hamcrest.CoreMatchers.nullValue;\r
-import static org.hamcrest.MatcherAssert.assertThat;\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.when;\r
-\r
-public class SumChildDistributionFormulaTest {\r
- SumChildDistributionFormula formula;\r
- FormulaContext context;\r
- FormulaData data;\r
-\r
- @Before\r
- public void init() {\r
- formula = new SumChildDistributionFormula();\r
- context = mock(FormulaContext.class);\r
- when(context.getResource()).thenReturn(new File("foo"));\r
- data = mock(FormulaData.class);\r
- }\r
-\r
- @Test\r
- public void testWhenGetChildrenReturnsNull() {\r
- when(context.getTargetMetric()).thenReturn(new Metric("foo"));\r
- when(data.getChildrenMeasures(new Metric("foo"))).thenReturn(null);\r
- assertNull(formula.calculate(data, context));\r
- }\r
-\r
- @Test\r
- public void testWhenGetChildrenReturnsEmpty() {\r
- when(context.getTargetMetric()).thenReturn(new Metric("foo"));\r
- when(data.getChildrenMeasures(new Metric("foo"))).thenReturn((List) Collections.emptyList());\r
- assertNull(formula.calculate(data, context));\r
- }\r
-\r
- @Test\r
- public void shouldNotSumDifferentRanges() {\r
- Metric m = new Metric("foo", Metric.ValueType.DATA);\r
- when(context.getTargetMetric()).thenReturn(m);\r
-\r
- List<Measure> list = Lists.newArrayList(\r
- new Measure(m, "1=0;2=2;5=0;10=10;20=2"),\r
- new Measure(m, "1=0;2=2;5=0;10=10;30=3")\r
- );\r
- when(data.getChildrenMeasures(new Metric("foo"))).thenReturn(list);\r
- assertThat(formula.calculate(data, context), nullValue());\r
- }\r
-\r
- @Test\r
- public void shouldSumSameIntRanges() {\r
- Metric m = new Metric("foo", Metric.ValueType.DATA);\r
- when(context.getTargetMetric()).thenReturn(m);\r
-\r
- List<Measure> list = Lists.newArrayList(\r
- new Measure(m, "1=0;2=2;5=0;10=10;20=2"),\r
- new Measure(m, "1=3;2=2;5=3;10=12;20=0")\r
- );\r
- when(data.getChildrenMeasures(new Metric("foo"))).thenReturn(list);\r
- assertThat(formula.calculate(data, context).getData(), is("1=3;2=4;5=3;10=22;20=2"));\r
- }\r
-\r
- @Test\r
- public void shouldSumSameDoubleRanges() {\r
- initContextWithChildren();\r
- assertThat(formula.calculate(data, context).getData(), is("0.5=3;2.5=6"));\r
- }\r
-\r
- @Test\r
- public void shouldNotPersistWhenScopeLowerThanMinimun() throws Exception {\r
- when(context.getResource()).thenReturn(JavaFile.fromRelativePath("org/Foo.java", false));\r
-\r
- initContextWithChildren();\r
- formula.setMinimumScopeToPersist(Scopes.DIRECTORY);\r
-\r
- Measure distribution = formula.calculate(data, context);\r
- assertThat(distribution.getPersistenceMode().useDatabase(), is(false));\r
- }\r
-\r
- @Test\r
- public void shouldPersistWhenScopeEqualsMinimun() throws Exception {\r
- when(context.getResource()).thenReturn(JavaFile.fromRelativePath("org/Foo.java", false));\r
-\r
- initContextWithChildren();\r
- formula.setMinimumScopeToPersist(Scopes.FILE);\r
-\r
- Measure distribution = formula.calculate(data, context);\r
- assertThat(distribution.getPersistenceMode().useDatabase(), is(true));\r
- }\r
-\r
- @Test\r
- public void shouldPersistWhenScopeHigherThanMinimun() throws Exception {\r
- when(context.getResource()).thenReturn(new JavaPackage("org.foo"));\r
-\r
- initContextWithChildren();\r
- formula.setMinimumScopeToPersist(Scopes.FILE);\r
-\r
- Measure distribution = formula.calculate(data, context);\r
- assertThat(distribution.getPersistenceMode().useDatabase(), is(true));\r
- }\r
-\r
- private void initContextWithChildren() {\r
- Metric m = new Metric("foo", Metric.ValueType.DATA);\r
- when(context.getTargetMetric()).thenReturn(m);\r
- List<Measure> list = Lists.newArrayList(\r
- new Measure(m, "0.5=0;2.5=2"),\r
- new Measure(m, "0.5=3;2.5=4")\r
- );\r
- when(data.getChildrenMeasures(new Metric("foo"))).thenReturn(list);\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.measures;
+
+import com.google.common.collect.Lists;
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.resources.File;
+import org.sonar.api.resources.JavaFile;
+import org.sonar.api.resources.JavaPackage;
+import org.sonar.api.resources.Scopes;
+
+import java.util.Collections;
+import java.util.List;
+
+import static junit.framework.Assert.assertNull;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class SumChildDistributionFormulaTest {
+ SumChildDistributionFormula formula;
+ FormulaContext context;
+ FormulaData data;
+
+ @Before
+ public void init() {
+ formula = new SumChildDistributionFormula();
+ context = mock(FormulaContext.class);
+ when(context.getResource()).thenReturn(new File("foo"));
+ data = mock(FormulaData.class);
+ }
+
+ @Test
+ public void testWhenGetChildrenReturnsNull() {
+ when(context.getTargetMetric()).thenReturn(new Metric("foo"));
+ when(data.getChildrenMeasures(new Metric("foo"))).thenReturn(null);
+ assertNull(formula.calculate(data, context));
+ }
+
+ @Test
+ public void testWhenGetChildrenReturnsEmpty() {
+ when(context.getTargetMetric()).thenReturn(new Metric("foo"));
+ when(data.getChildrenMeasures(new Metric("foo"))).thenReturn((List) Collections.emptyList());
+ assertNull(formula.calculate(data, context));
+ }
+
+ @Test
+ public void shouldNotSumDifferentRanges() {
+ Metric m = new Metric("foo", Metric.ValueType.DATA);
+ when(context.getTargetMetric()).thenReturn(m);
+
+ List<Measure> list = Lists.newArrayList(
+ new Measure(m, "1=0;2=2;5=0;10=10;20=2"),
+ new Measure(m, "1=0;2=2;5=0;10=10;30=3")
+ );
+ when(data.getChildrenMeasures(new Metric("foo"))).thenReturn(list);
+ assertThat(formula.calculate(data, context), nullValue());
+ }
+
+ @Test
+ public void shouldSumSameIntRanges() {
+ Metric m = new Metric("foo", Metric.ValueType.DATA);
+ when(context.getTargetMetric()).thenReturn(m);
+
+ List<Measure> list = Lists.newArrayList(
+ new Measure(m, "1=0;2=2;5=0;10=10;20=2"),
+ new Measure(m, "1=3;2=2;5=3;10=12;20=0")
+ );
+ when(data.getChildrenMeasures(new Metric("foo"))).thenReturn(list);
+ assertThat(formula.calculate(data, context).getData(), is("1=3;2=4;5=3;10=22;20=2"));
+ }
+
+ @Test
+ public void shouldSumSameDoubleRanges() {
+ initContextWithChildren();
+ assertThat(formula.calculate(data, context).getData(), is("0.5=3;2.5=6"));
+ }
+
+ @Test
+ public void shouldNotPersistWhenScopeLowerThanMinimun() throws Exception {
+ when(context.getResource()).thenReturn(JavaFile.fromRelativePath("org/Foo.java", false));
+
+ initContextWithChildren();
+ formula.setMinimumScopeToPersist(Scopes.DIRECTORY);
+
+ Measure distribution = formula.calculate(data, context);
+ assertThat(distribution.getPersistenceMode().useDatabase(), is(false));
+ }
+
+ @Test
+ public void shouldPersistWhenScopeEqualsMinimun() throws Exception {
+ when(context.getResource()).thenReturn(JavaFile.fromRelativePath("org/Foo.java", false));
+
+ initContextWithChildren();
+ formula.setMinimumScopeToPersist(Scopes.FILE);
+
+ Measure distribution = formula.calculate(data, context);
+ assertThat(distribution.getPersistenceMode().useDatabase(), is(true));
+ }
+
+ @Test
+ public void shouldPersistWhenScopeHigherThanMinimun() throws Exception {
+ when(context.getResource()).thenReturn(new JavaPackage("org.foo"));
+
+ initContextWithChildren();
+ formula.setMinimumScopeToPersist(Scopes.FILE);
+
+ Measure distribution = formula.calculate(data, context);
+ assertThat(distribution.getPersistenceMode().useDatabase(), is(true));
+ }
+
+ private void initContextWithChildren() {
+ Metric m = new Metric("foo", Metric.ValueType.DATA);
+ when(context.getTargetMetric()).thenReturn(m);
+ List<Measure> list = Lists.newArrayList(
+ new Measure(m, "0.5=0;2.5=2"),
+ new Measure(m, "0.5=3;2.5=4")
+ );
+ when(data.getChildrenMeasures(new Metric("foo"))).thenReturn(list);
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts;\r
-\r
-import org.apache.commons.io.IOUtils;\r
-import org.jfree.chart.encoders.KeypointPNGEncoderAdapter;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.sonar.api.charts.Chart;\r
-import org.sonar.api.charts.ChartParameters;\r
-import org.sonar.server.charts.deprecated.*;\r
-import org.sonar.server.platform.Platform;\r
-\r
-import javax.servlet.ServletException;\r
-import javax.servlet.http.HttpServlet;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-import java.util.Enumeration;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-public class ChartsServlet extends HttpServlet {\r
-\r
- private static final Logger LOG = LoggerFactory.getLogger(ChartsServlet.class);\r
-\r
- @Override\r
- public void doGet(HttpServletRequest request, HttpServletResponse response)\r
- throws ServletException, IOException {\r
- if (isDeprecatedChart(request)) {\r
- deprecatedDoGet(request, response);\r
-\r
- } else {\r
- ChartFactory chartFactory = Platform.getInstance().getContainer().getComponent(ChartFactory.class);\r
- Chart chart = chartFactory.getChart(request.getParameter("ck"));\r
- if (chart != null) {\r
- BufferedImage image = chart.generateImage(getParams(request));\r
- OutputStream out = response.getOutputStream();\r
- try {\r
- response.setContentType("image/png");\r
- exportAsPNG(image, out);\r
-\r
- } catch (Exception e) {\r
- LOG.error("Generating chart " + chart.getClass().getName(), e);\r
-\r
- } finally {\r
- out.close();\r
- }\r
- }\r
- }\r
- }\r
-\r
- private ChartParameters getParams(HttpServletRequest request) {\r
- Map<String, String> map = new HashMap<String, String>();\r
- Enumeration keys = request.getParameterNames();\r
- while (keys.hasMoreElements()) {\r
- String key = (String) keys.nextElement();\r
- String value = request.getParameter(key);\r
- map.put(key, value);\r
- }\r
- return new ChartParameters(map);\r
- }\r
-\r
- private void exportAsPNG(BufferedImage image, OutputStream out) throws IOException {\r
- KeypointPNGEncoderAdapter encoder = new KeypointPNGEncoderAdapter();\r
- encoder.setEncodingAlpha(true);\r
- encoder.encode(image, out);\r
- }\r
-\r
- public boolean isDeprecatedChart(HttpServletRequest request) {\r
- String chartType = request.getParameter(BaseChartWeb.CHART_PARAM_TYPE);\r
- if (BaseChartWeb.BAR_CHART_HORIZONTAL.equals(chartType) || BaseChartWeb.BAR_CHART_VERTICAL.equals(chartType) || BaseChartWeb.STACKED_BAR_CHART.equals(chartType)) {\r
- return true;\r
- }\r
- if (BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM.equals(chartType)) {\r
- return true;\r
- }\r
- if (BaseChartWeb.PIE_CHART.equals(chartType)) {\r
- return true;\r
- }\r
- if (BaseChartWeb.SPARKLINES_CHART.equals(chartType)) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- public void deprecatedDoGet(HttpServletRequest request, HttpServletResponse response)\r
- throws ServletException, IOException {\r
-\r
- Map<String, String> params = new HashMap<String, String>();\r
- params.put(BaseChartWeb.CHART_PARAM_TYPE, request.getParameter(BaseChartWeb.CHART_PARAM_TYPE));\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, request.getParameter(BaseChartWeb.CHART_PARAM_VALUES));\r
- params.put(BaseChartWeb.CHART_PARAM_COLORS, request.getParameter(BaseChartWeb.CHART_PARAM_COLORS));\r
- params.put(BaseChartWeb.CHART_PARAM_RANGEMAX, request.getParameter(BaseChartWeb.CHART_PARAM_RANGEMAX));\r
- params.put(BaseChartWeb.CHART_PARAM_TITLE, request.getParameter(BaseChartWeb.CHART_PARAM_TITLE));\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, request.getParameter(BaseChartWeb.CHART_PARAM_DIMENSIONS));\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE, request.getParameter(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE));\r
- params.put(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE, request.getParameter(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE));\r
- params.put(BaseChartWeb.CHART_PARAM_SERIES, request.getParameter(BaseChartWeb.CHART_PARAM_SERIES));\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES, request.getParameter(BaseChartWeb.CHART_PARAM_CATEGORIES));\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_LOWER, request.getParameter(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_LOWER));\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_UPPER, request.getParameter(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_UPPER));\r
- params.put(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_LOWER, request.getParameter(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_LOWER));\r
- params.put(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_UPPER, request.getParameter(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_UPPER));\r
- params.put(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_TICKUNIT, request.getParameter(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_TICKUNIT));\r
- params.put(BaseChartWeb.CHART_PARAM_INSETS, request.getParameter(BaseChartWeb.CHART_PARAM_INSETS));\r
- params.put(BaseChartWeb.CHART_PARAM_OUTLINE_RANGEGRIDLINES_VISIBLE, request.getParameter(BaseChartWeb.CHART_PARAM_OUTLINE_RANGEGRIDLINES_VISIBLE));\r
- params.put(BaseChartWeb.CHART_PARAM_OUTLINE_VISIBLE, request.getParameter(BaseChartWeb.CHART_PARAM_OUTLINE_VISIBLE));\r
-\r
- String chartType = params.get(BaseChartWeb.CHART_PARAM_TYPE);\r
-\r
- DeprecatedChart chart = null;\r
-\r
- if (BaseChartWeb.BAR_CHART_HORIZONTAL.equals(chartType) || BaseChartWeb.BAR_CHART_VERTICAL.equals(chartType) || BaseChartWeb.STACKED_BAR_CHART.equals(chartType)) {\r
- chart = new BarChart(params);\r
- } else if (BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM.equals(chartType)) {\r
- chart = new CustomBarChart(params);\r
- } else if (BaseChartWeb.PIE_CHART.equals(chartType)) {\r
- chart = new PieChart(params);\r
- } else if (BaseChartWeb.SPARKLINES_CHART.equals(chartType)) {\r
- chart = new SparkLinesChart(params);\r
- }\r
-\r
- OutputStream out = null;\r
- try {\r
- if (chart != null) {\r
- out = response.getOutputStream();\r
- response.setContentType("image/png");\r
- chart.exportChartAsPNG(out);\r
- }\r
-\r
- } catch (Exception e) {\r
- LOG.error("Generating chart " + chart.getClass().getName(), e);\r
-\r
- } finally {\r
- IOUtils.closeQuietly(out);\r
- }\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts;
+
+import org.apache.commons.io.IOUtils;
+import org.jfree.chart.encoders.KeypointPNGEncoderAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.charts.Chart;
+import org.sonar.api.charts.ChartParameters;
+import org.sonar.server.charts.deprecated.*;
+import org.sonar.server.platform.Platform;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ChartsServlet extends HttpServlet {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ChartsServlet.class);
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ if (isDeprecatedChart(request)) {
+ deprecatedDoGet(request, response);
+
+ } else {
+ ChartFactory chartFactory = Platform.getInstance().getContainer().getComponent(ChartFactory.class);
+ Chart chart = chartFactory.getChart(request.getParameter("ck"));
+ if (chart != null) {
+ BufferedImage image = chart.generateImage(getParams(request));
+ OutputStream out = response.getOutputStream();
+ try {
+ response.setContentType("image/png");
+ exportAsPNG(image, out);
+
+ } catch (Exception e) {
+ LOG.error("Generating chart " + chart.getClass().getName(), e);
+
+ } finally {
+ out.close();
+ }
+ }
+ }
+ }
+
+ private ChartParameters getParams(HttpServletRequest request) {
+ Map<String, String> map = new HashMap<String, String>();
+ Enumeration keys = request.getParameterNames();
+ while (keys.hasMoreElements()) {
+ String key = (String) keys.nextElement();
+ String value = request.getParameter(key);
+ map.put(key, value);
+ }
+ return new ChartParameters(map);
+ }
+
+ private void exportAsPNG(BufferedImage image, OutputStream out) throws IOException {
+ KeypointPNGEncoderAdapter encoder = new KeypointPNGEncoderAdapter();
+ encoder.setEncodingAlpha(true);
+ encoder.encode(image, out);
+ }
+
+ public boolean isDeprecatedChart(HttpServletRequest request) {
+ String chartType = request.getParameter(BaseChartWeb.CHART_PARAM_TYPE);
+ if (BaseChartWeb.BAR_CHART_HORIZONTAL.equals(chartType) || BaseChartWeb.BAR_CHART_VERTICAL.equals(chartType) || BaseChartWeb.STACKED_BAR_CHART.equals(chartType)) {
+ return true;
+ }
+ if (BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM.equals(chartType)) {
+ return true;
+ }
+ if (BaseChartWeb.PIE_CHART.equals(chartType)) {
+ return true;
+ }
+ if (BaseChartWeb.SPARKLINES_CHART.equals(chartType)) {
+ return true;
+ }
+ return false;
+ }
+
+ public void deprecatedDoGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(BaseChartWeb.CHART_PARAM_TYPE, request.getParameter(BaseChartWeb.CHART_PARAM_TYPE));
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, request.getParameter(BaseChartWeb.CHART_PARAM_VALUES));
+ params.put(BaseChartWeb.CHART_PARAM_COLORS, request.getParameter(BaseChartWeb.CHART_PARAM_COLORS));
+ params.put(BaseChartWeb.CHART_PARAM_RANGEMAX, request.getParameter(BaseChartWeb.CHART_PARAM_RANGEMAX));
+ params.put(BaseChartWeb.CHART_PARAM_TITLE, request.getParameter(BaseChartWeb.CHART_PARAM_TITLE));
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, request.getParameter(BaseChartWeb.CHART_PARAM_DIMENSIONS));
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE, request.getParameter(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE));
+ params.put(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE, request.getParameter(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE));
+ params.put(BaseChartWeb.CHART_PARAM_SERIES, request.getParameter(BaseChartWeb.CHART_PARAM_SERIES));
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES, request.getParameter(BaseChartWeb.CHART_PARAM_CATEGORIES));
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_LOWER, request.getParameter(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_LOWER));
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_UPPER, request.getParameter(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_UPPER));
+ params.put(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_LOWER, request.getParameter(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_LOWER));
+ params.put(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_UPPER, request.getParameter(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_UPPER));
+ params.put(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_TICKUNIT, request.getParameter(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_TICKUNIT));
+ params.put(BaseChartWeb.CHART_PARAM_INSETS, request.getParameter(BaseChartWeb.CHART_PARAM_INSETS));
+ params.put(BaseChartWeb.CHART_PARAM_OUTLINE_RANGEGRIDLINES_VISIBLE, request.getParameter(BaseChartWeb.CHART_PARAM_OUTLINE_RANGEGRIDLINES_VISIBLE));
+ params.put(BaseChartWeb.CHART_PARAM_OUTLINE_VISIBLE, request.getParameter(BaseChartWeb.CHART_PARAM_OUTLINE_VISIBLE));
+
+ String chartType = params.get(BaseChartWeb.CHART_PARAM_TYPE);
+
+ DeprecatedChart chart = null;
+
+ if (BaseChartWeb.BAR_CHART_HORIZONTAL.equals(chartType) || BaseChartWeb.BAR_CHART_VERTICAL.equals(chartType) || BaseChartWeb.STACKED_BAR_CHART.equals(chartType)) {
+ chart = new BarChart(params);
+ } else if (BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM.equals(chartType)) {
+ chart = new CustomBarChart(params);
+ } else if (BaseChartWeb.PIE_CHART.equals(chartType)) {
+ chart = new PieChart(params);
+ } else if (BaseChartWeb.SPARKLINES_CHART.equals(chartType)) {
+ chart = new SparkLinesChart(params);
+ }
+
+ OutputStream out = null;
+ try {
+ if (chart != null) {
+ out = response.getOutputStream();
+ response.setContentType("image/png");
+ chart.exportChartAsPNG(out);
+ }
+
+ } catch (Exception e) {
+ LOG.error("Generating chart " + chart.getClass().getName(), e);
+
+ } finally {
+ IOUtils.closeQuietly(out);
+ }
+ }
+
+}
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts.deprecated;\r
-\r
-import org.jfree.chart.JFreeChart;\r
-import org.jfree.chart.axis.CategoryAxis;\r
-import org.jfree.chart.axis.NumberAxis;\r
-import org.jfree.chart.axis.NumberTickUnit;\r
-import org.jfree.chart.plot.CategoryPlot;\r
-import org.jfree.chart.plot.PlotOrientation;\r
-import org.jfree.chart.renderer.category.BarRenderer;\r
-import org.jfree.chart.renderer.category.StackedBarRenderer;\r
-import org.jfree.chart.title.TextTitle;\r
-import org.jfree.data.category.DefaultCategoryDataset;\r
-import org.jfree.ui.RectangleInsets;\r
-\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.util.Map;\r
-import java.util.StringTokenizer;\r
-\r
-public class BarChart extends BaseChartWeb implements DeprecatedChart {\r
-\r
- private BarRenderer renderer = null;\r
- protected DefaultCategoryDataset dataset = null;\r
- protected CategoryAxis categoryAxis = null;\r
- protected NumberAxis numberAxis = null;\r
-\r
- public BarChart(Map<String, String> params) {\r
- super(params);\r
- jfreechart = new JFreeChart(null, TextTitle.DEFAULT_FONT, new CategoryPlot(), false);\r
- }\r
-\r
- @Override\r
- protected BufferedImage getChartImage() throws IOException {\r
- configure();\r
- return getBufferedImage(jfreechart);\r
- }\r
-\r
- protected void configure() {\r
- configureChart(jfreechart, false);\r
- configureCategoryDataset();\r
- configureCategoryAxis();\r
- configureRenderer();\r
- configureRangeAxis();\r
- configureCategoryPlot();\r
- applyParams();\r
- }\r
-\r
- protected void configureCategoryPlot() {\r
- CategoryPlot plot = jfreechart.getCategoryPlot();\r
- plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA);\r
- plot.setInsets(RectangleInsets.ZERO_INSETS); // To remove inner space around chart\r
- plot.setDataset(dataset);\r
- plot.setDomainAxis(categoryAxis);\r
- plot.setRenderer(renderer);\r
- plot.setRangeAxis(numberAxis);\r
- }\r
-\r
- protected void configureCategoryDataset() {\r
- dataset = new DefaultCategoryDataset();\r
- }\r
-\r
- protected void configureCategoryAxis() {\r
- categoryAxis = new CategoryAxis();\r
- categoryAxis.setLabelFont(DEFAULT_FONT);\r
- categoryAxis.setLabelPaint(BASE_COLOR);\r
- categoryAxis.setTickLabelFont(DEFAULT_FONT);\r
- categoryAxis.setTickLabelPaint(BASE_COLOR);\r
- categoryAxis.setVisible(false);\r
- }\r
-\r
- protected void configureRenderer() {\r
- if (params.get(BaseChartWeb.CHART_PARAM_TYPE).equals(BaseChartWeb.STACKED_BAR_CHART)) {\r
- renderer = new StackedBarRenderer();\r
- } else {\r
- renderer = new BarRenderer();\r
- }\r
- renderer.setItemMargin(0.0);\r
- renderer.setDrawBarOutline(false);\r
- }\r
-\r
- protected void configureRangeAxis() {\r
- numberAxis = new NumberAxis();\r
- numberAxis.setLabelFont(DEFAULT_FONT);\r
- numberAxis.setLabelPaint(BASE_COLOR);\r
- numberAxis.setTickLabelFont(DEFAULT_FONT);\r
- numberAxis.setTickLabelPaint(BASE_COLOR);\r
- numberAxis.setTickMarksVisible(true);\r
- numberAxis.setVisible(false);\r
- numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());\r
- }\r
-\r
- protected void applyCommomParamsBar() {\r
- // -- Plot\r
- CategoryPlot plot = jfreechart.getCategoryPlot();\r
- plot.setOrientation(BaseChartWeb.BAR_CHART_VERTICAL.equals(params.get(BaseChartWeb.CHART_PARAM_TYPE)) || BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM.equals(params.get(BaseChartWeb.CHART_PARAM_TYPE)) ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL);\r
- plot.setOutlineVisible("y".equals(params.get(BaseChartWeb.CHART_PARAM_OUTLINE_VISIBLE)));\r
- plot.setRangeGridlinesVisible("y".equals(params.get(BaseChartWeb.CHART_PARAM_OUTLINE_RANGEGRIDLINES_VISIBLE)));\r
- String insetsParam = params.get(CHART_PARAM_INSETS);\r
- if (isParamValueValid(insetsParam)) {\r
- double insets = convertParamToDouble(insetsParam);\r
- RectangleInsets rectangleInsets = new RectangleInsets(insets, insets, insets, insets);\r
- plot.setInsets(rectangleInsets);\r
- }\r
-\r
- // -- Category Axis\r
- boolean categoryAxisIsVisible = "y".equals(params.get(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE));\r
- double categoryAxisUpperMargin = convertParamToDouble(params.get(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_UPPER), DEFAULT_CATEGORIES_AXISMARGIN);\r
- double categoryAxisLowerMargin = convertParamToDouble(params.get(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_LOWER), DEFAULT_CATEGORIES_AXISMARGIN);\r
- categoryAxis.setVisible(categoryAxisIsVisible);\r
- categoryAxis.setTickLabelsVisible(categoryAxisIsVisible);\r
- categoryAxis.setLowerMargin(categoryAxisLowerMargin);\r
- categoryAxis.setUpperMargin(categoryAxisUpperMargin);\r
-\r
- // -- Range Axis\r
- boolean rangeAxisIsVisible = "y".equals(params.get(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE));\r
- double rangeAxisUpperMargin = convertParamToDouble(params.get(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_UPPER), DEFAULT_SERIES_AXISMARGIN);\r
- double rangeAxisLowerMargin = convertParamToDouble(params.get(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_LOWER), DEFAULT_SERIES_AXISMARGIN);\r
- numberAxis.setTickLabelsVisible(rangeAxisIsVisible);\r
- numberAxis.setVisible(rangeAxisIsVisible);\r
- numberAxis.setLowerMargin(rangeAxisLowerMargin);\r
- numberAxis.setUpperMargin(rangeAxisUpperMargin);\r
- String rangeMax = params.get(BaseChartWeb.CHART_PARAM_RANGEMAX);\r
- if (isParamValueValid(rangeMax)) {\r
- double iRangeMax = Double.parseDouble(rangeMax);\r
- numberAxis.setRange(0.0, iRangeMax);\r
- }\r
- String tickUnit = params.get(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_TICKUNIT);\r
- if (isParamValueValid(tickUnit)) {\r
- numberAxis.setTickUnit(new NumberTickUnit(convertParamToDouble(tickUnit)));\r
- }\r
- }\r
-\r
- private void applyParams() {\r
- applyCommonParams();\r
- applyCommomParamsBar();\r
-\r
- configureColors(params.get(BaseChartWeb.CHART_PARAM_COLORS), renderer);\r
- addMeasures(params.get(BaseChartWeb.CHART_PARAM_VALUES));\r
- }\r
-\r
- private void addMeasures(String values) {\r
- if (values != null && values.length() > 0) {\r
- // Values\r
- StringTokenizer stValues = new StringTokenizer(values, ",");\r
- int nbValues = stValues.countTokens();\r
-\r
- // Categories\r
- String categoriesParam = params.get(BaseChartWeb.CHART_PARAM_CATEGORIES);\r
- boolean categoriesPresent = categoriesParam != null && categoriesParam.length() > 0;\r
- String[] categoriesSplit = null;\r
- if (categoriesPresent) {\r
- categoriesSplit = categoriesParam.split(",");\r
- } else {\r
- categoriesSplit = new String[1];\r
- categoriesSplit[0] = BaseChartWeb.DEFAULT_NAME_CATEGORY;\r
- }\r
- int nbCategories = categoriesSplit.length;\r
-\r
- // Series\r
- String seriesParam = params.get(BaseChartWeb.CHART_PARAM_SERIES);\r
- boolean seriesPresent = seriesParam != null && seriesParam.length() > 0;\r
- String[] seriesSplit = null;\r
- if (seriesPresent) {\r
- seriesSplit = seriesParam.split(",");\r
- } else {\r
- seriesSplit = new String[nbValues];\r
- for (int i = 0; i < nbValues; i++) {\r
- seriesSplit[i] = BaseChartWeb.DEFAULT_NAME_SERIE + i;\r
- }\r
- }\r
- int nbSeries = seriesSplit.length;\r
-\r
- for (int iCategories = 0; iCategories < nbCategories; iCategories++) {\r
- String currentCategory = categoriesSplit[iCategories];\r
- for (int iSeries = 0; iSeries < nbSeries; iSeries++) {\r
- String currentSerie = seriesSplit[iSeries];\r
- double currentValue = 0.0;\r
- if (stValues.hasMoreTokens()) {\r
- try {\r
- currentValue = Double.parseDouble(stValues.nextToken());\r
- } catch (NumberFormatException e) {\r
- }\r
- }\r
- dataset.addValue(currentValue, currentSerie, currentCategory);\r
- }\r
- }\r
- }\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts.deprecated;
+
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.CategoryAxis;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.NumberTickUnit;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.renderer.category.BarRenderer;
+import org.jfree.chart.renderer.category.StackedBarRenderer;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.category.DefaultCategoryDataset;
+import org.jfree.ui.RectangleInsets;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+public class BarChart extends BaseChartWeb implements DeprecatedChart {
+
+ private BarRenderer renderer = null;
+ protected DefaultCategoryDataset dataset = null;
+ protected CategoryAxis categoryAxis = null;
+ protected NumberAxis numberAxis = null;
+
+ public BarChart(Map<String, String> params) {
+ super(params);
+ jfreechart = new JFreeChart(null, TextTitle.DEFAULT_FONT, new CategoryPlot(), false);
+ }
+
+ @Override
+ protected BufferedImage getChartImage() throws IOException {
+ configure();
+ return getBufferedImage(jfreechart);
+ }
+
+ protected void configure() {
+ configureChart(jfreechart, false);
+ configureCategoryDataset();
+ configureCategoryAxis();
+ configureRenderer();
+ configureRangeAxis();
+ configureCategoryPlot();
+ applyParams();
+ }
+
+ protected void configureCategoryPlot() {
+ CategoryPlot plot = jfreechart.getCategoryPlot();
+ plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA);
+ plot.setInsets(RectangleInsets.ZERO_INSETS); // To remove inner space around chart
+ plot.setDataset(dataset);
+ plot.setDomainAxis(categoryAxis);
+ plot.setRenderer(renderer);
+ plot.setRangeAxis(numberAxis);
+ }
+
+ protected void configureCategoryDataset() {
+ dataset = new DefaultCategoryDataset();
+ }
+
+ protected void configureCategoryAxis() {
+ categoryAxis = new CategoryAxis();
+ categoryAxis.setLabelFont(DEFAULT_FONT);
+ categoryAxis.setLabelPaint(BASE_COLOR);
+ categoryAxis.setTickLabelFont(DEFAULT_FONT);
+ categoryAxis.setTickLabelPaint(BASE_COLOR);
+ categoryAxis.setVisible(false);
+ }
+
+ protected void configureRenderer() {
+ if (params.get(BaseChartWeb.CHART_PARAM_TYPE).equals(BaseChartWeb.STACKED_BAR_CHART)) {
+ renderer = new StackedBarRenderer();
+ } else {
+ renderer = new BarRenderer();
+ }
+ renderer.setItemMargin(0.0);
+ renderer.setDrawBarOutline(false);
+ }
+
+ protected void configureRangeAxis() {
+ numberAxis = new NumberAxis();
+ numberAxis.setLabelFont(DEFAULT_FONT);
+ numberAxis.setLabelPaint(BASE_COLOR);
+ numberAxis.setTickLabelFont(DEFAULT_FONT);
+ numberAxis.setTickLabelPaint(BASE_COLOR);
+ numberAxis.setTickMarksVisible(true);
+ numberAxis.setVisible(false);
+ numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
+ }
+
+ protected void applyCommomParamsBar() {
+ // -- Plot
+ CategoryPlot plot = jfreechart.getCategoryPlot();
+ plot.setOrientation(BaseChartWeb.BAR_CHART_VERTICAL.equals(params.get(BaseChartWeb.CHART_PARAM_TYPE)) || BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM.equals(params.get(BaseChartWeb.CHART_PARAM_TYPE)) ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL);
+ plot.setOutlineVisible("y".equals(params.get(BaseChartWeb.CHART_PARAM_OUTLINE_VISIBLE)));
+ plot.setRangeGridlinesVisible("y".equals(params.get(BaseChartWeb.CHART_PARAM_OUTLINE_RANGEGRIDLINES_VISIBLE)));
+ String insetsParam = params.get(CHART_PARAM_INSETS);
+ if (isParamValueValid(insetsParam)) {
+ double insets = convertParamToDouble(insetsParam);
+ RectangleInsets rectangleInsets = new RectangleInsets(insets, insets, insets, insets);
+ plot.setInsets(rectangleInsets);
+ }
+
+ // -- Category Axis
+ boolean categoryAxisIsVisible = "y".equals(params.get(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE));
+ double categoryAxisUpperMargin = convertParamToDouble(params.get(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_UPPER), DEFAULT_CATEGORIES_AXISMARGIN);
+ double categoryAxisLowerMargin = convertParamToDouble(params.get(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_LOWER), DEFAULT_CATEGORIES_AXISMARGIN);
+ categoryAxis.setVisible(categoryAxisIsVisible);
+ categoryAxis.setTickLabelsVisible(categoryAxisIsVisible);
+ categoryAxis.setLowerMargin(categoryAxisLowerMargin);
+ categoryAxis.setUpperMargin(categoryAxisUpperMargin);
+
+ // -- Range Axis
+ boolean rangeAxisIsVisible = "y".equals(params.get(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE));
+ double rangeAxisUpperMargin = convertParamToDouble(params.get(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_UPPER), DEFAULT_SERIES_AXISMARGIN);
+ double rangeAxisLowerMargin = convertParamToDouble(params.get(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_LOWER), DEFAULT_SERIES_AXISMARGIN);
+ numberAxis.setTickLabelsVisible(rangeAxisIsVisible);
+ numberAxis.setVisible(rangeAxisIsVisible);
+ numberAxis.setLowerMargin(rangeAxisLowerMargin);
+ numberAxis.setUpperMargin(rangeAxisUpperMargin);
+ String rangeMax = params.get(BaseChartWeb.CHART_PARAM_RANGEMAX);
+ if (isParamValueValid(rangeMax)) {
+ double iRangeMax = Double.parseDouble(rangeMax);
+ numberAxis.setRange(0.0, iRangeMax);
+ }
+ String tickUnit = params.get(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_TICKUNIT);
+ if (isParamValueValid(tickUnit)) {
+ numberAxis.setTickUnit(new NumberTickUnit(convertParamToDouble(tickUnit)));
+ }
+ }
+
+ private void applyParams() {
+ applyCommonParams();
+ applyCommomParamsBar();
+
+ configureColors(params.get(BaseChartWeb.CHART_PARAM_COLORS), renderer);
+ addMeasures(params.get(BaseChartWeb.CHART_PARAM_VALUES));
+ }
+
+ private void addMeasures(String values) {
+ if (values != null && values.length() > 0) {
+ // Values
+ StringTokenizer stValues = new StringTokenizer(values, ",");
+ int nbValues = stValues.countTokens();
+
+ // Categories
+ String categoriesParam = params.get(BaseChartWeb.CHART_PARAM_CATEGORIES);
+ boolean categoriesPresent = categoriesParam != null && categoriesParam.length() > 0;
+ String[] categoriesSplit = null;
+ if (categoriesPresent) {
+ categoriesSplit = categoriesParam.split(",");
+ } else {
+ categoriesSplit = new String[1];
+ categoriesSplit[0] = BaseChartWeb.DEFAULT_NAME_CATEGORY;
+ }
+ int nbCategories = categoriesSplit.length;
+
+ // Series
+ String seriesParam = params.get(BaseChartWeb.CHART_PARAM_SERIES);
+ boolean seriesPresent = seriesParam != null && seriesParam.length() > 0;
+ String[] seriesSplit = null;
+ if (seriesPresent) {
+ seriesSplit = seriesParam.split(",");
+ } else {
+ seriesSplit = new String[nbValues];
+ for (int i = 0; i < nbValues; i++) {
+ seriesSplit[i] = BaseChartWeb.DEFAULT_NAME_SERIE + i;
+ }
+ }
+ int nbSeries = seriesSplit.length;
+
+ for (int iCategories = 0; iCategories < nbCategories; iCategories++) {
+ String currentCategory = categoriesSplit[iCategories];
+ for (int iSeries = 0; iSeries < nbSeries; iSeries++) {
+ String currentSerie = seriesSplit[iSeries];
+ double currentValue = 0.0;
+ if (stValues.hasMoreTokens()) {
+ try {
+ currentValue = Double.parseDouble(stValues.nextToken());
+ } catch (NumberFormatException e) {
+ }
+ }
+ dataset.addValue(currentValue, currentSerie, currentCategory);
+ }
+ }
+ }
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts.deprecated;\r
-\r
-import org.jfree.chart.plot.CategoryPlot;\r
-import org.jfree.data.category.DefaultCategoryDataset;\r
-import org.jfree.ui.RectangleInsets;\r
-\r
-import java.awt.*;\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.util.Map;\r
-import java.util.StringTokenizer;\r
-\r
-public class CustomBarChart extends BarChart {\r
-\r
- private CustomBarRenderer renderer = null;\r
-\r
- public CustomBarChart(Map<String, String> params) {\r
- super(params);\r
- }\r
-\r
- @Override\r
- protected BufferedImage getChartImage() throws IOException {\r
- configure();\r
- return getBufferedImage(jfreechart);\r
- }\r
-\r
- @Override\r
- protected void configure() {\r
- configureChart(jfreechart, false);\r
- configureCategoryDataset();\r
- configureCategoryAxis();\r
- configureRenderer();\r
- configureRangeAxis();\r
- configureCategoryPlot();\r
- applyParams();\r
- }\r
-\r
- @Override\r
- protected void configureCategoryDataset() {\r
- dataset = new DefaultCategoryDataset();\r
- }\r
-\r
- @Override\r
- protected void configureRenderer() {\r
- renderer = new CustomBarRenderer(null);\r
- renderer.setItemMargin(0.0);\r
- renderer.setDrawBarOutline(false);\r
- }\r
-\r
- @Override\r
- protected void configureCategoryPlot() {\r
- CategoryPlot plot = jfreechart.getCategoryPlot();\r
- plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA);\r
- plot.setInsets(RectangleInsets.ZERO_INSETS); // To remove inner space around chart\r
- plot.setDataset(dataset);\r
- plot.setDomainAxis(categoryAxis);\r
- plot.setRenderer(renderer);\r
- plot.setRangeAxis(numberAxis);\r
- }\r
-\r
- protected void applyParams() {\r
- applyCommonParams();\r
- applyCommomParamsBar();\r
-\r
- configureColors(params.get(CHART_PARAM_COLORS));\r
- addMeasures(params.get(CHART_PARAM_VALUES));\r
- }\r
-\r
- private void configureColors(String colorsParam) {\r
- Paint[] colors = CustomBarRenderer.COLORS;\r
- if (colorsParam != null && colorsParam.length() > 0) {\r
- StringTokenizer stColors = new StringTokenizer(colorsParam, ",");\r
- colors = new Paint[stColors.countTokens()];\r
- int i = 0;\r
- while (stColors.hasMoreTokens()) {\r
- colors[i] = Color.decode("0x" + stColors.nextToken());\r
- i++;\r
- }\r
- }\r
-\r
- renderer.setColors(colors);\r
- }\r
-\r
- private void addMeasures(String values) {\r
- if (values != null && values.length() > 0) {\r
- // Values\r
- StringTokenizer stValues = new StringTokenizer(values, ",");\r
- int nbValues = stValues.countTokens();\r
-\r
- // Categories\r
- String categoriesParam = params.get(CHART_PARAM_CATEGORIES);\r
- boolean categoriesPresent = categoriesParam != null && categoriesParam.length() > 0;\r
- String[] categoriesSplit = null;\r
- if (categoriesPresent) {\r
- categoriesSplit = categoriesParam.split(",");\r
- } else {\r
- categoriesSplit = new String[nbValues];\r
- for (int i = 0; i < nbValues; i++) {\r
- categoriesSplit[i] = DEFAULT_NAME_CATEGORY + i;\r
- }\r
- }\r
- int nbCategories = categoriesSplit.length;\r
-\r
- // Series\r
- String[] seriesSplit = {DEFAULT_NAME_SERIE};\r
- int nbSeries = 1;\r
-\r
- //\r
- for (int iCategories = 0; iCategories < nbCategories; iCategories++) {\r
- String currentCategory = categoriesSplit[iCategories];\r
- for (int iSeries = 0; iSeries < nbSeries; iSeries++) {\r
- String currentSerie = seriesSplit[iSeries];\r
- double currentValue = 0.0;\r
- if (stValues.hasMoreTokens()) {\r
- try {\r
- currentValue = Double.parseDouble(stValues.nextToken());\r
- } catch (NumberFormatException e) {\r
- }\r
- }\r
- dataset.addValue(currentValue, currentSerie, currentCategory);\r
- }\r
- }\r
- }\r
- }\r
-\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts.deprecated;
+
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.data.category.DefaultCategoryDataset;
+import org.jfree.ui.RectangleInsets;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+public class CustomBarChart extends BarChart {
+
+ private CustomBarRenderer renderer = null;
+
+ public CustomBarChart(Map<String, String> params) {
+ super(params);
+ }
+
+ @Override
+ protected BufferedImage getChartImage() throws IOException {
+ configure();
+ return getBufferedImage(jfreechart);
+ }
+
+ @Override
+ protected void configure() {
+ configureChart(jfreechart, false);
+ configureCategoryDataset();
+ configureCategoryAxis();
+ configureRenderer();
+ configureRangeAxis();
+ configureCategoryPlot();
+ applyParams();
+ }
+
+ @Override
+ protected void configureCategoryDataset() {
+ dataset = new DefaultCategoryDataset();
+ }
+
+ @Override
+ protected void configureRenderer() {
+ renderer = new CustomBarRenderer(null);
+ renderer.setItemMargin(0.0);
+ renderer.setDrawBarOutline(false);
+ }
+
+ @Override
+ protected void configureCategoryPlot() {
+ CategoryPlot plot = jfreechart.getCategoryPlot();
+ plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA);
+ plot.setInsets(RectangleInsets.ZERO_INSETS); // To remove inner space around chart
+ plot.setDataset(dataset);
+ plot.setDomainAxis(categoryAxis);
+ plot.setRenderer(renderer);
+ plot.setRangeAxis(numberAxis);
+ }
+
+ protected void applyParams() {
+ applyCommonParams();
+ applyCommomParamsBar();
+
+ configureColors(params.get(CHART_PARAM_COLORS));
+ addMeasures(params.get(CHART_PARAM_VALUES));
+ }
+
+ private void configureColors(String colorsParam) {
+ Paint[] colors = CustomBarRenderer.COLORS;
+ if (colorsParam != null && colorsParam.length() > 0) {
+ StringTokenizer stColors = new StringTokenizer(colorsParam, ",");
+ colors = new Paint[stColors.countTokens()];
+ int i = 0;
+ while (stColors.hasMoreTokens()) {
+ colors[i] = Color.decode("0x" + stColors.nextToken());
+ i++;
+ }
+ }
+
+ renderer.setColors(colors);
+ }
+
+ private void addMeasures(String values) {
+ if (values != null && values.length() > 0) {
+ // Values
+ StringTokenizer stValues = new StringTokenizer(values, ",");
+ int nbValues = stValues.countTokens();
+
+ // Categories
+ String categoriesParam = params.get(CHART_PARAM_CATEGORIES);
+ boolean categoriesPresent = categoriesParam != null && categoriesParam.length() > 0;
+ String[] categoriesSplit = null;
+ if (categoriesPresent) {
+ categoriesSplit = categoriesParam.split(",");
+ } else {
+ categoriesSplit = new String[nbValues];
+ for (int i = 0; i < nbValues; i++) {
+ categoriesSplit[i] = DEFAULT_NAME_CATEGORY + i;
+ }
+ }
+ int nbCategories = categoriesSplit.length;
+
+ // Series
+ String[] seriesSplit = {DEFAULT_NAME_SERIE};
+ int nbSeries = 1;
+
+ //
+ for (int iCategories = 0; iCategories < nbCategories; iCategories++) {
+ String currentCategory = categoriesSplit[iCategories];
+ for (int iSeries = 0; iSeries < nbSeries; iSeries++) {
+ String currentSerie = seriesSplit[iSeries];
+ double currentValue = 0.0;
+ if (stValues.hasMoreTokens()) {
+ try {
+ currentValue = Double.parseDouble(stValues.nextToken());
+ } catch (NumberFormatException e) {
+ }
+ }
+ dataset.addValue(currentValue, currentSerie, currentCategory);
+ }
+ }
+ }
+ }
+
}
\ No newline at end of file
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts.deprecated;\r
-\r
-import org.jfree.chart.JFreeChart;\r
-import org.jfree.chart.plot.PiePlot;\r
-import org.jfree.chart.title.TextTitle;\r
-import org.jfree.data.general.DefaultPieDataset;\r
-import org.jfree.ui.RectangleInsets;\r
-\r
-import java.awt.*;\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.util.Map;\r
-import java.util.StringTokenizer;\r
-\r
-public class PieChart extends BaseChartWeb implements DeprecatedChart {\r
-\r
- private DefaultPieDataset dataset = null;\r
-\r
- public PieChart(Map<String, String> params) {\r
- super(params);\r
- jfreechart = new JFreeChart(null, TextTitle.DEFAULT_FONT, new PiePlot(), false);\r
- }\r
-\r
- @Override\r
- protected BufferedImage getChartImage() throws IOException {\r
- configure();\r
- return getBufferedImage(jfreechart);\r
- }\r
-\r
- private void configure() {\r
- configureChart(jfreechart, false);\r
- configureDataset();\r
- configurePlot();\r
- applyParams();\r
- }\r
-\r
- private void configureDataset() {\r
- dataset = new DefaultPieDataset();\r
- }\r
-\r
- private void configurePlot() {\r
- PiePlot plot = (PiePlot) jfreechart.getPlot();\r
- plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA);\r
- plot.setInsets(RectangleInsets.ZERO_INSETS);\r
- plot.setDataset(dataset);\r
- plot.setBackgroundAlpha(0.0f);\r
- plot.setCircular(true);\r
- plot.setLabelGenerator(null);\r
- plot.setIgnoreNullValues(true);\r
- plot.setIgnoreZeroValues(true);\r
- plot.setShadowPaint(null);\r
- plot.setLabelLinkMargin(0.0);\r
- plot.setInteriorGap(0.02);\r
- plot.setMaximumLabelWidth(0.10);\r
- }\r
-\r
- private void configureColors(String colors) {\r
- try {\r
- if (colors != null && colors.length() > 0) {\r
- StringTokenizer stringTokenizer = new StringTokenizer(colors, ",");\r
- int i = 0;\r
- while (stringTokenizer.hasMoreTokens()) {\r
- ((PiePlot) jfreechart.getPlot()).setSectionPaint(Integer.toString(i), Color.decode("0x" + stringTokenizer.nextToken()));\r
- i++;\r
- }\r
- } else {\r
- configureDefaultColors();\r
- }\r
- }\r
- catch (Exception e) {\r
- configureDefaultColors();\r
- }\r
- }\r
-\r
- private void configureDefaultColors() {\r
- PiePlot plot = (PiePlot) jfreechart.getPlot();\r
- for (int i=0 ; i<COLORS.length ; i++) {\r
- plot.setSectionPaint("" + i, COLORS[i]);\r
- }\r
- }\r
-\r
- private void applyParams() {\r
- applyCommonParams();\r
-\r
- configureColors(params.get(CHART_PARAM_COLORS));\r
- addMeasures(params.get(CHART_PARAM_VALUES));\r
-\r
- // -- Plot\r
- PiePlot plot = (PiePlot) jfreechart.getPlot();\r
- plot.setOutlineVisible(isParamValueValid(params.get(CHART_PARAM_OUTLINE_VISIBLE)) && Boolean.getBoolean(params.get(CHART_PARAM_OUTLINE_VISIBLE)));\r
- }\r
-\r
- private void addMeasures(String values) {\r
- if (values != null && values.length() > 0) {\r
- StringTokenizer st = new StringTokenizer(values, ",");\r
- int i = 0;\r
- while (st.hasMoreTokens()) {\r
- double measure = 0;\r
- try {\r
- measure = Double.parseDouble(st.nextToken());\r
- }\r
- catch (NumberFormatException e) {\r
- }\r
- dataset.setValue(Integer.toString(i), measure);\r
- i++;\r
- }\r
- }\r
- }\r
-\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts.deprecated;
+
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PiePlot;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.general.DefaultPieDataset;
+import org.jfree.ui.RectangleInsets;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+public class PieChart extends BaseChartWeb implements DeprecatedChart {
+
+ private DefaultPieDataset dataset = null;
+
+ public PieChart(Map<String, String> params) {
+ super(params);
+ jfreechart = new JFreeChart(null, TextTitle.DEFAULT_FONT, new PiePlot(), false);
+ }
+
+ @Override
+ protected BufferedImage getChartImage() throws IOException {
+ configure();
+ return getBufferedImage(jfreechart);
+ }
+
+ private void configure() {
+ configureChart(jfreechart, false);
+ configureDataset();
+ configurePlot();
+ applyParams();
+ }
+
+ private void configureDataset() {
+ dataset = new DefaultPieDataset();
+ }
+
+ private void configurePlot() {
+ PiePlot plot = (PiePlot) jfreechart.getPlot();
+ plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA);
+ plot.setInsets(RectangleInsets.ZERO_INSETS);
+ plot.setDataset(dataset);
+ plot.setBackgroundAlpha(0.0f);
+ plot.setCircular(true);
+ plot.setLabelGenerator(null);
+ plot.setIgnoreNullValues(true);
+ plot.setIgnoreZeroValues(true);
+ plot.setShadowPaint(null);
+ plot.setLabelLinkMargin(0.0);
+ plot.setInteriorGap(0.02);
+ plot.setMaximumLabelWidth(0.10);
+ }
+
+ private void configureColors(String colors) {
+ try {
+ if (colors != null && colors.length() > 0) {
+ StringTokenizer stringTokenizer = new StringTokenizer(colors, ",");
+ int i = 0;
+ while (stringTokenizer.hasMoreTokens()) {
+ ((PiePlot) jfreechart.getPlot()).setSectionPaint(Integer.toString(i), Color.decode("0x" + stringTokenizer.nextToken()));
+ i++;
+ }
+ } else {
+ configureDefaultColors();
+ }
+ }
+ catch (Exception e) {
+ configureDefaultColors();
+ }
+ }
+
+ private void configureDefaultColors() {
+ PiePlot plot = (PiePlot) jfreechart.getPlot();
+ for (int i=0 ; i<COLORS.length ; i++) {
+ plot.setSectionPaint("" + i, COLORS[i]);
+ }
+ }
+
+ private void applyParams() {
+ applyCommonParams();
+
+ configureColors(params.get(CHART_PARAM_COLORS));
+ addMeasures(params.get(CHART_PARAM_VALUES));
+
+ // -- Plot
+ PiePlot plot = (PiePlot) jfreechart.getPlot();
+ plot.setOutlineVisible(isParamValueValid(params.get(CHART_PARAM_OUTLINE_VISIBLE)) && Boolean.getBoolean(params.get(CHART_PARAM_OUTLINE_VISIBLE)));
+ }
+
+ private void addMeasures(String values) {
+ if (values != null && values.length() > 0) {
+ StringTokenizer st = new StringTokenizer(values, ",");
+ int i = 0;
+ while (st.hasMoreTokens()) {
+ double measure = 0;
+ try {
+ measure = Double.parseDouble(st.nextToken());
+ }
+ catch (NumberFormatException e) {
+ }
+ dataset.setValue(Integer.toString(i), measure);
+ i++;
+ }
+ }
+ }
+
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts.deprecated;\r
-\r
-import org.jfree.chart.JFreeChart;\r
-import org.jfree.chart.axis.DateAxis;\r
-import org.jfree.chart.axis.DateTickUnit;\r
-import org.jfree.chart.axis.NumberAxis;\r
-import org.jfree.chart.plot.XYPlot;\r
-import org.jfree.chart.renderer.xy.StandardXYItemRenderer;\r
-import org.jfree.chart.title.TextTitle;\r
-import org.jfree.data.xy.XYSeries;\r
-import org.jfree.data.xy.XYSeriesCollection;\r
-import org.jfree.ui.RectangleInsets;\r
-\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.util.Map;\r
-import java.util.StringTokenizer;\r
-\r
-public class SparkLinesChart extends BaseChartWeb implements DeprecatedChart {\r
-\r
- private XYSeriesCollection dataset = null;\r
- private DateAxis x = null;\r
- private NumberAxis y = null;\r
- private StandardXYItemRenderer renderer = null;\r
-\r
- public SparkLinesChart(Map<String, String> params) {\r
- super(params);\r
- jfreechart = new JFreeChart(null, TextTitle.DEFAULT_FONT, new XYPlot(), false);\r
- }\r
-\r
- @Override\r
- protected BufferedImage getChartImage() throws IOException {\r
- configure();\r
- return getBufferedImage(jfreechart);\r
- }\r
-\r
- private void configure() {\r
- configureChart(jfreechart, false);\r
- configureXAxis();\r
- configureYAxis();\r
- configureRenderer();\r
- configureDataset();\r
- configurePlot();\r
- applyParams();\r
- }\r
-\r
- private void configureRenderer() {\r
- renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);\r
- }\r
-\r
- private void configureYAxis() {\r
- y = new NumberAxis();\r
- y.setTickLabelsVisible(false);\r
- y.setTickMarksVisible(false);\r
- y.setAxisLineVisible(false);\r
- y.setNegativeArrowVisible(false);\r
- y.setPositiveArrowVisible(false);\r
- y.setVisible(false);\r
- }\r
-\r
- private void configureXAxis() {\r
- x = new DateAxis();\r
- x.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1));\r
- x.setTickLabelsVisible(false);\r
- x.setTickMarksVisible(false);\r
- x.setAxisLineVisible(false);\r
- x.setNegativeArrowVisible(false);\r
- x.setPositiveArrowVisible(false);\r
- x.setVisible(false);\r
- }\r
-\r
- private void configureDataset() {\r
- dataset = new XYSeriesCollection();\r
- }\r
-\r
- private void configurePlot() {\r
- XYPlot plot = (XYPlot) jfreechart.getPlot();\r
- plot.setInsets(RectangleInsets.ZERO_INSETS);\r
- plot.setDataset(dataset);\r
- plot.setDomainAxis(x);\r
- plot.setDomainGridlinesVisible(false);\r
- plot.setDomainCrosshairVisible(false);\r
- plot.setRangeGridlinesVisible(false);\r
- plot.setRangeCrosshairVisible(false);\r
- plot.setRangeAxis(y);\r
- plot.setRenderer(renderer);\r
- plot.setBackgroundAlpha(0.0f);\r
- }\r
-\r
- private void applyParams() {\r
- applyCommonParams();\r
-\r
- configureColors(params.get(CHART_PARAM_COLORS), renderer);\r
- addMeasures(params.get(CHART_PARAM_VALUES));\r
-\r
- // -- Plot\r
- XYPlot plot = (XYPlot) jfreechart.getPlot();\r
- plot.setOutlineVisible(isParamValueValid(params.get(CHART_PARAM_OUTLINE_VISIBLE)) && Boolean.getBoolean(params.get(CHART_PARAM_OUTLINE_VISIBLE)));\r
- }\r
-\r
- private void addMeasures(String values) {\r
- double min = Double.MAX_VALUE;\r
- double max = Double.MIN_VALUE;\r
- XYSeries series1 = new XYSeries("");\r
- if (values != null && values.length() > 0) {\r
- StringTokenizer st = new StringTokenizer(values, ",");\r
- while (st.hasMoreTokens()) {\r
- double v_x = convertParamToDouble(st.nextToken());\r
- double v_y = 0.0;\r
- if (st.hasMoreTokens()) {\r
- v_y = convertParamToDouble(st.nextToken());\r
- }\r
- series1.add(v_x, v_y);\r
-\r
- min = (v_y < min ? v_y : min);\r
- max = (v_y > max ? v_y : max);\r
- }\r
- dataset.addSeries(series1);\r
- y.setRange(min-1, max+1);\r
- }\r
- }\r
-\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts.deprecated;
+
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.DateAxis;
+import org.jfree.chart.axis.DateTickUnit;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.xy.XYSeries;
+import org.jfree.data.xy.XYSeriesCollection;
+import org.jfree.ui.RectangleInsets;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+public class SparkLinesChart extends BaseChartWeb implements DeprecatedChart {
+
+ private XYSeriesCollection dataset = null;
+ private DateAxis x = null;
+ private NumberAxis y = null;
+ private StandardXYItemRenderer renderer = null;
+
+ public SparkLinesChart(Map<String, String> params) {
+ super(params);
+ jfreechart = new JFreeChart(null, TextTitle.DEFAULT_FONT, new XYPlot(), false);
+ }
+
+ @Override
+ protected BufferedImage getChartImage() throws IOException {
+ configure();
+ return getBufferedImage(jfreechart);
+ }
+
+ private void configure() {
+ configureChart(jfreechart, false);
+ configureXAxis();
+ configureYAxis();
+ configureRenderer();
+ configureDataset();
+ configurePlot();
+ applyParams();
+ }
+
+ private void configureRenderer() {
+ renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);
+ }
+
+ private void configureYAxis() {
+ y = new NumberAxis();
+ y.setTickLabelsVisible(false);
+ y.setTickMarksVisible(false);
+ y.setAxisLineVisible(false);
+ y.setNegativeArrowVisible(false);
+ y.setPositiveArrowVisible(false);
+ y.setVisible(false);
+ }
+
+ private void configureXAxis() {
+ x = new DateAxis();
+ x.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1));
+ x.setTickLabelsVisible(false);
+ x.setTickMarksVisible(false);
+ x.setAxisLineVisible(false);
+ x.setNegativeArrowVisible(false);
+ x.setPositiveArrowVisible(false);
+ x.setVisible(false);
+ }
+
+ private void configureDataset() {
+ dataset = new XYSeriesCollection();
+ }
+
+ private void configurePlot() {
+ XYPlot plot = (XYPlot) jfreechart.getPlot();
+ plot.setInsets(RectangleInsets.ZERO_INSETS);
+ plot.setDataset(dataset);
+ plot.setDomainAxis(x);
+ plot.setDomainGridlinesVisible(false);
+ plot.setDomainCrosshairVisible(false);
+ plot.setRangeGridlinesVisible(false);
+ plot.setRangeCrosshairVisible(false);
+ plot.setRangeAxis(y);
+ plot.setRenderer(renderer);
+ plot.setBackgroundAlpha(0.0f);
+ }
+
+ private void applyParams() {
+ applyCommonParams();
+
+ configureColors(params.get(CHART_PARAM_COLORS), renderer);
+ addMeasures(params.get(CHART_PARAM_VALUES));
+
+ // -- Plot
+ XYPlot plot = (XYPlot) jfreechart.getPlot();
+ plot.setOutlineVisible(isParamValueValid(params.get(CHART_PARAM_OUTLINE_VISIBLE)) && Boolean.getBoolean(params.get(CHART_PARAM_OUTLINE_VISIBLE)));
+ }
+
+ private void addMeasures(String values) {
+ double min = Double.MAX_VALUE;
+ double max = Double.MIN_VALUE;
+ XYSeries series1 = new XYSeries("");
+ if (values != null && values.length() > 0) {
+ StringTokenizer st = new StringTokenizer(values, ",");
+ while (st.hasMoreTokens()) {
+ double v_x = convertParamToDouble(st.nextToken());
+ double v_y = 0.0;
+ if (st.hasMoreTokens()) {
+ v_y = convertParamToDouble(st.nextToken());
+ }
+ series1.add(v_x, v_y);
+
+ min = (v_y < min ? v_y : min);
+ max = (v_y > max ? v_y : max);
+ }
+ dataset.addSeries(series1);
+ y.setRange(min-1, max+1);
+ }
+ }
+
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts.jruby;\r
-\r
-import org.apache.commons.lang.LocaleUtils;\r
-import org.jfree.chart.JFreeChart;\r
-import org.jfree.chart.axis.AxisLocation;\r
-import org.jfree.chart.axis.DateAxis;\r
-import org.jfree.chart.axis.NumberAxis;\r
-import org.jfree.chart.plot.Marker;\r
-import org.jfree.chart.plot.ValueMarker;\r
-import org.jfree.chart.plot.XYPlot;\r
-import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;\r
-import org.jfree.chart.title.TextTitle;\r
-import org.jfree.data.time.Day;\r
-import org.jfree.data.time.TimeSeries;\r
-import org.jfree.data.time.TimeSeriesCollection;\r
-import org.jfree.ui.RectangleAnchor;\r
-import org.jfree.ui.RectangleEdge;\r
-import org.jfree.ui.RectangleInsets;\r
-import org.jfree.ui.TextAnchor;\r
-import org.sonar.server.charts.deprecated.BaseChart;\r
-\r
-import java.awt.*;\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.text.DateFormat;\r
-import java.text.DecimalFormat;\r
-import java.text.ParseException;\r
-import java.util.Date;\r
-import java.util.TreeMap;\r
-\r
-public class TrendsChart extends BaseChart {\r
-\r
- private XYPlot plot;\r
- private TreeMap<Long, TimeSeries> seriesById;\r
- private int percentAxisId = -1;\r
- private boolean displayLegend;\r
-\r
- public TrendsChart(int width, int height, String localeKey, boolean displayLegend) {\r
- super(width, height);\r
- this.displayLegend = displayLegend;\r
- seriesById = new TreeMap<Long, TimeSeries>();\r
- plot = new XYPlot();\r
- DateAxis dateAxis = new DateAxis();\r
- dateAxis.setDateFormatOverride(DateFormat.getDateInstance(DateFormat.SHORT, LocaleUtils.toLocale(localeKey)));\r
- plot.setDomainAxis(dateAxis);\r
- }\r
-\r
- public void initSerie(Long serieId, String legend, boolean isPercent) {\r
- TimeSeries series = new TimeSeries(legend);\r
-\r
- int index=seriesById.size();\r
- seriesById.put(serieId, series);\r
-\r
- TimeSeriesCollection timeSeriesColl = new TimeSeriesCollection();\r
- timeSeriesColl.addSeries(series);\r
- plot.setDataset(index, timeSeriesColl);\r
-\r
- if (isPercent) {\r
- if (percentAxisId == -1) {\r
- NumberAxis rangeAxis = new NumberAxis();\r
- rangeAxis.setNumberFormatOverride(new DecimalFormat("0'%'"));\r
- rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());\r
- rangeAxis.setUpperBound(100.0);\r
- rangeAxis.setLowerBound(0.0);\r
- plot.setRangeAxisLocation(index, AxisLocation.TOP_OR_LEFT);\r
- plot.setRangeAxis(index, rangeAxis);\r
- plot.mapDatasetToRangeAxis(index, index);\r
- percentAxisId = index;\r
-\r
- } else {\r
- plot.mapDatasetToRangeAxis(index, percentAxisId);\r
- }\r
- } else {\r
- NumberAxis rangeAxis = new NumberAxis(displayLegend ? legend : null);\r
- rangeAxis.setAutoRangeIncludesZero(false);\r
- rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());\r
- rangeAxis.setAutoRangeMinimumSize(2.0);\r
- plot.setRangeAxisLocation(index, AxisLocation.TOP_OR_RIGHT);\r
- plot.setRangeAxis(index, rangeAxis);\r
- plot.mapDatasetToRangeAxis(index, index);\r
- }\r
-\r
- XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();\r
- renderer.setBaseShapesVisible(false);\r
- renderer.setSeriesStroke(0, new BasicStroke(2.0f));\r
- renderer.setSeriesPaint(0, COLORS[index % COLORS.length]);\r
- plot.setRenderer(index, renderer);\r
- }\r
-\r
- public void addMeasure(Double value, Date date, Long serieId) {\r
- seriesById.get(serieId).addOrUpdate(new Day(date), value);\r
- }\r
-\r
- public void addLabel(Date date, String label) throws ParseException {\r
- addLabel(date, label, false);\r
- }\r
-\r
- public void addLabel(Date date, String label, boolean lower) throws ParseException {\r
- Day d = new Day(date);\r
- double millis = d.getFirstMillisecond();\r
- Marker marker = new ValueMarker(millis);\r
- marker.setLabel(label);\r
- marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);\r
- marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);\r
- Color c = new Color(17, 40, 95);\r
- marker.setLabelPaint(c);\r
- marker.setPaint(c);\r
- marker.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3.0f, new float[]{5f, 5f, 5f, 5f}, 2.0f));\r
- if (lower) {\r
- marker.setLabelOffset(new RectangleInsets(18, 0, 0, 5));\r
- }\r
- plot.addDomainMarker(marker);\r
- }\r
-\r
- @Override\r
- protected BufferedImage getChartImage() throws IOException {\r
- JFreeChart chart = new JFreeChart(null, TextTitle.DEFAULT_FONT, plot, true);\r
- configureChart(chart, displayLegend ? RectangleEdge.BOTTOM : null);\r
- return super.getBufferedImage(chart);\r
- }\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts.jruby;
+
+import org.apache.commons.lang.LocaleUtils;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.AxisLocation;
+import org.jfree.chart.axis.DateAxis;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.plot.Marker;
+import org.jfree.chart.plot.ValueMarker;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.time.Day;
+import org.jfree.data.time.TimeSeries;
+import org.jfree.data.time.TimeSeriesCollection;
+import org.jfree.ui.RectangleAnchor;
+import org.jfree.ui.RectangleEdge;
+import org.jfree.ui.RectangleInsets;
+import org.jfree.ui.TextAnchor;
+import org.sonar.server.charts.deprecated.BaseChart;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.TreeMap;
+
+public class TrendsChart extends BaseChart {
+
+ private XYPlot plot;
+ private TreeMap<Long, TimeSeries> seriesById;
+ private int percentAxisId = -1;
+ private boolean displayLegend;
+
+ public TrendsChart(int width, int height, String localeKey, boolean displayLegend) {
+ super(width, height);
+ this.displayLegend = displayLegend;
+ seriesById = new TreeMap<Long, TimeSeries>();
+ plot = new XYPlot();
+ DateAxis dateAxis = new DateAxis();
+ dateAxis.setDateFormatOverride(DateFormat.getDateInstance(DateFormat.SHORT, LocaleUtils.toLocale(localeKey)));
+ plot.setDomainAxis(dateAxis);
+ }
+
+ public void initSerie(Long serieId, String legend, boolean isPercent) {
+ TimeSeries series = new TimeSeries(legend);
+
+ int index=seriesById.size();
+ seriesById.put(serieId, series);
+
+ TimeSeriesCollection timeSeriesColl = new TimeSeriesCollection();
+ timeSeriesColl.addSeries(series);
+ plot.setDataset(index, timeSeriesColl);
+
+ if (isPercent) {
+ if (percentAxisId == -1) {
+ NumberAxis rangeAxis = new NumberAxis();
+ rangeAxis.setNumberFormatOverride(new DecimalFormat("0'%'"));
+ rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
+ rangeAxis.setUpperBound(100.0);
+ rangeAxis.setLowerBound(0.0);
+ plot.setRangeAxisLocation(index, AxisLocation.TOP_OR_LEFT);
+ plot.setRangeAxis(index, rangeAxis);
+ plot.mapDatasetToRangeAxis(index, index);
+ percentAxisId = index;
+
+ } else {
+ plot.mapDatasetToRangeAxis(index, percentAxisId);
+ }
+ } else {
+ NumberAxis rangeAxis = new NumberAxis(displayLegend ? legend : null);
+ rangeAxis.setAutoRangeIncludesZero(false);
+ rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
+ rangeAxis.setAutoRangeMinimumSize(2.0);
+ plot.setRangeAxisLocation(index, AxisLocation.TOP_OR_RIGHT);
+ plot.setRangeAxis(index, rangeAxis);
+ plot.mapDatasetToRangeAxis(index, index);
+ }
+
+ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
+ renderer.setBaseShapesVisible(false);
+ renderer.setSeriesStroke(0, new BasicStroke(2.0f));
+ renderer.setSeriesPaint(0, COLORS[index % COLORS.length]);
+ plot.setRenderer(index, renderer);
+ }
+
+ public void addMeasure(Double value, Date date, Long serieId) {
+ seriesById.get(serieId).addOrUpdate(new Day(date), value);
+ }
+
+ public void addLabel(Date date, String label) throws ParseException {
+ addLabel(date, label, false);
+ }
+
+ public void addLabel(Date date, String label, boolean lower) throws ParseException {
+ Day d = new Day(date);
+ double millis = d.getFirstMillisecond();
+ Marker marker = new ValueMarker(millis);
+ marker.setLabel(label);
+ marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
+ marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
+ Color c = new Color(17, 40, 95);
+ marker.setLabelPaint(c);
+ marker.setPaint(c);
+ marker.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3.0f, new float[]{5f, 5f, 5f, 5f}, 2.0f));
+ if (lower) {
+ marker.setLabelOffset(new RectangleInsets(18, 0, 0, 5));
+ }
+ plot.addDomainMarker(marker);
+ }
+
+ @Override
+ protected BufferedImage getChartImage() throws IOException {
+ JFreeChart chart = new JFreeChart(null, TextTitle.DEFAULT_FONT, plot, true);
+ configureChart(chart, displayLegend ? RectangleEdge.BOTTOM : null);
+ return super.getBufferedImage(chart);
+ }
}
\ No newline at end of file
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.configuration;\r
-\r
-import org.apache.commons.configuration.Configuration;\r
-import org.apache.commons.lang.StringUtils;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import java.util.Iterator;\r
-\r
-public final class ConfigurationLogger {\r
-\r
- private ConfigurationLogger() {\r
- // only static methods\r
- }\r
-\r
- public static void log(Configuration configuration) {\r
- Logger log = LoggerFactory.getLogger(ConfigurationLogger.class);\r
- if (log.isDebugEnabled()) {\r
- Iterator<String> keys = configuration.getKeys();\r
- while (keys.hasNext()) {\r
- String key = keys.next();\r
- String property = getTruncatedProperty(configuration, key);\r
- log.debug("Property: " + key + " is: '" + property + "'");\r
- }\r
- }\r
- }\r
-\r
- static String getTruncatedProperty(Configuration configuration, String key) {\r
- String property = StringUtils.join(configuration.getStringArray(key), ",");\r
- return StringUtils.abbreviate(property, 100);\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.configuration;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Iterator;
+
+public final class ConfigurationLogger {
+
+ private ConfigurationLogger() {
+ // only static methods
+ }
+
+ public static void log(Configuration configuration) {
+ Logger log = LoggerFactory.getLogger(ConfigurationLogger.class);
+ if (log.isDebugEnabled()) {
+ Iterator<String> keys = configuration.getKeys();
+ while (keys.hasNext()) {
+ String key = keys.next();
+ String property = getTruncatedProperty(configuration, key);
+ log.debug("Property: " + key + " is: '" + property + "'");
+ }
+ }
+ }
+
+ static String getTruncatedProperty(Configuration configuration, String key) {
+ String property = StringUtils.join(configuration.getStringArray(key), ",");
+ return StringUtils.abbreviate(property, 100);
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.startup;\r
-\r
-import com.google.common.collect.Lists;\r
-import com.google.common.collect.Maps;\r
-import org.sonar.api.database.DatabaseSession;\r
-import org.sonar.api.measures.CoreMetrics;\r
-import org.sonar.api.measures.Metric;\r
-import org.sonar.api.measures.Metrics;\r
-import org.sonar.api.profiles.Alert;\r
-import org.sonar.api.utils.Logs;\r
-import org.sonar.api.utils.TimeProfiler;\r
-import org.sonar.jpa.dao.MeasuresDao;\r
-import org.sonar.server.platform.ServerStartException;\r
-\r
-import javax.persistence.Query;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-public class RegisterMetrics {\r
-\r
- private MeasuresDao measuresDao;\r
- private Metrics[] metricsRepositories = null;\r
- private DatabaseSession session;\r
-\r
- public RegisterMetrics(DatabaseSession session, MeasuresDao measuresDao, Metrics[] metricsRepositories) {\r
- this.session = session;\r
- this.measuresDao = measuresDao;\r
- this.metricsRepositories = metricsRepositories;\r
- }\r
-\r
- public void start() {\r
- TimeProfiler profiler = new TimeProfiler().start("Load metrics");\r
- measuresDao.disableAutomaticMetrics();\r
-\r
- List<Metric> metricsToRegister = Lists.newArrayList();\r
- metricsToRegister.addAll(CoreMetrics.getMetrics());\r
-\r
- Map<String, Metrics> metricsByRepository = Maps.newHashMap();\r
- if (metricsRepositories != null) {\r
- for (Metrics metrics : metricsRepositories) {\r
- checkMetrics(metricsByRepository, metrics);\r
- metricsToRegister.addAll(metrics.getMetrics());\r
- }\r
- }\r
- register(metricsToRegister);\r
- cleanAlerts();\r
- profiler.stop();\r
- }\r
-\r
- private void checkMetrics(Map<String, Metrics> metricsByRepository, Metrics metrics) {\r
- for (Metric metric : metrics.getMetrics()) {\r
- String metricKey = metric.getKey();\r
- if (CoreMetrics.metrics.contains(metric)) {\r
- throw new ServerStartException("The following metric is already defined in sonar: " + metricKey);\r
- }\r
- Metrics anotherRepository = metricsByRepository.get(metricKey);\r
- if (anotherRepository != null) {\r
- throw new ServerStartException("The metric '" + metricKey + "' is already defined in the extension: " + anotherRepository);\r
- }\r
- metricsByRepository.put(metricKey, metrics);\r
- }\r
- }\r
-\r
- protected void cleanAlerts() {\r
- Logs.INFO.info("cleaning alert thresholds...");\r
- Query query = session.createQuery("delete from " + Alert.class.getSimpleName() + " a where NOT EXISTS(FROM Metric m WHERE m=a.metric))");\r
- query.executeUpdate();\r
-\r
- query = session.createQuery("delete from " + Alert.class.getSimpleName() + " a where NOT EXISTS(FROM Metric m WHERE m=a.metric and m.enabled=true))");\r
- query.executeUpdate();\r
- session.commit();\r
- }\r
-\r
- protected void register(List<Metric> metrics) {\r
- measuresDao.registerMetrics(metrics);\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.startup;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.sonar.api.database.DatabaseSession;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.measures.Metrics;
+import org.sonar.api.profiles.Alert;
+import org.sonar.api.utils.Logs;
+import org.sonar.api.utils.TimeProfiler;
+import org.sonar.jpa.dao.MeasuresDao;
+import org.sonar.server.platform.ServerStartException;
+
+import javax.persistence.Query;
+
+import java.util.List;
+import java.util.Map;
+
+public class RegisterMetrics {
+
+ private MeasuresDao measuresDao;
+ private Metrics[] metricsRepositories = null;
+ private DatabaseSession session;
+
+ public RegisterMetrics(DatabaseSession session, MeasuresDao measuresDao, Metrics[] metricsRepositories) {
+ this.session = session;
+ this.measuresDao = measuresDao;
+ this.metricsRepositories = metricsRepositories;
+ }
+
+ public void start() {
+ TimeProfiler profiler = new TimeProfiler().start("Load metrics");
+ measuresDao.disableAutomaticMetrics();
+
+ List<Metric> metricsToRegister = Lists.newArrayList();
+ metricsToRegister.addAll(CoreMetrics.getMetrics());
+
+ Map<String, Metrics> metricsByRepository = Maps.newHashMap();
+ if (metricsRepositories != null) {
+ for (Metrics metrics : metricsRepositories) {
+ checkMetrics(metricsByRepository, metrics);
+ metricsToRegister.addAll(metrics.getMetrics());
+ }
+ }
+ register(metricsToRegister);
+ cleanAlerts();
+ profiler.stop();
+ }
+
+ private void checkMetrics(Map<String, Metrics> metricsByRepository, Metrics metrics) {
+ for (Metric metric : metrics.getMetrics()) {
+ String metricKey = metric.getKey();
+ if (CoreMetrics.metrics.contains(metric)) {
+ throw new ServerStartException("The following metric is already defined in sonar: " + metricKey);
+ }
+ Metrics anotherRepository = metricsByRepository.get(metricKey);
+ if (anotherRepository != null) {
+ throw new ServerStartException("The metric '" + metricKey + "' is already defined in the extension: " + anotherRepository);
+ }
+ metricsByRepository.put(metricKey, metrics);
+ }
+ }
+
+ protected void cleanAlerts() {
+ Logs.INFO.info("cleaning alert thresholds...");
+ Query query = session.createQuery("delete from " + Alert.class.getSimpleName() + " a where NOT EXISTS(FROM Metric m WHERE m=a.metric))");
+ query.executeUpdate();
+
+ query = session.createQuery("delete from " + Alert.class.getSimpleName() + " a where NOT EXISTS(FROM Metric m WHERE m=a.metric and m.enabled=true))");
+ query.executeUpdate();
+ session.commit();
+ }
+
+ protected void register(List<Metric> metrics) {
+ measuresDao.registerMetrics(metrics);
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-require 'fastercsv'\r
-require "json"\r
-\r
-class Api::RulesController < Api::RestController\r
-\r
- def rest_call\r
- set_backward_compatibility_params\r
- language = params[:language] || ''\r
- options= {}\r
-\r
- options[:plugins]=params[:plugins].split(',') if params[:plugins]\r
- options[:language]=language\r
- options[:priorities]=params[:priorities].split(',') if params[:priorities]\r
- options[:status]=params[:status]\r
- options[:searchtext]=params[:searchtext]\r
- options[:include_parameters]=true\r
- options[:inheritance]=params[:inheritance]\r
- \r
-\r
- if params[:profile]\r
- profile = Profile.find_by_name_and_language(params[:profile], language)\r
- if profile.nil?\r
- rest_render([])\r
- else\r
- options[:profile]=profile\r
- rules = Rule.search(java_facade, options)\r
- rest_render(rules, profile)\r
- end\r
- else\r
- rules = Rule.search(java_facade, options)\r
- rest_render(rules)\r
- end\r
- end\r
- \r
- def set_backward_compatibility_params\r
- params[:plugins]=params[:plugin] if params[:plugin]\r
- params[:priorities]=params[:levels] if params[:levels]\r
- end\r
-\r
-\r
- private\r
-\r
- def rest_render(rules=[], profile=nil)\r
- respond_to do |format|\r
- format.json{ render :json => rest_to_json(rules, profile) }\r
- format.xml { render :xml => rest_to_xml(rules, profile) }\r
- format.csv {\r
- send_data(rest_to_csv(rules, profile),\r
- :type => 'text/csv; charset=utf-8; header=present',\r
- :disposition => 'attachment; filename=rules.csv')\r
- }\r
- end\r
- end\r
-\r
- def rest_to_json(rules, profile)\r
- JSON(rules.collect{|rule| rule.to_hash_json(profile)})\r
- end\r
-\r
- def rest_to_xml(rules, profile)\r
- xml = Builder::XmlMarkup.new(:indent => 0)\r
- xml.instruct!\r
- xml.rules do\r
- rules.each do |rule|\r
- xml << rule.to_xml(profile)\r
- end\r
- end\r
- end\r
-\r
- def rest_to_csv(rules, profile)\r
- FasterCSV.generate do |csv|\r
- header = ["title", "key", "plugin"]\r
- header.concat(["priority","status"]) if profile\r
- csv << header\r
- rules.each do |rule|\r
- csv << rule.to_csv(profile)\r
- end\r
- end\r
- end\r
-\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+require 'fastercsv'
+require "json"
+
+class Api::RulesController < Api::RestController
+
+ def rest_call
+ set_backward_compatibility_params
+ language = params[:language] || ''
+ options= {}
+
+ options[:plugins]=params[:plugins].split(',') if params[:plugins]
+ options[:language]=language
+ options[:priorities]=params[:priorities].split(',') if params[:priorities]
+ options[:status]=params[:status]
+ options[:searchtext]=params[:searchtext]
+ options[:include_parameters]=true
+ options[:inheritance]=params[:inheritance]
+
+
+ if params[:profile]
+ profile = Profile.find_by_name_and_language(params[:profile], language)
+ if profile.nil?
+ rest_render([])
+ else
+ options[:profile]=profile
+ rules = Rule.search(java_facade, options)
+ rest_render(rules, profile)
+ end
+ else
+ rules = Rule.search(java_facade, options)
+ rest_render(rules)
+ end
+ end
+
+ def set_backward_compatibility_params
+ params[:plugins]=params[:plugin] if params[:plugin]
+ params[:priorities]=params[:levels] if params[:levels]
+ end
+
+
+ private
+
+ def rest_render(rules=[], profile=nil)
+ respond_to do |format|
+ format.json{ render :json => rest_to_json(rules, profile) }
+ format.xml { render :xml => rest_to_xml(rules, profile) }
+ format.csv {
+ send_data(rest_to_csv(rules, profile),
+ :type => 'text/csv; charset=utf-8; header=present',
+ :disposition => 'attachment; filename=rules.csv')
+ }
+ end
+ end
+
+ def rest_to_json(rules, profile)
+ JSON(rules.collect{|rule| rule.to_hash_json(profile)})
+ end
+
+ def rest_to_xml(rules, profile)
+ xml = Builder::XmlMarkup.new(:indent => 0)
+ xml.instruct!
+ xml.rules do
+ rules.each do |rule|
+ xml << rule.to_xml(profile)
+ end
+ end
+ end
+
+ def rest_to_csv(rules, profile)
+ FasterCSV.generate do |csv|
+ header = ["title", "key", "plugin"]
+ header.concat(["priority","status"]) if profile
+ csv << header
+ rules.each do |rule|
+ csv << rule.to_csv(profile)
+ end
+ end
+ end
+
end
\ No newline at end of file
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-\r
-require "json"\r
-\r
-class Api::SourcesController < Api::RestController\r
-\r
- def rest_call\r
- resource_id=params[:resource]\r
- if resource_id\r
- @resource=Project.by_key(resource_id)\r
- if @resource.nil?\r
- rest_status_ko("Resource [#{resource_id}] not found", 404)\r
- return\r
- end\r
- end\r
- return access_denied unless has_role?(:codeviewer, @resource)\r
-\r
- source = @resource.last_snapshot.source\r
- if !source\r
- rest_status_ko("Resource [#{@resource.id}] has no sources", 404)\r
- else\r
- #optimization\r
- #source.snapshot.project=@resource\r
- rest_render({:source => source, :params => params})\r
- end\r
- end\r
-\r
- def rest_to_json(objects)\r
- source = objects[:source]\r
- params = objects[:params]\r
- JSON([source.to_hash_json(params)])\r
- end\r
-\r
- def rest_to_xml(objects)\r
- source = objects[:source]\r
- params = objects[:params]\r
- xml = Builder::XmlMarkup.new(:indent => 0)\r
- xml.instruct!\r
- source.to_xml(xml, params)\r
- end\r
-\r
- def rest_to_text(objects)\r
- source = objects[:source]\r
- params = objects[:params]\r
- source.to_txt(params)\r
- end\r
-\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+
+require "json"
+
+class Api::SourcesController < Api::RestController
+
+ def rest_call
+ resource_id=params[:resource]
+ if resource_id
+ @resource=Project.by_key(resource_id)
+ if @resource.nil?
+ rest_status_ko("Resource [#{resource_id}] not found", 404)
+ return
+ end
+ end
+ return access_denied unless has_role?(:codeviewer, @resource)
+
+ source = @resource.last_snapshot.source
+ if !source
+ rest_status_ko("Resource [#{@resource.id}] has no sources", 404)
+ else
+ #optimization
+ #source.snapshot.project=@resource
+ rest_render({:source => source, :params => params})
+ end
+ end
+
+ def rest_to_json(objects)
+ source = objects[:source]
+ params = objects[:params]
+ JSON([source.to_hash_json(params)])
+ end
+
+ def rest_to_xml(objects)
+ source = objects[:source]
+ params = objects[:params]
+ xml = Builder::XmlMarkup.new(:indent => 0)
+ xml.instruct!
+ source.to_xml(xml, params)
+ end
+
+ def rest_to_text(objects)
+ source = objects[:source]
+ params = objects[:params]
+ source.to_txt(params)
+ end
+
end
\ No newline at end of file
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-\r
-require "json"\r
-\r
-class Api::ViolationsController < Api::ResourceRestController\r
-\r
- def rest_call\r
- snapshot = @resource.last_snapshot\r
- \r
- conditions=[]\r
- values={}\r
- if params['scopes']\r
- conditions << 'snapshots.scope in (:scopes)'\r
- values[:scopes]=params['scopes'].split(',')\r
- end\r
- if params['qualifiers']\r
- conditions << 'snapshots.qualifier in (:qualifiers)'\r
- values[:qualifiers]=params['qualifiers'].split(',')\r
- end\r
-\r
- depth=(params['depth'] ? params['depth'].to_i : 0)\r
- if depth==0\r
- conditions << 'snapshots.id=:sid'\r
- values[:sid]=snapshot.id\r
- \r
- elsif depth>0\r
- # all the resource tree\r
- conditions << 'snapshots.root_snapshot_id=:root_sid'\r
- values[:root_sid] = (snapshot.root_snapshot_id || snapshot.id)\r
-\r
- conditions << 'snapshots.path LIKE :path'\r
- values[:path]="#{snapshot.path}#{snapshot.id}.%"\r
-\r
- conditions << 'snapshots.depth=:depth'\r
- values[:depth] = snapshot.depth + depth\r
-\r
- else\r
- # negative : all the resource tree\r
- conditions << '(snapshots.id=:sid OR (snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path))'\r
- values[:sid] = snapshot.id\r
- values[:root_sid] = (snapshot.root_snapshot_id || snapshot.id)\r
- values[:path]="#{snapshot.path}#{snapshot.id}.%"\r
- end\r
- \r
- if params[:rules]\r
- rule_ids=params[:rules].split(',').map do |key_or_id|\r
- Rule.to_i(key_or_id)\r
- end.compact\r
- conditions << 'rule_id IN (:rule_ids)'\r
- values[:rule_ids] = rule_ids\r
- end\r
- if params[:priorities]\r
- conditions << 'rule_failures.failure_level IN (:priorities)'\r
- values[:priorities]=params[:priorities].split(',').map do |p|\r
- Sonar::RulePriority.id(p)\r
- end.compact\r
- end\r
-\r
- limit = (params[:limit] ? [params[:limit].to_i,5000].min : 5000) \r
- violations = RuleFailure.find(:all,\r
- :conditions => [ conditions.join(' AND '), values],\r
- :include => [:snapshot, {:snapshot => :project}, :rule],\r
- :order => 'rule_failures.failure_level DESC',\r
- :limit => limit)\r
- rest_render(violations)\r
- end\r
-\r
- def rest_to_json(rule_failures)\r
- JSON(rule_failures.collect{|rule_failure| rule_failure.to_hash_json})\r
- end\r
-\r
- def rest_to_xml(rule_failures)\r
- xml = Builder::XmlMarkup.new(:indent => 0)\r
- xml.instruct!\r
- xml.violations do\r
- rule_failures.each do |rule_failure|\r
- rule_failure.to_xml(xml)\r
- end\r
- end\r
- end\r
-\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+
+require "json"
+
+class Api::ViolationsController < Api::ResourceRestController
+
+ def rest_call
+ snapshot = @resource.last_snapshot
+
+ conditions=[]
+ values={}
+ if params['scopes']
+ conditions << 'snapshots.scope in (:scopes)'
+ values[:scopes]=params['scopes'].split(',')
+ end
+ if params['qualifiers']
+ conditions << 'snapshots.qualifier in (:qualifiers)'
+ values[:qualifiers]=params['qualifiers'].split(',')
+ end
+
+ depth=(params['depth'] ? params['depth'].to_i : 0)
+ if depth==0
+ conditions << 'snapshots.id=:sid'
+ values[:sid]=snapshot.id
+
+ elsif depth>0
+ # all the resource tree
+ conditions << 'snapshots.root_snapshot_id=:root_sid'
+ values[:root_sid] = (snapshot.root_snapshot_id || snapshot.id)
+
+ conditions << 'snapshots.path LIKE :path'
+ values[:path]="#{snapshot.path}#{snapshot.id}.%"
+
+ conditions << 'snapshots.depth=:depth'
+ values[:depth] = snapshot.depth + depth
+
+ else
+ # negative : all the resource tree
+ conditions << '(snapshots.id=:sid OR (snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path))'
+ values[:sid] = snapshot.id
+ values[:root_sid] = (snapshot.root_snapshot_id || snapshot.id)
+ values[:path]="#{snapshot.path}#{snapshot.id}.%"
+ end
+
+ if params[:rules]
+ rule_ids=params[:rules].split(',').map do |key_or_id|
+ Rule.to_i(key_or_id)
+ end.compact
+ conditions << 'rule_id IN (:rule_ids)'
+ values[:rule_ids] = rule_ids
+ end
+ if params[:priorities]
+ conditions << 'rule_failures.failure_level IN (:priorities)'
+ values[:priorities]=params[:priorities].split(',').map do |p|
+ Sonar::RulePriority.id(p)
+ end.compact
+ end
+
+ limit = (params[:limit] ? [params[:limit].to_i,5000].min : 5000)
+ violations = RuleFailure.find(:all,
+ :conditions => [ conditions.join(' AND '), values],
+ :include => [:snapshot, {:snapshot => :project}, :rule],
+ :order => 'rule_failures.failure_level DESC',
+ :limit => limit)
+ rest_render(violations)
+ end
+
+ def rest_to_json(rule_failures)
+ JSON(rule_failures.collect{|rule_failure| rule_failure.to_hash_json})
+ end
+
+ def rest_to_xml(rule_failures)
+ xml = Builder::XmlMarkup.new(:indent => 0)
+ xml.instruct!
+ xml.violations do
+ rule_failures.each do |rule_failure|
+ rule_failure.to_xml(xml)
+ end
+ end
+ end
+
end
\ No newline at end of file
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-require 'cgi'\r
-\r
-class RulesConfigurationController < ApplicationController\r
-\r
- SECTION=Navigation::SECTION_CONFIGURATION\r
- \r
- STATUS_ACTIVE = "ACTIVE"\r
- STATUS_INACTIVE = "INACTIVE"\r
- ANY_SELECTION = [["Any", '']]\r
- RULE_PRIORITIES = Sonar::RulePriority.as_options.reverse\r
-\r
- # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)\r
- verify :method => :post, :only => ['activate_rule', 'update_param', 'bulk_edit', 'create', 'update', 'delete', 'revert_rule'], :redirect_to => { :action => 'index' }\r
-\r
- before_filter :admin_required, :except => [ 'index', 'export' ]\r
-\r
- def index\r
- unless params[:id].blank?\r
- if params[:id].to_i<=0\r
- redirect_to :controller => 'profiles'\r
- return\r
- end\r
- begin\r
- @profile = Profile.find(params[:id].to_i)\r
- rescue\r
- redirect_to :controller => 'profiles'\r
- return\r
- end\r
- else\r
- @profile = Profile.default_profile\r
- end\r
- \r
- init_params()\r
- \r
- @select_plugins = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.getName(true), repo.getKey()]}.sort\r
- @select_priority = ANY_SELECTION + RULE_PRIORITIES\r
- @select_status = [['Any',''], ["Active", STATUS_ACTIVE], ["Inactive", STATUS_INACTIVE]]\r
- @select_inheritance = [['Any',''], ["Not inherited", 'NOT'], ["Inherited", 'INHERITED'], ["Overrides", 'OVERRIDES']]\r
-\r
- @rules = Rule.search(java_facade, {\r
- :profile => @profile, :status => @status, :priorities => @priorities, :inheritance => @inheritance,\r
- :plugins => @plugins, :searchtext => @searchtext, :include_parameters => true, :language => @profile.language})\r
-\r
- unless @searchtext.blank?\r
- if @status==STATUS_ACTIVE\r
- @hidden_inactives=Rule.search(java_facade, {\r
- :profile => @profile, :status => STATUS_INACTIVE, :priorities => @priorities,\r
- :plugins => @plugins, :language => @profile.language, :searchtext => @searchtext, :include_parameters => false}).size\r
-\r
- elsif @status==STATUS_INACTIVE\r
- @hidden_actives=Rule.search(java_facade, {\r
- :profile => @profile, :status => STATUS_ACTIVE, :priorities => @priorities,\r
- :plugins => @plugins, :language => @profile.language, :searchtext => @searchtext, :include_parameters => false}).size\r
- end\r
- end\r
-\r
- end\r
-\r
-\r
- #\r
- #\r
- # POST /rules_configuration/revert_rule?id=<profile id>&active_rule_id=<active rule id>\r
- #\r
- #\r
- def revert_rule\r
- id = params[:id].to_i\r
- rule_id = params[:active_rule_id].to_i\r
- java_facade.revertRule(id, rule_id)\r
- redirect_to request.query_parameters.merge({:action => 'index', :id => params[:id], :commit => nil})\r
- end\r
-\r
-\r
- #\r
- #\r
- # POST /rules_configuration/activate_rule?id=<profile id>&rule_id=<rule id>&level=<priority>\r
- #\r
- # If the parameter "level" is blank or null, then the rule is removed from the profile.\r
- #\r
- #\r
- def activate_rule\r
- profile = Profile.find(params[:id].to_i)\r
- if profile && !profile.provided?\r
- rule=Rule.find(:first, :conditions => {:id => params[:rule_id].to_i, :enabled => true})\r
- priority=params[:level]\r
-\r
- active_rule=profile.active_by_rule_id(rule.id)\r
- if priority.blank?\r
- # deactivate the rule\r
- active_rule.destroy if active_rule\r
- active_rule=nil\r
- java_facade.ruleDeactivated(profile.id, rule.id)\r
- else\r
- # activate the rule\r
- if active_rule.nil?\r
- active_rule = ActiveRule.new(:profile_id => profile.id, :rule => rule)\r
- rule.parameters.select{|p| p.default_value.present?}.each do |p|\r
- active_rule.active_rule_parameters.build(:rules_parameter => p, :value => p.default_value)\r
- end\r
- end\r
- active_rule.failure_level=Sonar::RulePriority.id(priority)\r
- active_rule.save!\r
- java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)\r
- end\r
- if active_rule\r
- active_rule.reload\r
- end\r
-\r
- is_admin=true # security has already been checked by controller filters\r
- render :update do |page|\r
- page.replace_html("rule_#{rule.id}", :partial => 'rule', :object => rule, :locals => {:profile => profile, :active_rule => active_rule, :is_admin => is_admin})\r
- page.assign('localModifications', true)\r
- end\r
- end\r
- end\r
-\r
-\r
- #\r
- #\r
- # GET /rules_configuration/new/<profile id>?rule_id=<rule id>\r
- #\r
- #\r
- def new\r
- # form to duplicate a rule\r
- @profile = Profile.find(params[:id].to_i)\r
- @rule = Rule.find(params[:rule_id])\r
- end\r
-\r
- #\r
- #\r
- # POST /rules_configuration/create/<profile id>?rule_id=<rule id>&rule[name]=<new name>&...\r
- #\r
- #\r
- def create\r
- template=Rule.find(params[:rule_id])\r
- rule=Rule.create(params[:rule].merge(\r
- {\r
- :priority => Sonar::RulePriority.id(params[:rule][:priority]),\r
- :parent_id => template.id,\r
- :plugin_name => template.plugin_name,\r
- :cardinality => 'SINGLE',\r
- :plugin_rule_key => "#{template.plugin_rule_key}_#{Time.now.to_i}",\r
- :plugin_config_key => template.plugin_config_key,\r
- :enabled => true}))\r
-\r
- template.parameters.each do |template_parameter|\r
- rule.rules_parameters.build(:name => template_parameter.name, :param_type => template_parameter.param_type, :description => template_parameter.description,\r
- :default_value => params[:rule_param][template_parameter.name])\r
- end\r
-\r
- if rule.save\r
- redirect_to :action => 'index', :id => params[:id], :searchtext => rule.name, :rule_status => 'INACTIVE', "plugins[]" => rule.plugin_name\r
- \r
- else\r
- flash[:error]="Rule is not valid: <br/>#{rule.errors.full_messages.join('<br/>')}"\r
- redirect_to :action => 'new', :id => params[:id], :rule_id => params[:rule_id]\r
- end \r
- end\r
-\r
-\r
- # deprecated since 2.3\r
- def export\r
- redirect_to request.query_parameters.merge({:controller => 'profiles', :action => 'export'}) \r
- end\r
-\r
- #\r
- #\r
- # GET /rules_configuration/new/<profile id>?rule_id=<rule id>\r
- #\r
- #\r
- def edit\r
- # form to edit a rule\r
- @profile = Profile.find(params[:id])\r
- @rule = Rule.find(params[:rule_id])\r
- if !@rule.editable?\r
- redirect_to :action => 'index', :id => params[:id]\r
- end\r
- end\r
-\r
- #\r
- #\r
- # POST /rules_configuration/update/<profile id>?rule_id=<rule id>&rule[name]=<new name>&...\r
- #\r
- #\r
- def update\r
- rule=Rule.find(params[:rule_id])\r
- if rule.editable?\r
- rule.name=params[:rule][:name]\r
- rule.description=params[:rule][:description]\r
- rule.priority=Sonar::RulePriority.id(params[:rule][:priority])\r
- rule.parameters.each do |parameter|\r
- parameter.default_value=params[:rule_param][parameter.name]\r
- parameter.save\r
- end\r
- if rule.save\r
- redirect_to :action => 'index', :id => params[:id], :searchtext => rule.name, :rule_status => '', "plugins[]" => rule.plugin_name\r
- else\r
- flash[:error]="Rule is not valid: <br/>#{rule.errors.full_messages.join('<br/>')}"\r
- redirect_to :action => 'new', :id => params[:id], :rule_id => params[:rule_id]\r
- end\r
- else\r
- flash[:error]='Unknown rule'\r
- redirect_to :action => 'index', :id => params[:id]\r
- end\r
- end\r
-\r
-\r
- #\r
- #\r
- # POST /rules_configuration/delete/<profile id>?rule_id=<rule id>\r
- #\r
- #\r
- def delete\r
- rule=Rule.find(params[:rule_id])\r
- if rule.editable?\r
- rule.enabled=false\r
- rule.save\r
-\r
- # it's mandatory to execute 'destroy_all' but not 'delete_all' because active_rule_parameters must\r
- # also be destroyed in cascade.\r
- ActiveRule.destroy_all("rule_id=#{rule.id}")\r
- flash[:notice]='Rule deleted'\r
- else\r
- flash[:error]='Unknown rule'\r
- end\r
- redirect_to :action => 'index', :id => params[:id]\r
- end\r
-\r
- #\r
- #\r
- # POST /rules_configuration/bulk_edit?id=<profile id>&bulk_rule_ids=<list of rule ids>&bulk_action=<action>\r
- #\r
- # Values of the parameter 'bulk_action' :\r
- # - 'activate' : activate all the selected rules with their default priority\r
- # - 'deactivate' : deactivate all the selected rules\r
- #\r
- #\r
- def bulk_edit\r
- profile = Profile.find(params[:id].to_i)\r
- rule_ids = params[:bulk_rule_ids].split(',').map{|id| id.to_i}\r
- status=params[:rule_status]\r
- \r
- case params[:bulk_action]\r
- when 'activate'\r
- count=activate_rules(profile, rule_ids)\r
- flash[:notice]="#{count} rules have been activated."\r
- status=STATUS_ACTIVE if status==STATUS_INACTIVE\r
-\r
- when 'deactivate'\r
- count=deactivate_rules(profile, rule_ids)\r
- flash[:notice]="#{count} rules have been deactivated."\r
- status=STATUS_INACTIVE if status==STATUS_ACTIVE\r
- end\r
-\r
- url_parameters=request.query_parameters.merge({:action => 'index', :bulk_action => nil, :bulk_rule_ids => nil, :id => profile.id, :rule_status => status})\r
- redirect_to url_parameters\r
- end\r
-\r
-\r
-\r
- def update_param\r
- is_admin=true # security has already been checked by controller filters\r
- profile = Profile.find(params[:profile_id].to_i)\r
- rule_param = RulesParameter.find(params[:param_id].to_i)\r
- active_rule = ActiveRule.find(params[:active_rule_id].to_i)\r
- active_param = ActiveRuleParameter.find(params[:id].to_i) if params[:id].to_i > 0\r
- value = params[:value]\r
- if !profile.provided?\r
- if value != ""\r
- active_param = ActiveRuleParameter.new(:rules_parameter => rule_param, :active_rule => active_rule ) if active_param.nil?\r
- active_param.value = value\r
- active_param.save\r
- active_param.valid?\r
- active_param.reload\r
- elsif !active_param.nil?\r
- active_param.destroy\r
- active_param = nil\r
- end\r
- java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)\r
- end\r
- render :partial => 'rule_param', :object => nil,\r
- :locals => {:parameter => rule_param, :active_parameter => active_param, :profile => profile, :active_rule => active_rule, :is_admin => is_admin }\r
- end\r
-\r
- private\r
-\r
- # return the number of newly activated rules\r
- def activate_rules(profile, rule_ids)\r
- count=0\r
- rule_ids_to_activate=(rule_ids - profile.active_rules.map{|ar| ar.rule_id})\r
- unless rule_ids_to_activate.empty?\r
- rules_to_activate=Rule.find(:all, :conditions => {:enabled=>true, :id => rule_ids_to_activate})\r
- count = rules_to_activate.size\r
- rules_to_activate.each do |rule|\r
- active_rule = profile.active_rules.create(:rule => rule, :failure_level => rule.priority)\r
- java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)\r
- end\r
- end\r
- count\r
- end\r
-\r
- def deactivate_rules(profile, rule_ids)\r
- count=0\r
- profile.active_rules.each do |ar|\r
- if rule_ids.include?(ar.rule_id) && !ar.inheritance.present?\r
- ar.destroy\r
- java_facade.ruleDeactivated(profile.id, ar.rule_id)\r
- count+=1\r
- end\r
- end\r
- count\r
- end\r
-\r
- def init_params\r
- @id = params[:id]\r
- @priorities = filter_any(params[:priorities]) || ['']\r
- @plugins=filter_any(params[:plugins]) || ['']\r
- @status=params[:rule_status] || STATUS_ACTIVE\r
- @inheritance=params[:inheritance] || ''\r
- @searchtext=params[:searchtext]\r
- end\r
-\r
- def filter_any(array)\r
- if array && array.size>1 && array.include?('')\r
- array=[''] #keep only 'any'\r
- end\r
- array\r
- end\r
-\r
-end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+require 'cgi'
+
+class RulesConfigurationController < ApplicationController
+
+ SECTION=Navigation::SECTION_CONFIGURATION
+
+ STATUS_ACTIVE = "ACTIVE"
+ STATUS_INACTIVE = "INACTIVE"
+ ANY_SELECTION = [["Any", '']]
+ RULE_PRIORITIES = Sonar::RulePriority.as_options.reverse
+
+ # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
+ verify :method => :post, :only => ['activate_rule', 'update_param', 'bulk_edit', 'create', 'update', 'delete', 'revert_rule'], :redirect_to => { :action => 'index' }
+
+ before_filter :admin_required, :except => [ 'index', 'export' ]
+
+ def index
+ unless params[:id].blank?
+ if params[:id].to_i<=0
+ redirect_to :controller => 'profiles'
+ return
+ end
+ begin
+ @profile = Profile.find(params[:id].to_i)
+ rescue
+ redirect_to :controller => 'profiles'
+ return
+ end
+ else
+ @profile = Profile.default_profile
+ end
+
+ init_params()
+
+ @select_plugins = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.getName(true), repo.getKey()]}.sort
+ @select_priority = ANY_SELECTION + RULE_PRIORITIES
+ @select_status = [['Any',''], ["Active", STATUS_ACTIVE], ["Inactive", STATUS_INACTIVE]]
+ @select_inheritance = [['Any',''], ["Not inherited", 'NOT'], ["Inherited", 'INHERITED'], ["Overrides", 'OVERRIDES']]
+
+ @rules = Rule.search(java_facade, {
+ :profile => @profile, :status => @status, :priorities => @priorities, :inheritance => @inheritance,
+ :plugins => @plugins, :searchtext => @searchtext, :include_parameters => true, :language => @profile.language})
+
+ unless @searchtext.blank?
+ if @status==STATUS_ACTIVE
+ @hidden_inactives=Rule.search(java_facade, {
+ :profile => @profile, :status => STATUS_INACTIVE, :priorities => @priorities,
+ :plugins => @plugins, :language => @profile.language, :searchtext => @searchtext, :include_parameters => false}).size
+
+ elsif @status==STATUS_INACTIVE
+ @hidden_actives=Rule.search(java_facade, {
+ :profile => @profile, :status => STATUS_ACTIVE, :priorities => @priorities,
+ :plugins => @plugins, :language => @profile.language, :searchtext => @searchtext, :include_parameters => false}).size
+ end
+ end
+
+ end
+
+
+ #
+ #
+ # POST /rules_configuration/revert_rule?id=<profile id>&active_rule_id=<active rule id>
+ #
+ #
+ def revert_rule
+ id = params[:id].to_i
+ rule_id = params[:active_rule_id].to_i
+ java_facade.revertRule(id, rule_id)
+ redirect_to request.query_parameters.merge({:action => 'index', :id => params[:id], :commit => nil})
+ end
+
+
+ #
+ #
+ # POST /rules_configuration/activate_rule?id=<profile id>&rule_id=<rule id>&level=<priority>
+ #
+ # If the parameter "level" is blank or null, then the rule is removed from the profile.
+ #
+ #
+ def activate_rule
+ profile = Profile.find(params[:id].to_i)
+ if profile && !profile.provided?
+ rule=Rule.find(:first, :conditions => {:id => params[:rule_id].to_i, :enabled => true})
+ priority=params[:level]
+
+ active_rule=profile.active_by_rule_id(rule.id)
+ if priority.blank?
+ # deactivate the rule
+ active_rule.destroy if active_rule
+ active_rule=nil
+ java_facade.ruleDeactivated(profile.id, rule.id)
+ else
+ # activate the rule
+ if active_rule.nil?
+ active_rule = ActiveRule.new(:profile_id => profile.id, :rule => rule)
+ rule.parameters.select{|p| p.default_value.present?}.each do |p|
+ active_rule.active_rule_parameters.build(:rules_parameter => p, :value => p.default_value)
+ end
+ end
+ active_rule.failure_level=Sonar::RulePriority.id(priority)
+ active_rule.save!
+ java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)
+ end
+ if active_rule
+ active_rule.reload
+ end
+
+ is_admin=true # security has already been checked by controller filters
+ render :update do |page|
+ page.replace_html("rule_#{rule.id}", :partial => 'rule', :object => rule, :locals => {:profile => profile, :active_rule => active_rule, :is_admin => is_admin})
+ page.assign('localModifications', true)
+ end
+ end
+ end
+
+
+ #
+ #
+ # GET /rules_configuration/new/<profile id>?rule_id=<rule id>
+ #
+ #
+ def new
+ # form to duplicate a rule
+ @profile = Profile.find(params[:id].to_i)
+ @rule = Rule.find(params[:rule_id])
+ end
+
+ #
+ #
+ # POST /rules_configuration/create/<profile id>?rule_id=<rule id>&rule[name]=<new name>&...
+ #
+ #
+ def create
+ template=Rule.find(params[:rule_id])
+ rule=Rule.create(params[:rule].merge(
+ {
+ :priority => Sonar::RulePriority.id(params[:rule][:priority]),
+ :parent_id => template.id,
+ :plugin_name => template.plugin_name,
+ :cardinality => 'SINGLE',
+ :plugin_rule_key => "#{template.plugin_rule_key}_#{Time.now.to_i}",
+ :plugin_config_key => template.plugin_config_key,
+ :enabled => true}))
+
+ template.parameters.each do |template_parameter|
+ rule.rules_parameters.build(:name => template_parameter.name, :param_type => template_parameter.param_type, :description => template_parameter.description,
+ :default_value => params[:rule_param][template_parameter.name])
+ end
+
+ if rule.save
+ redirect_to :action => 'index', :id => params[:id], :searchtext => rule.name, :rule_status => 'INACTIVE', "plugins[]" => rule.plugin_name
+
+ else
+ flash[:error]="Rule is not valid: <br/>#{rule.errors.full_messages.join('<br/>')}"
+ redirect_to :action => 'new', :id => params[:id], :rule_id => params[:rule_id]
+ end
+ end
+
+
+ # deprecated since 2.3
+ def export
+ redirect_to request.query_parameters.merge({:controller => 'profiles', :action => 'export'})
+ end
+
+ #
+ #
+ # GET /rules_configuration/new/<profile id>?rule_id=<rule id>
+ #
+ #
+ def edit
+ # form to edit a rule
+ @profile = Profile.find(params[:id])
+ @rule = Rule.find(params[:rule_id])
+ if !@rule.editable?
+ redirect_to :action => 'index', :id => params[:id]
+ end
+ end
+
+ #
+ #
+ # POST /rules_configuration/update/<profile id>?rule_id=<rule id>&rule[name]=<new name>&...
+ #
+ #
+ def update
+ rule=Rule.find(params[:rule_id])
+ if rule.editable?
+ rule.name=params[:rule][:name]
+ rule.description=params[:rule][:description]
+ rule.priority=Sonar::RulePriority.id(params[:rule][:priority])
+ rule.parameters.each do |parameter|
+ parameter.default_value=params[:rule_param][parameter.name]
+ parameter.save
+ end
+ if rule.save
+ redirect_to :action => 'index', :id => params[:id], :searchtext => rule.name, :rule_status => '', "plugins[]" => rule.plugin_name
+ else
+ flash[:error]="Rule is not valid: <br/>#{rule.errors.full_messages.join('<br/>')}"
+ redirect_to :action => 'new', :id => params[:id], :rule_id => params[:rule_id]
+ end
+ else
+ flash[:error]='Unknown rule'
+ redirect_to :action => 'index', :id => params[:id]
+ end
+ end
+
+
+ #
+ #
+ # POST /rules_configuration/delete/<profile id>?rule_id=<rule id>
+ #
+ #
+ def delete
+ rule=Rule.find(params[:rule_id])
+ if rule.editable?
+ rule.enabled=false
+ rule.save
+
+ # it's mandatory to execute 'destroy_all' but not 'delete_all' because active_rule_parameters must
+ # also be destroyed in cascade.
+ ActiveRule.destroy_all("rule_id=#{rule.id}")
+ flash[:notice]='Rule deleted'
+ else
+ flash[:error]='Unknown rule'
+ end
+ redirect_to :action => 'index', :id => params[:id]
+ end
+
+ #
+ #
+ # POST /rules_configuration/bulk_edit?id=<profile id>&bulk_rule_ids=<list of rule ids>&bulk_action=<action>
+ #
+ # Values of the parameter 'bulk_action' :
+ # - 'activate' : activate all the selected rules with their default priority
+ # - 'deactivate' : deactivate all the selected rules
+ #
+ #
+ def bulk_edit
+ profile = Profile.find(params[:id].to_i)
+ rule_ids = params[:bulk_rule_ids].split(',').map{|id| id.to_i}
+ status=params[:rule_status]
+
+ case params[:bulk_action]
+ when 'activate'
+ count=activate_rules(profile, rule_ids)
+ flash[:notice]="#{count} rules have been activated."
+ status=STATUS_ACTIVE if status==STATUS_INACTIVE
+
+ when 'deactivate'
+ count=deactivate_rules(profile, rule_ids)
+ flash[:notice]="#{count} rules have been deactivated."
+ status=STATUS_INACTIVE if status==STATUS_ACTIVE
+ end
+
+ url_parameters=request.query_parameters.merge({:action => 'index', :bulk_action => nil, :bulk_rule_ids => nil, :id => profile.id, :rule_status => status})
+ redirect_to url_parameters
+ end
+
+
+
+ def update_param
+ is_admin=true # security has already been checked by controller filters
+ profile = Profile.find(params[:profile_id].to_i)
+ rule_param = RulesParameter.find(params[:param_id].to_i)
+ active_rule = ActiveRule.find(params[:active_rule_id].to_i)
+ active_param = ActiveRuleParameter.find(params[:id].to_i) if params[:id].to_i > 0
+ value = params[:value]
+ if !profile.provided?
+ if value != ""
+ active_param = ActiveRuleParameter.new(:rules_parameter => rule_param, :active_rule => active_rule ) if active_param.nil?
+ active_param.value = value
+ active_param.save
+ active_param.valid?
+ active_param.reload
+ elsif !active_param.nil?
+ active_param.destroy
+ active_param = nil
+ end
+ java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)
+ end
+ render :partial => 'rule_param', :object => nil,
+ :locals => {:parameter => rule_param, :active_parameter => active_param, :profile => profile, :active_rule => active_rule, :is_admin => is_admin }
+ end
+
+ private
+
+ # return the number of newly activated rules
+ def activate_rules(profile, rule_ids)
+ count=0
+ rule_ids_to_activate=(rule_ids - profile.active_rules.map{|ar| ar.rule_id})
+ unless rule_ids_to_activate.empty?
+ rules_to_activate=Rule.find(:all, :conditions => {:enabled=>true, :id => rule_ids_to_activate})
+ count = rules_to_activate.size
+ rules_to_activate.each do |rule|
+ active_rule = profile.active_rules.create(:rule => rule, :failure_level => rule.priority)
+ java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)
+ end
+ end
+ count
+ end
+
+ def deactivate_rules(profile, rule_ids)
+ count=0
+ profile.active_rules.each do |ar|
+ if rule_ids.include?(ar.rule_id) && !ar.inheritance.present?
+ ar.destroy
+ java_facade.ruleDeactivated(profile.id, ar.rule_id)
+ count+=1
+ end
+ end
+ count
+ end
+
+ def init_params
+ @id = params[:id]
+ @priorities = filter_any(params[:priorities]) || ['']
+ @plugins=filter_any(params[:plugins]) || ['']
+ @status=params[:rule_status] || STATUS_ACTIVE
+ @inheritance=params[:inheritance] || ''
+ @searchtext=params[:searchtext]
+ end
+
+ def filter_any(array)
+ if array && array.size>1 && array.include?('')
+ array=[''] #keep only 'any'
+ end
+ array
+ end
+
+end
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-class RulesController < ApplicationController\r
-\r
- SECTION=Navigation::SECTION_CONFIGURATION\r
- \r
- def show\r
- key=params[:id]\r
- if key.to_i==0\r
- parts=key.split(':')\r
- @rule=Rule.find(:first, :conditions => ['plugin_name=? and plugin_rule_key=?', parts[0], parts[1]])\r
- else\r
- @rule=Rule.find(key)\r
- end\r
- @page_title=@rule.name\r
- end\r
-\r
-end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class RulesController < ApplicationController
+
+ SECTION=Navigation::SECTION_CONFIGURATION
+
+ def show
+ key=params[:id]
+ if key.to_i==0
+ parts=key.split(':')
+ @rule=Rule.find(:first, :conditions => ['plugin_name=? and plugin_rule_key=?', parts[0], parts[1]])
+ else
+ @rule=Rule.find(key)
+ end
+ @page_title=@rule.name
+ end
+
+end
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-module WidgetPropertiesHelper\r
- \r
- \r
- def property_value_field(definition, value)\r
- val=value || definition.defaultValue()\r
- if definition.type.name()==WidgetProperty::TYPE_INTEGER\r
- text_field_tag definition.key(), val, :size => 10\r
- \r
- elsif definition.type.name()==WidgetProperty::TYPE_FLOAT\r
- text_field_tag definition.key(), val, :size => 10\r
-\r
- elsif definition.type.name()==WidgetProperty::TYPE_BOOLEAN\r
- check_box_tag definition.key(), "true", val=='true'\r
-\r
- elsif definition.type.name()==WidgetProperty::TYPE_STRING\r
- text_field_tag definition.key(), val, :size => 10\r
-\r
- else\r
- hidden_field_tag definition.key()\r
- end\r
- end\r
- \r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+module WidgetPropertiesHelper
+
+
+ def property_value_field(definition, value)
+ val=value || definition.defaultValue()
+ if definition.type.name()==WidgetProperty::TYPE_INTEGER
+ text_field_tag definition.key(), val, :size => 10
+
+ elsif definition.type.name()==WidgetProperty::TYPE_FLOAT
+ text_field_tag definition.key(), val, :size => 10
+
+ elsif definition.type.name()==WidgetProperty::TYPE_BOOLEAN
+ check_box_tag definition.key(), "true", val=='true'
+
+ elsif definition.type.name()==WidgetProperty::TYPE_STRING
+ text_field_tag definition.key(), val, :size => 10
+
+ else
+ hidden_field_tag definition.key()
+ end
+ end
+
end
\ No newline at end of file
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-class ActiveDashboard < ActiveRecord::Base\r
-\r
- belongs_to :user\r
- belongs_to :dashboard\r
-\r
- def name\r
- dashboard.name\r
- end\r
-\r
- def order_index\r
- read_attribute(:order_index) || 1\r
- end\r
-\r
- def shared?\r
- dashboard.shared\r
- end\r
-\r
- def owner?(user)\r
- dashboard.owner?(user)\r
- end\r
-\r
- def follower?(user)\r
- self.user.nil? || self.user_id==user.id\r
- end\r
-\r
- def self.user_dashboards(user)\r
- result=nil\r
- if user && user.id\r
- result=find(:all, :include => 'dashboard', :conditions => ['user_id=?', user.id], :order => 'order_index')\r
- end\r
- if result.nil? || result.empty?\r
- result=default_dashboards\r
- end\r
- result\r
- end\r
-\r
- def self.default_dashboards\r
- find(:all, :include => 'dashboard', :conditions => ['user_id IS NULL'], :order => 'order_index')\r
- end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class ActiveDashboard < ActiveRecord::Base
+
+ belongs_to :user
+ belongs_to :dashboard
+
+ def name
+ dashboard.name
+ end
+
+ def order_index
+ read_attribute(:order_index) || 1
+ end
+
+ def shared?
+ dashboard.shared
+ end
+
+ def owner?(user)
+ dashboard.owner?(user)
+ end
+
+ def follower?(user)
+ self.user.nil? || self.user_id==user.id
+ end
+
+ def self.user_dashboards(user)
+ result=nil
+ if user && user.id
+ result=find(:all, :include => 'dashboard', :conditions => ['user_id=?', user.id], :order => 'order_index')
+ end
+ if result.nil? || result.empty?
+ result=default_dashboards
+ end
+ result
+ end
+
+ def self.default_dashboards
+ find(:all, :include => 'dashboard', :conditions => ['user_id IS NULL'], :order => 'order_index')
+ end
end
\ No newline at end of file
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-class ActiveRule < ActiveRecord::Base\r
- belongs_to :rules_profile, :class_name => 'Profile', :foreign_key => 'profile_id'\r
- belongs_to :rule\r
- has_many :active_rule_parameters, :dependent => :destroy\r
-\r
- def level\r
- failure_level\r
- end\r
-\r
- def priority\r
- failure_level\r
- end\r
-\r
- def priority_text\r
- Sonar::RulePriority.to_s failure_level\r
- end\r
-\r
- def error?\r
- Sonar::RulePriority::major?(failure_level)\r
- end\r
-\r
- def warning?\r
- Sonar::RulePriority::minor?(failure_level)\r
- end\r
- \r
- def info?\r
- Sonar::RulePriority::info?(failure_level)\r
- end\r
- \r
- def minor?\r
- Sonar::RulePriority::minor?(failure_level)\r
- end\r
-\r
- def major?\r
- Sonar::RulePriority::major?(failure_level)\r
- end\r
- \r
- def critical?\r
- Sonar::RulePriority::critical?(failure_level)\r
- end\r
- \r
- def blocker?\r
- Sonar::RulePriority::blocker?(failure_level)\r
- end\r
-\r
- def activated?\r
- error? || warning?\r
- end\r
-\r
- def value(param_id)\r
- active_rule_parameters.each do |param|\r
- return param.value if param.rules_parameter_id == param_id\r
- end\r
- nil\r
- end\r
-\r
- def parameters\r
- active_rule_parameters\r
- end\r
-\r
- def parameter(name)\r
- result=nil\r
- parameters.each do |param|\r
- result=param if (param.name==name)\r
- end\r
- result\r
- end\r
-\r
- def active_param_by_param_id(param_id)\r
- parameters.each do |param|\r
- return param if param.rules_parameter_id==param_id\r
- end\r
- nil\r
- end\r
-\r
- def copy\r
- new_active_rule = ActiveRule.new(:rule => rule, :failure_level => failure_level)\r
- self.active_rule_parameters.each do |active_rule_parameter|\r
- new_active_rule.active_rule_parameters << active_rule_parameter.copy\r
- end \r
- new_active_rule \r
- end\r
-\r
- def inherited?\r
- inheritance=='INHERITED'\r
- end\r
-\r
- def overrides?\r
- inheritance=='OVERRIDES'\r
- end\r
-end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class ActiveRule < ActiveRecord::Base
+ belongs_to :rules_profile, :class_name => 'Profile', :foreign_key => 'profile_id'
+ belongs_to :rule
+ has_many :active_rule_parameters, :dependent => :destroy
+
+ def level
+ failure_level
+ end
+
+ def priority
+ failure_level
+ end
+
+ def priority_text
+ Sonar::RulePriority.to_s failure_level
+ end
+
+ def error?
+ Sonar::RulePriority::major?(failure_level)
+ end
+
+ def warning?
+ Sonar::RulePriority::minor?(failure_level)
+ end
+
+ def info?
+ Sonar::RulePriority::info?(failure_level)
+ end
+
+ def minor?
+ Sonar::RulePriority::minor?(failure_level)
+ end
+
+ def major?
+ Sonar::RulePriority::major?(failure_level)
+ end
+
+ def critical?
+ Sonar::RulePriority::critical?(failure_level)
+ end
+
+ def blocker?
+ Sonar::RulePriority::blocker?(failure_level)
+ end
+
+ def activated?
+ error? || warning?
+ end
+
+ def value(param_id)
+ active_rule_parameters.each do |param|
+ return param.value if param.rules_parameter_id == param_id
+ end
+ nil
+ end
+
+ def parameters
+ active_rule_parameters
+ end
+
+ def parameter(name)
+ result=nil
+ parameters.each do |param|
+ result=param if (param.name==name)
+ end
+ result
+ end
+
+ def active_param_by_param_id(param_id)
+ parameters.each do |param|
+ return param if param.rules_parameter_id==param_id
+ end
+ nil
+ end
+
+ def copy
+ new_active_rule = ActiveRule.new(:rule => rule, :failure_level => failure_level)
+ self.active_rule_parameters.each do |active_rule_parameter|
+ new_active_rule.active_rule_parameters << active_rule_parameter.copy
+ end
+ new_active_rule
+ end
+
+ def inherited?
+ inheritance=='INHERITED'
+ end
+
+ def overrides?
+ inheritance=='OVERRIDES'
+ end
+end
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with {library}; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
- class ActiveRuleParameter < ActiveRecord::Base\r
- belongs_to :active_rule\r
- belongs_to :rules_parameter\r
-\r
- def name\r
- rules_parameter.name\r
- end\r
-\r
- def parameter\r
- rules_parameter\r
- end\r
-\r
- def validate_on_update\r
- rules_parameter.validate_value(value, errors, "value" )\r
- end\r
-\r
- def copy\r
- ActiveRuleParameter.new(:rules_parameter => rules_parameter, :value => value)\r
- end\r
-\r
- end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 {library}; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+ class ActiveRuleParameter < ActiveRecord::Base
+ belongs_to :active_rule
+ belongs_to :rules_parameter
+
+ def name
+ rules_parameter.name
+ end
+
+ def parameter
+ rules_parameter
+ end
+
+ def validate_on_update
+ rules_parameter.validate_value(value, errors, "value" )
+ end
+
+ def copy
+ ActiveRuleParameter.new(:rules_parameter => rules_parameter, :value => value)
+ end
+
+ end
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-class Dashboard < ActiveRecord::Base\r
-\r
- DEFAULT_LAYOUT='50%-50%'\r
-\r
- belongs_to :user\r
-\r
- has_many :widgets, :include => 'properties', :dependent => :delete_all\r
- has_many :active_dashboards, :dependent => :delete_all\r
-\r
- validates_length_of :name, :within => 1..256\r
- validates_length_of :description, :maximum => 1000, :allow_blank => true, :allow_nil => true\r
- validates_length_of :column_layout, :maximum => 20, :allow_blank => false, :allow_nil => false\r
- validates_uniqueness_of :name, :scope => :user_id\r
-\r
- def shared?\r
- read_attribute(:shared) || false\r
- end\r
-\r
- def layout\r
- column_layout\r
- end\r
-\r
- def user_name\r
- user_id ? user.name : nil\r
- end\r
-\r
- def editable_by?(user)\r
- (user && self.user_id==user.id) || (user_id.nil? && user.has_role?(:admin))\r
- end\r
-\r
- def owner?(user)\r
- self.user_id==user.id\r
- end\r
-\r
- def number_of_columns\r
- column_layout.split('-').size\r
- end\r
-\r
- def column_size(column_index)\r
- last_widget=widgets.select{|w| w.column_index==column_index}.max{|x,y| x.row_index <=> y.row_index}\r
- last_widget ? last_widget.row_index : 0\r
- end\r
-\r
- def deep_copy()\r
- dashboard=Dashboard.new(attributes)\r
- dashboard.shared=false\r
- self.widgets.each do |child|\r
- new_widget = Widget.create(child.attributes)\r
-\r
- child.properties.each do |prop|\r
- widget_prop = WidgetProperty.create(prop.attributes)\r
- new_widget.properties << widget_prop\r
- end\r
-\r
- new_widget.save\r
- dashboard.widgets << new_widget\r
- end\r
- dashboard.save\r
- dashboard\r
- end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class Dashboard < ActiveRecord::Base
+
+ DEFAULT_LAYOUT='50%-50%'
+
+ belongs_to :user
+
+ has_many :widgets, :include => 'properties', :dependent => :delete_all
+ has_many :active_dashboards, :dependent => :delete_all
+
+ validates_length_of :name, :within => 1..256
+ validates_length_of :description, :maximum => 1000, :allow_blank => true, :allow_nil => true
+ validates_length_of :column_layout, :maximum => 20, :allow_blank => false, :allow_nil => false
+ validates_uniqueness_of :name, :scope => :user_id
+
+ def shared?
+ read_attribute(:shared) || false
+ end
+
+ def layout
+ column_layout
+ end
+
+ def user_name
+ user_id ? user.name : nil
+ end
+
+ def editable_by?(user)
+ (user && self.user_id==user.id) || (user_id.nil? && user.has_role?(:admin))
+ end
+
+ def owner?(user)
+ self.user_id==user.id
+ end
+
+ def number_of_columns
+ column_layout.split('-').size
+ end
+
+ def column_size(column_index)
+ last_widget=widgets.select{|w| w.column_index==column_index}.max{|x,y| x.row_index <=> y.row_index}
+ last_widget ? last_widget.row_index : 0
+ end
+
+ def deep_copy()
+ dashboard=Dashboard.new(attributes)
+ dashboard.shared=false
+ self.widgets.each do |child|
+ new_widget = Widget.create(child.attributes)
+
+ child.properties.each do |prop|
+ widget_prop = WidgetProperty.create(prop.attributes)
+ new_widget.properties << widget_prop
+ end
+
+ new_widget.save
+ dashboard.widgets << new_widget
+ end
+ dashboard.save
+ dashboard
+ end
end
\ No newline at end of file
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
- #\r
- # Sonar, entreprise quality control tool.\r
- # Copyright (C) 2009 SonarSource SA\r
- # mailto:contact AT sonarsource DOT com\r
- #\r
- # Sonar is free software; you can redistribute it and/or\r
- # modify it under the terms of the GNU Lesser General Public\r
- # License as published by the Free Software Foundation; either\r
- # version 3 of the License, or (at your option) any later version.\r
- #\r
- # Sonar is distributed in the hope that it will be useful,\r
- # but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- # Lesser General Public License for more details.\r
- #\r
- # You should have received a copy of the GNU Lesser General Public\r
- # License along with Sonar; if not, write to the Free Software\r
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- #\r
-class Role < ActiveRecord::Base\r
- ADMIN = 'sonar_admin'\r
+ #
+ # Sonar, entreprise quality control tool.
+ # Copyright (C) 2008-2011 SonarSource
+ # mailto:contact AT sonarsource DOT com
+ #
+ # Sonar 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.
+ #
+ # Sonar 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 Sonar; if not, write to the Free Software
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ #
+class Role < ActiveRecord::Base
+ ADMIN = 'sonar_admin'
end
\ No newline at end of file
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-class Widget < ActiveRecord::Base\r
- has_many :properties, :dependent => :delete_all, :class_name => 'WidgetProperty'\r
- belongs_to :dashboards\r
-\r
- validates_presence_of :name\r
- validates_length_of :name, :within => 1..256\r
-\r
- validates_presence_of :widget_key\r
- validates_length_of :widget_key, :within => 1..256\r
-\r
- def property(key)\r
- properties().each do |p|\r
- return p if (p.key==key)\r
- end\r
- nil\r
- end\r
-\r
- def property_value(key, default_value=nil)\r
- prop=property(key)\r
- (prop ? prop.value : nil) || default_value\r
- end\r
-\r
- def set_property(key, value, value_type)\r
- prop=property(key)\r
- if prop\r
- prop.text_value=value\r
- prop.value_type=value_type\r
- else\r
- prop=self.properties.build(:kee => key, :text_value => value, :value_type => value_type)\r
- end\r
- properties_as_hash[key]=prop.typed_value\r
- end\r
-\r
- def unset_property(key)\r
- prop=property(key)\r
- self.properties.delete(prop) if prop\r
- end\r
-\r
- def delete_property(key)\r
- prop=property(key)\r
- if prop\r
- properties.delete(prop)\r
- end\r
- end\r
-\r
- def properties_as_hash\r
- @properties_hash ||=\r
- begin\r
- hash={}\r
- properties.each do |prop|\r
- hash[prop.key]=prop.typed_value\r
- end\r
- hash\r
- end\r
- @properties_hash\r
- end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class Widget < ActiveRecord::Base
+ has_many :properties, :dependent => :delete_all, :class_name => 'WidgetProperty'
+ belongs_to :dashboards
+
+ validates_presence_of :name
+ validates_length_of :name, :within => 1..256
+
+ validates_presence_of :widget_key
+ validates_length_of :widget_key, :within => 1..256
+
+ def property(key)
+ properties().each do |p|
+ return p if (p.key==key)
+ end
+ nil
+ end
+
+ def property_value(key, default_value=nil)
+ prop=property(key)
+ (prop ? prop.value : nil) || default_value
+ end
+
+ def set_property(key, value, value_type)
+ prop=property(key)
+ if prop
+ prop.text_value=value
+ prop.value_type=value_type
+ else
+ prop=self.properties.build(:kee => key, :text_value => value, :value_type => value_type)
+ end
+ properties_as_hash[key]=prop.typed_value
+ end
+
+ def unset_property(key)
+ prop=property(key)
+ self.properties.delete(prop) if prop
+ end
+
+ def delete_property(key)
+ prop=property(key)
+ if prop
+ properties.delete(prop)
+ end
+ end
+
+ def properties_as_hash
+ @properties_hash ||=
+ begin
+ hash={}
+ properties.each do |prop|
+ hash[prop.key]=prop.typed_value
+ end
+ hash
+ end
+ @properties_hash
+ end
end
\ No newline at end of file
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-class WidgetProperty < ActiveRecord::Base\r
- TYPE_INTEGER = 'INTEGER'\r
- TYPE_BOOLEAN = 'BOOLEAN'\r
- TYPE_FLOAT = 'FLOAT'\r
- TYPE_STRING = 'STRING'\r
-\r
- belongs_to :widget\r
-\r
- validates_length_of :kee, :within => 1..100\r
- validates_length_of :text_value, :maximum => 4000, :allow_blank => true, :allow_nil => true\r
-\r
- def key\r
- kee\r
- end\r
-\r
- def value\r
- text_value\r
- end\r
-\r
- def typed_value\r
- case value_type\r
- when TYPE_INTEGER\r
- value.to_i\r
- when TYPE_FLOAT\r
- Float(value)\r
- when TYPE_BOOLEAN\r
- value=='true'\r
- else\r
- value\r
- end\r
- end\r
-\r
- def to_hash_json\r
- {:key => key, :value => value.to_s}\r
- end\r
-\r
- def to_xml(xml=Builder::XmlMarkup.new(:indent => 0))\r
- xml.property do\r
- xml.key(prop_key)\r
- xml.value {xml.cdata!(text_value.to_s)}\r
- end\r
- xml\r
- end\r
-\r
- def self.validate_definition(definition, value)\r
- errors=[]\r
- if value.empty?\r
- errors<<"Missing value" unless definition.optional()\r
- else\r
- errors<<"Please type an integer (example: 123)" if definition.type.name()==TYPE_INTEGER && value.to_i.to_s!=value\r
- if definition.type.name()==TYPE_FLOAT\r
- begin\r
- Float(value)\r
- rescue\r
- errors<<"Please type a number (example: 123.45)"\r
- end\r
- end\r
- errors<<"Please check value" if definition.type.name()==TYPE_BOOLEAN && !(value=="true" || value=="false")\r
- end\r
- errors\r
- end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class WidgetProperty < ActiveRecord::Base
+ TYPE_INTEGER = 'INTEGER'
+ TYPE_BOOLEAN = 'BOOLEAN'
+ TYPE_FLOAT = 'FLOAT'
+ TYPE_STRING = 'STRING'
+
+ belongs_to :widget
+
+ validates_length_of :kee, :within => 1..100
+ validates_length_of :text_value, :maximum => 4000, :allow_blank => true, :allow_nil => true
+
+ def key
+ kee
+ end
+
+ def value
+ text_value
+ end
+
+ def typed_value
+ case value_type
+ when TYPE_INTEGER
+ value.to_i
+ when TYPE_FLOAT
+ Float(value)
+ when TYPE_BOOLEAN
+ value=='true'
+ else
+ value
+ end
+ end
+
+ def to_hash_json
+ {:key => key, :value => value.to_s}
+ end
+
+ def to_xml(xml=Builder::XmlMarkup.new(:indent => 0))
+ xml.property do
+ xml.key(prop_key)
+ xml.value {xml.cdata!(text_value.to_s)}
+ end
+ xml
+ end
+
+ def self.validate_definition(definition, value)
+ errors=[]
+ if value.empty?
+ errors<<"Missing value" unless definition.optional()
+ else
+ errors<<"Please type an integer (example: 123)" if definition.type.name()==TYPE_INTEGER && value.to_i.to_s!=value
+ if definition.type.name()==TYPE_FLOAT
+ begin
+ Float(value)
+ rescue
+ errors<<"Please type a number (example: 123.45)"
+ end
+ end
+ errors<<"Please check value" if definition.type.name()==TYPE_BOOLEAN && !(value=="true" || value=="false")
+ end
+ errors
+ end
end
\ No newline at end of file
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-class AddMetricsNames < ActiveRecord::Migration\r
-\r
- def self.up\r
- add_column(:metrics, :domain, :string, :null => true, :limit => 64)\r
- add_column(:metrics, :short_name, :string, :null => true, :limit => 64)\r
- add_column(:metrics, :qualitative, :boolean, :null => false, :default => false)\r
- end\r
-\r
-end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class AddMetricsNames < ActiveRecord::Migration
+
+ def self.up
+ add_column(:metrics, :domain, :string, :null => true, :limit => 64)
+ add_column(:metrics, :short_name, :string, :null => true, :limit => 64)
+ add_column(:metrics, :qualitative, :boolean, :null => false, :default => false)
+ end
+
+end
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-class CreateRulesProfiles < ActiveRecord::Migration\r
-\r
- def self.up\r
- create_table 'rules_profiles'do |t|\r
- t.column :name, :string, :limit => 40, :null => false\r
- t.column :active, :boolean, :default => false\r
- end\r
-\r
- create_table 'active_rules' do |t|\r
- t.column :profile_id, :integer, :null => false\r
- t.column :rule_id, :integer, :null => false\r
- t.column :failure_level, :integer, :null => false\r
- end\r
-\r
- create_table :active_rule_parameters do |t|\r
- t.column :active_rule_id, :integer, :null => false\r
- t.column :rules_parameter_id, :integer, :null => false\r
- t.column :value, :string, :limit => 4000, :null => true\r
- end\r
- end\r
-\r
-end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class CreateRulesProfiles < ActiveRecord::Migration
+
+ def self.up
+ create_table 'rules_profiles'do |t|
+ t.column :name, :string, :limit => 40, :null => false
+ t.column :active, :boolean, :default => false
+ end
+
+ create_table 'active_rules' do |t|
+ t.column :profile_id, :integer, :null => false
+ t.column :rule_id, :integer, :null => false
+ t.column :failure_level, :integer, :null => false
+ end
+
+ create_table :active_rule_parameters do |t|
+ t.column :active_rule_id, :integer, :null => false
+ t.column :rules_parameter_id, :integer, :null => false
+ t.column :value, :string, :limit => 4000, :null => true
+ end
+ end
+
+end
-#\r
-# Sonar, entreprise quality control tool.\r
-# Copyright (C) 2009 SonarSource SA\r
-# mailto:contact AT sonarsource DOT com\r
-#\r
-# Sonar is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU Lesser General Public\r
-# License as published by the Free Software Foundation; either\r
-# version 3 of the License, or (at your option) any later version.\r
-#\r
-# Sonar is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-# Lesser General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU Lesser General Public\r
-# License along with Sonar; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
-#\r
-class AddRulesProfilesProvidedColumn < ActiveRecord::Migration\r
-\r
- def self.up\r
- add_column(:rules_profiles, :provided, :boolean, :default => false, :null => false)\r
- Profile.reset_column_information\r
- end\r
-\r
-end\r
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class AddRulesProfilesProvidedColumn < ActiveRecord::Migration
+
+ def self.up
+ add_column(:rules_profiles, :provided, :boolean, :default => false, :null => false)
+ Profile.reset_column_information
+ end
+
+end
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
- # Copyright (C) 2009 SonarSource SA
+ # Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
#
# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts.deprecated;\r
-\r
-import org.junit.Ignore;\r
-import org.junit.Test;\r
-\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-public class BarChartTest extends BaseChartWebTest {\r
-\r
- @Test\r
- public void testBarChartDefaultDimensions() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "bar-chart-default.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- @Test\r
- public void testBarChartRange() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_RANGEMAX, "200");\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "bar-chart-range.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- @Test\r
- public void testBarChartSpecificDimensions() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "750x250");\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "bar-chart-specific-dimensions.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- @Test\r
- public void testBarChartOneValue() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "100");\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "bar-chart-one-value.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- @Test\r
- public void testBarChartOthersColors() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_COLORS, "FFFF00,9900FF");\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "bar-chart-others-colors.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- @Test\r
- public void testBarChartNullValues() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, null);\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "bar-chart-null-values.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- @Test\r
- public void testBarChartWrongValues() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "wrong,value");\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "bar-chart-wrong-values.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- @Test\r
- public void testBarChartTitle() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_TITLE, "JFreeChart by Servlet");\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "750x250");\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "bar-chart-title.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- @Test\r
- @Ignore\r
- public void testBarChartTitle2() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_TITLE, "JFreeChart by Servlet");\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "750x250");\r
- params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_VERTICAL);\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES, "0+,5+,10+,20+,30+,60+,90+");\r
- params.put(BaseChartWeb.CHART_PARAM_SERIES, "1,2,3");\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE, "y");\r
- params.put(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE, "y");\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50,75,92,30,58");\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "bar-chart-vertical-multi-series.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- @Test\r
- public void testStackedBarCharteightyTwenty() throws IOException {\r
- Map<String, String> params = new HashMap<String, String>();\r
- params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.STACKED_BAR_CHART);\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "80,20");\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "stacked-bar-chart-80-20.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- @Test\r
- public void testStackedBarChartfiftyFifty() throws IOException {\r
- Map<String, String> params = new HashMap<String, String>();\r
- params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.STACKED_BAR_CHART);\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "50,50");\r
- BarChart chart = new BarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "stacked-bar-chart-50-50.png");\r
- assertChartSizeGreaterThan(img, 100);\r
- }\r
-\r
- private Map<String, String> getDefaultParams() {\r
- Map<String, String> params = new HashMap<String, String>();\r
- params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_HORIZONTAL);\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50");\r
- return params;\r
- }\r
-\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts.deprecated;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class BarChartTest extends BaseChartWebTest {
+
+ @Test
+ public void testBarChartDefaultDimensions() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "bar-chart-default.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ @Test
+ public void testBarChartRange() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_RANGEMAX, "200");
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "bar-chart-range.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ @Test
+ public void testBarChartSpecificDimensions() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "750x250");
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "bar-chart-specific-dimensions.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ @Test
+ public void testBarChartOneValue() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "100");
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "bar-chart-one-value.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ @Test
+ public void testBarChartOthersColors() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_COLORS, "FFFF00,9900FF");
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "bar-chart-others-colors.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ @Test
+ public void testBarChartNullValues() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, null);
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "bar-chart-null-values.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ @Test
+ public void testBarChartWrongValues() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "wrong,value");
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "bar-chart-wrong-values.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ @Test
+ public void testBarChartTitle() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_TITLE, "JFreeChart by Servlet");
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "750x250");
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "bar-chart-title.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ @Test
+ @Ignore
+ public void testBarChartTitle2() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_TITLE, "JFreeChart by Servlet");
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "750x250");
+ params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_VERTICAL);
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES, "0+,5+,10+,20+,30+,60+,90+");
+ params.put(BaseChartWeb.CHART_PARAM_SERIES, "1,2,3");
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE, "y");
+ params.put(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE, "y");
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50,75,92,30,58");
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "bar-chart-vertical-multi-series.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ @Test
+ public void testStackedBarCharteightyTwenty() throws IOException {
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.STACKED_BAR_CHART);
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "80,20");
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "stacked-bar-chart-80-20.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ @Test
+ public void testStackedBarChartfiftyFifty() throws IOException {
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.STACKED_BAR_CHART);
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "50,50");
+ BarChart chart = new BarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "stacked-bar-chart-50-50.png");
+ assertChartSizeGreaterThan(img, 100);
+ }
+
+ private Map<String, String> getDefaultParams() {
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_HORIZONTAL);
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50");
+ return params;
+ }
+
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts.deprecated;\r
-\r
-import org.junit.Test;\r
-\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-public class CustomBarChartTest extends BaseChartWebTest {\r
-\r
- @Test\r
- public void testEmptyParameters() throws IOException {\r
- Map<String, String> params = new HashMap<String, String>();\r
- CustomBarChart chart = new CustomBarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "custom-horizontal-bar-chart-empty.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testAllParameters() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_TITLE, "JFreeChart by Servlet");\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "750x250");\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE, "y");\r
- params.put(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE, "y");\r
- params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM);\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "6,2,3,7,5,1,9");\r
- params.put(BaseChartWeb.CHART_PARAM_SERIES, "1,2");\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES, "0+,5+,10+,20+,30+,60+,90+");\r
- params.put(BaseChartWeb.CHART_PARAM_COLORS, "FF0000,FF0000,FF0000,CC9900,CC9900,CC9900,00FF00,00FF00,00FF00");\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_UPPER, "0.05");\r
- params.put(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_UPPER, "0.05");\r
- params.put(BaseChartWeb.CHART_PARAM_INSETS, "20");\r
- CustomBarChart chart = new CustomBarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "custom-horizontal-bar-chart-all.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testComplexityChart() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "150x100");\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE, "y");\r
- params.put(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE, "y");\r
- params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM);\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "6,2,3");\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES, "0+,5+,10+,20+,30+,60+,90+");\r
- params.put(BaseChartWeb.CHART_PARAM_COLORS, "4192D9");\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_UPPER, "0.05");\r
- params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_LOWER, "0.05");\r
- params.put(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_UPPER, "0.2");\r
- params.put(BaseChartWeb.CHART_PARAM_INSETS, "1");\r
- params.put(BaseChartWeb.CHART_PARAM_OUTLINE_RANGEGRIDLINES_VISIBLE, "y");\r
- params.put(BaseChartWeb.CHART_PARAM_OUTLINE_VISIBLE, "y");\r
- CustomBarChart chart = new CustomBarChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "custom-horizontal-bar-chart-complexity.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- private Map<String, String> getDefaultParams() {\r
- Map<String, String> params = new HashMap<String, String>();\r
- params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_HORIZONTAL);\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50");\r
- return params;\r
- }\r
-\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts.deprecated;
+
+import org.junit.Test;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class CustomBarChartTest extends BaseChartWebTest {
+
+ @Test
+ public void testEmptyParameters() throws IOException {
+ Map<String, String> params = new HashMap<String, String>();
+ CustomBarChart chart = new CustomBarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "custom-horizontal-bar-chart-empty.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testAllParameters() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_TITLE, "JFreeChart by Servlet");
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "750x250");
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE, "y");
+ params.put(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE, "y");
+ params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM);
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "6,2,3,7,5,1,9");
+ params.put(BaseChartWeb.CHART_PARAM_SERIES, "1,2");
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES, "0+,5+,10+,20+,30+,60+,90+");
+ params.put(BaseChartWeb.CHART_PARAM_COLORS, "FF0000,FF0000,FF0000,CC9900,CC9900,CC9900,00FF00,00FF00,00FF00");
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_UPPER, "0.05");
+ params.put(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_UPPER, "0.05");
+ params.put(BaseChartWeb.CHART_PARAM_INSETS, "20");
+ CustomBarChart chart = new CustomBarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "custom-horizontal-bar-chart-all.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testComplexityChart() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "150x100");
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_VISIBLE, "y");
+ params.put(BaseChartWeb.CHART_PARAM_RANGEAXIS_VISIBLE, "y");
+ params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_VERTICAL_CUSTOM);
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "6,2,3");
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES, "0+,5+,10+,20+,30+,60+,90+");
+ params.put(BaseChartWeb.CHART_PARAM_COLORS, "4192D9");
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_UPPER, "0.05");
+ params.put(BaseChartWeb.CHART_PARAM_CATEGORIES_AXISMARGIN_LOWER, "0.05");
+ params.put(BaseChartWeb.CHART_PARAM_SERIES_AXISMARGIN_UPPER, "0.2");
+ params.put(BaseChartWeb.CHART_PARAM_INSETS, "1");
+ params.put(BaseChartWeb.CHART_PARAM_OUTLINE_RANGEGRIDLINES_VISIBLE, "y");
+ params.put(BaseChartWeb.CHART_PARAM_OUTLINE_VISIBLE, "y");
+ CustomBarChart chart = new CustomBarChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "custom-horizontal-bar-chart-complexity.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ private Map<String, String> getDefaultParams() {
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_HORIZONTAL);
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50");
+ return params;
+ }
+
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts.deprecated;\r
-\r
-import org.junit.Test;\r
-\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-public class PieChartTest extends BaseChartWebTest {\r
-\r
- @Test\r
- public void testPieChartDefaultDimensions() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- PieChart chart = new PieChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "pie-chart-default.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testPieChartSpecificDimensions() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "200x200");\r
- PieChart chart = new PieChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "pie-chart-specific-dimensions.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testPieChartOneValue() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "100");\r
- PieChart chart = new PieChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "pie-chart-one-value.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testPieChartOthersColors() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_COLORS, "FFFF00,9900FF");\r
- PieChart chart = new PieChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "pie-chart-others-colors.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testPieChartNullValues() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, null);\r
- PieChart chart = new PieChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "pie-chart-null-values.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testPieChartWrongValues() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "wrong,value");\r
- PieChart chart = new PieChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "pie-chart-wrong-values.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testPieChartTitle() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_TITLE, "JFreeChart by Servlet");\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "200x200");\r
- PieChart chart = new PieChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "pie-chart-title.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- private Map<String, String> getDefaultParams() {\r
- Map<String, String> params = new HashMap<String, String>();\r
- params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.PIE_CHART);\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50");\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "50x50");\r
- return params;\r
- }\r
-\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts.deprecated;
+
+import org.junit.Test;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class PieChartTest extends BaseChartWebTest {
+
+ @Test
+ public void testPieChartDefaultDimensions() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ PieChart chart = new PieChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "pie-chart-default.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testPieChartSpecificDimensions() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "200x200");
+ PieChart chart = new PieChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "pie-chart-specific-dimensions.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testPieChartOneValue() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "100");
+ PieChart chart = new PieChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "pie-chart-one-value.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testPieChartOthersColors() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_COLORS, "FFFF00,9900FF");
+ PieChart chart = new PieChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "pie-chart-others-colors.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testPieChartNullValues() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, null);
+ PieChart chart = new PieChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "pie-chart-null-values.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testPieChartWrongValues() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "wrong,value");
+ PieChart chart = new PieChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "pie-chart-wrong-values.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testPieChartTitle() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_TITLE, "JFreeChart by Servlet");
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "200x200");
+ PieChart chart = new PieChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "pie-chart-title.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ private Map<String, String> getDefaultParams() {
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.PIE_CHART);
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50");
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "50x50");
+ return params;
+ }
+
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts.deprecated;\r
-\r
-import org.junit.Test;\r
-\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-public class SparkLinesChartTest extends BaseChartWebTest {\r
-\r
- @Test\r
- public void testSparkLinesChartDefaultDimensions() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- SparkLinesChart chart = new SparkLinesChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "sparklines-chart-default.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testSparklinesChartSpecificDimensions() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "200x200");\r
- SparkLinesChart chart = new SparkLinesChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "sparklines-chart-specific-dimensions.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testSparklinesChartOneValue() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,100");\r
- SparkLinesChart chart = new SparkLinesChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "sparklines-chart-one-value.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testSparklinesChartOthersColors() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_COLORS, "9900FF");\r
- SparkLinesChart chart = new SparkLinesChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "sparklines-chart-others-colors.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testSparklinesChartNullValues() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, null);\r
- SparkLinesChart chart = new SparkLinesChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "sparklines-chart-null-values.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testSparklinesChartWrongValues() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "wrong,value");\r
- SparkLinesChart chart = new SparkLinesChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "sparklines-chart-wrong-values.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testSparklinesChartTitle() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_TITLE, "JFreeChart by Servlet");\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "200x200");\r
- SparkLinesChart chart = new SparkLinesChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "sparklines-chart-title.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- @Test\r
- public void testSparklinesChartDates() throws IOException {\r
- Map<String, String> params = getDefaultParams();\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "20080101,1,20080201,4,20080301,3,20080401,5,20080501,5,20080601,7,20080701,7,20080801,8");\r
- params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "200x200");\r
- SparkLinesChart chart = new SparkLinesChart(params);\r
- BufferedImage img = chart.getChartImage();\r
- saveChart(img, "sparklines-chart-dates.png");\r
- assertChartSizeGreaterThan(img, 50);\r
- }\r
-\r
- private Map<String, String> getDefaultParams() {\r
- Map<String, String> params = new HashMap<String, String>();\r
- params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.SPARKLINES_CHART);\r
- params.put(BaseChartWeb.CHART_PARAM_VALUES, "1,1,2,4,3,3,4,5,5,5,6,7,7,7,8,8");\r
- return params;\r
- }\r
-\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts.deprecated;
+
+import org.junit.Test;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SparkLinesChartTest extends BaseChartWebTest {
+
+ @Test
+ public void testSparkLinesChartDefaultDimensions() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ SparkLinesChart chart = new SparkLinesChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "sparklines-chart-default.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testSparklinesChartSpecificDimensions() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "200x200");
+ SparkLinesChart chart = new SparkLinesChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "sparklines-chart-specific-dimensions.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testSparklinesChartOneValue() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,100");
+ SparkLinesChart chart = new SparkLinesChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "sparklines-chart-one-value.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testSparklinesChartOthersColors() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_COLORS, "9900FF");
+ SparkLinesChart chart = new SparkLinesChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "sparklines-chart-others-colors.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testSparklinesChartNullValues() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, null);
+ SparkLinesChart chart = new SparkLinesChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "sparklines-chart-null-values.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testSparklinesChartWrongValues() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "wrong,value");
+ SparkLinesChart chart = new SparkLinesChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "sparklines-chart-wrong-values.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testSparklinesChartTitle() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_TITLE, "JFreeChart by Servlet");
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "200x200");
+ SparkLinesChart chart = new SparkLinesChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "sparklines-chart-title.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ @Test
+ public void testSparklinesChartDates() throws IOException {
+ Map<String, String> params = getDefaultParams();
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "20080101,1,20080201,4,20080301,3,20080401,5,20080501,5,20080601,7,20080701,7,20080801,8");
+ params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "200x200");
+ SparkLinesChart chart = new SparkLinesChart(params);
+ BufferedImage img = chart.getChartImage();
+ saveChart(img, "sparklines-chart-dates.png");
+ assertChartSizeGreaterThan(img, 50);
+ }
+
+ private Map<String, String> getDefaultParams() {
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.SPARKLINES_CHART);
+ params.put(BaseChartWeb.CHART_PARAM_VALUES, "1,1,2,4,3,3,4,5,5,5,6,7,7,7,8,8");
+ return params;
+ }
+
}
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.charts.jruby;\r
-\r
-import org.sonar.server.charts.deprecated.BaseChartTest;\r
-\r
-import java.awt.image.BufferedImage;\r
-import java.io.IOException;\r
-import java.text.ParseException;\r
-\r
-public class TrendsChartTest extends BaseChartTest {\r
- private static final int WIDTH = 900;\r
- private static final int HEIGHT = 350;\r
-\r
- private TrendsChart chart;\r
-\r
- public void testTrendsChart() throws ParseException, IOException {\r
- chart = new TrendsChart(WIDTH, HEIGHT, "fr", true);\r
- chart.initSerie(0L, "Global", false);\r
- chart.initSerie(6L, "Efficiency", true);\r
- chart.initSerie(9L, "Maintanability", false);\r
- chart.initSerie(3L, "Portability", false);\r
- chart.initSerie(24L, "Reliability", true);\r
- chart.initSerie(60L, "Usability", false);\r
-\r
- chart.addMeasure(20.0, stringToDate("12-10-07 8h30"), 0L);\r
- chart.addMeasure(35.0, stringToDate("12-10-07 8h30"), 6L);\r
- chart.addMeasure(12.4, stringToDate("12-10-07 8h30"), 9L);\r
- chart.addMeasure(99.99, stringToDate("12-10-07 8h30"), 3L);\r
- chart.addMeasure(2.3, stringToDate("12-10-07 8h30"), 24L);\r
- chart.addMeasure(12.5, stringToDate("12-10-07 8h30"), 60L);\r
-\r
- chart.addMeasure(10.0, stringToDate("12-11-07 8h30"), 0L);\r
- chart.addMeasure(30.0, stringToDate("12-11-07 8h30"), 6L);\r
- chart.addMeasure(22.4, stringToDate("12-11-07 8h30"), 9L);\r
- chart.addMeasure(99.99, stringToDate("12-11-07 8h30"), 3L);\r
- chart.addMeasure(0.3, stringToDate("12-11-07 8h30"), 24L);\r
- chart.addMeasure(12.5, stringToDate("12-11-07 8h30"), 60L);\r
-\r
- chart.addMeasure(30.0, stringToDate("12-12-07 8h30"), 0L);\r
- chart.addMeasure(15.0, stringToDate("12-12-07 8h30"), 6L);\r
- chart.addMeasure(82.4, stringToDate("12-12-07 8h30"), 9L);\r
- chart.addMeasure(99.99, stringToDate("12-12-07 8h30"), 3L);\r
- chart.addMeasure(52.3, stringToDate("12-12-07 8h30"), 24L);\r
- chart.addMeasure(12.5, stringToDate("12-12-07 8h30"), 60L);\r
-\r
- chart.addLabel(stringToDate("12-11-07 12h35"), "Label A");\r
- chart.addLabel(stringToDate("11-11-07 12h35"), "Label B", true);\r
-\r
- BufferedImage img = chart.getChartImage();\r
- assertChartSizeGreaterThan(img, 1000);\r
- saveChart(img, "trends-chart.png");\r
- }\r
-\r
-\r
- public void testSingleSerieWithoutLegends() throws ParseException, IOException {\r
- chart = new TrendsChart(WIDTH, HEIGHT, "fr", false);\r
- chart.initSerie(0L, "single", false);\r
-\r
- chart.addMeasure(20.0, stringToDate("12-10-07 8h30"), 0L);\r
- chart.addMeasure(10.0, stringToDate("12-11-07 8h30"), 0L);\r
- chart.addMeasure(30.0, stringToDate("12-12-07 8h30"), 0L);\r
-\r
- BufferedImage img = chart.getChartImage();\r
- assertChartSizeGreaterThan(img, 1000);\r
- saveChart(img, "trends-single-without-legends.png");\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.charts.jruby;
+
+import org.sonar.server.charts.deprecated.BaseChartTest;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.text.ParseException;
+
+public class TrendsChartTest extends BaseChartTest {
+ private static final int WIDTH = 900;
+ private static final int HEIGHT = 350;
+
+ private TrendsChart chart;
+
+ public void testTrendsChart() throws ParseException, IOException {
+ chart = new TrendsChart(WIDTH, HEIGHT, "fr", true);
+ chart.initSerie(0L, "Global", false);
+ chart.initSerie(6L, "Efficiency", true);
+ chart.initSerie(9L, "Maintanability", false);
+ chart.initSerie(3L, "Portability", false);
+ chart.initSerie(24L, "Reliability", true);
+ chart.initSerie(60L, "Usability", false);
+
+ chart.addMeasure(20.0, stringToDate("12-10-07 8h30"), 0L);
+ chart.addMeasure(35.0, stringToDate("12-10-07 8h30"), 6L);
+ chart.addMeasure(12.4, stringToDate("12-10-07 8h30"), 9L);
+ chart.addMeasure(99.99, stringToDate("12-10-07 8h30"), 3L);
+ chart.addMeasure(2.3, stringToDate("12-10-07 8h30"), 24L);
+ chart.addMeasure(12.5, stringToDate("12-10-07 8h30"), 60L);
+
+ chart.addMeasure(10.0, stringToDate("12-11-07 8h30"), 0L);
+ chart.addMeasure(30.0, stringToDate("12-11-07 8h30"), 6L);
+ chart.addMeasure(22.4, stringToDate("12-11-07 8h30"), 9L);
+ chart.addMeasure(99.99, stringToDate("12-11-07 8h30"), 3L);
+ chart.addMeasure(0.3, stringToDate("12-11-07 8h30"), 24L);
+ chart.addMeasure(12.5, stringToDate("12-11-07 8h30"), 60L);
+
+ chart.addMeasure(30.0, stringToDate("12-12-07 8h30"), 0L);
+ chart.addMeasure(15.0, stringToDate("12-12-07 8h30"), 6L);
+ chart.addMeasure(82.4, stringToDate("12-12-07 8h30"), 9L);
+ chart.addMeasure(99.99, stringToDate("12-12-07 8h30"), 3L);
+ chart.addMeasure(52.3, stringToDate("12-12-07 8h30"), 24L);
+ chart.addMeasure(12.5, stringToDate("12-12-07 8h30"), 60L);
+
+ chart.addLabel(stringToDate("12-11-07 12h35"), "Label A");
+ chart.addLabel(stringToDate("11-11-07 12h35"), "Label B", true);
+
+ BufferedImage img = chart.getChartImage();
+ assertChartSizeGreaterThan(img, 1000);
+ saveChart(img, "trends-chart.png");
+ }
+
+
+ public void testSingleSerieWithoutLegends() throws ParseException, IOException {
+ chart = new TrendsChart(WIDTH, HEIGHT, "fr", false);
+ chart.initSerie(0L, "single", false);
+
+ chart.addMeasure(20.0, stringToDate("12-10-07 8h30"), 0L);
+ chart.addMeasure(10.0, stringToDate("12-11-07 8h30"), 0L);
+ chart.addMeasure(30.0, stringToDate("12-12-07 8h30"), 0L);
+
+ BufferedImage img = chart.getChartImage();
+ assertChartSizeGreaterThan(img, 1000);
+ saveChart(img, "trends-single-without-legends.png");
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package org.sonar.server.startup;\r
-\r
-import static org.junit.Assert.assertFalse;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import org.junit.Test;\r
-import org.sonar.api.measures.CoreMetrics;\r
-import org.sonar.api.measures.Metric;\r
-import org.sonar.jpa.dao.MeasuresDao;\r
-import org.sonar.jpa.test.AbstractDbUnitTestCase;\r
-\r
-import java.sql.SQLException;\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-public class RegisterMetricsTest extends AbstractDbUnitTestCase {\r
-\r
- @Test\r
- public void shouldSaveIfNew() {\r
- setupData("shouldSaveIfNew");\r
-\r
- Metric metric1 = new Metric("new1", "short1", "desc1", Metric.ValueType.FLOAT, 1, true, "domain1", false);\r
- Metric metric2 = new Metric("new2", "short2", "desc2", Metric.ValueType.FLOAT, 1, true, "domain2", false);\r
- RegisterMetrics synchronizer = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);\r
- synchronizer.register(Arrays.asList(metric1, metric2));\r
- checkTables("shouldSaveIfNew", "metrics");\r
- }\r
-\r
- @Test\r
- public void shouldUpdateIfAlreadyExists() {\r
- setupData("shouldUpdateIfAlreadyExists");\r
-\r
- final List<Metric> metrics = new ArrayList<Metric>();\r
- metrics.add(new Metric("key", "new short name", "new description", Metric.ValueType.FLOAT, -1, true, "new domain", false));\r
- RegisterMetrics synchronizer = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);\r
- synchronizer.register(metrics);\r
-\r
- checkTables("shouldUpdateIfAlreadyExists", "metrics");\r
- }\r
-\r
- @Test\r
- public void enableOnlyLoadedMetrics() throws SQLException {\r
- setupData("enableOnlyLoadedMetrics");\r
-\r
- RegisterMetrics loader = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);\r
- loader.start();\r
-\r
- assertFalse(getDao().getMeasuresDao().getMetric("deprecated").getEnabled());\r
- assertTrue(getDao().getMeasuresDao().getMetric(CoreMetrics.COMPLEXITY).getEnabled());\r
- }\r
-\r
- @Test\r
- public void cleanAlerts() throws SQLException {\r
- setupData("cleanAlerts");\r
-\r
- RegisterMetrics loader = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);\r
- loader.cleanAlerts();\r
-\r
- checkTables("cleanAlerts", "metrics", "alerts");\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.startup;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.Metric;
+import org.sonar.jpa.dao.MeasuresDao;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class RegisterMetricsTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void shouldSaveIfNew() {
+ setupData("shouldSaveIfNew");
+
+ Metric metric1 = new Metric("new1", "short1", "desc1", Metric.ValueType.FLOAT, 1, true, "domain1", false);
+ Metric metric2 = new Metric("new2", "short2", "desc2", Metric.ValueType.FLOAT, 1, true, "domain2", false);
+ RegisterMetrics synchronizer = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);
+ synchronizer.register(Arrays.asList(metric1, metric2));
+ checkTables("shouldSaveIfNew", "metrics");
+ }
+
+ @Test
+ public void shouldUpdateIfAlreadyExists() {
+ setupData("shouldUpdateIfAlreadyExists");
+
+ final List<Metric> metrics = new ArrayList<Metric>();
+ metrics.add(new Metric("key", "new short name", "new description", Metric.ValueType.FLOAT, -1, true, "new domain", false));
+ RegisterMetrics synchronizer = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);
+ synchronizer.register(metrics);
+
+ checkTables("shouldUpdateIfAlreadyExists", "metrics");
+ }
+
+ @Test
+ public void enableOnlyLoadedMetrics() throws SQLException {
+ setupData("enableOnlyLoadedMetrics");
+
+ RegisterMetrics loader = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);
+ loader.start();
+
+ assertFalse(getDao().getMeasuresDao().getMetric("deprecated").getEnabled());
+ assertTrue(getDao().getMeasuresDao().getMetric(CoreMetrics.COMPLEXITY).getEnabled());
+ }
+
+ @Test
+ public void cleanAlerts() throws SQLException {
+ setupData("cleanAlerts");
+
+ RegisterMetrics loader = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);
+ loader.cleanAlerts();
+
+ checkTables("cleanAlerts", "metrics", "alerts");
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
source = new SourceUnmarshaller().toModel(loadFile("/sources/source.json"));
assertThat(source.getLines().size(), is(236));
- assertThat(source.getLine(3), is(" * Copyright (C) 2009 SonarSource SA"));
+ assertThat(source.getLine(3), is(" * Copyright (C) 2008-2011 SonarSource"));
}
@Test
Source source = new SourceUnmarshaller().toModel(loadFile("/sources/from_line_to_line.json"));
assertThat(source.getLines().size(), is(15));
assertThat(source.getLine(1), nullValue());
- assertThat(source.getLine(3), is(" * Copyright (C) 2009 SonarSource SA"));
+ assertThat(source.getLine(3), is(" * Copyright (C) 2008-2011 SonarSource"));
}
}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
-[{"3":" * Copyright (C) 2009 SonarSource SA","4":" * mailto:contact AT sonarsource DOT com","5":" *","6":" * Sonar is free software; you can redistribute it and\/or","7":" * modify it under the terms of the GNU Lesser General Public","8":" * License as published by the Free Software Foundation; either","9":" * version 3 of the License, or (at your option) any later version.","10":" *","11":" * Sonar is distributed in the hope that it will be useful,","12":" * but WITHOUT ANY WARRANTY; without even the implied warranty of","13":" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU","14":" * Lesser General Public License for more details.","15":" *","16":" * You should have received a copy of the GNU Lesser General Public","17":" * License along with Sonar; if not, write to the Free Software"}]
\ No newline at end of file
+[{"3":" * Copyright (C) 2008-2011 SonarSource","4":" * mailto:contact AT sonarsource DOT com","5":" *","6":" * Sonar is free software; you can redistribute it and\/or","7":" * modify it under the terms of the GNU Lesser General Public","8":" * License as published by the Free Software Foundation; either","9":" * version 3 of the License, or (at your option) any later version.","10":" *","11":" * Sonar is distributed in the hope that it will be useful,","12":" * but WITHOUT ANY WARRANTY; without even the implied warranty of","13":" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU","14":" * Lesser General Public License for more details.","15":" *","16":" * You should have received a copy of the GNU Lesser General Public","17":" * License along with Sonar; if not, write to the Free Software"}]
\ No newline at end of file
-[{"1":"\/*","2":" * Sonar, open source software quality management tool.","3":" * Copyright (C) 2009 SonarSource SA","4":" * mailto:contact AT sonarsource DOT com","5":" *","6":" * Sonar is free software; you can redistribute it and\/or","7":" * modify it under the terms of the GNU Lesser General Public","8":" * License as published by the Free Software Foundation; either","9":" * version 3 of the License, or (at your option) any later version.","10":" *","11":" * Sonar is distributed in the hope that it will be useful,","12":" * but WITHOUT ANY WARRANTY; without even the implied warranty of","13":" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU","14":" * Lesser General Public License for more details.","15":" *","16":" * You should have received a copy of the GNU Lesser General Public","17":" * License along with Sonar; if not, write to the Free Software","18":" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02","19":" *\/","20":"package org.sonar.api.utils;","21":"","22":"import com.google.common.collect.Multiset;","23":"import org.apache.commons.collections.Bag;","24":"import org.apache.commons.lang.StringUtils;","25":"import org.apache.commons.lang.math.NumberUtils;","26":"import org.sonar.api.rules.RulePriority;","27":"import org.slf4j.LoggerFactory;","28":"","29":"import java.util.HashMap;","30":"import java.util.Map;","31":"","32":"\/**","33":" * Util class to format key\/value data. Output is a string representation ready to be","34":" * injected into the database","35":" *","36":" * @since 1.10","37":" *\/","38":"public final class KeyValueFormat {","39":"","40":" private KeyValueFormat() {","41":" }","42":"","43":" \/**","44":" * Transforms a string with the following format : "key1=value1;key2=value2..."","45":" * into a Map<KEY, VALUE>. Requires to implement the transform(key,value) method","46":" *","47":" * @param data the input string","48":" * @param transformer the interface to implement","49":" * @return a Map of <key, value>","50":" *\/","51":" public static <KEY, VALUE> Map<KEY, VALUE> parse(String data, Transformer<KEY, VALUE> transformer) {","52":" Map<String, String> rawData = parse(data);","53":" Map<KEY, VALUE> map = new HashMap<KEY, VALUE>();","54":" for (Map.Entry<String, String> entry : rawData.entrySet()) {","55":" KeyValue<KEY, VALUE> keyVal = transformer.transform(entry.getKey(), entry.getValue());","56":" if (keyVal != null) {","57":" map.put(keyVal.getKey(), keyVal.getValue());","58":" }","59":" }","60":" return map;","61":" }","62":"","63":" \/**","64":" * Transforms a string with the following format : "key1=value1;key2=value2..."","65":" * into a Map<String,String>","66":" *","67":" * @param data the string to parse","68":" * @return a map","69":" *\/","70":" public static Map<String, String> parse(String data) {","71":" Map<String, String> map = new HashMap<String, String>();","72":" String[] pairs = StringUtils.split(data, ";");","73":" for (String pair : pairs) {","74":" String[] keyValue = StringUtils.split(pair, "=");","75":" String key = keyValue[0];","76":" String value = (keyValue.length == 2 ? keyValue[1] : "");","77":" map.put(key, value);","78":" }","79":" return map;","80":" }","81":"","82":" \/**","83":" * Transforms a map<KEY,VALUE> into a string with the format : "key1=value1;key2=value2..."","84":" *","85":" * @param map the map to transform","86":" * @return the formatted string","87":" *\/","88":" public static <KEY, VALUE> String format(Map<KEY, VALUE> map) {","89":" StringBuilder sb = new StringBuilder();","90":" boolean first = true;","91":" for (Map.Entry<?, ?> entry : map.entrySet()) {","92":" if (!first) {","93":" sb.append(";");","94":" }","95":" sb.append(entry.getKey().toString());","96":" sb.append("=");","97":" if (entry.getValue() != null) {","98":" sb.append(entry.getValue());","99":" }","100":" first = false;","101":" }","102":"","103":" return sb.toString();","104":" }","105":"","106":" \/**","107":" * @since 1.11","108":" * @deprecated use Multiset from google collections instead of commons-collections bags","109":" *\/","110":" public static String format(Bag bag) {","111":" return format(bag, 0);","112":" }","113":"","114":" \/**","115":" * @since 1.11","116":" * @deprecated use Multiset from google collections instead of commons-collections bags","117":" *\/","118":" public static String format(Bag bag, int var) {","119":" StringBuilder sb = new StringBuilder();","120":" boolean first = true;","121":" for (Object obj : bag.uniqueSet()) {","122":" if (!first) {","123":" sb.append(";");","124":" }","125":" sb.append(obj.toString());","126":" sb.append("=");","127":" sb.append(bag.getCount(obj) + var);","128":" first = false;","129":" }","130":"","131":" return sb.toString();","132":" }","133":"","134":" \/**","135":" * Transforms a Multiset<?> into a string with the format : "key1=count1;key2=count2..."","136":" *","137":" * @param set the set to transform","138":" * @return the formatted string","139":" *\/","140":" public static String format(Multiset<?> set) {","141":" StringBuilder sb = new StringBuilder();","142":" boolean first = true;","143":" for (Multiset.Entry<?> entry : set.entrySet()) {","144":" if (!first) {","145":" sb.append(";");","146":" }","147":" sb.append(entry.getElement().toString());","148":" sb.append("=");","149":" sb.append(entry.getCount());","150":" first = false;","151":" }","152":" return sb.toString();","153":" }","154":"","155":" \/**","156":" * Transforms a Object... into a string with the format : "object1=object2;object3=object4..."","157":" *","158":" * @param objects the object list to transform","159":" * @return the formatted string","160":" *\/","161":" public static String format(Object... objects) {","162":" StringBuilder sb = new StringBuilder();","163":" boolean first = true;","164":" if (objects != null) {","165":" for (int i = 0; i < objects.length; i++) {","166":" if (!first) {","167":" sb.append(";");","168":" }","169":" sb.append(objects[i++].toString());","170":" sb.append("=");","171":" sb.append(objects[i]);","172":" first = false;","173":" }","174":" }","175":" return sb.toString();","176":" }","177":"","178":" public interface Transformer<KEY, VALUE> {","179":" KeyValue<KEY, VALUE> transform(String key, String value);","180":" }","181":"","182":" \/**","183":" * Implementation of Transformer<String, Double>","184":" *\/","185":" public static class StringNumberPairTransformer implements Transformer<String, Double> {","186":"","187":" public KeyValue<String, Double> transform(String key, String value) {","188":" return new KeyValue<String, Double>(key, toDouble(value));","189":" }","190":" }","191":"","192":" \/**","193":" * Implementation of Transformer<Double, Double>","194":" *\/","195":" public static class DoubleNumbersPairTransformer implements Transformer<Double, Double> {","196":"","197":" public KeyValue<Double, Double> transform(String key, String value) {","198":" return new KeyValue<Double, Double>(toDouble(key), toDouble(value));","199":" }","200":" }","201":"","202":" \/**","203":" * Implementation of Transformer<Integer, Integer>","204":" *\/","205":" public static class IntegerNumbersPairTransformer implements Transformer<Integer, Integer> {","206":"","207":" public KeyValue<Integer, Integer> transform(String key, String value) {","208":" return new KeyValue<Integer, Integer>(toInteger(key), toInteger(value));","209":" }","210":" }","211":"","212":" \/**","213":" * Implementation of Transformer<RulePriority, Integer>","214":" *\/","215":" public static class RulePriorityNumbersPairTransformer implements Transformer<RulePriority, Integer> {","216":"","217":" public KeyValue<RulePriority, Integer> transform(String key, String value) {","218":" try {","219":" if (StringUtils.isBlank(value)) { value = "0"; }","220":" return new KeyValue<RulePriority, Integer>(RulePriority.valueOf(key.toUpperCase()), Integer.parseInt(value));","221":" }","222":" catch (Exception e) {","223":" LoggerFactory.getLogger(RulePriorityNumbersPairTransformer.class).warn("Property " + key + " has invalid value: " + value, e);","224":" return null;","225":" }","226":" }","227":" }","228":"","229":" private static Double toDouble(String value) {","230":" return StringUtils.isBlank(value) ? null : NumberUtils.toDouble(value);","231":" }","232":"","233":" private static Integer toInteger(String value) {","234":" return StringUtils.isBlank(value) ? null : NumberUtils.toInt(value);","235":" }","236":"}"}]
\ No newline at end of file
+[{"1":"\/*","2":" * Sonar, open source software quality management tool.","3":" * Copyright (C) 2008-2011 SonarSource","4":" * mailto:contact AT sonarsource DOT com","5":" *","6":" * Sonar is free software; you can redistribute it and\/or","7":" * modify it under the terms of the GNU Lesser General Public","8":" * License as published by the Free Software Foundation; either","9":" * version 3 of the License, or (at your option) any later version.","10":" *","11":" * Sonar is distributed in the hope that it will be useful,","12":" * but WITHOUT ANY WARRANTY; without even the implied warranty of","13":" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU","14":" * Lesser General Public License for more details.","15":" *","16":" * You should have received a copy of the GNU Lesser General Public","17":" * License along with Sonar; if not, write to the Free Software","18":" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02","19":" *\/","20":"package org.sonar.api.utils;","21":"","22":"import com.google.common.collect.Multiset;","23":"import org.apache.commons.collections.Bag;","24":"import org.apache.commons.lang.StringUtils;","25":"import org.apache.commons.lang.math.NumberUtils;","26":"import org.sonar.api.rules.RulePriority;","27":"import org.slf4j.LoggerFactory;","28":"","29":"import java.util.HashMap;","30":"import java.util.Map;","31":"","32":"\/**","33":" * Util class to format key\/value data. Output is a string representation ready to be","34":" * injected into the database","35":" *","36":" * @since 1.10","37":" *\/","38":"public final class KeyValueFormat {","39":"","40":" private KeyValueFormat() {","41":" }","42":"","43":" \/**","44":" * Transforms a string with the following format : "key1=value1;key2=value2..."","45":" * into a Map<KEY, VALUE>. Requires to implement the transform(key,value) method","46":" *","47":" * @param data the input string","48":" * @param transformer the interface to implement","49":" * @return a Map of <key, value>","50":" *\/","51":" public static <KEY, VALUE> Map<KEY, VALUE> parse(String data, Transformer<KEY, VALUE> transformer) {","52":" Map<String, String> rawData = parse(data);","53":" Map<KEY, VALUE> map = new HashMap<KEY, VALUE>();","54":" for (Map.Entry<String, String> entry : rawData.entrySet()) {","55":" KeyValue<KEY, VALUE> keyVal = transformer.transform(entry.getKey(), entry.getValue());","56":" if (keyVal != null) {","57":" map.put(keyVal.getKey(), keyVal.getValue());","58":" }","59":" }","60":" return map;","61":" }","62":"","63":" \/**","64":" * Transforms a string with the following format : "key1=value1;key2=value2..."","65":" * into a Map<String,String>","66":" *","67":" * @param data the string to parse","68":" * @return a map","69":" *\/","70":" public static Map<String, String> parse(String data) {","71":" Map<String, String> map = new HashMap<String, String>();","72":" String[] pairs = StringUtils.split(data, ";");","73":" for (String pair : pairs) {","74":" String[] keyValue = StringUtils.split(pair, "=");","75":" String key = keyValue[0];","76":" String value = (keyValue.length == 2 ? keyValue[1] : "");","77":" map.put(key, value);","78":" }","79":" return map;","80":" }","81":"","82":" \/**","83":" * Transforms a map<KEY,VALUE> into a string with the format : "key1=value1;key2=value2..."","84":" *","85":" * @param map the map to transform","86":" * @return the formatted string","87":" *\/","88":" public static <KEY, VALUE> String format(Map<KEY, VALUE> map) {","89":" StringBuilder sb = new StringBuilder();","90":" boolean first = true;","91":" for (Map.Entry<?, ?> entry : map.entrySet()) {","92":" if (!first) {","93":" sb.append(";");","94":" }","95":" sb.append(entry.getKey().toString());","96":" sb.append("=");","97":" if (entry.getValue() != null) {","98":" sb.append(entry.getValue());","99":" }","100":" first = false;","101":" }","102":"","103":" return sb.toString();","104":" }","105":"","106":" \/**","107":" * @since 1.11","108":" * @deprecated use Multiset from google collections instead of commons-collections bags","109":" *\/","110":" public static String format(Bag bag) {","111":" return format(bag, 0);","112":" }","113":"","114":" \/**","115":" * @since 1.11","116":" * @deprecated use Multiset from google collections instead of commons-collections bags","117":" *\/","118":" public static String format(Bag bag, int var) {","119":" StringBuilder sb = new StringBuilder();","120":" boolean first = true;","121":" for (Object obj : bag.uniqueSet()) {","122":" if (!first) {","123":" sb.append(";");","124":" }","125":" sb.append(obj.toString());","126":" sb.append("=");","127":" sb.append(bag.getCount(obj) + var);","128":" first = false;","129":" }","130":"","131":" return sb.toString();","132":" }","133":"","134":" \/**","135":" * Transforms a Multiset<?> into a string with the format : "key1=count1;key2=count2..."","136":" *","137":" * @param set the set to transform","138":" * @return the formatted string","139":" *\/","140":" public static String format(Multiset<?> set) {","141":" StringBuilder sb = new StringBuilder();","142":" boolean first = true;","143":" for (Multiset.Entry<?> entry : set.entrySet()) {","144":" if (!first) {","145":" sb.append(";");","146":" }","147":" sb.append(entry.getElement().toString());","148":" sb.append("=");","149":" sb.append(entry.getCount());","150":" first = false;","151":" }","152":" return sb.toString();","153":" }","154":"","155":" \/**","156":" * Transforms a Object... into a string with the format : "object1=object2;object3=object4..."","157":" *","158":" * @param objects the object list to transform","159":" * @return the formatted string","160":" *\/","161":" public static String format(Object... objects) {","162":" StringBuilder sb = new StringBuilder();","163":" boolean first = true;","164":" if (objects != null) {","165":" for (int i = 0; i < objects.length; i++) {","166":" if (!first) {","167":" sb.append(";");","168":" }","169":" sb.append(objects[i++].toString());","170":" sb.append("=");","171":" sb.append(objects[i]);","172":" first = false;","173":" }","174":" }","175":" return sb.toString();","176":" }","177":"","178":" public interface Transformer<KEY, VALUE> {","179":" KeyValue<KEY, VALUE> transform(String key, String value);","180":" }","181":"","182":" \/**","183":" * Implementation of Transformer<String, Double>","184":" *\/","185":" public static class StringNumberPairTransformer implements Transformer<String, Double> {","186":"","187":" public KeyValue<String, Double> transform(String key, String value) {","188":" return new KeyValue<String, Double>(key, toDouble(value));","189":" }","190":" }","191":"","192":" \/**","193":" * Implementation of Transformer<Double, Double>","194":" *\/","195":" public static class DoubleNumbersPairTransformer implements Transformer<Double, Double> {","196":"","197":" public KeyValue<Double, Double> transform(String key, String value) {","198":" return new KeyValue<Double, Double>(toDouble(key), toDouble(value));","199":" }","200":" }","201":"","202":" \/**","203":" * Implementation of Transformer<Integer, Integer>","204":" *\/","205":" public static class IntegerNumbersPairTransformer implements Transformer<Integer, Integer> {","206":"","207":" public KeyValue<Integer, Integer> transform(String key, String value) {","208":" return new KeyValue<Integer, Integer>(toInteger(key), toInteger(value));","209":" }","210":" }","211":"","212":" \/**","213":" * Implementation of Transformer<RulePriority, Integer>","214":" *\/","215":" public static class RulePriorityNumbersPairTransformer implements Transformer<RulePriority, Integer> {","216":"","217":" public KeyValue<RulePriority, Integer> transform(String key, String value) {","218":" try {","219":" if (StringUtils.isBlank(value)) { value = "0"; }","220":" return new KeyValue<RulePriority, Integer>(RulePriority.valueOf(key.toUpperCase()), Integer.parseInt(value));","221":" }","222":" catch (Exception e) {","223":" LoggerFactory.getLogger(RulePriorityNumbersPairTransformer.class).warn("Property " + key + " has invalid value: " + value, e);","224":" return null;","225":" }","226":" }","227":" }","228":"","229":" private static Double toDouble(String value) {","230":" return StringUtils.isBlank(value) ? null : NumberUtils.toDouble(value);","231":" }","232":"","233":" private static Integer toInteger(String value) {","234":" return StringUtils.isBlank(value) ? null : NumberUtils.toInt(value);","235":" }","236":"}"}]
\ No newline at end of file
-/*\r
- * Sonar, open source software quality management tool.\r
- * Copyright (C) 2009 SonarSource SA\r
- * mailto:contact AT sonarsource DOT com\r
- *\r
- * Sonar is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or (at your option) any later version.\r
- *\r
- * Sonar is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with Sonar; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
- */\r
-package itests;\r
-\r
-import itests.footer.SampleFooter;\r
-import itests.languages.LanguageWithoutRulesEngine;\r
-import itests.page.GwtSamplePage;\r
-import itests.page.RubyApiTestsPage;\r
-import itests.resourcetab.SampleResourceTab;\r
-import itests.ws.RubyWebService;\r
-import org.sonar.api.Plugin;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-public class ITestsPlugin implements Plugin {\r
-\r
- public String getKey() {\r
- return "it";\r
- }\r
-\r
- public String getName() {\r
- return "Integration tests";\r
- }\r
-\r
- public String getDescription() {\r
- return "Integration tests";\r
- }\r
-\r
- public List getExtensions() {\r
- List extensions = new ArrayList();\r
-\r
- extensions.add(SampleSensor.class);\r
- extensions.add(LanguageWithoutRulesEngine.class);\r
- extensions.add(ServerSideExtensionUsingExternalDependency.class);\r
- extensions.add(ExcludedResourceFilter.class);\r
-\r
- // web\r
- extensions.add(SampleResourceTab.class);\r
- extensions.add(SampleFooter.class);\r
- extensions.add(GwtSamplePage.class);\r
- extensions.add(RubyApiTestsPage.class);\r
- \r
- // web service\r
- extensions.add(RubyWebService.class);\r
-\r
- return extensions;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return getKey();\r
- }\r
-}\r
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package itests;
+
+import itests.footer.SampleFooter;
+import itests.languages.LanguageWithoutRulesEngine;
+import itests.page.GwtSamplePage;
+import itests.page.RubyApiTestsPage;
+import itests.resourcetab.SampleResourceTab;
+import itests.ws.RubyWebService;
+import org.sonar.api.Plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ITestsPlugin implements Plugin {
+
+ public String getKey() {
+ return "it";
+ }
+
+ public String getName() {
+ return "Integration tests";
+ }
+
+ public String getDescription() {
+ return "Integration tests";
+ }
+
+ public List getExtensions() {
+ List extensions = new ArrayList();
+
+ extensions.add(SampleSensor.class);
+ extensions.add(LanguageWithoutRulesEngine.class);
+ extensions.add(ServerSideExtensionUsingExternalDependency.class);
+ extensions.add(ExcludedResourceFilter.class);
+
+ // web
+ extensions.add(SampleResourceTab.class);
+ extensions.add(SampleFooter.class);
+ extensions.add(GwtSamplePage.class);
+ extensions.add(RubyApiTestsPage.class);
+
+ // web service
+ extensions.add(RubyWebService.class);
+
+ return extensions;
+ }
+
+ @Override
+ public String toString() {
+ return getKey();
+ }
+}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
#
# Sonar, open source software quality management tool.
-# Copyright (C) 2009 SonarSource SA
+# Copyright (C) 2008-2011 SonarSource
# mailto:contact AT sonarsource DOT com
#
# Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or