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.persistence.model.JobExecutionInfo;
20  import org.gwe.persistence.model.JobInfo;
21  import org.gwe.utils.web.HtmlLink;
22  import org.gwe.utils.web.HtmlTable;
23  import org.gwe.utils.web.HtmlTableCell;
24  
25  /**
26   * @author Marco Ruiz
27   * @since Dec 18, 2008
28   */
29  public class HtmlExecsTable extends HtmlTable {
30  
31  	public HtmlExecsTable(String clusterId, JobInfo job) {
32  		if (job == null) return;
33  	    HtmlTable table = new HtmlTable("Number", "Allocation", "Started", "Prepared", "Dispatched", "Processed", "Completed", "Failed");
34          for (JobExecutionInfo exec : job.getExecutions()) {
35          	HtmlTableCell num = new HtmlTableCell("[" + exec.getExecutionNum() + " ]", "", new HtmlLink(false, "#" + exec.getExecutionNum()));
36      		table.addRow(num, getAllocationId(exec), exec.getWhenCreated(), exec.getWhenPrepared(), 
37  					exec.getWhenDispatched(), exec.getWhenProcessed(), exec.getWhenCompleted(), exec.getWhenFailed());
38          }
39      }
40  
41  	private Object getAllocationId(JobExecutionInfo exec) {
42  	    return (exec.getAllocation() != null) ? exec.getAllocation().getId() : null;
43      }
44  }