View Javadoc

1   /*
2    * Copyright 2007-2008 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.gwe.app.client.web.view;
18  
19  import org.gwe.app.client.web.request.Param;
20  import org.gwe.persistence.model.JobExecutionInfo;
21  import org.gwe.persistence.model.JobInfo;
22  import org.gwe.persistence.model.OrderInfo;
23  import org.gwe.utils.web.HtmlLink;
24  import org.gwe.utils.web.HtmlTable;
25  import org.gwe.utils.web.HtmlTableCell;
26  
27  /**
28   * @author Marco Ruiz
29   * @since Dec 18, 2008
30   */
31  public class HtmlJobsTable extends HtmlTable {
32  
33  	public HtmlJobsTable(String clusterId, OrderInfo order) {
34  	    super("Status", "Number", "Failures", "Allocation", "Started", "Prepared", "Dispatched", "Processed", "Completed", "Failed");
35          for (JobInfo job : order.getJobs()) {
36          	HtmlTableCell num = new HtmlTableCell("[ " + job.getJobNum() + " ]", "", new HtmlJobLink(clusterId, job)) ;
37          	JobExecutionInfo exec = job.getExecution();
38          	HtmlTableCell status = new HtmlTableCell("", "", null, HtmlExecPropsTable.getStatusImage(exec));
39          	if (exec != null) {
40          		Object allocId = (exec.getAllocation() != null) ? exec.getAllocation().getId() : null;
41  				addRow(status, num, job.getFailures(), allocId, exec.getWhenCreated(), exec.getWhenPrepared(), 
42  						exec.getWhenDispatched(), exec.getWhenProcessed(), exec.getWhenCompleted(), exec.getWhenFailed());
43          	} else {
44          		addRow(status, num, null, null, null, null, null, null, null, null);
45          	}
46          }
47      }
48  }
49  
50  class HtmlJobLink extends HtmlLink {
51  
52  	public HtmlJobLink(String clusterId, JobInfo job) {
53  	    super(false, "job");
54  	    addParam(Param.CLUSTER_ID, clusterId);
55  	    addParam(Param.ORDER_ID, job.getOrder().getId());
56  	    addParam(Param.JOB_NUM, job.getJobNum());
57      }
58  }