Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[JENKINS-31202] Replacing occurences of AbstractProject with Job and …
…AbstractBuild with Run.
  • Loading branch information
benjaminfuchs committed Jul 17, 2016
1 parent 7a6538f commit 05d7c5d76514b7d5ddc8270ba12cb4c2fb009130
@@ -17,11 +17,11 @@

import jenkins.model.Jenkins;

import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.model.Action;
import hudson.model.Api;
import hudson.model.Run;
import hudson.plugins.analysis.graph.BuildResultGraph;
import hudson.plugins.analysis.graph.DefaultGraphConfigurationView;
import hudson.plugins.analysis.graph.DifferenceGraph;
@@ -38,7 +38,7 @@
import hudson.util.Graph;

/**
* A project action displays a link on the side panel of a project. This action
* A job action displays a link on the side panel of a job. This action
* also is responsible to render the historical trend via its associated
* 'floatingBox.jelly' view.
*
@@ -52,7 +52,7 @@
private static final Logger LOGGER = Logger.getLogger(AbstractProjectAction.class.getName());

/** Project that owns this action. */
private final AbstractProject<?, ?> project;
private final Job<?, ?> job;
/** The type of the result action. */
private final Class<? extends T> resultActionType;
/** The icon URL of this action: it will be shown as soon as a result is available. */
@@ -69,8 +69,8 @@
/**
* Creates a new instance of {@link AbstractProjectAction}.
*
* @param project
* the project that owns this action
* @param job
* the job that owns this action
* @param resultActionType
* the type of the result action
* @param name
@@ -84,16 +84,39 @@
* @param resultUrl
* the URL of the associated build results
*/
public AbstractProjectAction(final AbstractProject<?, ?> project, final Class<? extends T> resultActionType,
public AbstractProjectAction(final Job<?, ?> job, final Class<? extends T> resultActionType,
final Localizable name, final Localizable trendName, final String pluginUrl, final String iconUrl, final String resultUrl) {
this.project = project;
this.job = job;
this.resultActionType = resultActionType;
this.name = name;
this.trendName = trendName;
this.pluginUrl = pluginUrl;
this.iconUrl = iconUrl;
this.resultUrl = resultUrl;
}

/**
* Creates a new instance of {@link AbstractProjectAction}.
*
* @param project
* the project that owns this action
* @param resultActionType
* the type of the result action
* @param name
* the human readable name of this action
* @param trendName
* the human readable name of the trend graph
* @param pluginUrl
* the URL of the associated plug-in
* @param iconUrl
* the icon to show
* @param resultUrl
* the URL of the associated build results
*/
public AbstractProjectAction(final AbstractProject<?, ?> project, final Class<? extends T> resultActionType,
final Localizable name, final Localizable trendName, final String pluginUrl, final String iconUrl, final String resultUrl) {
this((Job<?, ?>) project, resultActionType, name, trendName, pluginUrl, iconUrl, resultUrl);
}

/**
* Gets the remote API for this action.
@@ -129,16 +152,16 @@ public String getTrendName() {
}

/**
* Returns the project this action belongs to.
* Returns the job this action belongs to.
*
* @return the project
* @return the job
*/
public final AbstractProject<?, ?> getProject() {
return project;
public final Job<?, ?> getProject() {
return job;
}

/**
* Returns the graph configuration view for this project. If the requested
* Returns the graph configuration view for this job. If the requested
* link is neither the user graph configuration nor the default
* configuration then <code>null</code> is returned.
*
@@ -303,7 +326,7 @@ protected GraphConfigurationView createDefaultConfiguration() {
* @return build history
*/
protected BuildHistory createBuildHistory() {
AbstractBuild<?, ?> lastFinishedBuild = getLastFinishedBuild();
Run<?, ?> lastFinishedBuild = getLastFinishedBuild();
if (lastFinishedBuild == null) {
return new NullBuildHistory();
}
@@ -358,10 +381,10 @@ protected GraphConfiguration createConfiguration(final List<BuildResultGraph> av
}

/**
* Returns the icon URL for the side-panel in the project screen. If there
* Returns the icon URL for the side-panel in the job screen. If there
* is no valid result yet, then <code>null</code> is returned.
*
* @return the icon URL for the side-panel in the project screen
* @return the icon URL for the side-panel in the job screen
*/
@Override
public String getIconFileName() {
@@ -378,7 +401,7 @@ public final String getUrlName() {
}

/**
* Returns whether this project has a valid result action attached.
* Returns whether this job has a valid result action attached.
*
* @return <code>true</code> if the results are valid
*/
@@ -394,7 +417,7 @@ public final boolean hasValidResults() {
*/
@CheckForNull
public ResultAction<?> getLastAction() {
AbstractBuild<?, ?> lastBuild = getLastFinishedBuild();
Run<?, ?> lastBuild = getLastFinishedBuild();
if (lastBuild == null) {
return null;
}
@@ -411,7 +434,7 @@ public ResultAction<?> getLastAction() {
* @return the action or <code>null</code> if there is no such action
*/
@CheckForNull
protected T getResultAction(final AbstractBuild<?, ?> lastBuild) {
protected T getResultAction(final Run<?, ?> lastBuild) {
return lastBuild.getAction(resultActionType);
}

@@ -422,11 +445,11 @@ protected T getResultAction(final AbstractBuild<?, ?> lastBuild) {
* such build
*/
@CheckForNull @Exported
public AbstractBuild<?, ?> getLastFinishedBuild() {
if (project == null) {
public Run<?, ?> getLastFinishedBuild() {
if (job == null) {
return null;
}
AbstractBuild<?, ?> lastBuild = project.getLastBuild();
Run<?, ?> lastBuild = job.getLastBuild();
while (lastBuild != null && (lastBuild.isBuilding() || getResultAction(lastBuild) == null)) {
lastBuild = lastBuild.getPreviousBuild();
}
@@ -444,7 +467,7 @@ protected T getResultAction(final AbstractBuild<?, ?> lastBuild) {
* in case of an error
*/
public void doIndex(final StaplerRequest request, final StaplerResponse response) throws IOException {
AbstractBuild<?, ?> build = getLastFinishedBuild();
Run<?, ?> build = getLastFinishedBuild();
if (build != null) {
response.sendRedirect2(String.format("../%d/%s", build.getNumber(), resultUrl));
}
@@ -464,6 +487,6 @@ public void doIndex(final StaplerRequest request, final StaplerResponse response
*/
@Deprecated
public AbstractProjectAction(final AbstractProject<?, ?> project, final Class<? extends T> resultActionType, final PluginDescriptor plugin) {
this(project, resultActionType, null, null, plugin.getPluginName(), plugin.getIconUrl(), plugin.getPluginResultUrlName());
this((Job<?, ?>) project, resultActionType, null, null, plugin.getPluginName(), plugin.getIconUrl(), plugin.getPluginResultUrlName());
}
}
@@ -8,7 +8,7 @@
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import hudson.model.AbstractProject;
import hudson.model.Job;

import hudson.plugins.analysis.Messages;
import hudson.plugins.analysis.core.BuildHistory;
@@ -24,39 +24,39 @@ public class DefaultGraphConfigurationView extends GraphConfigurationView {
*
* @param configuration
* the graph configuration
* @param project
* the owning project to configure the graphs for
* @param job
* the owning job to configure the graphs for
* @param pluginName
* The URL of the project action (there might be a one to many mapping to this defaults view)
* The URL of the job action (there might be a one to many mapping to this defaults view)
* @param buildHistory
* the build history for this project
* the build history for this job
* @param url
* The URL of this view
*/
public DefaultGraphConfigurationView(final GraphConfiguration configuration, final AbstractProject<?, ?> project,
public DefaultGraphConfigurationView(final GraphConfiguration configuration, final Job<?, ?> job,
final String pluginName, final BuildHistory buildHistory, final String url) {
super(configuration, project, pluginName, buildHistory);
super(configuration, job, pluginName, buildHistory);
this.url = url;

configuration.initializeFromFile(createDefaultsFile(project, pluginName));
configuration.initializeFromFile(createDefaultsFile(job, pluginName));
}

/**
* Creates a new instance of {@link DefaultGraphConfigurationView}.
*
* @param configuration
* the graph configuration
* @param project
* the owning project to configure the graphs for
* @param job
* the owning job to configure the graphs for
* @param pluginName
* The name of the plug-in.
* @param buildHistory
* the build history for this project
* the build history for this job
*/
public DefaultGraphConfigurationView(final GraphConfiguration configuration, final AbstractProject<?, ?> project,
public DefaultGraphConfigurationView(final GraphConfiguration configuration, final Job<?, ?> job,
final String pluginName, final BuildHistory buildHistory) {
this(configuration, project, pluginName, buildHistory,
project.getAbsoluteUrl() + pluginName + "/configureDefaults");
this(configuration, job, pluginName, buildHistory,
job.getAbsoluteUrl() + pluginName + "/configureDefaults");
}

@Override
@@ -16,7 +16,7 @@

import net.sf.json.JSONObject;

import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.model.ModelObject;
import hudson.plugins.analysis.core.AbstractHealthDescriptor;
import hudson.plugins.analysis.core.BuildHistory;
@@ -28,8 +28,8 @@
public abstract class GraphConfigurationView implements ModelObject {
private static final Logger LOGGER = Logger.getLogger(GraphConfigurationView.class.getName());

/** The owning project to configure the graphs for. */
private final AbstractProject<?, ?> project;
/** The owning job to configure the graphs for. */
private final Job<?, ?> job;

private final String key;
private final BuildHistory buildHistory;
@@ -42,16 +42,16 @@ public abstract class GraphConfigurationView implements ModelObject {
*
* @param configuration
* the graph configuration
* @param project
* the owning project to configure the graphs for
* @param job
* the owning job to configure the graphs for
* @param key
* unique key of this graph
* @param buildHistory
* the build history for this project
* the build history for this job
*/
public GraphConfigurationView(final GraphConfiguration configuration, final AbstractProject<?, ?> project, final String key, final BuildHistory buildHistory) {
public GraphConfigurationView(final GraphConfiguration configuration, final Job<?, ?> job, final String key, final BuildHistory buildHistory) {
this.configuration = configuration;
this.project = project;
this.job = job;
this.key = key;
this.buildHistory = buildHistory;
healthDescriptor = buildHistory.getHealthDescriptor();
@@ -60,14 +60,14 @@ public GraphConfigurationView(final GraphConfiguration configuration, final Abst
/**
* Creates a file with for the default values.
*
* @param project
* the project used as directory for the file
* @param job
* the job used as directory for the file
* @param pluginName
* the name of the plug-in
* @return the created file
*/
protected static File createDefaultsFile(final AbstractProject<?, ?> project, final String pluginName) {
return new File(project.getRootDir(), pluginName + ".txt");
protected static File createDefaultsFile(final Job<?, ?> job, final String pluginName) {
return new File(job.getRootDir(), pluginName + ".txt");
}

/**
@@ -86,12 +86,12 @@ public List<? extends BuildResultGraph> getAvailableGraphs() {
}

/**
* Returns the project.
* Returns the job.
*
* @return the project
* @return the job
*/
public AbstractProject<?, ?> getOwner() {
return project;
public Job<?, ?> getOwner() {
return job;
}

/**
@@ -134,7 +134,7 @@ public void doSave(final StaplerRequest request, final StaplerResponse response)
}
finally {
try {
response.sendRedirect(project.getAbsoluteUrl());
response.sendRedirect(job.getAbsoluteUrl());
}
catch (IOException exception) {
LOGGER.log(Level.SEVERE, "Can't redirect", exception);
@@ -2,7 +2,7 @@

import org.kohsuke.stapler.StaplerRequest;

import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.util.Graph;

/**
@@ -14,22 +14,22 @@ public class TrendDetails {
/** The graph to display. */
private final Graph trendGraph;
private final String id;
/** The project of the graph. */
private final AbstractProject<?, ?> project;
/** The job of the graph. */
private final Job<?, ?> job;

/**
* Creates a new instance of {@link TrendDetails}.
*
* @param project
* the project of the graph
* @param job
* the job of the graph
* @param trendGraph
* the graph
* @param id
* the ID of the trend graph
*/
public TrendDetails(final AbstractProject<?, ?> project, final Graph trendGraph,
public TrendDetails(final Job<?, ?> job, final Graph trendGraph,
final String id) {
this.project = project;
this.job = job;
this.trendGraph = trendGraph;
this.id = id;
}
@@ -59,8 +59,8 @@ public String getTrendGraphId() {
*
* @return the abstractProject
*/
public AbstractProject<?, ?> getProject() {
return project;
public Job<?, ?> getJob() {
return job;
}
}

0 comments on commit 05d7c5d

Please sign in to comment.