refs 4041: Accounting Manager portlet: give possibility to download raw data to users
https://support.d4science.org/issues/4041 Added CSV file creation on workspace git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@128908 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2920cc1f3a
commit
22026c1d1b
110
pom.xml
110
pom.xml
|
@ -61,22 +61,36 @@
|
|||
<profile>
|
||||
<id>localRun</id>
|
||||
<dependencies>
|
||||
<!-- Storage -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-lib</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Home Library -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-model</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Authorization -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-authorization</artifactId>
|
||||
|
@ -89,6 +103,28 @@
|
|||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Logger -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Accounting -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-lib</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
@ -210,15 +246,7 @@
|
|||
<artifactId>aslsocial</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- WSLT dependencies <dependency> <groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>workspace-light-tree</artifactId> <version>[2.13.1-SNAPSHOT,
|
||||
3.0.0-SNAPSHOT)</version> </dependency> <dependency> <groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId> <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope> </dependency> -->
|
||||
|
||||
|
||||
<!-- Session Checker -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
|
@ -233,6 +261,39 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Storage -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Home Library -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-model</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Accounting Lib -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
|
@ -262,6 +323,15 @@
|
|||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Commons CSV -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-csv</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- LOGGING -->
|
||||
<dependency>
|
||||
<groupId>com.allen-sauer.gwt.log</groupId>
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.AccountingMenuEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.FiltersChangeEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.StateChangeEvent;
|
||||
|
@ -24,8 +25,9 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerSessionExpiredException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpiredException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.session.UserInfo;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
|
||||
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -99,7 +101,7 @@ public class AccountingManagerController {
|
|||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.info("No valid user found: " + caught.getMessage());
|
||||
if (caught instanceof AccountingManagerSessionExpiredException) {
|
||||
if (caught instanceof SessionExpiredException) {
|
||||
UtilsGXT3.alert("Error", "Expired Session");
|
||||
sessionExpiredShowDelayed();
|
||||
} else {
|
||||
|
@ -198,6 +200,18 @@ public class AccountingManagerController {
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(DownloadCSVRequestEvent.TYPE,
|
||||
new DownloadCSVRequestEvent.DownloadCSVRequestEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onDownload(DownloadCSVRequestEvent event) {
|
||||
Log.debug("Catch DownloadDataRequestEvent");
|
||||
doSaveDataOnWorkspace(event);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.fireEvent(new UIStateEvent(UIStateType.START));
|
||||
|
||||
|
@ -266,7 +280,7 @@ public class AccountingManagerController {
|
|||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
accountingMonitor.hide();
|
||||
if (caught instanceof AccountingManagerSessionExpiredException) {
|
||||
if (caught instanceof SessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
|
@ -317,7 +331,7 @@ public class AccountingManagerController {
|
|||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
accountingMonitor.hide();
|
||||
if (caught instanceof AccountingManagerSessionExpiredException) {
|
||||
if (caught instanceof SessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
|
@ -386,7 +400,7 @@ public class AccountingManagerController {
|
|||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
accountingMonitor.hide();
|
||||
if (caught instanceof AccountingManagerSessionExpiredException) {
|
||||
if (caught instanceof SessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
|
@ -401,6 +415,70 @@ public class AccountingManagerController {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private void doSaveDataOnWorkspace(DownloadCSVRequestEvent event) {
|
||||
accountingMonitor = new AccountingMonitor();
|
||||
Log.debug("Call saveCSVOnWorkspace on server, params: " + event.getAccountingType());
|
||||
|
||||
AccountingManagerServiceAsync.INSTANCE.saveCSVOnWorkspace(accountingState.getState(event.getAccountingType()), new AsyncCallback<ItemDescription>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
accountingMonitor.hide();
|
||||
if (caught instanceof SessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error:" + caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
caught.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ItemDescription result) {
|
||||
Log.debug("ItemDescription: " + result);
|
||||
doDownloadCSV(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void doDownloadCSV(ItemDescription itemDescription) {
|
||||
Log.debug("DownloadCSV from server: " + itemDescription);
|
||||
|
||||
AccountingManagerServiceAsync.INSTANCE.getPublicLink(itemDescription, new AsyncCallback<String>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
accountingMonitor.hide();
|
||||
if (caught instanceof SessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error:" + caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
caught.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
accountingMonitor.hide();
|
||||
Log.debug("Link: " + result);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void doSessionExpiredCommand(SessionExpiredEvent event) {
|
||||
Log.debug("Session Expired Event: " + event.getSessionExpiredType());
|
||||
sessionExpiredShow();
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.client.event;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.google.gwt.event.shared.HasHandlers;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DownloadCSVRequestEvent extends
|
||||
GwtEvent<DownloadCSVRequestEvent.DownloadCSVRequestEventHandler> {
|
||||
|
||||
public static Type<DownloadCSVRequestEventHandler> TYPE = new Type<DownloadCSVRequestEventHandler>();
|
||||
private AccountingType accountingType;
|
||||
|
||||
public interface DownloadCSVRequestEventHandler extends EventHandler {
|
||||
void onDownload(DownloadCSVRequestEvent event);
|
||||
}
|
||||
|
||||
public interface HasDownloadCSVRequestEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addDownloadCSVRequestEventHandler(
|
||||
DownloadCSVRequestEventHandler handler);
|
||||
}
|
||||
|
||||
public DownloadCSVRequestEvent(AccountingType accountingType) {
|
||||
this.accountingType = accountingType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(DownloadCSVRequestEventHandler handler) {
|
||||
handler.onDownload(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<DownloadCSVRequestEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<DownloadCSVRequestEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source,
|
||||
DownloadCSVRequestEvent accountingMenuEvent) {
|
||||
source.fireEvent(accountingMenuEvent);
|
||||
}
|
||||
|
||||
public AccountingType getAccountingType() {
|
||||
return accountingType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DownloadCSVRequestEvent [accountingType=" + accountingType
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerSessionExpiredException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpiredException;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.cell.client.AbstractCell;
|
||||
|
@ -779,7 +779,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof AccountingManagerSessionExpiredException) {
|
||||
if (caught instanceof SessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.Account
|
|||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.AccountingChartBuilder;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.AccountingChartDirector;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.AccountingChartPanel;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerChartDrawException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
|
@ -86,19 +86,19 @@ public class ChartViewerPanel extends FramedPanel {
|
|||
|
||||
switch (event.getAccountingStateData().getAccountingType()) {
|
||||
case JOB:
|
||||
createChart(new AccountingChart4Job(event.getAccountingStateData()));
|
||||
createChart(new AccountingChart4Job(eventBus, event.getAccountingStateData()));
|
||||
break;
|
||||
case PORTLET:
|
||||
createChart(new AccountingChart4Portlet(event.getAccountingStateData()));
|
||||
createChart(new AccountingChart4Portlet(eventBus, event.getAccountingStateData()));
|
||||
break;
|
||||
case SERVICE:
|
||||
createChart(new AccountingChart4Service(event.getAccountingStateData()));
|
||||
createChart(new AccountingChart4Service(eventBus, event.getAccountingStateData()));
|
||||
break;
|
||||
case STORAGE:
|
||||
createChart(new AccountingChart4Storage(event.getAccountingStateData()));
|
||||
createChart(new AccountingChart4Storage(eventBus, event.getAccountingStateData()));
|
||||
break;
|
||||
case TASK:
|
||||
createChart(new AccountingChart4Task(event.getAccountingStateData()));
|
||||
createChart(new AccountingChart4Task(eventBus, event.getAccountingStateData()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -119,7 +119,7 @@ public class ChartViewerPanel extends FramedPanel {
|
|||
add(chart.getChart());
|
||||
}
|
||||
|
||||
} catch (AccountingManagerChartDrawException e) {
|
||||
} catch (ChartDrawException e) {
|
||||
Log.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -3,8 +3,9 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
|
|||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartBasicPanel;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerChartDrawException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
|
||||
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||
|
||||
/**
|
||||
|
@ -17,13 +18,15 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
|||
public class AccountingChart4Job extends AccountingChartBuilder {
|
||||
|
||||
private AccountingStateData accountingStateData;
|
||||
private EventBus eventBus;
|
||||
|
||||
public AccountingChart4Job(AccountingStateData accountingStateData) {
|
||||
public AccountingChart4Job(EventBus eventBus, AccountingStateData accountingStateData) {
|
||||
this.eventBus=eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildChart() throws AccountingManagerChartDrawException {
|
||||
public void buildChart() throws ChartDrawException {
|
||||
AccountingChartPanel accountingChartPanel = null;
|
||||
|
||||
if (accountingStateData == null
|
||||
|
@ -48,7 +51,7 @@ public class AccountingChart4Job extends AccountingChartBuilder {
|
|||
}
|
||||
|
||||
private SimpleContainer createJobChartPanel()
|
||||
throws AccountingManagerChartDrawException {
|
||||
throws ChartDrawException {
|
||||
|
||||
if (accountingStateData == null
|
||||
|| accountingStateData.getSeriesRequest() == null
|
||||
|
@ -68,7 +71,7 @@ public class AccountingChart4Job extends AccountingChartBuilder {
|
|||
//return new JobChartTopPanel(accountingStateData);
|
||||
//createJobChart(new JobChart4Top(accountingStateData));
|
||||
case Basic:
|
||||
return new JobChartBasicPanel(accountingStateData);
|
||||
return new JobChartBasicPanel(eventBus, accountingStateData);
|
||||
//createJobChart(new JobChart4Basic(
|
||||
//accountingStateData));
|
||||
default:
|
||||
|
|
|
@ -2,7 +2,9 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
|
|||
|
||||
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.ChartDrawException;
|
||||
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
|
||||
/**
|
||||
* Accounting Chart 4 Portlet
|
||||
|
@ -12,15 +14,16 @@ import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingMan
|
|||
*
|
||||
*/
|
||||
public class AccountingChart4Portlet extends AccountingChartBuilder {
|
||||
|
||||
private EventBus eventBus;
|
||||
private AccountingStateData accountingStateData;
|
||||
|
||||
public AccountingChart4Portlet(AccountingStateData accountingStateData) {
|
||||
public AccountingChart4Portlet(EventBus eventBus, AccountingStateData accountingStateData) {
|
||||
this.eventBus = eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildChart() throws AccountingManagerChartDrawException {
|
||||
public void buildChart() throws ChartDrawException {
|
||||
AccountingChartPanel accountingChartPanel = null;
|
||||
|
||||
if (accountingStateData == null
|
||||
|
|
|
@ -4,8 +4,9 @@ import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service
|
|||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartTopPanel;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerChartDrawException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
|
||||
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||
|
||||
/**
|
||||
|
@ -16,15 +17,17 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
|||
*
|
||||
*/
|
||||
public class AccountingChart4Service extends AccountingChartBuilder {
|
||||
|
||||
private EventBus eventBus;
|
||||
private AccountingStateData accountingStateData;
|
||||
|
||||
|
||||
public AccountingChart4Service(AccountingStateData accountingStateData) {
|
||||
public AccountingChart4Service(EventBus eventBus, AccountingStateData accountingStateData) {
|
||||
this.eventBus=eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildChart() throws AccountingManagerChartDrawException {
|
||||
public void buildChart() throws ChartDrawException {
|
||||
AccountingChartPanel accountingChartPanel = null;
|
||||
|
||||
if (accountingStateData == null
|
||||
|
@ -49,7 +52,7 @@ public class AccountingChart4Service extends AccountingChartBuilder {
|
|||
}
|
||||
|
||||
private SimpleContainer createServiceChartPanel()
|
||||
throws AccountingManagerChartDrawException {
|
||||
throws ChartDrawException {
|
||||
|
||||
if (accountingStateData == null
|
||||
|| accountingStateData.getSeriesRequest() == null
|
||||
|
@ -64,9 +67,9 @@ public class AccountingChart4Service extends AccountingChartBuilder {
|
|||
.getAccountingFilterDefinition().getChartType()) {
|
||||
|
||||
case Top:
|
||||
return new ServiceChartTopPanel(accountingStateData);
|
||||
return new ServiceChartTopPanel(eventBus,accountingStateData);
|
||||
case Basic:
|
||||
return new ServiceChartBasicPanel(accountingStateData);
|
||||
return new ServiceChartBasicPanel(eventBus, accountingStateData);
|
||||
default:
|
||||
|
||||
return null;
|
||||
|
|
|
@ -4,8 +4,9 @@ import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage
|
|||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartTopPanel;
|
||||
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.ChartDrawException;
|
||||
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||
|
||||
/**
|
||||
|
@ -16,15 +17,17 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
|||
*
|
||||
*/
|
||||
public class AccountingChart4Storage extends AccountingChartBuilder {
|
||||
|
||||
private EventBus eventBus;
|
||||
private AccountingStateData accountingStateData;
|
||||
|
||||
|
||||
public AccountingChart4Storage(AccountingStateData accountingStateData) {
|
||||
public AccountingChart4Storage(EventBus eventBus, AccountingStateData accountingStateData) {
|
||||
this.eventBus=eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildChart() throws AccountingManagerChartDrawException {
|
||||
public void buildChart() throws ChartDrawException {
|
||||
AccountingChartPanel accountingChartPanel = null;
|
||||
|
||||
if (accountingStateData == null
|
||||
|
@ -49,7 +52,7 @@ public class AccountingChart4Storage extends AccountingChartBuilder {
|
|||
}
|
||||
|
||||
private SimpleContainer createStorageChartPanel()
|
||||
throws AccountingManagerChartDrawException {
|
||||
throws ChartDrawException {
|
||||
|
||||
if (accountingStateData == null
|
||||
|| accountingStateData.getSeriesRequest() == null
|
||||
|
@ -65,10 +68,10 @@ public class AccountingChart4Storage extends AccountingChartBuilder {
|
|||
.getAccountingFilterDefinition().getChartType()) {
|
||||
|
||||
case Top:
|
||||
return new StorageChartTopPanel(accountingStateData);
|
||||
return new StorageChartTopPanel(eventBus, accountingStateData);
|
||||
//createStorageChart(new StorageChart4Top(accountingStateData));
|
||||
case Basic:
|
||||
return new StorageChartBasicPanel(accountingStateData);
|
||||
return new StorageChartBasicPanel(eventBus, accountingStateData);
|
||||
//createStorageChart(new StorageChart4Basic(
|
||||
//accountingStateData));
|
||||
default:
|
||||
|
|
|
@ -2,7 +2,9 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
|
|||
|
||||
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.ChartDrawException;
|
||||
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
|
||||
/**
|
||||
* Accounting Chart 4 Task
|
||||
|
@ -12,15 +14,17 @@ import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingMan
|
|||
*
|
||||
*/
|
||||
public class AccountingChart4Task extends AccountingChartBuilder {
|
||||
|
||||
private EventBus eventBus;
|
||||
private AccountingStateData accountingStateData;
|
||||
|
||||
|
||||
public AccountingChart4Task(AccountingStateData accountingStateData) {
|
||||
public AccountingChart4Task(EventBus eventBus, AccountingStateData accountingStateData) {
|
||||
this.eventBus=eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildChart() throws AccountingManagerChartDrawException {
|
||||
public void buildChart() throws ChartDrawException {
|
||||
AccountingChartPanel accountingChartPanel = null;
|
||||
|
||||
if (accountingStateData == null
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerChartDrawException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
|
||||
|
||||
/**
|
||||
* Abstract class for build Accounting Chart
|
||||
|
@ -20,7 +20,7 @@ public abstract class AccountingChartBuilder {
|
|||
|
||||
}
|
||||
|
||||
public abstract void buildChart() throws AccountingManagerChartDrawException;
|
||||
public abstract void buildChart() throws ChartDrawException;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerChartDrawException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ public class AccountingChartDirector {
|
|||
|
||||
}
|
||||
|
||||
public void constructAccountingChart() throws AccountingManagerChartDrawException {
|
||||
public void constructAccountingChart() throws ChartDrawException {
|
||||
accountingChartBuilder.createSpec();
|
||||
accountingChartBuilder.buildChart();
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure;
|
||||
|
@ -23,6 +24,7 @@ import com.github.highcharts4gwt.model.highcharts.option.api.SeriesArea;
|
|||
import com.github.highcharts4gwt.model.highcharts.option.api.SeriesColumn;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
|
||||
|
@ -58,11 +60,13 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
private HighchartsLayoutPanel highchartsLayoutPanel;
|
||||
|
||||
// Download Menu
|
||||
private MenuItem downloadCSVItem;
|
||||
private MenuItem downloadPNGItem;
|
||||
private MenuItem downloadJPGItem;
|
||||
private MenuItem downloadPDFItem;
|
||||
private MenuItem downloadSVGItem;
|
||||
|
||||
|
||||
// Time Unit Menu
|
||||
private MenuItem msItem;
|
||||
private MenuItem sItem;
|
||||
|
@ -76,8 +80,10 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
private String unitMeasureLabel = TimeUnitMeasure.MS;
|
||||
private TextButton unitButton;
|
||||
private ToggleButton toggleButton;
|
||||
private EventBus eventBus;
|
||||
|
||||
public JobChartBasicPanel(AccountingStateData accountingStateData) {
|
||||
public JobChartBasicPanel(EventBus eventBus, AccountingStateData accountingStateData) {
|
||||
this.eventBus=eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
forceLayoutOnResize = true;
|
||||
create();
|
||||
|
@ -222,6 +228,8 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
private Menu createDownloadMenu() {
|
||||
|
||||
Menu menuDownload = new Menu();
|
||||
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
|
||||
AccountingManagerResources.INSTANCE.accountingByte24());
|
||||
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
|
||||
AccountingManagerResources.INSTANCE.accountingFilePNG24());
|
||||
downloadPNGItem.setHeight(30);
|
||||
|
@ -235,6 +243,20 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
AccountingManagerResources.INSTANCE.accountingFileSVG24());
|
||||
downloadSVGItem.setHeight(30);
|
||||
|
||||
|
||||
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadCSV();
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
|
@ -271,7 +293,8 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
onDownloadSVG(id);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
menuDownload.add(downloadCSVItem);
|
||||
menuDownload.add(downloadPNGItem);
|
||||
menuDownload.add(downloadJPGItem);
|
||||
menuDownload.add(downloadPDFItem);
|
||||
|
@ -279,6 +302,13 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
return menuDownload;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void onDownloadCSV() {
|
||||
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
|
||||
accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.github.highcharts4gwt.model.highcharts.option.api.ChartOptions;
|
|||
import com.github.highcharts4gwt.model.highcharts.option.api.SeriesColumn;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
|
||||
|
@ -53,6 +54,7 @@ public class JobChartTopPanel extends SimpleContainer {
|
|||
private DateTimeFormat dtf = DateTimeFormat
|
||||
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
|
||||
|
||||
private EventBus eventBus;
|
||||
private AccountingStateData accountingStateData;
|
||||
private HighchartsLayoutPanel highchartsLayoutPanel;
|
||||
|
||||
|
@ -85,7 +87,9 @@ public class JobChartTopPanel extends SimpleContainer {
|
|||
|
||||
private VerticalLayoutContainer vert;
|
||||
|
||||
public JobChartTopPanel(AccountingStateData accountingStateData) {
|
||||
public JobChartTopPanel(EventBus eventBus,
|
||||
AccountingStateData accountingStateData) {
|
||||
this.eventBus = eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
forceLayoutOnResize = true;
|
||||
create();
|
||||
|
@ -234,8 +238,7 @@ public class JobChartTopPanel extends SimpleContainer {
|
|||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
measureButton.setText(JobChartMeasure.OperationCount
|
||||
.getLabel());
|
||||
measureButton.setText(JobChartMeasure.OperationCount.getLabel());
|
||||
measure = JobChartMeasure.OperationCount;
|
||||
unitButton.setVisible(false);
|
||||
updateChart();
|
||||
|
@ -458,14 +461,12 @@ public class JobChartTopPanel extends SimpleContainer {
|
|||
+ " }" + " }");
|
||||
|
||||
ArrayList<SeriesColumn> seriesColumn = new ArrayList<>();
|
||||
for (int i = 0; i < seriesJobTop.getSeriesJobDataTopList()
|
||||
.size(); i++) {
|
||||
for (int i = 0; i < seriesJobTop.getSeriesJobDataTopList().size(); i++) {
|
||||
SeriesColumn seriesColumnData = highchartsFactory
|
||||
.createSeriesColumn();
|
||||
|
||||
seriesColumnData.name(seriesJobTop
|
||||
.getSeriesJobDataTopList().get(i).getFilterValue()
|
||||
.getValue());
|
||||
seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList().get(i)
|
||||
.getFilterValue().getValue());
|
||||
seriesColumnData.color(colors.get(i));
|
||||
seriesColumnData.type("column");
|
||||
|
||||
|
@ -553,12 +554,11 @@ public class JobChartTopPanel extends SimpleContainer {
|
|||
+ " \"style\": {" + " \"color\": \""
|
||||
+ colors.get(1) + "\"" + " }" + " }" + "}]";
|
||||
case OperationCount:
|
||||
return "[{" + " \"id\": \""
|
||||
+ JobChartMeasure.OperationCount.name() + "\","
|
||||
+ " \"labels\": { " + " \"format\": \"{value}\","
|
||||
+ " \"style\": { " + " \"color\": \""
|
||||
+ colors.get(1) + "\"" + " }" + " },"
|
||||
+ " \"stackLabels\": {" + " \"enabled\": \"true\","
|
||||
return "[{" + " \"id\": \"" + JobChartMeasure.OperationCount.name()
|
||||
+ "\"," + " \"labels\": { "
|
||||
+ " \"format\": \"{value}\"," + " \"style\": { "
|
||||
+ " \"color\": \"" + colors.get(1) + "\"" + " }"
|
||||
+ " }," + " \"stackLabels\": {" + " \"enabled\": \"true\","
|
||||
+ " \"style\": {" + " \"fontWeight\": \"bold\","
|
||||
+ " \"color\": \"gray\"" + " } " + " },"
|
||||
+ " \"title\": { " + " \"text\": \""
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.github.highcharts4gwt.model.highcharts.option.api.SeriesArea;
|
|||
import com.github.highcharts4gwt.model.highcharts.option.api.SeriesColumn;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
|
||||
|
@ -53,7 +54,8 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
|
||||
private static final String TIME_UNIT = "Time Unit";
|
||||
private static final String SINGLE_AXIS = "Single Axis";
|
||||
|
||||
|
||||
private EventBus eventBus;
|
||||
private AccountingStateData accountingStateData;
|
||||
private HighchartsLayoutPanel highchartsLayoutPanel;
|
||||
|
||||
|
@ -76,8 +78,10 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
private String unitMeasureLabel = TimeUnitMeasure.MS;
|
||||
private TextButton unitButton;
|
||||
private ToggleButton toggleButton;
|
||||
|
||||
|
||||
public ServiceChartBasicPanel(AccountingStateData accountingStateData) {
|
||||
public ServiceChartBasicPanel(EventBus eventBus, AccountingStateData accountingStateData) {
|
||||
this.eventBus=eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
forceLayoutOnResize = true;
|
||||
create();
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.github.highcharts4gwt.model.highcharts.option.api.ChartOptions;
|
|||
import com.github.highcharts4gwt.model.highcharts.option.api.SeriesColumn;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
|
||||
|
@ -53,6 +54,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
|
|||
private DateTimeFormat dtf = DateTimeFormat
|
||||
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
|
||||
|
||||
private EventBus eventBus;
|
||||
private AccountingStateData accountingStateData;
|
||||
private HighchartsLayoutPanel highchartsLayoutPanel;
|
||||
|
||||
|
@ -84,8 +86,10 @@ public class ServiceChartTopPanel extends SimpleContainer {
|
|||
private TextButton measureButton;
|
||||
|
||||
private VerticalLayoutContainer vert;
|
||||
|
||||
|
||||
public ServiceChartTopPanel(AccountingStateData accountingStateData) {
|
||||
public ServiceChartTopPanel(EventBus eventBus, AccountingStateData accountingStateData) {
|
||||
this.eventBus=eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
forceLayoutOnResize = true;
|
||||
create();
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storag
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ByteUnitMeasure;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
|
||||
|
@ -23,6 +24,7 @@ import com.github.highcharts4gwt.model.highcharts.option.api.SeriesArea;
|
|||
import com.github.highcharts4gwt.model.highcharts.option.api.SeriesColumn;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
|
||||
|
@ -52,10 +54,12 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
private DateTimeFormat dtf = DateTimeFormat
|
||||
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
|
||||
|
||||
private EventBus eventBus;
|
||||
private AccountingStateData accountingStateData;
|
||||
private HighchartsLayoutPanel highchartsLayoutPanel;
|
||||
|
||||
// Download Menu
|
||||
private MenuItem downloadCSVItem;
|
||||
private MenuItem downloadPNGItem;
|
||||
private MenuItem downloadJPGItem;
|
||||
private MenuItem downloadPDFItem;
|
||||
|
@ -74,7 +78,9 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
private ChartOptions options;
|
||||
private VerticalLayoutContainer vert;
|
||||
|
||||
public StorageChartBasicPanel(AccountingStateData accountingStateData) {
|
||||
public StorageChartBasicPanel(EventBus eventBus,
|
||||
AccountingStateData accountingStateData) {
|
||||
this.eventBus = eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
forceLayoutOnResize = true;
|
||||
create();
|
||||
|
@ -122,7 +128,7 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
createChart();
|
||||
highchartsLayoutPanel.renderChart(options);
|
||||
forceLayout();
|
||||
|
||||
|
||||
/*
|
||||
* vert.remove(highchartsLayoutPanel); // createChart();
|
||||
*
|
||||
|
@ -209,6 +215,8 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
|
||||
private Menu createDownloadMenu() {
|
||||
Menu menuDownload = new Menu();
|
||||
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
|
||||
AccountingManagerResources.INSTANCE.accountingByte24());
|
||||
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
|
||||
AccountingManagerResources.INSTANCE.accountingFilePNG24());
|
||||
downloadPNGItem.setHeight(30);
|
||||
|
@ -222,6 +230,16 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
AccountingManagerResources.INSTANCE.accountingFileSVG24());
|
||||
downloadSVGItem.setHeight(30);
|
||||
|
||||
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadCSV();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
|
@ -259,6 +277,7 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
}
|
||||
});
|
||||
|
||||
menuDownload.add(downloadCSVItem);
|
||||
menuDownload.add(downloadPNGItem);
|
||||
menuDownload.add(downloadJPGItem);
|
||||
menuDownload.add(downloadPDFItem);
|
||||
|
@ -267,6 +286,12 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
|
||||
}
|
||||
|
||||
private void onDownloadCSV() {
|
||||
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
|
||||
accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
|
||||
|
||||
public static native void onDownloadPNG(String id) /*-{
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storag
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ByteUnitMeasure;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
|
||||
|
@ -23,6 +24,7 @@ import com.github.highcharts4gwt.model.highcharts.option.api.ChartOptions;
|
|||
import com.github.highcharts4gwt.model.highcharts.option.api.SeriesColumn;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
|
||||
|
@ -52,11 +54,13 @@ public class StorageChartTopPanel extends SimpleContainer {
|
|||
|
||||
private DateTimeFormat dtf = DateTimeFormat
|
||||
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
|
||||
|
||||
|
||||
private EventBus eventBus;
|
||||
private AccountingStateData accountingStateData;
|
||||
private HighchartsLayoutPanel highchartsLayoutPanel;
|
||||
|
||||
// Download Menu
|
||||
private MenuItem downloadCSVItem;
|
||||
private MenuItem downloadPNGItem;
|
||||
private MenuItem downloadJPGItem;
|
||||
private MenuItem downloadPDFItem;
|
||||
|
@ -83,7 +87,9 @@ public class StorageChartTopPanel extends SimpleContainer {
|
|||
|
||||
private VerticalLayoutContainer vert;
|
||||
|
||||
public StorageChartTopPanel(AccountingStateData accountingStateData) {
|
||||
|
||||
public StorageChartTopPanel(EventBus eventBus, AccountingStateData accountingStateData) {
|
||||
this.eventBus=eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
forceLayoutOnResize = true;
|
||||
create();
|
||||
|
@ -158,6 +164,8 @@ public class StorageChartTopPanel extends SimpleContainer {
|
|||
|
||||
private Menu createDownloadMenu() {
|
||||
Menu menuDownload = new Menu();
|
||||
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
|
||||
AccountingManagerResources.INSTANCE.accountingByte24());
|
||||
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
|
||||
AccountingManagerResources.INSTANCE.accountingFilePNG24());
|
||||
downloadPNGItem.setHeight(30);
|
||||
|
@ -170,7 +178,17 @@ public class StorageChartTopPanel extends SimpleContainer {
|
|||
downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
|
||||
AccountingManagerResources.INSTANCE.accountingFileSVG24());
|
||||
downloadSVGItem.setHeight(30);
|
||||
|
||||
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadCSV();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
|
@ -319,6 +337,12 @@ public class StorageChartTopPanel extends SimpleContainer {
|
|||
return menuUnit;
|
||||
|
||||
}
|
||||
|
||||
private void onDownloadCSV() {
|
||||
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
|
||||
accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils;
|
|||
*/
|
||||
public class DownloadConstants {
|
||||
public static final String DOWNLOAD = "Download";
|
||||
public static final String DOWNLOAD_CSV = "Download CSV";
|
||||
public static final String DOWNLOAD_PNG = "Download PNG Image";
|
||||
public static final String DOWNLOAD_JPG = "Download JPG Image";
|
||||
public static final String DOWNLOAD_PDF = "Download PDF Document";
|
||||
|
|
|
@ -2,14 +2,16 @@ package org.gcube.portlets.admin.accountingmanager.client.rpc;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.session.UserInfo;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
@ -26,9 +28,9 @@ public interface AccountingManagerService extends RemoteService {
|
|||
* Get informations on the current user
|
||||
*
|
||||
* @return
|
||||
* @throws AccountingManagerServiceException
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public UserInfo hello() throws AccountingManagerServiceException;
|
||||
public UserInfo hello() throws ServiceException;
|
||||
|
||||
/**
|
||||
* Retrieve Accounting Series
|
||||
|
@ -38,31 +40,49 @@ public interface AccountingManagerService extends RemoteService {
|
|||
* @param seriesRequest
|
||||
* filters and constraints descriptions
|
||||
* @return
|
||||
* @throws AccountingManagerServiceException
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public SeriesResponse getSeries(AccountingType accountingType,
|
||||
SeriesRequest seriesRequest)
|
||||
throws AccountingManagerServiceException;
|
||||
throws ServiceException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param accountingType
|
||||
* type of accounting
|
||||
* @return list of filter keys
|
||||
* @throws AccountingManagerServiceException
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public ArrayList<FilterKey> getFilterKeys(AccountingType accountingType)
|
||||
throws AccountingManagerServiceException;
|
||||
throws ServiceException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param filterValuesRequest request values available
|
||||
* @return
|
||||
* @throws AccountingManagerServiceException
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public ArrayList<FilterValue> getFilterValues(FilterValuesRequest filterValuesRequest)
|
||||
throws AccountingManagerServiceException;
|
||||
throws ServiceException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param itemDescription item description
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public String getPublicLink(ItemDescription itemDescription)
|
||||
throws ServiceException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param accountingStateData
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public ItemDescription saveCSVOnWorkspace(AccountingStateData accountingStateData)
|
||||
throws ServiceException;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.portlets.admin.accountingmanager.client.rpc;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
||||
|
@ -12,6 +13,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesReques
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.session.UserInfo;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -61,5 +63,21 @@ public interface AccountingManagerServiceAsync {
|
|||
*/
|
||||
void getFilterValues(FilterValuesRequest filterValuesRequest,
|
||||
AsyncCallback<ArrayList<FilterValue>> callback);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param itemDescription item description
|
||||
* @param callback
|
||||
*/
|
||||
void getPublicLink(ItemDescription itemDescription,
|
||||
AsyncCallback<String> callback);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param accountingStateData
|
||||
* @param callback
|
||||
*/
|
||||
void saveCSVOnWorkspace(AccountingStateData accountingStateData,
|
||||
AsyncCallback<ItemDescription> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@ import javax.servlet.http.HttpSession;
|
|||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerService;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCaller;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCallerInterface;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCallerTester;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.csv.CSVManager;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.storage.StorageUtil;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
|
||||
|
@ -17,8 +20,9 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.session.UserInfo;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -58,7 +62,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserInfo hello() throws AccountingManagerServiceException {
|
||||
public UserInfo hello() throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
|
@ -68,13 +72,13 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
|||
aslSession.getUserEmailAddress(),
|
||||
aslSession.getUserFullName());
|
||||
return userInfo;
|
||||
} catch (AccountingManagerServiceException e) {
|
||||
} catch (ServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Hello(): " + e.getLocalizedMessage(), e);
|
||||
throw new AccountingManagerServiceException(e.getLocalizedMessage());
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -85,29 +89,28 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
|||
*/
|
||||
@Override
|
||||
public SeriesResponse getSeries(AccountingType accountingType,
|
||||
SeriesRequest seriesRequest)
|
||||
throws AccountingManagerServiceException {
|
||||
SeriesRequest seriesRequest) throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getASLSession(session);
|
||||
AccountingCallerInterface accountingCaller;
|
||||
if(Constants.DEBUG_MODE){
|
||||
accountingCaller= new AccountingCallerTester();
|
||||
if (Constants.DEBUG_MODE) {
|
||||
accountingCaller = new AccountingCallerTester();
|
||||
} else {
|
||||
accountingCaller= new AccountingCaller();
|
||||
accountingCaller = new AccountingCaller();
|
||||
}
|
||||
SeriesResponse seriesResponse = accountingCaller.getSeries(
|
||||
accountingType, seriesRequest);
|
||||
|
||||
return seriesResponse;
|
||||
|
||||
} catch (AccountingManagerServiceException e) {
|
||||
} catch (ServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
logger.error("getSeries(): " + e.getLocalizedMessage(), e);
|
||||
throw new AccountingManagerServiceException(e.getLocalizedMessage());
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -118,27 +121,28 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
|||
*/
|
||||
@Override
|
||||
public ArrayList<FilterKey> getFilterKeys(AccountingType accountingType)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getASLSession(session);
|
||||
AccountingCallerInterface accountingCaller;
|
||||
if(Constants.DEBUG_MODE){
|
||||
accountingCaller= new AccountingCallerTester();
|
||||
if (Constants.DEBUG_MODE) {
|
||||
accountingCaller = new AccountingCallerTester();
|
||||
} else {
|
||||
accountingCaller= new AccountingCaller();
|
||||
accountingCaller = new AccountingCaller();
|
||||
}
|
||||
ArrayList<FilterKey> filterKeys = accountingCaller.getFilterKeys(accountingType);
|
||||
|
||||
ArrayList<FilterKey> filterKeys = accountingCaller
|
||||
.getFilterKeys(accountingType);
|
||||
|
||||
return filterKeys;
|
||||
|
||||
} catch (AccountingManagerServiceException e) {
|
||||
|
||||
} catch (ServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
logger.error("getFilterKeys(): " + e.getLocalizedMessage(), e);
|
||||
throw new AccountingManagerServiceException(e.getLocalizedMessage());
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -149,31 +153,74 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
|||
*/
|
||||
@Override
|
||||
public ArrayList<FilterValue> getFilterValues(
|
||||
FilterValuesRequest filterValuesRequest)
|
||||
throws AccountingManagerServiceException {
|
||||
FilterValuesRequest filterValuesRequest) throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getASLSession(session);
|
||||
|
||||
AccountingCallerInterface accountingCaller;
|
||||
if(Constants.DEBUG_MODE){
|
||||
accountingCaller= new AccountingCallerTester();
|
||||
if (Constants.DEBUG_MODE) {
|
||||
accountingCaller = new AccountingCallerTester();
|
||||
} else {
|
||||
accountingCaller= new AccountingCaller();
|
||||
accountingCaller = new AccountingCaller();
|
||||
}
|
||||
ArrayList<FilterValue> filterValues = accountingCaller.getFilterValues(filterValuesRequest);
|
||||
|
||||
ArrayList<FilterValue> filterValues = accountingCaller
|
||||
.getFilterValues(filterValuesRequest);
|
||||
|
||||
return filterValues;
|
||||
|
||||
} catch (AccountingManagerServiceException e) {
|
||||
|
||||
} catch (ServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
logger.error("getFilterValues(): " + e.getLocalizedMessage(), e);
|
||||
throw new AccountingManagerServiceException(e.getLocalizedMessage());
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDescription saveCSVOnWorkspace(AccountingStateData accountingStateData)
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
logger.debug("SaveDataOnWorkspace(): " + accountingStateData);
|
||||
CSVManager csvManager=new CSVManager(aslSession.getUsername());
|
||||
ItemDescription itemDescription=csvManager.saveOnWorkspace(accountingStateData);
|
||||
return itemDescription;
|
||||
} catch (ServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("SaveDataOnWorkspace(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getPublicLink(ItemDescription itemDescription)
|
||||
throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
logger.debug("GetPublicLink(): " + itemDescription);
|
||||
String link = StorageUtil.getPublicLink(aslSession.getUsername(),
|
||||
itemDescription.getId());
|
||||
|
||||
return link;
|
||||
} catch (ServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("getPublicLink(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ import org.gcube.application.framework.core.session.ASLSession;
|
|||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerSessionExpiredException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpiredException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class SessionUtil {
|
|||
private static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
|
||||
|
||||
public static ASLSession getASLSession(HttpSession httpSession)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
String username = (String) httpSession
|
||||
.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||
ASLSession aslSession;
|
||||
|
@ -49,7 +49,7 @@ public class SessionUtil {
|
|||
aslSession.setScope(scope);
|
||||
} else {
|
||||
logger.info("No user found in session");
|
||||
throw new AccountingManagerSessionExpiredException("Session Expired!");
|
||||
throw new SessionExpiredException("Session Expired!");
|
||||
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -40,14 +40,14 @@ public class AccountingCaller implements AccountingCallerInterface {
|
|||
}
|
||||
|
||||
public ArrayList<FilterKey> getFilterKeys(AccountingType accountingType)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
AccountingCommandGetFilterKeys accountingCommand=new AccountingCommandGetFilterKeys(accountingType);
|
||||
return accountingCommand.execute();
|
||||
}
|
||||
|
||||
public ArrayList<FilterValue> getFilterValues(
|
||||
FilterValuesRequest filterValuesRequest)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
AccountingCommandGetFilterValues accountingCommand=new AccountingCommandGetFilterValues(filterValuesRequest);
|
||||
return accountingCommand.execute();
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class AccountingCaller implements AccountingCallerInterface {
|
|||
|
||||
public SeriesResponse getSeries(AccountingType accountingType,
|
||||
SeriesRequest seriesRequest)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
try {
|
||||
logger.debug("getSeries(): [AccountingType=" + accountingType
|
||||
+ " , seriesRequest=" + seriesRequest + "]");
|
||||
|
@ -71,7 +71,7 @@ public class AccountingCaller implements AccountingCallerInterface {
|
|||
logger.debug("Query: " + query);
|
||||
|
||||
if (query == null || query.getChartType() == null) {
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error in invocation: Operation not supported");
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class AccountingCaller implements AccountingCallerInterface {
|
|||
AccountingCommandTop accountingCommandTop=new AccountingCommandTop(accountingQueryTop,accountingType);
|
||||
return accountingCommandTop.execute();
|
||||
default:
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error in invocation: Operation not supported");
|
||||
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class AccountingCaller implements AccountingCallerInterface {
|
|||
} catch (Throwable e) {
|
||||
logger.error("Error in GetSeries(): " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -101,9 +101,9 @@ public class AccountingCaller implements AccountingCallerInterface {
|
|||
|
||||
private AccountingQueryBuilder getAccountQueryBuilder(
|
||||
AccountingType accountingType, SeriesRequest seriesRequest)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
if (accountingType == null) {
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error accounting type is null");
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ public class AccountingCaller implements AccountingCallerInterface {
|
|||
case TASK:
|
||||
return new AccountingQuery4Task(seriesRequest);
|
||||
default:
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error request type is unknow!");
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -19,14 +19,14 @@ import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingMan
|
|||
public interface AccountingCallerInterface {
|
||||
|
||||
public ArrayList<FilterKey> getFilterKeys(AccountingType accountingType)
|
||||
throws AccountingManagerServiceException;
|
||||
throws ServiceException;
|
||||
|
||||
public ArrayList<FilterValue> getFilterValues(
|
||||
FilterValuesRequest filterValuesRequest)
|
||||
throws AccountingManagerServiceException;
|
||||
throws ServiceException;
|
||||
|
||||
public SeriesResponse getSeries(AccountingType accountingType,
|
||||
SeriesRequest seriesRequest)
|
||||
throws AccountingManagerServiceException;
|
||||
throws ServiceException;
|
||||
|
||||
}
|
|
@ -30,7 +30,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.S
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDefinition;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class AccountingCallerTester implements AccountingCallerInterface {
|
|||
}
|
||||
|
||||
public ArrayList<FilterKey> getFilterKeys(AccountingType accountingType)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
try {
|
||||
logger.debug("getFilterKeys(): [AccountingType=" + accountingType
|
||||
+ "]");
|
||||
|
@ -68,14 +68,14 @@ public class AccountingCallerTester implements AccountingCallerInterface {
|
|||
} catch (Throwable e) {
|
||||
logger.error("Error in getFilterKeys(): " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("No keys available!");
|
||||
throw new ServiceException("No keys available!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<FilterValue> getFilterValues(
|
||||
FilterValuesRequest filterValuesRequest)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
try {
|
||||
logger.debug("getFilterValue(): [FilterValueRequest="
|
||||
+ filterValuesRequest + "]");
|
||||
|
@ -115,14 +115,14 @@ public class AccountingCallerTester implements AccountingCallerInterface {
|
|||
logger.error("Error in getFilterValues(): "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("No values available!");
|
||||
throw new ServiceException("No values available!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public SeriesResponse getSeries(AccountingType accountingType,
|
||||
SeriesRequest seriesRequest)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
try {
|
||||
logger.debug("getSeries(): [AccountingType=" + accountingType
|
||||
+ " , seriesRequest=" + seriesRequest + "]");
|
||||
|
@ -268,7 +268,7 @@ public class AccountingCallerTester implements AccountingCallerInterface {
|
|||
}
|
||||
|
||||
if (seriesResponse == null) {
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error creating series response!");
|
||||
}
|
||||
logger.debug("SeriesResponse Created: " + seriesResponse);
|
||||
|
@ -276,7 +276,7 @@ public class AccountingCallerTester implements AccountingCallerInterface {
|
|||
} catch (Throwable e) {
|
||||
logger.error("Error in GetSeries(): " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,6 @@ import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingMan
|
|||
*/
|
||||
public interface AccountingCommand<T> {
|
||||
|
||||
T execute() throws AccountingManagerServiceException;
|
||||
T execute() throws ServiceException;
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.gcube.portlets.admin.accountingmanager.server.amservice.response.Seri
|
|||
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponseDirector;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class AccountingCommandBasic implements AccountingCommand<SeriesResponse>
|
|||
|
||||
|
||||
@Override
|
||||
public SeriesResponse execute() throws AccountingManagerServiceException {
|
||||
public SeriesResponse execute() throws ServiceException {
|
||||
try {
|
||||
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance();
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class AccountingCommandBasic implements AccountingCommand<SeriesResponse>
|
|||
accountingQueryBasic.getFilters(), true);
|
||||
|
||||
if (sm == null || sm.values()==null) {
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error retrieving info: sorted map is null!");
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class AccountingCommandBasic implements AccountingCommand<SeriesResponse>
|
|||
.getSeriesResponse();
|
||||
|
||||
if (seriesResponse == null) {
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error creating series response!");
|
||||
}
|
||||
logger.debug("SeriesResponse Created: " + seriesResponse);
|
||||
|
@ -78,16 +78,16 @@ public class AccountingCommandBasic implements AccountingCommand<SeriesResponse>
|
|||
} catch (Throwable e) {
|
||||
logger.error("Error in AccountingCommandBasic(): " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private SeriesResponseBuilder getSeriesResponseBuilder(
|
||||
AccountingType accountingType, List<Info> infos)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
if (accountingType == null) {
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error accounting type is null");
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class AccountingCommandBasic implements AccountingCommand<SeriesResponse>
|
|||
case TASK:
|
||||
return new SeriesResponse4TaskBasic(infos);
|
||||
default:
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error request type is unknow!");
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
|||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class AccountingCommandGetFilterKeys implements AccountingCommand<ArrayLi
|
|||
|
||||
|
||||
@Override
|
||||
public ArrayList<FilterKey> execute() throws AccountingManagerServiceException {
|
||||
public ArrayList<FilterKey> execute() throws ServiceException {
|
||||
try {
|
||||
logger.debug("getFilterKeys(): [AccountingType=" + accountingType
|
||||
+ "]");
|
||||
|
@ -70,7 +70,7 @@ public class AccountingCommandGetFilterKeys implements AccountingCommand<ArrayLi
|
|||
} catch (Throwable e) {
|
||||
logger.error("Error in AccountingCommandGetFilterKeys(): " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("No keys available!");
|
||||
throw new ServiceException("No keys available!");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
|||
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class AccountingCommandGetFilterValues implements
|
|||
|
||||
@Override
|
||||
public ArrayList<FilterValue> execute()
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
try {
|
||||
logger.debug("getFilterValue(): [FilterValueRequest="
|
||||
+ filterValuesRequest + "]");
|
||||
|
@ -70,7 +70,7 @@ public class AccountingCommandGetFilterValues implements
|
|||
.getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
throw new ServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar
|
||||
|
@ -80,7 +80,7 @@ public class AccountingCommandGetFilterValues implements
|
|||
.getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
throw new ServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
|
@ -136,7 +136,7 @@ public class AccountingCommandGetFilterValues implements
|
|||
logger.error("Error in AccountingCommandGetFilterValues(): "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("No values available!");
|
||||
throw new ServiceException("No values available!");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.gcube.portlets.admin.accountingmanager.server.amservice.response.Seri
|
|||
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponseDirector;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SeriesResponse execute() throws AccountingManagerServiceException {
|
||||
public SeriesResponse execute() throws ServiceException {
|
||||
try {
|
||||
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory
|
||||
.getInstance();
|
||||
|
@ -58,7 +58,7 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
|
|||
accountingQueryTop.getTopNumber());
|
||||
|
||||
if (topSM == null) {
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error retrieving info for top: sorted map is null!");
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
|
|||
.getSeriesResponse();
|
||||
|
||||
if (seriesResponse == null) {
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error creating series response!");
|
||||
}
|
||||
logger.debug("SeriesResponse Created: " + seriesResponse);
|
||||
|
@ -86,16 +86,16 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
|
|||
logger.error("Error in AccountingCommandTop(): "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private SeriesResponseBuilder getSeriesResponseBuilder(
|
||||
AccountingType accountingType, SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM)
|
||||
throws AccountingManagerServiceException {
|
||||
throws ServiceException {
|
||||
if (accountingType == null) {
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error accounting type is null");
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
|
|||
case TASK:
|
||||
return new SeriesResponse4TaskTop(topSM);
|
||||
default:
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error request type is unknow!");
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildOpEx() throws AccountingManagerServiceException {
|
||||
public void buildOpEx() throws ServiceException {
|
||||
|
||||
Calendar startCalendar = GregorianCalendar
|
||||
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
|
@ -43,7 +43,7 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
|
|||
.getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
throw new ServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar
|
||||
|
@ -53,7 +53,7 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
|
|||
.getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
throw new ServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
|
@ -110,14 +110,14 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
|
|||
temporalConstraint, filters);
|
||||
} else {
|
||||
logger.error("Invalid Request: " + seriesRequest);
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Invalid Request!");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
logger.error("Invalid Request: " + seriesRequest);
|
||||
throw new AccountingManagerServiceException("Invalid Request!");
|
||||
throw new ServiceException("Invalid Request!");
|
||||
}
|
||||
|
||||
accountingQuerySpec.setOp(invocation);
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildOpEx() throws AccountingManagerServiceException {
|
||||
public void buildOpEx() throws ServiceException {
|
||||
Calendar startCalendar = GregorianCalendar
|
||||
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
|
@ -42,7 +42,7 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
|
|||
.getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
throw new ServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar
|
||||
|
@ -52,7 +52,7 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
|
|||
.getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
throw new ServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
|
@ -109,14 +109,14 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
|
|||
temporalConstraint, filters);
|
||||
} else {
|
||||
logger.error("Invalid Request: " + seriesRequest);
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Invalid Request!");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
logger.error("Invalid Request: " + seriesRequest);
|
||||
throw new AccountingManagerServiceException("Invalid Request!");
|
||||
throw new ServiceException("Invalid Request!");
|
||||
}
|
||||
|
||||
accountingQuerySpec.setOp(invocation);
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildOpEx() throws AccountingManagerServiceException {
|
||||
public void buildOpEx() throws ServiceException {
|
||||
|
||||
Calendar startCalendar = GregorianCalendar
|
||||
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
|
@ -43,7 +43,7 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
|
|||
.getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
throw new ServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar
|
||||
|
@ -53,7 +53,7 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
|
|||
.getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
throw new ServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
|
@ -110,14 +110,14 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
|
|||
temporalConstraint, filters);
|
||||
} else {
|
||||
logger.error("Invalid Request: " + seriesRequest);
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Invalid Request!");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
logger.error("Invalid Request: " + seriesRequest);
|
||||
throw new AccountingManagerServiceException("Invalid Request!");
|
||||
throw new ServiceException("Invalid Request!");
|
||||
}
|
||||
|
||||
accountingQuerySpec.setOp(invocation);
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildOpEx() throws AccountingManagerServiceException {
|
||||
public void buildOpEx() throws ServiceException {
|
||||
|
||||
Calendar startCalendar = GregorianCalendar
|
||||
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
|
@ -43,7 +43,7 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
|
|||
.getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
throw new ServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar
|
||||
|
@ -53,7 +53,7 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
|
|||
.getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
throw new ServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
|
@ -110,14 +110,14 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
|
|||
temporalConstraint, filters);
|
||||
} else {
|
||||
logger.error("Invalid Request: " + seriesRequest);
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Invalid Request!");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
logger.error("Invalid Request: " + seriesRequest);
|
||||
throw new AccountingManagerServiceException("Invalid Request!");
|
||||
throw new ServiceException("Invalid Request!");
|
||||
}
|
||||
|
||||
accountingQuerySpec.setOp(invocation);
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildOpEx() throws AccountingManagerServiceException {
|
||||
public void buildOpEx() throws ServiceException {
|
||||
Calendar startCalendar = GregorianCalendar
|
||||
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
|
@ -42,7 +42,7 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
|
|||
.getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
throw new ServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar
|
||||
|
@ -52,7 +52,7 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
|
|||
.getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
throw new ServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
|
@ -109,14 +109,14 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
|
|||
temporalConstraint, filters);
|
||||
} else {
|
||||
logger.error("Invalid Request: " + seriesRequest);
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Invalid Request!");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
logger.error("Invalid Request: " + seriesRequest);
|
||||
throw new AccountingManagerServiceException("Invalid Request!");
|
||||
throw new ServiceException("Invalid Request!");
|
||||
}
|
||||
|
||||
accountingQuerySpec.setOp(invocation);
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
/**
|
||||
* Abstract class for build Accounting Query
|
||||
|
@ -23,7 +23,7 @@ public abstract class AccountingQueryBuilder {
|
|||
|
||||
}
|
||||
|
||||
public abstract void buildOpEx() throws AccountingManagerServiceException;
|
||||
public abstract void buildOpEx() throws ServiceException;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ public class AccountingQueryDirector {
|
|||
|
||||
}
|
||||
|
||||
public void constructAccountingQuery() throws AccountingManagerServiceException {
|
||||
public void constructAccountingQuery() throws ServiceException {
|
||||
accountingQueryBuilder.createSpec();
|
||||
accountingQueryBuilder.buildOpEx();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -30,11 +30,11 @@ public class SeriesResponse4JobBasic extends SeriesResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
try {
|
||||
if (infos.size() <= 0) {
|
||||
logger.error("Error creating series for job accounting: No data available!");
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"No data available!");
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class SeriesResponse4JobBasic extends SeriesResponseBuilder {
|
|||
logger.error("Error creating series for job accounting basic chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error creating series for job accounting basic chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -35,11 +35,11 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
try {
|
||||
if (topSM == null || topSM.isEmpty()) {
|
||||
logger.error("Error creating series for job accounting: No data available!");
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"No data available!");
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder {
|
|||
logger.error("Error creating series for job accounting top chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error creating series for job accounting top chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.accounting.analytics.Info;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -26,10 +26,10 @@ public class SeriesResponse4PortletBasic extends SeriesResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
if(infos.size()<=0){
|
||||
logger.error("Error creating series for portlet accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
}
|
||||
|
||||
//SeriesPortletBasic seriesPortletBasic=new SeriesPortletBasic(series);
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesPor
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletDataTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -35,11 +35,11 @@ public class SeriesResponse4PortletTop extends SeriesResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
try {
|
||||
if (topSM == null || topSM.isEmpty()) {
|
||||
logger.error("Error creating series for portlet accounting: No data available!");
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"No data available!");
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class SeriesResponse4PortletTop extends SeriesResponseBuilder {
|
|||
logger.error("Error creating series for portlet accounting top chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error creating series for portlet accounting top chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -30,11 +30,11 @@ public class SeriesResponse4ServiceBasic extends SeriesResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
try {
|
||||
if(infos.size()<=0){
|
||||
logger.error("Error creating series for service accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
}
|
||||
|
||||
ArrayList<SeriesServiceData> series=new ArrayList<SeriesServiceData>();
|
||||
|
@ -58,7 +58,7 @@ public class SeriesResponse4ServiceBasic extends SeriesResponseBuilder {
|
|||
} catch (Throwable e) {
|
||||
logger.error("Error creating series for service accounting chart basic: "+e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Error creating series for service accounting chart basic: "+e.getLocalizedMessage());
|
||||
throw new ServiceException("Error creating series for service accounting chart basic: "+e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesSer
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -35,11 +35,11 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
try {
|
||||
if (topSM == null || topSM.isEmpty()) {
|
||||
logger.error("Error creating series for service accounting: No data available!");
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"No data available!");
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
|
|||
logger.error("Error creating series for service accounting top chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error creating series for service accounting top chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -30,11 +30,11 @@ public class SeriesResponse4StorageBasic extends SeriesResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
try {
|
||||
if(infos.size()<=0){
|
||||
logger.error("Error creating series for storage accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
}
|
||||
|
||||
ArrayList<SeriesStorageData> series=new ArrayList<SeriesStorageData>();
|
||||
|
@ -54,7 +54,7 @@ public class SeriesResponse4StorageBasic extends SeriesResponseBuilder {
|
|||
} catch (Throwable e) {
|
||||
logger.error("Error creating series for storage accounting basic chart: "+e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Error creating series for storage accounting basic chart: "+e.getLocalizedMessage());
|
||||
throw new ServiceException("Error creating series for storage accounting basic chart: "+e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesSto
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -34,11 +34,11 @@ public class SeriesResponse4StorageTop extends SeriesResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
try {
|
||||
if(topSM==null||topSM.isEmpty()){
|
||||
logger.error("Error creating series for storage accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class SeriesResponse4StorageTop extends SeriesResponseBuilder {
|
|||
} catch (Throwable e) {
|
||||
logger.error("Error creating series for storage accounting top chart: "+e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Error creating series for storage accounting basic chart: "+e.getLocalizedMessage());
|
||||
throw new ServiceException("Error creating series for storage accounting basic chart: "+e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.accounting.analytics.Info;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -25,10 +25,10 @@ public class SeriesResponse4TaskBasic extends SeriesResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
if(infos.size()<=0){
|
||||
logger.error("Error creating series for task accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
}
|
||||
|
||||
//SeriesTaskBasic seriesTaskBasic=new SeriesTaskBasic(series);
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesTas
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskDataTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -34,11 +34,11 @@ public class SeriesResponse4TaskTop extends SeriesResponseBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
try {
|
||||
if (topSM == null || topSM.isEmpty()) {
|
||||
logger.error("Error creating series for task accounting: No data available!");
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"No data available!");
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class SeriesResponse4TaskTop extends SeriesResponseBuilder {
|
|||
logger.error("Error creating series for portlet accounting top chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException(
|
||||
throw new ServiceException(
|
||||
"Error creating series for portlet accounting top chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
/**
|
||||
* Abstract class for build Series Response
|
||||
|
@ -20,7 +20,7 @@ public abstract class SeriesResponseBuilder {
|
|||
|
||||
}
|
||||
|
||||
public abstract void buildSeriesResponse() throws AccountingManagerServiceException;
|
||||
public abstract void buildSeriesResponse() throws ServiceException;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ public class SeriesResponseDirector {
|
|||
|
||||
}
|
||||
|
||||
public void constructSeriesResponse() throws AccountingManagerServiceException {
|
||||
public void constructSeriesResponse() throws ServiceException {
|
||||
seriesResponseBuilder.createSpec();
|
||||
seriesResponseBuilder.buildSeriesResponse();
|
||||
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVPrinter;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVDataRow;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModel;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModel4Storage;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModelBuilder;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModelDirector;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.storage.StorageUtil;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* CSV Manager
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVManager {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(CSVManager.class);
|
||||
private String userName;
|
||||
|
||||
public CSVManager(String userName){
|
||||
this.userName=userName;
|
||||
}
|
||||
|
||||
public ItemDescription saveOnWorkspace(AccountingStateData accountingStateData) throws ServiceException {
|
||||
try {
|
||||
if (accountingStateData == null) {
|
||||
logger.error("AccountingStateData is null");
|
||||
throw new ServiceException("AccountingStateData is null!");
|
||||
}
|
||||
|
||||
if (accountingStateData.getAccountingType() == null) {
|
||||
logger.error("Accounting Type is null");
|
||||
throw new ServiceException("Accounting Type is null!");
|
||||
}
|
||||
|
||||
CSVModelBuilder csvModelBuilder = null;
|
||||
|
||||
switch (accountingStateData.getAccountingType()) {
|
||||
case SERVICE:
|
||||
break;
|
||||
case STORAGE:
|
||||
csvModelBuilder = new CSVModel4Storage(accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
logger.error("Accounting Type not supported!");
|
||||
throw new ServiceException("Accounting Type not supported!!");
|
||||
}
|
||||
|
||||
CSVModelDirector director = new CSVModelDirector();
|
||||
director.setCSVModelBuilder(csvModelBuilder);
|
||||
director.constructCSVModel();
|
||||
CSVModel csvModel = director.getCSVModel();
|
||||
logger.debug("CSVModel: " + csvModel);
|
||||
|
||||
if (csvModel == null) {
|
||||
logger.error("CSV model created is null");
|
||||
throw new ServiceException("CSVModel created is null!");
|
||||
}
|
||||
|
||||
Path tempFile = Files.createTempFile(csvModel.getFileName(),
|
||||
csvModel.getFileExtension());
|
||||
logger.debug("Temp File: " + tempFile.toString());
|
||||
|
||||
// Create the CSVFormat object
|
||||
CSVFormat format = CSVFormat.RFC4180.withHeader()
|
||||
.withDelimiter(',');
|
||||
|
||||
PrintStream printStream = new PrintStream(tempFile.toFile());
|
||||
// CSV Write Example using CSVPrinter
|
||||
CSVPrinter printer = new CSVPrinter(printStream, format);
|
||||
printer.printRecord(csvModel.getHeader());
|
||||
for (CSVDataRow row : csvModel.getRows()) {
|
||||
printer.printRecord(row.getData());
|
||||
}
|
||||
// close the printer
|
||||
printer.close();
|
||||
printStream.close();
|
||||
|
||||
String destinationFolderId = StorageUtil
|
||||
.createAccountingFolderOnWorkspace(userName);
|
||||
ItemDescription itemDescription=null;
|
||||
try (InputStream is = Files.newInputStream(tempFile,
|
||||
StandardOpenOption.READ)) {
|
||||
itemDescription=StorageUtil.saveOnWorkspace(userName, destinationFolderId,
|
||||
csvModel.getFileName() + csvModel.getFileExtension(),
|
||||
csvModel.getFileName(), is);
|
||||
}
|
||||
|
||||
try {
|
||||
Files.delete(tempFile);
|
||||
} catch (IOException e) {
|
||||
logger.error("Error in deleting temp file: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error deleting temp file: "+e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
|
||||
return itemDescription;
|
||||
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error saving data: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error saving data: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Row of csv
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVDataRow implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -707694572028800959L;
|
||||
private ArrayList<String> data;
|
||||
|
||||
public CSVDataRow() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CSVDataRow(ArrayList<String> data) {
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ArrayList<String> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(ArrayList<String> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CSVDataRow [data=" + data + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7127656837246518599L;
|
||||
private String fileName;
|
||||
private String fileExtension;
|
||||
private ArrayList<String> header;
|
||||
private ArrayList<CSVDataRow> rows;
|
||||
|
||||
public CSVModel() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CSVModel(String fileName, ArrayList<String> header,
|
||||
ArrayList<CSVDataRow> rows) {
|
||||
super();
|
||||
this.fileName = fileName;
|
||||
this.fileExtension =".csv";
|
||||
this.header = header;
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
return fileExtension;
|
||||
}
|
||||
|
||||
public void setFileExtension(String fileExtension) {
|
||||
this.fileExtension = fileExtension;
|
||||
}
|
||||
|
||||
public ArrayList<String> getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public void setHeader(ArrayList<String> header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public ArrayList<CSVDataRow> getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(ArrayList<CSVDataRow> rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CSVModel [fileName=" + fileName + ", fileExtension="
|
||||
+ fileExtension + ", header=" + header + ", rows=" + rows + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDefinition;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* CSV Model 4 Service
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVModel4Service extends CSVModelBuilder {
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(CSVModel4Service.class);
|
||||
private AccountingStateData accountingStateData;
|
||||
|
||||
public CSVModel4Service(AccountingStateData accountingStateData) {
|
||||
this.accountingStateData = accountingStateData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildOpEx() throws ServiceException {
|
||||
SeriesRequest seriesRequest = accountingStateData.getSeriesRequest();
|
||||
|
||||
if (seriesRequest == null) {
|
||||
logger.error("Error series request is null");
|
||||
throw new ServiceException(
|
||||
"Error series request is null");
|
||||
|
||||
}
|
||||
|
||||
String startDate = sdfFile.format(seriesRequest.getAccountingPeriod()
|
||||
.getStartDate());
|
||||
String endDate = sdfFile.format(seriesRequest.getAccountingPeriod()
|
||||
.getEndDate());
|
||||
String periodType = seriesRequest.getAccountingPeriod().getPeriod()
|
||||
.getLabel();
|
||||
|
||||
SeriesResponse seriesResponse = accountingStateData.getSeriesResponse();
|
||||
|
||||
if (seriesResponse == null) {
|
||||
logger.error("Error series response is null");
|
||||
throw new ServiceException(
|
||||
"Error series response is null");
|
||||
}
|
||||
|
||||
String fileName = "Untitled";
|
||||
ArrayList<String> header;
|
||||
ArrayList<CSVDataRow> rows = new ArrayList<>();
|
||||
if (seriesResponse instanceof SeriesService) {
|
||||
SeriesService seriesService = (SeriesService) seriesResponse;
|
||||
SeriesServiceDefinition definition = seriesService
|
||||
.getSerieServiceDefinition();
|
||||
if (definition instanceof SeriesServiceBasic) {
|
||||
SeriesServiceBasic seriesServiceBasic = (SeriesServiceBasic) definition;
|
||||
fileName = "Service_" + periodType + "_" + startDate + "_"
|
||||
+ endDate;
|
||||
header = new ArrayList<>(Arrays.asList(new String[] { "Date",
|
||||
"Operation Count", "Duration", "Max Invocation",
|
||||
"Min Invocation" }));
|
||||
ArrayList<SeriesServiceData> listData = seriesServiceBasic
|
||||
.getSeries();
|
||||
for (SeriesServiceData seriesData : listData) {
|
||||
ArrayList<String> data = new ArrayList<>();
|
||||
data.add(sdf.format(seriesData.getDate()));
|
||||
data.add(String.valueOf(seriesData.getOperationCount()));
|
||||
data.add(String.valueOf(seriesData.getDuration()));
|
||||
data.add(String.valueOf(seriesData.getMaxInvocationTime()));
|
||||
data.add(String.valueOf(seriesData.getMinInvocationTime()));
|
||||
CSVDataRow csvDataRow = new CSVDataRow(data);
|
||||
rows.add(csvDataRow);
|
||||
}
|
||||
} else {
|
||||
if (definition instanceof SeriesServiceTop) {
|
||||
SeriesServiceTop seriesServiceTop = (SeriesServiceTop) definition;
|
||||
fileName = "ServiceTop_" + periodType + "_" + startDate
|
||||
+ "_" + endDate;
|
||||
header = new ArrayList<>(Arrays.asList(new String[] {
|
||||
"Value", "Date", "Operation Count", "Duration",
|
||||
"Max Invocation", "Min Invocation" }));
|
||||
ArrayList<SeriesServiceDataTop> listDataTop = seriesServiceTop
|
||||
.getSeriesServiceDataTopList();
|
||||
for (SeriesServiceDataTop seriesDataTop : listDataTop) {
|
||||
FilterValue filterValue = seriesDataTop
|
||||
.getFilterValue();
|
||||
ArrayList<SeriesServiceData> listData = seriesDataTop
|
||||
.getSeries();
|
||||
for (SeriesServiceData seriesData : listData) {
|
||||
ArrayList<String> data = new ArrayList<>();
|
||||
data.add(filterValue.getValue());
|
||||
data.add(sdf.format(seriesData.getDate()));
|
||||
data.add(String.valueOf(seriesData
|
||||
.getOperationCount()));
|
||||
data.add(String.valueOf(seriesData.getDuration()));
|
||||
data.add(String.valueOf(seriesData
|
||||
.getMaxInvocationTime()));
|
||||
data.add(String.valueOf(seriesData
|
||||
.getMinInvocationTime()));
|
||||
CSVDataRow csvDataRow = new CSVDataRow(data);
|
||||
rows.add(csvDataRow);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.error("Unsupported Serie Definition for Service: "
|
||||
+ definition);
|
||||
throw new ServiceException(
|
||||
"Unsupported Serie Definition for Service: "
|
||||
+ definition);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.error("Service not support this serie response: "
|
||||
+ seriesResponse);
|
||||
throw new ServiceException(
|
||||
"Service not support this serie response: "
|
||||
+ seriesResponse);
|
||||
}
|
||||
|
||||
CSVModel invocation = new CSVModel(fileName, header, rows);
|
||||
csvModelSpec.setOp(invocation);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDefinition;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* CSV Model 4 Storage
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVModel4Storage extends CSVModelBuilder {
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(CSVModel4Storage.class);
|
||||
private AccountingStateData accountingStateData;
|
||||
|
||||
public CSVModel4Storage(AccountingStateData accountingStateData) {
|
||||
this.accountingStateData = accountingStateData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildOpEx() throws ServiceException {
|
||||
SeriesRequest seriesRequest = accountingStateData.getSeriesRequest();
|
||||
|
||||
if (seriesRequest == null) {
|
||||
logger.error("Error series request is null");
|
||||
throw new ServiceException(
|
||||
"Error series request is null");
|
||||
|
||||
}
|
||||
|
||||
String startDate = sdfFile.format(seriesRequest.getAccountingPeriod()
|
||||
.getStartDate());
|
||||
String endDate = sdfFile.format(seriesRequest.getAccountingPeriod()
|
||||
.getEndDate());
|
||||
String periodType = seriesRequest.getAccountingPeriod().getPeriod()
|
||||
.getLabel();
|
||||
|
||||
SeriesResponse seriesResponse = accountingStateData.getSeriesResponse();
|
||||
|
||||
if (seriesResponse == null) {
|
||||
logger.error("Error series response is null");
|
||||
throw new ServiceException(
|
||||
"Error series response is null");
|
||||
}
|
||||
|
||||
String fileName = "Untitled";
|
||||
ArrayList<String> header;
|
||||
ArrayList<CSVDataRow> rows = new ArrayList<>();
|
||||
if (seriesResponse instanceof SeriesStorage) {
|
||||
SeriesStorage seriesStorage = (SeriesStorage) seriesResponse;
|
||||
SeriesStorageDefinition definition = seriesStorage
|
||||
.getSeriesStorageDefinition();
|
||||
if (definition instanceof SeriesStorageBasic) {
|
||||
SeriesStorageBasic seriesStorageBasic = (SeriesStorageBasic) definition;
|
||||
fileName = "Storage_" + periodType + "_" + startDate + "_"
|
||||
+ endDate;
|
||||
header = new ArrayList<>(Arrays.asList(new String[] { "Date",
|
||||
"Operation Count", "Data Volume" }));
|
||||
ArrayList<SeriesStorageData> listData = seriesStorageBasic
|
||||
.getSeries();
|
||||
for (SeriesStorageData seriesData : listData) {
|
||||
ArrayList<String> data = new ArrayList<>();
|
||||
data.add(sdf.format(seriesData.getDate()));
|
||||
data.add(sdf.format(seriesData.getOperationCount()));
|
||||
data.add(sdf.format(seriesData.getDataVolume()));
|
||||
CSVDataRow csvDataRow = new CSVDataRow(data);
|
||||
rows.add(csvDataRow);
|
||||
}
|
||||
} else {
|
||||
if (definition instanceof SeriesStorageTop) {
|
||||
SeriesStorageTop seriesStorageTop = (SeriesStorageTop) definition;
|
||||
fileName = "StorageTop_" + periodType + "_" + startDate
|
||||
+ "_" + endDate;
|
||||
header = new ArrayList<>(
|
||||
Arrays.asList(new String[] { "Value", "Date",
|
||||
"Operation Count", "Data Volume" }));
|
||||
ArrayList<SeriesStorageDataTop> listDataTop = seriesStorageTop
|
||||
.getSeriesStorageDataTopList();
|
||||
for (SeriesStorageDataTop seriesDataTop : listDataTop) {
|
||||
FilterValue filterValue = seriesDataTop
|
||||
.getFilterValue();
|
||||
ArrayList<SeriesStorageData> listData = seriesDataTop
|
||||
.getSeries();
|
||||
for (SeriesStorageData seriesData : listData) {
|
||||
ArrayList<String> data = new ArrayList<>();
|
||||
data.add(filterValue.getValue());
|
||||
data.add(sdf.format(seriesData.getDate()));
|
||||
data.add(sdf.format(seriesData.getOperationCount()));
|
||||
data.add(sdf.format(seriesData.getDataVolume()));
|
||||
CSVDataRow csvDataRow = new CSVDataRow(data);
|
||||
rows.add(csvDataRow);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.error("Unsupported Serie Definition for Storage: "
|
||||
+ definition);
|
||||
throw new ServiceException(
|
||||
"Unsupported Serie Definition for Storage: "
|
||||
+ definition);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.error("Storage not support this serie response: "
|
||||
+ seriesResponse);
|
||||
throw new ServiceException(
|
||||
"Storage not support this serie response: "
|
||||
+ seriesResponse);
|
||||
}
|
||||
|
||||
CSVModel invocation = new CSVModel(fileName,header, rows);
|
||||
csvModelSpec.setOp(invocation);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
/**
|
||||
* Abstract class for build CSV Model
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public abstract class CSVModelBuilder {
|
||||
protected CSVModelSpec csvModelSpec;
|
||||
protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
protected SimpleDateFormat sdfFile = new SimpleDateFormat("yyyyMMdd");
|
||||
|
||||
public CSVModelSpec getCSVModelSpec(){
|
||||
return csvModelSpec;
|
||||
}
|
||||
public void createSpec(){
|
||||
csvModelSpec=new CSVModelSpec();
|
||||
|
||||
}
|
||||
|
||||
public abstract void buildOpEx() throws ServiceException;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* CSV Model Director
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVModelDirector {
|
||||
CSVModelBuilder csvModelBuilder;
|
||||
|
||||
public void setCSVModelBuilder(
|
||||
CSVModelBuilder csvModelBuilder) {
|
||||
this.csvModelBuilder = csvModelBuilder;
|
||||
}
|
||||
|
||||
public CSVModel getCSVModel() {
|
||||
return csvModelBuilder.getCSVModelSpec().getOp();
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<CSVModel> getListOfCSVModel() {
|
||||
return csvModelBuilder.getCSVModelSpec().getOps();
|
||||
|
||||
}
|
||||
|
||||
public void constructCSVModel() throws ServiceException {
|
||||
csvModelBuilder.createSpec();
|
||||
csvModelBuilder.buildOpEx();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* CSV Model Specification
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVModelSpec {
|
||||
private CSVModel op;
|
||||
private ArrayList<CSVModel> ops;
|
||||
|
||||
public CSVModel getOp() {
|
||||
return op;
|
||||
}
|
||||
|
||||
public void setOp(CSVModel op) {
|
||||
this.op = op;
|
||||
}
|
||||
|
||||
public ArrayList<CSVModel> getOps() {
|
||||
return ops;
|
||||
}
|
||||
|
||||
public void setOps(ArrayList<CSVModel> ops) {
|
||||
this.ops = ops;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.storage;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class StorageUtil {
|
||||
|
||||
private static final String ACCOUNTING_MANAGER = "AccountingManager";
|
||||
private static Logger logger = Logger.getLogger(StorageUtil.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* User
|
||||
* @param itemId
|
||||
* Item id
|
||||
* @return Public link
|
||||
* @throws StatAlgoImporterServiceException
|
||||
*/
|
||||
public static String getPublicLink(String user, String itemId)
|
||||
throws ServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(itemId);
|
||||
if (workSpaceItem.isFolder()) {
|
||||
throw new ServiceException("Attention this is a folder!");
|
||||
}
|
||||
|
||||
if (workSpaceItem instanceof FolderItem) {
|
||||
return workSpaceItem.getPublicLink(true);
|
||||
} else {
|
||||
throw new ServiceException(
|
||||
"Attention no public link for this item!");
|
||||
}
|
||||
|
||||
} catch (WorkspaceFolderNotFoundException | InternalErrorException
|
||||
| HomeNotFoundException | ItemNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* @param destinationFolderId
|
||||
* @param folderName
|
||||
* @param folderDescription
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public static String createAccountingFolderOnWorkspace(String user)
|
||||
throws ServiceException {
|
||||
try {
|
||||
logger.debug("CreateAccountingFolderOnWorkspace: [User=" + user
|
||||
+ "]");
|
||||
Workspace ws = HomeLibrary.getUserWorkspace(user);
|
||||
WorkspaceItem workspaceItem = ws.find(ACCOUNTING_MANAGER);
|
||||
if (workspaceItem == null) {
|
||||
workspaceItem = ws.createFolder(ACCOUNTING_MANAGER,
|
||||
ACCOUNTING_MANAGER, ws.getRoot().getId());
|
||||
}
|
||||
return workspaceItem.getId();
|
||||
|
||||
} catch (WorkspaceFolderNotFoundException | InternalErrorException
|
||||
| HomeNotFoundException | InsufficientPrivilegesException
|
||||
| ItemAlreadyExistException | WrongDestinationException
|
||||
| ItemNotFoundException e) {
|
||||
logger.error("CreateAccountingFolderOnWorkspace: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage(), e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* @param destinationFolderId
|
||||
* @param fileName
|
||||
* @param fileDescription
|
||||
* @param mimeType
|
||||
* @param is
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public static ItemDescription saveOnWorkspace(String user,
|
||||
String destinationFolderId, String fileName,
|
||||
String fileDescription, InputStream is) throws ServiceException {
|
||||
try {
|
||||
logger.debug("saveOnWorkspace: [User=" + user + ", FolderId:"
|
||||
+ destinationFolderId + ", fileName=" + fileName
|
||||
+ ", fileDescription=" + fileDescription + "]");
|
||||
Workspace ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workspaceItem = ws.getItem(destinationFolderId);
|
||||
if (workspaceItem.isFolder()) {
|
||||
ExternalFile externalfile = ws.createExternalFile(fileName,
|
||||
fileDescription, null, is, destinationFolderId);
|
||||
ItemDescription itemDescription=new ItemDescription(externalfile.getId(), externalfile.getName(),
|
||||
externalfile.getOwner().getId(), externalfile.getPath(),
|
||||
externalfile.getType().name());
|
||||
|
||||
return itemDescription;
|
||||
} else {
|
||||
throw new ServiceException("Invalid destination folder!");
|
||||
}
|
||||
|
||||
} catch (WorkspaceFolderNotFoundException | InternalErrorException
|
||||
| HomeNotFoundException | InsufficientPrivilegesException
|
||||
| ItemAlreadyExistException | WrongDestinationException
|
||||
| ItemNotFoundException e) {
|
||||
logger.error("SaveOnWorkspace: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage(), e);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ package org.gcube.portlets.admin.accountingmanager.shared.exception;
|
|||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class AccountingManagerChartDrawException extends Exception {
|
||||
public class ChartDrawException extends Exception {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -8737011216478988776L;
|
||||
|
@ -18,19 +18,19 @@ public class AccountingManagerChartDrawException extends Exception {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public AccountingManagerChartDrawException() {
|
||||
public ChartDrawException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public AccountingManagerChartDrawException(String message) {
|
||||
public ChartDrawException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
public AccountingManagerChartDrawException(String message,Throwable t) {
|
||||
public ChartDrawException(String message,Throwable t) {
|
||||
super(message,t);
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ package org.gcube.portlets.admin.accountingmanager.shared.exception;
|
|||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class AccountingManagerServiceException extends Exception {
|
||||
public class ServiceException extends Exception {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -2255657546267656458L;
|
||||
|
@ -18,19 +18,19 @@ public class AccountingManagerServiceException extends Exception {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public AccountingManagerServiceException() {
|
||||
public ServiceException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public AccountingManagerServiceException(String message) {
|
||||
public ServiceException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
public AccountingManagerServiceException(String message,Throwable t) {
|
||||
public ServiceException(String message,Throwable t) {
|
||||
super(message,t);
|
||||
}
|
||||
|
|
@ -6,21 +6,21 @@ package org.gcube.portlets.admin.accountingmanager.shared.exception;
|
|||
* @author "Giancarlo Panichi"
|
||||
*
|
||||
*/
|
||||
public class AccountingManagerSessionExpiredException extends AccountingManagerServiceException {
|
||||
public class SessionExpiredException extends ServiceException {
|
||||
|
||||
private static final long serialVersionUID = -4831171355042165166L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public AccountingManagerSessionExpiredException() {
|
||||
public SessionExpiredException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public AccountingManagerSessionExpiredException(String message) {
|
||||
public SessionExpiredException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class AccountingManagerSessionExpiredException extends AccountingManager
|
|||
* @param message
|
||||
* @param t
|
||||
*/
|
||||
public AccountingManagerSessionExpiredException(String message,Throwable t) {
|
||||
public SessionExpiredException(String message,Throwable t) {
|
||||
super(message,t);
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.shared.workspace;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ItemDescription implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6624452446980057923L;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String owner;
|
||||
private String path;
|
||||
private String type;
|
||||
private String publicLink;
|
||||
|
||||
public ItemDescription() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ItemDescription(String id, String name, String owner, String path,
|
||||
String type) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.owner = owner;
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPublicLink() {
|
||||
return publicLink;
|
||||
}
|
||||
|
||||
public void setPublicLink(String publicLink) {
|
||||
this.publicLink = publicLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare basic information with another ItemDescription not null
|
||||
*
|
||||
* @param itemDescription
|
||||
* @return boolean
|
||||
*
|
||||
*/
|
||||
public boolean compareInfo(ItemDescription itemDescription){
|
||||
if(itemDescription!=null && id.compareTo(itemDescription.getId())==0 &&
|
||||
name.compareTo(itemDescription.getName())==0 &&
|
||||
owner.compareTo(itemDescription.getOwner())==0 &&
|
||||
path.compareTo(itemDescription.getPath())==0 &&
|
||||
type.compareTo(itemDescription.getType())==0
|
||||
){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemDescription [id=" + id + ", name=" + name + ", owner="
|
||||
+ owner + ", path=" + path + ", type=" + type + ", publicLink="
|
||||
+ publicLink + "]";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue