Skip to content

Commit

Permalink
[FIXED JENKINS-8478] Based on xbeumala, thomasfox, mattakis and gauth…
Browse files Browse the repository at this point in the history
…ierde pull requests
  • Loading branch information
Eric Nielsen committed Nov 6, 2013
1 parent 3899ab7 commit fc4ee19
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
8 changes: 3 additions & 5 deletions src/main/java/hudson/plugins/plot/Plot.java
Expand Up @@ -7,8 +7,6 @@

import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Build;
import hudson.model.Project;
import hudson.model.Run;
import hudson.util.ChartUtil;
import hudson.util.ShiftedCategoryAxis;
Expand Down Expand Up @@ -92,7 +90,7 @@ public class Plot implements Comparable {
* to the project is needed to retrieve and save the CSV file
* that is stored in the project's root directory.
*/
private transient AbstractProject project;
private transient AbstractProject<?, ?> project;

/** All plots share the same JFreeChart drawing supplier object. */
private static final DrawingSupplier supplier = new DefaultDrawingSupplier(
Expand Down Expand Up @@ -371,7 +369,7 @@ private int getHeight() {
*
* @param project the project
*/
public void setProject(Project project) {
public void setProject(AbstractProject<?, ?> project) {
this.project = project;
}

Expand Down Expand Up @@ -443,7 +441,7 @@ public void plotGraphMap(StaplerRequest req, StaplerResponse rsp)
* @param build
* @param logger
*/
public void addBuild(Build build, PrintStream logger) {
public void addBuild(AbstractBuild<?, ?> build, PrintStream logger) {
if (project == null) project = build.getProject();

// load the existing plot data from disk
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hudson/plugins/plot/PlotAction.java
Expand Up @@ -4,8 +4,8 @@
*/
package hudson.plugins.plot;

import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Project;

import java.io.IOException;
import java.util.logging.Logger;
Expand All @@ -22,15 +22,15 @@
public class PlotAction implements Action, StaplerProxy {

private static final Logger LOGGER = Logger.getLogger(PlotAction.class.getName());
private final Project project;
private final AbstractProject<?, ?> project;
private final PlotPublisher publisher;

public PlotAction(Project project, PlotPublisher publisher) {
public PlotAction(AbstractProject<?, ?> project, PlotPublisher publisher) {
this.project = project;
this.publisher = publisher;
}

public Project getProject() {
public AbstractProject<?, ?> getProject() {
return project;
}

Expand Down
24 changes: 10 additions & 14 deletions src/main/java/hudson/plugins/plot/PlotPublisher.java
Expand Up @@ -8,12 +8,11 @@
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.matrix.MatrixProject;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Build;
import hudson.model.BuildListener;
import hudson.model.Project;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Publisher;
Expand Down Expand Up @@ -64,7 +63,7 @@ private Object readResolve() {
/**
* Converts a URL friendly plot group name to the original group name.
* If the given urlGroup doesn't already exist then the empty string will
* be returned.
* be returned.
*/
public String urlGroupToOriginalGroup(String urlGroup) {
if (urlGroup == null || "nogroup".equals(urlGroup)) {
Expand Down Expand Up @@ -108,7 +107,7 @@ public String[] getOriginalGroups() {

/**
* Replaces the plots managed by this object with the given list.
*
*
* @param plots the new list of plots
*/
public void setPlots(Plot[] plots) {
Expand All @@ -120,8 +119,8 @@ public void setPlots(Plot[] plots) {
}

/**
* Adds the new plot to the plot data structures managed by this object.
*
* Adds the new plot to the plot data structures managed by this object.
*
* @param plot the new plot
*/
public void addPlot(Plot plot) {
Expand Down Expand Up @@ -163,7 +162,7 @@ public Plot[] getPlots(String urlGroup) {
*/
@Override
public Action getProjectAction(AbstractProject<?, ?> project) {
return project instanceof Project ? new PlotAction((Project) project, this) : null;
return new PlotAction(project, this);
}

public BuildStepMonitor getRequiredMonitorService() {
Expand All @@ -184,14 +183,10 @@ public BuildStepDescriptor<Publisher> getDescriptor() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
BuildListener listener) throws IOException, InterruptedException {
// Should always be a Build due to isApplicable below
if (!(build instanceof Build)) {
return true;
}
listener.getLogger().println("Recording plot data");
// add the build to each plot
for (Plot plot : getPlots()) {
plot.addBuild((Build) build, listener.getLogger());
plot.addBuild(build, listener.getLogger());
}
// misconfigured plots will not fail a build so always return true
return true;
Expand All @@ -211,7 +206,8 @@ public String getDisplayName() {

@Override
public boolean isApplicable(Class<? extends AbstractProject> jobType) {
return Project.class.isAssignableFrom(jobType);
return AbstractProject.class.isAssignableFrom(jobType)
&& !MatrixProject.class.isAssignableFrom(jobType);
}

/**
Expand All @@ -235,7 +231,7 @@ private static Plot bindPlot(JSONObject data, StaplerRequest req) {
/**
* Checks if the series file is valid.
*/
public FormValidation doCheckSeriesFile(@AncestorInPath AbstractProject project,
public FormValidation doCheckSeriesFile(@AncestorInPath AbstractProject<?, ?> project,
@QueryParameter String value) throws IOException {
return FilePath.validateFileMask(project.getSomeWorkspace(), value);
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/hudson/plugins/plot/PlotReport.java
Expand Up @@ -4,7 +4,7 @@
*/
package hudson.plugins.plot;

import hudson.model.Project;
import hudson.model.AbstractProject;

import java.io.File;
import java.io.FileReader;
Expand All @@ -28,7 +28,7 @@
public class PlotReport {
private static final Logger LOGGER = Logger.getLogger(PlotReport.class.getName());

private final Project project;
private final AbstractProject<?, ?> project;

/**
* The sorted list of plots that belong to the same group.
Expand All @@ -40,15 +40,15 @@ public class PlotReport {
*/
private String group;

public PlotReport(Project project, String group, Plot[] plots) {
public PlotReport(AbstractProject<?, ?> project, String group, Plot[] plots) {
Arrays.sort(plots);
this.plots = plots;
this.group = group;
this.project = project;
}

// called from PlotReport/index.jelly
public Project getProject() {
public AbstractProject<?, ?> getProject() {
return project;
}

Expand Down

0 comments on commit fc4ee19

Please sign in to comment.