View Javadoc

1   package org.whatsitcalled.webflange.webapp.model;
2   
3   import java.util.Iterator;
4   import java.util.List;
5   
6   import org.apache.wicket.markup.repeater.data.IDataProvider;
7   import org.apache.wicket.model.IModel;
8   import org.whatsitcalled.webflange.ResourceFactory;
9   import org.whatsitcalled.webflange.model.LoadTest;
10  import org.whatsitcalled.webflange.model.LoadTestRun;
11  import org.whatsitcalled.webflange.model.LoadTestSummary;
12  
13  public class LoadTestSummaryDataProvider implements IDataProvider {
14  	private LoadTestRun run;
15  
16  	private LoadTest test = null;
17  
18  	public LoadTestSummaryDataProvider(LoadTestRun run) {
19  		this.run = run;
20  	}
21  
22  	public LoadTestSummaryDataProvider(LoadTest test) {
23  		this.test = test;
24  	}
25  
26  	public Iterator iterator(int first, int count) {
27  		List sums;
28  		if (test == null) {
29  			sums = ResourceFactory.getLoadTestSummaryDAO()
30  					.getLoadTestSummaries(run);
31  			LoadTestSummary total = ResourceFactory.getLoadTestSummaryDAO()
32  					.getLoadTestRunTotal(run);
33  			sums.add(total);
34  		} else {
35  			sums = ResourceFactory.getLoadTestSummaryDAO()
36  					.getLoadTestRunTotals(test);
37  		}
38  
39  		return sums.iterator();
40  	}
41  
42  	public IModel model(Object object) {
43  		return new LoadTestSummaryDetachableModel((LoadTestSummary) object);
44  	}
45  
46  	public int size() {
47  		List sums = null;
48  		int size = 0;
49  		if (test == null) {
50  			sums = ResourceFactory.getLoadTestSummaryDAO()
51  					.getLoadTestSummaries(run);
52  			size = sums.size() + 1;
53  		} else {
54  			sums = ResourceFactory.getLoadTestSummaryDAO()
55  					.getLoadTestRunTotals(test);
56  			size = sums.size();
57  		}
58  		return size;
59  	}
60  
61  	public void detach() {
62  	}
63  
64  }