Permalink
Browse files

Merge pull request #32 from jenkinsci/vgaidarji/make-compatible-with-…

…pipeline

[JENKINS-35571] Make compatible with Pipeline
  • Loading branch information...
vgaidarji committed Nov 2, 2017
2 parents 2995edb + a012cb6 commit 7141331f3e7c5e55638328ce519a1daefec9e038
Showing with 858 additions and 283 deletions.
  1. +2 −0 .gitignore
  2. +27 −3 pom.xml
  3. +37 −21 src/main/java/hudson/plugins/plot/CSVSeries.java
  4. +4 −4 src/main/java/hudson/plugins/plot/MatrixPlotAction.java
  5. +6 −6 src/main/java/hudson/plugins/plot/MatrixPlotPublisher.java
  6. +90 −76 src/main/java/hudson/plugins/plot/Plot.java
  7. +29 −16 src/main/java/hudson/plugins/plot/PlotAction.java
  8. +42 −0 src/main/java/hudson/plugins/plot/PlotBuildAction.java
  9. +198 −0 src/main/java/hudson/plugins/plot/PlotBuilder.java
  10. +9 −14 src/main/java/hudson/plugins/plot/PlotCategoryDataset.java
  11. +7 −9 src/main/java/hudson/plugins/plot/PlotDescriptor.java
  12. +43 −35 src/main/java/hudson/plugins/plot/PlotPublisher.java
  13. +24 −13 src/main/java/hudson/plugins/plot/PlotReport.java
  14. +23 −2 src/main/java/hudson/plugins/plot/PropertiesSeries.java
  15. +26 −8 src/main/java/hudson/plugins/plot/Series.java
  16. +1 −4 src/main/java/hudson/plugins/plot/SeriesFactory.java
  17. +35 −30 src/main/java/hudson/plugins/plot/XMLSeries.java
  18. +1 −0 src/main/resources/hudson/plugins/plot/AbstractPlotPublisher/config.jelly
  19. +1 −0 src/main/resources/hudson/plugins/plot/AbstractPlotPublisher/help.jelly
  20. +65 −0 src/main/resources/hudson/plugins/plot/CSVSeries/config.jelly
  21. +1 −0 src/main/resources/hudson/plugins/plot/MatrixPlotAction/index.jelly
  22. +4 −0 src/main/resources/hudson/plugins/plot/Messages.properties
  23. +3 −2 src/main/resources/hudson/plugins/plot/PlotAction/index.jelly
  24. +82 −0 src/main/resources/hudson/plugins/plot/PlotBuilder/config.jelly
  25. +2 −1 src/main/resources/hudson/plugins/plot/PlotReport/index.jelly
  26. +1 −0 src/main/resources/hudson/plugins/plot/PlotReport/table_report.jelly
  27. +21 −0 src/main/resources/hudson/plugins/plot/PropertiesSeries/config.jelly
  28. +54 −0 src/main/resources/hudson/plugins/plot/XMLSeries/config.jelly
  29. +1 −0 src/main/resources/index.jelly
  30. +2 −3 src/test/java/hudson/plugins/plot/CSVReaderTest.java
  31. +1 −3 src/test/java/hudson/plugins/plot/CSVSeriesTest.java
  32. +2 −1 src/test/java/hudson/plugins/plot/PlotTest.java
  33. +2 −4 src/test/java/hudson/plugins/plot/PropertiesSeriesTest.java
  34. +0 −2 src/test/java/hudson/plugins/plot/SeriesFactoryTest.java
  35. +0 −1 src/test/java/hudson/plugins/plot/SeriesTestCase.java
  36. +12 −25 src/test/java/hudson/plugins/plot/XMLSeriesTest.java
@@ -3,3 +3,5 @@ work
.classpath
.project
.settings
*.iml
.idea
30 pom.xml
@@ -1,15 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.565</version>
<version>2.32</version>
<relativePath/>
</parent>

