summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-21 06:19:38 (EST)
committer Winston Prakash2011-12-01 20:46:48 (EST)
commitc0853d3df8d06128e8143a527d1a27bff0d86fe3 (patch)
treef2b597e77d402a6bfa340cd10583a08d6baa8480
parent6698f8b0d4008e64223196d9285b74d4b6c9a4ad (diff)
downloadorg.eclipse.hudson.core-c0853d3df8d06128e8143a527d1a27bff0d86fe3.zip
org.eclipse.hudson.core-c0853d3df8d06128e8143a527d1a27bff0d86fe3.tar.gz
org.eclipse.hudson.core-c0853d3df8d06128e8143a527d1a27bff0d86fe3.tar.bz2
Template and TemplateName were relocated to Job.
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java51
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java51
2 files changed, 51 insertions, 51 deletions
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index 4259418..69866b6 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -219,15 +219,6 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
@CopyOnWrite
protected transient volatile List<Action> transientActions = new Vector<Action>();
- /**
- * The name of the template.
- */
- private String templateName;
-
- /**
- * Selected template for this project.
- */
- private transient P template;
private boolean concurrentBuild;
@@ -264,9 +255,6 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
super.onLoad(parent, name);
- //TODO fix it
- template = (P) Functions.getItemByName(Hudson.getInstance().getAllItems(this.getClass()), templateName);
-
this.builds = new RunMap<R>();
this.builds.load(this,new Constructor<R>() {
public R create(File dir) throws IOException {
@@ -1964,43 +1952,4 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName()));
return item;
}
-
- /**
- * Returns template name.
- *
- * @return template name.
- */
- public String getTemplateName() {
- return templateName;
- }
-
- /**
- * Sets template name.
- *
- * @param templateName template name.
- */
- @SuppressWarnings({"unchecked"})
- public void setTemplateName(String templateName) {
- this.templateName = templateName;
- //TODO fix it
- this.template = (P)Functions.getItemByName(Hudson.getInstance().getAllItems(this.getClass()), templateName);
- }
-
- /**
- * Returns selected template.
- *
- * @return template.
- */
- @SuppressWarnings({"unchecked"})
- public P getTemplate() {
- return template;
- }
-
- /**
- * Checks whether current project is inherited from other project.
- * @return boolean.
- */
- protected boolean hasParentTemplate() {
- return null != getTemplate();
- }
}
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index d49fd42..3ae40dd 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -16,6 +16,7 @@
package hudson.model;
+import hudson.Functions;
import hudson.util.graph.GraphSeries;
import hudson.widgets.Widget;
import org.apache.commons.lang3.StringUtils;
@@ -142,6 +143,16 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
*/
protected CopyOnWriteList<JobProperty<? super JobT>> properties = new CopyOnWriteList<JobProperty<? super JobT>>();
+ /**
+ * The name of the template.
+ */
+ private String templateName;
+
+ /**
+ * Selected template for this job.
+ */
+ private transient JobT template;
+
protected Job(ItemGroup parent, String name) {
super(parent, name);
}
@@ -155,9 +166,11 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
}
@Override
+ @SuppressWarnings("unchecked")
public void onLoad(ItemGroup<? extends Item> parent, String name)
throws IOException {
super.onLoad(parent, name);
+ template = (JobT) Functions.getItemByName(Hudson.getInstance().getAllItems(this.getClass()), templateName);
TextFile f = getNextBuildNumberFile();
if (f.exists()) {
@@ -1193,6 +1206,44 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
this.creationTime = creationTime;
}
+ /**
+ * Returns template name.
+ *
+ * @return template name.
+ */
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ /**
+ * Sets template name.
+ *
+ * @param templateName template name.
+ */
+ @SuppressWarnings("unchecked")
+ public void setTemplateName(String templateName) {
+ this.templateName = templateName;
+ this.template = (JobT)Functions.getItemByName(Hudson.getInstance().getAllItems(this.getClass()), templateName);
+ }
+
+ /**
+ * Returns selected template.
+ *
+ * @return template.
+ */
+ @SuppressWarnings({"unchecked"})
+ public JobT getTemplate() {
+ return template;
+ }
+
+ /**
+ * Checks whether current job is inherited from other project.
+ * @return boolean.
+ */
+ protected boolean hasParentTemplate() {
+ return null != getTemplate();
+ }
+
public Graph getBuildTimeGraph() {
Graph graph = new Graph(getLastBuild().getTimestamp(), 500, 400);