94 lines
2.9 KiB
Java
94 lines
2.9 KiB
Java
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
|
|
|
|
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChart4Top;
|
|
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartBuilder;
|
|
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartDirector;
|
|
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartPanel;
|
|
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
|
|
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
|
|
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerChartDrawException;
|
|
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerStorageChartDrawException;
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
|
|
/**
|
|
* Accounting Chart 4 Storage
|
|
*
|
|
* @author "Giancarlo Panichi" email: <a
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
*
|
|
*/
|
|
public class AccountingChart4Storage extends AccountingChartBuilder {
|
|
|
|
private AccountingStateData accountingStateData;
|
|
|
|
public AccountingChart4Storage(AccountingStateData accountingStateData) {
|
|
this.accountingStateData = accountingStateData;
|
|
}
|
|
|
|
@Override
|
|
public void buildChart() throws AccountingManagerChartDrawException {
|
|
AccountingChartPanel accountingChartPanel = null;
|
|
|
|
if (accountingStateData == null
|
|
|| accountingStateData.getAccountingType() == null
|
|
|| accountingStateData.getSeriesRequest() == null
|
|
|| accountingStateData.getSeriesResponse() == null) {
|
|
accountingChartSpec.setChart(accountingChartPanel);
|
|
return;
|
|
}
|
|
|
|
if (!(accountingStateData.getSeriesResponse() instanceof SeriesStorage)) {
|
|
accountingChartSpec.setChart(accountingChartPanel);
|
|
return;
|
|
}
|
|
|
|
StorageChartPanel container = createStorageChartPanel();
|
|
|
|
accountingChartPanel = new AccountingChartPanel(container.getChart());
|
|
|
|
accountingChartSpec.setChart(accountingChartPanel);
|
|
|
|
}
|
|
|
|
private StorageChartPanel createStorageChartPanel() throws AccountingManagerStorageChartDrawException {
|
|
|
|
if (accountingStateData == null
|
|
|| accountingStateData.getAccountingType() == null) {
|
|
return null;
|
|
}
|
|
|
|
switch (accountingStateData.getAccountingType()) {
|
|
|
|
case STORAGE:
|
|
return createStorageChart(new StorageChart4Top(
|
|
accountingStateData));
|
|
|
|
default:
|
|
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
private StorageChartPanel createStorageChart(
|
|
StorageChartBuilder chartBuilder) throws AccountingManagerStorageChartDrawException {
|
|
|
|
try {
|
|
StorageChartDirector director = new StorageChartDirector();
|
|
director.setStorageChartBuilder(chartBuilder);
|
|
director.constructStorageChart();
|
|
|
|
StorageChartPanel chart = director.getStorageChart();
|
|
|
|
return chart;
|
|
} catch (AccountingManagerStorageChartDrawException e) {
|
|
Log.error(e.getLocalizedMessage());
|
|
e.printStackTrace();
|
|
throw e;
|
|
}
|
|
|
|
}
|
|
|
|
}
|