<properties>
<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. -->
<jenkins.version>1.625.3</jenkins.version>
<!-- Java Level to use. Java 7 required when using core >= 1.612 -->
<java.level>7</java.level>
</properties>

<artifactId>plot</artifactId>
<packaging>hpi</packaging>
<name>Plot plugin</name>
<version>1.12-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Plot+Plugin</url>

<developers>
@@ -21,13 +30,28 @@
<id>ericbn</id>
<name>Eric Nielsen</name>
</developer>
<developer>
<id>vgaidarji</id>
<name>Veaceslav Gaidarji</name>
<email>veaceslav.gaidarji@gmail.com</email>
</developer>
</developers>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<version>1.0</version>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1.20</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
@@ -5,12 +5,15 @@

package hudson.plugins.plot;

import hudson.Extension;
import hudson.FilePath;

import hudson.model.Descriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -21,12 +24,14 @@

import javax.servlet.ServletException;

import net.sf.json.JSONObject;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.ObjectUtils;
import org.kohsuke.stapler.DataBoundConstructor;

import au.com.bytecode.opencsv.CSVReader;
import org.kohsuke.stapler.StaplerRequest;

/**
* Represents a plot data series configuration from an CSV file.
@@ -72,16 +77,6 @@

private boolean displayTableFlag;

/**
*
* @param file
* @param label
* @param req
* Stapler request
* @param radioButtonId
* ID used to find the parameters specific to this instance.
* @throws ServletException
*/
@DataBoundConstructor
public CSVSeries(String file, String url, String inclusionFlag,
String exclusionValues, boolean displayTableFlag) {
@@ -128,9 +123,9 @@ public boolean getDisplayTableFlag() {
InputStreamReader inputReader = null;

try {
List<PlotPoint> ret = new ArrayList<PlotPoint>();
List<PlotPoint> ret = new ArrayList<>();

FilePath[] seriesFiles = null;
FilePath[] seriesFiles;
try {
seriesFiles = workspaceRootDir.list(getFile());
} catch (Exception e) {
@@ -163,7 +158,7 @@ public boolean getDisplayTableFlag() {
+ getFile());

// load existing plot file
inputReader = new InputStreamReader(in);
inputReader = new InputStreamReader(in, Charset.defaultCharset().name());
reader = new CSVReader(inputReader);
String[] nextLine;

@@ -239,15 +234,14 @@ public boolean getDisplayTableFlag() {
/**
* This function checks the exclusion/inclusion filters from the properties
* file and returns true if a point should be excluded.
*
*
* @return true if the point should be excluded based on label or column
*/
private boolean excludePoint(String label, int index) {
if (inclusionFlag == null || inclusionFlag == InclusionFlag.OFF)
return false;

boolean retVal = false;

boolean retVal;
switch (inclusionFlag) {
case INCLUDE_BY_STRING:
// if the set contains it, don't exclude it.
@@ -268,6 +262,8 @@ private boolean excludePoint(String label, int index) {
// if the set doesn't contain it, don't exclude it.
retVal = colExclusionSet.contains(Integer.valueOf(index));
break;
default:
retVal = false;
}

if (LOGGER.isLoggable(Level.FINEST))
@@ -293,13 +289,15 @@ private void loadExclusionSet() {
switch (inclusionFlag) {
case INCLUDE_BY_STRING:
case EXCLUDE_BY_STRING:
strExclusionSet = new HashSet<String>();
strExclusionSet = new HashSet<>();
break;

case INCLUDE_BY_COLUMN:
case EXCLUDE_BY_COLUMN:
colExclusionSet = new HashSet<Integer>();
colExclusionSet = new HashSet<>();
break;
default:
LOGGER.log(Level.SEVERE, "Failed to initialize columns exclusions set.");
}

for (String str : PAT_COMMA.split(exclusionValues)) {
@@ -321,11 +319,29 @@ private void loadExclusionSet() {
LOGGER.finest(inclusionFlag + " CSV Column: " + str);
colExclusionSet.add(Integer.valueOf(str));
} catch (NumberFormatException nfe) {
LOGGER.log(Level.SEVERE, "Exception converting to integer",
nfe);
LOGGER.log(Level.SEVERE, "Exception converting to integer", nfe);
}
break;
break;
default:
LOGGER.log(Level.SEVERE, "Failed to identify columns exclusions.");
}
}
}

@Override
public Descriptor<Series> getDescriptor() {
return new DescriptorImpl();
}

@Extension
public static class DescriptorImpl extends Descriptor<Series> {
public String getDisplayName() {
return Messages.Plot_CsvSeries();
}

@Override
public Series newInstance(StaplerRequest req, JSONObject formData) throws FormException {
return SeriesFactory.createSeries(formData, req);
}
}
}
@@ -32,22 +32,22 @@ public MatrixPlotAction(MatrixConfiguration project,
return project;
}

// called from PlotAction/index.jelly
// called from MatrixPlotAction/index.jelly
public boolean hasPlots() throws IOException {
return CollectionUtils.isNotEmpty(publisher.getPlots(project));
}

// called from PlotAction/index.jelly
// called from MatrixPlotAction/index.jelly
public List<String> getOriginalGroups() {
return publisher.getOriginalGroups(project);
}

// called from PlotAction/index.jelly
// called from MatrixPlotAction/index.jelly
public String getUrlGroup(String originalGroup) {
return publisher.originalGroupToUrlEncodedGroup(originalGroup);
}

// called from href created in PlotAction/index.jelly
// called from href created in MatrixPlotAction/index.jelly
public PlotReport getDynamic(String group, StaplerRequest req,
StaplerResponse rsp) throws IOException {
return new PlotReport(project, publisher.urlGroupToOriginalGroup(
@@ -35,7 +35,7 @@
*/
public class MatrixPlotPublisher extends AbstractPlotPublisher {

transient private Map<MatrixConfiguration, List<Plot>> plotsOfConfigurations = new HashMap<MatrixConfiguration, List<Plot>>();
transient private Map<MatrixConfiguration, List<Plot>> plotsOfConfigurations = new HashMap<>();

transient private Map<String, List<Plot>> groupMap = new HashMap<String, List<Plot>>();

@@ -66,7 +66,7 @@ public String urlGroupToOriginalGroup(String urlGroup, MatrixConfiguration c) {
* Returns all group names as the original user specified strings.
*/
public List<String> getOriginalGroups(MatrixConfiguration configuration) {
List<String> originalGroups = new ArrayList<String>();
List<String> originalGroups = new ArrayList<>();
for (String urlGroup : groupMap.keySet()) {
originalGroups
.add(urlGroupToOriginalGroup(urlGroup, configuration));
@@ -83,8 +83,8 @@ public String urlGroupToOriginalGroup(String urlGroup, MatrixConfiguration c) {
*/
public void setPlots(List<Plot> plots) {
this.plots = plots;
groupMap = new HashMap<String, List<Plot>>();
plotsOfConfigurations = new HashMap<MatrixConfiguration, List<Plot>>();
groupMap = new HashMap<>();
plotsOfConfigurations = new HashMap<>();
}

/**
@@ -99,7 +99,7 @@ public void addPlot(Plot plot) {
List<Plot> list = groupMap.get(urlGroup);
list.add(plot);
} else {
List<Plot> list = new ArrayList<Plot>();
List<Plot> list = new ArrayList<>();
list.add(plot);
groupMap.put(urlGroup, list);
}
@@ -132,7 +132,7 @@ public void addPlot(Plot plot) {
*/
public List<Plot> getPlots(String urlGroup,
MatrixConfiguration configuration) {
List<Plot> groupPlots = new ArrayList<Plot>();
List<Plot> groupPlots = new ArrayList<>();
List<Plot> p = groupMap.get(urlGroup);
if (p != null) {
for (Plot plot : p) {
Oops, something went wrong.

0 comments on commit 7141331

Please sign in to comment.