refs 4041: Accounting Manager portlet: give possibility to download raw data to users

Task-Url: https://support.d4science.org/issues/4041

Fixed download for Storage

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@128921 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-05-31 13:50:31 +00:00
parent 61c5568d4d
commit f4e0d99e6f
40 changed files with 804 additions and 266 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/accounting-manager-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/accounting-manager-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/accounting-manager-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/accounting-manager-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -45,5 +45,5 @@
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/> <classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/> <classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="output" path="target/accounting-manager-1.2.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/accounting-manager-1.3.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -4,7 +4,7 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="java-output-path" value="/accounting-manager/target/accounting-manager-1.2.0-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/accounting-manager/target/accounting-manager-1.3.0-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="accounting-manager"/> <property name="context-root" value="accounting-manager"/>
</wb-module> </wb-module>
</project-modules> </project-modules>

View File

@ -1,4 +1,8 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-3-0"
date="2016-07-01">
<Change>Added CSV download [Ticket #4041]</Change>
</Changeset>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-2-0" <Changeset component="org.gcube.portlets.admin.accounting-manager.1-2-0"
date="2016-05-01"> date="2016-05-01">
<Change>Added Top N Chart[Ticket #2251]</Change> <Change>Added Top N Chart[Ticket #2251]</Change>

38
pom.xml
View File

@ -13,7 +13,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.admin</groupId> <groupId>org.gcube.portlets.admin</groupId>
<artifactId>accounting-manager</artifactId> <artifactId>accounting-manager</artifactId>
<version>1.2.0-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
@ -61,6 +61,20 @@
<profile> <profile>
<id>localRun</id> <id>localRun</id>
<dependencies> <dependencies>
<!-- Authorization -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Storage --> <!-- Storage -->
<dependency> <dependency>
<groupId>org.gcube.contentmanagement</groupId> <groupId>org.gcube.contentmanagement</groupId>
@ -90,18 +104,7 @@
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!-- Authorization -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Logger --> <!-- Logger -->
<dependency> <dependency>
@ -211,6 +214,11 @@
<artifactId>aslcore</artifactId> <artifactId>aslcore</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<scope>provided</scope>
</dependency>
<!-- Authorization --> <!-- Authorization -->
@ -246,7 +254,7 @@
<artifactId>aslsocial</artifactId> <artifactId>aslsocial</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Session Checker --> <!-- Session Checker -->
<dependency> <dependency>
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
@ -261,7 +269,7 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Storage --> <!-- Storage -->
<dependency> <dependency>
<groupId>org.gcube.contentmanagement</groupId> <groupId>org.gcube.contentmanagement</groupId>
@ -293,7 +301,7 @@
<artifactId>home-library-model</artifactId> <artifactId>home-library-model</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Accounting Lib --> <!-- Accounting Lib -->
<dependency> <dependency>
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>

View File

@ -11,8 +11,8 @@ import org.gcube.portlets.admin.accountingmanager.client.event.StateChangeEvent;
import org.gcube.portlets.admin.accountingmanager.client.event.UIStateEvent; import org.gcube.portlets.admin.accountingmanager.client.event.UIStateEvent;
import org.gcube.portlets.admin.accountingmanager.client.monitor.AccountingMonitor; import org.gcube.portlets.admin.accountingmanager.client.monitor.AccountingMonitor;
import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerServiceAsync; import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerServiceAsync;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingState; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientState;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.client.type.SessionExpiredType; import org.gcube.portlets.admin.accountingmanager.client.type.SessionExpiredType;
import org.gcube.portlets.admin.accountingmanager.client.type.StateChangeType; import org.gcube.portlets.admin.accountingmanager.client.type.StateChangeType;
import org.gcube.portlets.admin.accountingmanager.client.type.UIStateType; import org.gcube.portlets.admin.accountingmanager.client.type.UIStateType;
@ -31,6 +31,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescripti
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession; import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat;
@ -53,7 +54,7 @@ public class AccountingManagerController {
private SimpleEventBus eventBus; private SimpleEventBus eventBus;
private UserInfo userInfo; private UserInfo userInfo;
private AccountingState accountingState; private AccountingClientState accountingState;
private AccountingType accountingType; private AccountingType accountingType;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private BorderLayoutContainer mainPanel; private BorderLayoutContainer mainPanel;
@ -62,8 +63,8 @@ public class AccountingManagerController {
public AccountingManagerController() { public AccountingManagerController() {
eventBus = new SimpleEventBus(); eventBus = new SimpleEventBus();
accountingType = AccountingType.STORAGE; accountingType = AccountingType.STORAGE;
accountingState = new AccountingState(); accountingState = new AccountingClientState();
AccountingStateData accountingStateData = new AccountingStateData( AccountingClientStateData accountingStateData = new AccountingClientStateData(
accountingType, null, null, null); accountingType, null, null, null);
accountingState.setState(accountingType, accountingStateData); accountingState.setState(accountingType, accountingStateData);
init(); init();
@ -77,7 +78,7 @@ public class AccountingManagerController {
private void checkSession() { private void checkSession() {
// if you do not need to something when the session expire // if you do not need to something when the session expire
//CheckSession.getInstance().startPolling(); // CheckSession.getInstance().startPolling();
} }
private void sessionExpiredShow() { private void sessionExpiredShow() {
@ -201,25 +202,24 @@ public class AccountingManagerController {
} }
}); });
eventBus.addHandler(DownloadCSVRequestEvent.TYPE, eventBus.addHandler(DownloadCSVRequestEvent.TYPE,
new DownloadCSVRequestEvent.DownloadCSVRequestEventHandler() { new DownloadCSVRequestEvent.DownloadCSVRequestEventHandler() {
@Override @Override
public void onDownload(DownloadCSVRequestEvent event) { public void onDownload(DownloadCSVRequestEvent event) {
Log.debug("Catch DownloadDataRequestEvent"); Log.debug("Catch DownloadDataRequestEvent");
doSaveDataOnWorkspace(event); doDownloadCSV(event);
} }
}); });
eventBus.fireEvent(new UIStateEvent(UIStateType.START)); eventBus.fireEvent(new UIStateEvent(UIStateType.START));
} }
private void doMenuCommand(AccountingMenuEvent event) { private void doMenuCommand(AccountingMenuEvent event) {
AccountingStateData accountingStateData = null; AccountingClientStateData accountingStateData = null;
if (event == null || event.getAccountingType() == null) { if (event == null || event.getAccountingType() == null) {
return; return;
} }
@ -254,18 +254,21 @@ public class AccountingManagerController {
private void createDefaultChart(AccountingType accountingType) { private void createDefaultChart(AccountingType accountingType) {
accountingMonitor = new AccountingMonitor(); accountingMonitor = new AccountingMonitor();
Date now = new Date(); Date now = new Date();
DateTimeFormat dtf=DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY); DateTimeFormat dtf = DateTimeFormat
String currentDate=dtf.format(now); .getFormat(PredefinedFormat.YEAR_MONTH_DAY);
Date date=dtf.parse(currentDate); String currentDate = dtf.format(now);
Date lastMonth=new Date(date.getTime()); Date date = dtf.parse(currentDate);
Date lastMonth = new Date(date.getTime());
CalendarUtil.addMonthsToDate(lastMonth, -1); CalendarUtil.addMonthsToDate(lastMonth, -1);
SeriesRequest seriesRequest = new SeriesRequest(new AccountingPeriod(dtf.format(lastMonth), SeriesRequest seriesRequest = new SeriesRequest(new AccountingPeriod(
dtf.format(date), AccountingPeriodMode.DAILY), new AccountingFilterBasic()); dtf.format(lastMonth), dtf.format(date),
Log.debug("DefaultSeriesRequest: "+seriesRequest); AccountingPeriodMode.DAILY), new AccountingFilterBasic());
Log.debug("LastMoth= "+dtf.format(lastMonth)+" , date="+dtf.format(date)); Log.debug("DefaultSeriesRequest: " + seriesRequest);
Log.debug("LastMoth= " + dtf.format(lastMonth) + " , date="
+ dtf.format(date));
this.accountingType = accountingType; this.accountingType = accountingType;
AccountingStateData accountingStateData = new AccountingStateData( AccountingClientStateData accountingStateData = new AccountingClientStateData(
accountingType, seriesRequest, null, null); accountingType, seriesRequest, null, null);
accountingState.setState(accountingType, accountingStateData); accountingState.setState(accountingType, accountingStateData);
@ -291,14 +294,13 @@ public class AccountingManagerController {
UtilsGXT3.alert("Error retrieving filter keys", UtilsGXT3.alert("Error retrieving filter keys",
caught.getLocalizedMessage()); caught.getLocalizedMessage());
} }
} }
@Override @Override
public void onSuccess(ArrayList<FilterKey> result) { public void onSuccess(ArrayList<FilterKey> result) {
Log.debug("FilterKeys: " + result); Log.debug("FilterKeys: " + result);
AccountingStateData accountingStateData = accountingState AccountingClientStateData accountingStateData = accountingState
.getState(accountingType); .getState(accountingType);
accountingStateData.setAvailableFilterKeys(result); accountingStateData.setAvailableFilterKeys(result);
accountingState.setState(accountingType, accountingState.setState(accountingType,
@ -318,7 +320,7 @@ public class AccountingManagerController {
@Override @Override
public void onSuccess(SeriesResponse seriesResponse) { public void onSuccess(SeriesResponse seriesResponse) {
Log.debug("SeriesResponse: " + seriesResponse); Log.debug("SeriesResponse: " + seriesResponse);
AccountingStateData accountingStateData = accountingState AccountingClientStateData accountingStateData = accountingState
.getState(accountingType); .getState(accountingType);
accountingStateData.setSeriesResponse(seriesResponse); accountingStateData.setSeriesResponse(seriesResponse);
accountingState.setState(accountingType, accountingState.setState(accountingType,
@ -359,7 +361,7 @@ public class AccountingManagerController {
switch (event.getFiltersChangeType()) { switch (event.getFiltersChangeType()) {
case Update: case Update:
SeriesRequest seriesRequest = event.getSeriesRequest(); SeriesRequest seriesRequest = event.getSeriesRequest();
AccountingStateData accountingStateData = accountingState AccountingClientStateData accountingStateData = accountingState
.getState(accountingType); .getState(accountingType);
if (accountingStateData != null) { if (accountingStateData != null) {
accountingMonitor = new AccountingMonitor(); accountingMonitor = new AccountingMonitor();
@ -387,7 +389,7 @@ public class AccountingManagerController {
@Override @Override
public void onSuccess(SeriesResponse seriesResponse) { public void onSuccess(SeriesResponse seriesResponse) {
Log.debug("SeriesResponse: " + seriesResponse); Log.debug("SeriesResponse: " + seriesResponse);
AccountingStateData accountingStateData = accountingState AccountingClientStateData accountingStateData = accountingState
.getState(accountingType); .getState(accountingType);
accountingStateData.setSeriesResponse(seriesResponse); accountingStateData.setSeriesResponse(seriesResponse);
accountingState.setState(accountingType, accountingState.setState(accountingType,
@ -416,70 +418,80 @@ public class AccountingManagerController {
} }
private void doSaveDataOnWorkspace(DownloadCSVRequestEvent event) { private void doSaveDataOnWorkspace(DownloadCSVRequestEvent event) {
accountingMonitor = new AccountingMonitor(); accountingMonitor = new AccountingMonitor();
Log.debug("Call saveCSVOnWorkspace on server, params: " + event.getAccountingType()); Log.debug("Call saveCSVOnWorkspace on server, params: "
+ event.getAccountingType());
AccountingManagerServiceAsync.INSTANCE.saveCSVOnWorkspace(accountingState.getState(event.getAccountingType()), new AsyncCallback<ItemDescription>() { AccountingManagerServiceAsync.INSTANCE.saveCSVOnWorkspace(
event.getAccountingType(),
new AsyncCallback<ItemDescription>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
accountingMonitor.hide(); accountingMonitor.hide();
if (caught instanceof SessionExpiredException) { if (caught instanceof SessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent( eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("Error:" + caught.getLocalizedMessage()); Log.error("Error:" + caught.getLocalizedMessage());
UtilsGXT3.alert("Error", UtilsGXT3.alert("Error",
caught.getLocalizedMessage()); caught.getLocalizedMessage());
caught.printStackTrace(); caught.printStackTrace();
} }
}
}
@Override @Override
public void onSuccess(ItemDescription result) { public void onSuccess(ItemDescription result) {
Log.debug("ItemDescription: " + result); Log.debug("ItemDescription: " + result);
doDownloadCSV(result); doDownloadCSVFromWorkspace(result);
} }
}); });
} }
private void doDownloadCSVFromWorkspace(
private void doDownloadCSV(final ItemDescription itemDescription) { final ItemDescription itemDescription) {
Log.debug("DownloadCSV from server: " + itemDescription); Log.debug("DownloadCSV from server: " + itemDescription);
AccountingManagerServiceAsync.INSTANCE.getPublicLink(itemDescription, new AsyncCallback<String>() { AccountingManagerServiceAsync.INSTANCE.getPublicLink(itemDescription,
new AsyncCallback<String>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
accountingMonitor.hide(); accountingMonitor.hide();
if (caught instanceof SessionExpiredException) { if (caught instanceof SessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent( eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("Error:" + caught.getLocalizedMessage()); Log.error("Error:" + caught.getLocalizedMessage());
UtilsGXT3.alert("Error", UtilsGXT3.alert("Error",
caught.getLocalizedMessage()); caught.getLocalizedMessage());
caught.printStackTrace(); caught.printStackTrace();
} }
} }
@Override @Override
public void onSuccess(String link) { public void onSuccess(String link) {
accountingMonitor.hide(); accountingMonitor.hide();
Log.debug("Retrieved link: " + link); Log.debug("Retrieved link: " + link);
Window.open(link, itemDescription.getName(), ""); Window.open(link, itemDescription.getName(), "");
} }
}); });
} }
private void doDownloadCSV(DownloadCSVRequestEvent event) {
StringBuilder actionUrl = new StringBuilder();
actionUrl.append(GWT.getModuleBaseURL());
actionUrl.append(Constants.DOWNLOAD_CVS_SERVLET + "?"
+ Constants.DOWNLOAD_CVS_SERVLET_ACCOUNTINGTYPE_PARAMETER + "="
+ event.getAccountingType().name());
Log.debug("Retrieved link: " + actionUrl);
Window.open(actionUrl.toString(), event.getAccountingType().toString(), "");
}
private void doSessionExpiredCommand(SessionExpiredEvent event) { private void doSessionExpiredCommand(SessionExpiredEvent event) {
Log.debug("Session Expired Event: " + event.getSessionExpiredType()); Log.debug("Session Expired Event: " + event.getSessionExpiredType());
sessionExpiredShow(); sessionExpiredShow();

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.admin.accountingmanager.client.event; package org.gcube.portlets.admin.accountingmanager.client.event;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.client.type.StateChangeType; import org.gcube.portlets.admin.accountingmanager.client.type.StateChangeType;
import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.EventHandler;
@ -19,7 +19,7 @@ public class StateChangeEvent extends
public static Type<StateChangeEventHandler> TYPE = new Type<StateChangeEventHandler>(); public static Type<StateChangeEventHandler> TYPE = new Type<StateChangeEventHandler>();
private StateChangeType stateChangeType; private StateChangeType stateChangeType;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
public interface StateChangeEventHandler extends EventHandler { public interface StateChangeEventHandler extends EventHandler {
void onStateChange(StateChangeEvent event); void onStateChange(StateChangeEvent event);
@ -31,7 +31,7 @@ public class StateChangeEvent extends
} }
public StateChangeEvent(StateChangeType stateChangeType, public StateChangeEvent(StateChangeType stateChangeType,
AccountingStateData accountingStateData) { AccountingClientStateData accountingStateData) {
this.stateChangeType = stateChangeType; this.stateChangeType = stateChangeType;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
} }
@ -59,7 +59,7 @@ public class StateChangeEvent extends
return stateChangeType; return stateChangeType;
} }
public AccountingStateData getAccountingStateData() { public AccountingClientStateData getAccountingStateData() {
return accountingStateData; return accountingStateData;
} }

View File

@ -7,10 +7,11 @@ import org.gcube.portlets.admin.accountingmanager.client.event.AccountingPeriodE
import org.gcube.portlets.admin.accountingmanager.client.event.AccountingPeriodRequestEvent; import org.gcube.portlets.admin.accountingmanager.client.event.AccountingPeriodRequestEvent;
import org.gcube.portlets.admin.accountingmanager.client.event.SessionExpiredEvent; import org.gcube.portlets.admin.accountingmanager.client.event.SessionExpiredEvent;
import org.gcube.portlets.admin.accountingmanager.client.event.StateChangeEvent; import org.gcube.portlets.admin.accountingmanager.client.event.StateChangeEvent;
import org.gcube.portlets.admin.accountingmanager.client.monitor.AccountingMonitor;
import org.gcube.portlets.admin.accountingmanager.client.properties.AccountingFilterProperties; import org.gcube.portlets.admin.accountingmanager.client.properties.AccountingFilterProperties;
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerServiceAsync; import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerServiceAsync;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.client.type.SessionExpiredType; import org.gcube.portlets.admin.accountingmanager.client.type.SessionExpiredType;
import org.gcube.portlets.admin.accountingmanager.client.utils.UtilsGXT3; import org.gcube.portlets.admin.accountingmanager.client.utils.UtilsGXT3;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
@ -90,7 +91,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
private Grid<AccountingFilter> grid; private Grid<AccountingFilter> grid;
private ListStore<AccountingFilter> store; private ListStore<AccountingFilter> store;
private boolean addStatus; private boolean addStatus;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
private ListStore<FilterKey> storeComboFilterKey; private ListStore<FilterKey> storeComboFilterKey;
private ComboBox<FilterKey> comboFilterKey; private ComboBox<FilterKey> comboFilterKey;
private ListStore<String> storeComboFilterValue; private ListStore<String> storeComboFilterValue;
@ -109,6 +110,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
private FilterKey filterKey; private FilterKey filterKey;
private boolean cancelValue; private boolean cancelValue;
private AccountingMonitor accountingMonitor;
public interface FilterKeyPropertiesCombo extends PropertyAccess<FilterKey> { public interface FilterKeyPropertiesCombo extends PropertyAccess<FilterKey> {
@ -769,7 +771,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
Log.debug("AccountingPeriod not valid"); Log.debug("AccountingPeriod not valid");
return; return;
} }
accountingMonitor=new AccountingMonitor();
FilterValuesRequest requestFilterValue = new FilterValuesRequest( FilterValuesRequest requestFilterValue = new FilterValuesRequest(
filterKey, accountingStateData.getAccountingType(), event.getAccountingPeriod()); filterKey, accountingStateData.getAccountingType(), event.getAccountingPeriod());
@ -779,6 +781,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
accountingMonitor.hide();
if (caught instanceof SessionExpiredException) { if (caught instanceof SessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent( eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
@ -794,6 +797,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
@Override @Override
public void onSuccess(ArrayList<FilterValue> result) { public void onSuccess(ArrayList<FilterValue> result) {
Log.debug("FilterValues: " + result); Log.debug("FilterValues: " + result);
accountingMonitor.hide();
ArrayList<String> values = new ArrayList<String>(); ArrayList<String> values = new ArrayList<String>();
for (FilterValue fv : result) { for (FilterValue fv : result) {
values.add(fv.getValue()); values.add(fv.getValue());

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; 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.maindata.charts.job.JobChartBasicPanel;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
@ -17,10 +17,10 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
*/ */
public class AccountingChart4Job extends AccountingChartBuilder { public class AccountingChart4Job extends AccountingChartBuilder {
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
private EventBus eventBus; private EventBus eventBus;
public AccountingChart4Job(EventBus eventBus, AccountingStateData accountingStateData) { public AccountingChart4Job(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus=eventBus; this.eventBus=eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
} }

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
@ -15,9 +15,9 @@ import com.google.gwt.event.shared.EventBus;
*/ */
public class AccountingChart4Portlet extends AccountingChartBuilder { public class AccountingChart4Portlet extends AccountingChartBuilder {
private EventBus eventBus; private EventBus eventBus;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
public AccountingChart4Portlet(EventBus eventBus, AccountingStateData accountingStateData) { public AccountingChart4Portlet(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
} }

View File

@ -2,7 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartBasicPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartBasicPanel;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartTopPanel; 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.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
@ -18,10 +18,10 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
*/ */
public class AccountingChart4Service extends AccountingChartBuilder { public class AccountingChart4Service extends AccountingChartBuilder {
private EventBus eventBus; private EventBus eventBus;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
public AccountingChart4Service(EventBus eventBus, AccountingStateData accountingStateData) { public AccountingChart4Service(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus=eventBus; this.eventBus=eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
} }

View File

@ -2,7 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartBasicPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartBasicPanel;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartTopPanel; 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.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
@ -18,10 +18,10 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
*/ */
public class AccountingChart4Storage extends AccountingChartBuilder { public class AccountingChart4Storage extends AccountingChartBuilder {
private EventBus eventBus; private EventBus eventBus;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
public AccountingChart4Storage(EventBus eventBus, AccountingStateData accountingStateData) { public AccountingChart4Storage(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus=eventBus; this.eventBus=eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
} }

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
@ -15,10 +15,10 @@ import com.google.gwt.event.shared.EventBus;
*/ */
public class AccountingChart4Task extends AccountingChartBuilder { public class AccountingChart4Task extends AccountingChartBuilder {
private EventBus eventBus; private EventBus eventBus;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
public AccountingChart4Task(EventBus eventBus, AccountingStateData accountingStateData) { public AccountingChart4Task(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus=eventBus; this.eventBus=eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
} }

View File

@ -8,7 +8,7 @@ import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.D
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; 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.SeriesJobBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
@ -56,7 +56,7 @@ public class JobChartBasicPanel extends SimpleContainer {
private static final String TIME_UNIT = "Time Unit"; private static final String TIME_UNIT = "Time Unit";
private static final String SINGLE_AXIS = "Single Axis"; private static final String SINGLE_AXIS = "Single Axis";
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel; private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu // Download Menu
@ -66,7 +66,6 @@ public class JobChartBasicPanel extends SimpleContainer {
private MenuItem downloadPDFItem; private MenuItem downloadPDFItem;
private MenuItem downloadSVGItem; private MenuItem downloadSVGItem;
// Time Unit Menu // Time Unit Menu
private MenuItem msItem; private MenuItem msItem;
private MenuItem sItem; private MenuItem sItem;
@ -82,8 +81,9 @@ public class JobChartBasicPanel extends SimpleContainer {
private ToggleButton toggleButton; private ToggleButton toggleButton;
private EventBus eventBus; private EventBus eventBus;
public JobChartBasicPanel(EventBus eventBus, AccountingStateData accountingStateData) { public JobChartBasicPanel(EventBus eventBus,
this.eventBus=eventBus; AccountingClientStateData accountingStateData) {
this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
forceLayoutOnResize = true; forceLayoutOnResize = true;
create(); create();
@ -229,7 +229,8 @@ public class JobChartBasicPanel extends SimpleContainer {
Menu menuDownload = new Menu(); Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV, downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingByte24()); AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG, downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24()); AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30); downloadPNGItem.setHeight(30);
@ -243,7 +244,6 @@ public class JobChartBasicPanel extends SimpleContainer {
AccountingManagerResources.INSTANCE.accountingFileSVG24()); AccountingManagerResources.INSTANCE.accountingFileSVG24());
downloadSVGItem.setHeight(30); downloadSVGItem.setHeight(30);
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() { downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override @Override
@ -252,11 +252,8 @@ public class JobChartBasicPanel extends SimpleContainer {
} }
}); });
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() { downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override @Override
@ -293,7 +290,7 @@ public class JobChartBasicPanel extends SimpleContainer {
onDownloadSVG(id); onDownloadSVG(id);
} }
}); });
menuDownload.add(downloadCSVItem); menuDownload.add(downloadCSVItem);
menuDownload.add(downloadPNGItem); menuDownload.add(downloadPNGItem);
menuDownload.add(downloadJPGItem); menuDownload.add(downloadJPGItem);
@ -302,7 +299,6 @@ public class JobChartBasicPanel extends SimpleContainer {
return menuDownload; return menuDownload;
} }
private void onDownloadCSV() { private void onDownloadCSV() {
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent( DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
@ -419,11 +415,10 @@ public class JobChartBasicPanel extends SimpleContainer {
+ JobChartMeasure.OperationCount.getLabel() + "\"," + JobChartMeasure.OperationCount.getLabel() + "\","
+ " \"style\": {" + " \"color\": \"" + colors.get(1) + " \"style\": {" + " \"color\": \"" + colors.get(1)
+ "\"" + " }" + " }" + "} , {" + " \"id\": \"" + "\"" + " }" + " }" + "} , {" + " \"id\": \""
+ JobChartMeasure.Duration.name() + "\", " + JobChartMeasure.Duration.name() + "\", " + " \"title\": {"
+ " \"title\": {" + " \"text\": \"" + " \"text\": \"" + JobChartMeasure.Duration.getLabel()
+ JobChartMeasure.Duration.getLabel() + "\"," + "\"," + " \"style\": {" + " \"color\": \""
+ " \"style\": {" + " \"color\": \"" + colors.get(0) + colors.get(0) + "\"" + " }" + " }," + " \"labels\": {"
+ "\"" + " }" + " }," + " \"labels\": {"
+ " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"format\": \"{value} " + unitMeasureLabel + "\","
+ " \"style\": {" + " \"color\": \"" + colors.get(0) + " \"style\": {" + " \"color\": \"" + colors.get(0)
+ "\"" + " }" + " }," + " \"opposite\": \"true\"" + "\"" + " }" + " }," + " \"opposite\": \"true\""
@ -463,8 +458,7 @@ public class JobChartBasicPanel extends SimpleContainer {
SeriesColumn seriesOperationCount = highchartsFactory SeriesColumn seriesOperationCount = highchartsFactory
.createSeriesColumn(); .createSeriesColumn();
seriesOperationCount seriesOperationCount.name(JobChartMeasure.OperationCount.getLabel());
.name(JobChartMeasure.OperationCount.getLabel());
seriesOperationCount.color(colors.get(1)); seriesOperationCount.color(colors.get(1));
seriesOperationCount.type("column"); seriesOperationCount.type("column");
@ -488,8 +482,8 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMaxInvocationTime.name(JobChartMeasure.MaxInvocationTime seriesMaxInvocationTime.name(JobChartMeasure.MaxInvocationTime
.getLabel()); .getLabel());
seriesMaxInvocationTime.color(colors.get(2)); seriesMaxInvocationTime.color(colors.get(2));
seriesMaxInvocationTime seriesMaxInvocationTime.yAxisAsString(JobChartMeasure.MaxInvocationTime
.yAxisAsString(JobChartMeasure.MaxInvocationTime.name()); .name());
ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime
.dataAsArrayNumber(); .dataAsArrayNumber();
@ -502,8 +496,8 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMinInvocationTime.name(JobChartMeasure.MinInvocationTime seriesMinInvocationTime.name(JobChartMeasure.MinInvocationTime
.getLabel()); .getLabel());
seriesMinInvocationTime.color(colors.get(3)); seriesMinInvocationTime.color(colors.get(3));
seriesMinInvocationTime seriesMinInvocationTime.yAxisAsString(JobChartMeasure.MinInvocationTime
.yAxisAsString(JobChartMeasure.MinInvocationTime.name()); .name());
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime ArrayNumber dataMinInvocationTime = seriesMinInvocationTime
.dataAsArrayNumber(); .dataAsArrayNumber();
@ -511,8 +505,7 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMinInvocationTime.pointInterval(interval).pointStart( seriesMinInvocationTime.pointInterval(interval).pointStart(
dateStart.getTime()); dateStart.getTime());
for (SeriesJobData seriesJobData : seriesJobBasic for (SeriesJobData seriesJobData : seriesJobBasic.getSeries()) {
.getSeries()) {
dataOperationCount.push(seriesJobData.getOperationCount()); dataOperationCount.push(seriesJobData.getOperationCount());
dataDuration.push(seriesJobData.getDuration() / unitMeasure); dataDuration.push(seriesJobData.getDuration() / unitMeasure);
dataMaxInvocationTime.push(seriesJobData.getMaxInvocationTime() dataMaxInvocationTime.push(seriesJobData.getMaxInvocationTime()
@ -593,10 +586,9 @@ public class JobChartBasicPanel extends SimpleContainer {
+ " \"text\": \"" + " \"text\": \""
+ JobChartMeasure.OperationCount.getLabel() + "\"," + JobChartMeasure.OperationCount.getLabel() + "\","
+ " \"style\": {" + " \"color\": \"" + colors.get(1) + " \"style\": {" + " \"color\": \"" + colors.get(1)
+ "\"" + " }" + " }" + "} , {" + "\"" + " }" + " }" + "} , {" + " \"id\": \"JobData\", "
+ " \"id\": \"JobData\", " + " \"linkedTo\": \"0\"," + " \"linkedTo\": \"0\"," + " \"gridLineWidth\": \"0\","
+ " \"gridLineWidth\": \"0\"," + " \"title\": {" + " \"title\": {" + " \"text\": \"\"," + " \"style\": {"
+ " \"text\": \"\"," + " \"style\": {"
+ " \"color\": \"" + colors.get(1) + "\"" + " }" + " \"color\": \"" + colors.get(1) + "\"" + " }"
+ " }," + " \"labels\": {" + " \"format\": \"{value} " + " }," + " \"labels\": {" + " \"format\": \"{value} "
+ unitMeasureLabel + "\"," + " \"style\": {" + unitMeasureLabel + "\"," + " \"style\": {"
@ -620,8 +612,7 @@ public class JobChartBasicPanel extends SimpleContainer {
SeriesColumn seriesOperationCount = highchartsFactory SeriesColumn seriesOperationCount = highchartsFactory
.createSeriesColumn(); .createSeriesColumn();
seriesOperationCount seriesOperationCount.name(JobChartMeasure.OperationCount.getLabel());
.name(JobChartMeasure.OperationCount.getLabel());
seriesOperationCount.color(colors.get(1)); seriesOperationCount.color(colors.get(1));
seriesOperationCount.type("column"); seriesOperationCount.type("column");
@ -634,7 +625,7 @@ public class JobChartBasicPanel extends SimpleContainer {
SeriesArea seriesDuration = highchartsFactory.createSeriesArea(); SeriesArea seriesDuration = highchartsFactory.createSeriesArea();
seriesDuration.name(JobChartMeasure.Duration.getLabel()); seriesDuration.name(JobChartMeasure.Duration.getLabel());
seriesDuration.color(colors.get(0)); seriesDuration.color(colors.get(0));
//seriesDuration.yAxisAsString("JobData"); // seriesDuration.yAxisAsString("JobData");
ArrayNumber dataDuration = seriesDuration.dataAsArrayNumber(); ArrayNumber dataDuration = seriesDuration.dataAsArrayNumber();
@ -645,7 +636,7 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMaxInvocationTime.name(JobChartMeasure.MaxInvocationTime seriesMaxInvocationTime.name(JobChartMeasure.MaxInvocationTime
.getLabel()); .getLabel());
seriesMaxInvocationTime.color(colors.get(2)); seriesMaxInvocationTime.color(colors.get(2));
//seriesMaxInvocationTime.yAxisAsString("JobData"); // seriesMaxInvocationTime.yAxisAsString("JobData");
ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime
.dataAsArrayNumber(); .dataAsArrayNumber();
@ -658,7 +649,7 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMinInvocationTime.name(JobChartMeasure.MinInvocationTime seriesMinInvocationTime.name(JobChartMeasure.MinInvocationTime
.getLabel()); .getLabel());
seriesMinInvocationTime.color(colors.get(3)); seriesMinInvocationTime.color(colors.get(3));
//seriesMinInvocationTime.yAxisAsString("JobData"); // seriesMinInvocationTime.yAxisAsString("JobData");
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime ArrayNumber dataMinInvocationTime = seriesMinInvocationTime
.dataAsArrayNumber(); .dataAsArrayNumber();
@ -666,8 +657,7 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMinInvocationTime.pointInterval(interval).pointStart( seriesMinInvocationTime.pointInterval(interval).pointStart(
dateStart.getTime()); dateStart.getTime());
for (SeriesJobData seriesJobData : seriesJobBasic for (SeriesJobData seriesJobData : seriesJobBasic.getSeries()) {
.getSeries()) {
dataOperationCount.push(seriesJobData.getOperationCount()); dataOperationCount.push(seriesJobData.getOperationCount());
dataDuration.push(seriesJobData.getDuration() / unitMeasure); dataDuration.push(seriesJobData.getDuration() / unitMeasure);
dataMaxInvocationTime.push(seriesJobData.getMaxInvocationTime() dataMaxInvocationTime.push(seriesJobData.getMaxInvocationTime()

View File

@ -3,12 +3,13 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; 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.ChartTimeMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; 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.SeriesJobData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop;
@ -55,10 +56,11 @@ public class JobChartTopPanel extends SimpleContainer {
.getFormat(PredefinedFormat.YEAR_MONTH_DAY); .getFormat(PredefinedFormat.YEAR_MONTH_DAY);
private EventBus eventBus; private EventBus eventBus;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel; private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu // Download Menu
private MenuItem downloadCSVItem;
private MenuItem downloadPNGItem; private MenuItem downloadPNGItem;
private MenuItem downloadJPGItem; private MenuItem downloadJPGItem;
private MenuItem downloadPDFItem; private MenuItem downloadPDFItem;
@ -88,7 +90,7 @@ public class JobChartTopPanel extends SimpleContainer {
private VerticalLayoutContainer vert; private VerticalLayoutContainer vert;
public JobChartTopPanel(EventBus eventBus, public JobChartTopPanel(EventBus eventBus,
AccountingStateData accountingStateData) { AccountingClientStateData accountingStateData) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
forceLayoutOnResize = true; forceLayoutOnResize = true;
@ -150,6 +152,9 @@ public class JobChartTopPanel extends SimpleContainer {
private Menu createDownloadMenu() { private Menu createDownloadMenu() {
Menu menuDownload = new Menu(); Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG, downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24()); AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30); downloadPNGItem.setHeight(30);
@ -162,7 +167,18 @@ public class JobChartTopPanel extends SimpleContainer {
downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG, downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
AccountingManagerResources.INSTANCE.accountingFileSVG24()); AccountingManagerResources.INSTANCE.accountingFileSVG24());
downloadSVGItem.setHeight(30); downloadSVGItem.setHeight(30);
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
onDownloadCSV();
}
});
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() { downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override @Override
@ -199,7 +215,8 @@ public class JobChartTopPanel extends SimpleContainer {
onDownloadSVG(id); onDownloadSVG(id);
} }
}); });
menuDownload.add(downloadCSVItem);
menuDownload.add(downloadPNGItem); menuDownload.add(downloadPNGItem);
menuDownload.add(downloadJPGItem); menuDownload.add(downloadJPGItem);
menuDownload.add(downloadPDFItem); menuDownload.add(downloadPDFItem);
@ -348,7 +365,13 @@ public class JobChartTopPanel extends SimpleContainer {
return menuUnit; return menuUnit;
} }
private void onDownloadCSV() {
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
accountingStateData.getAccountingType());
eventBus.fireEvent(event);
}
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick(); // chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
public static native void onDownloadPNG(String id) /*-{ public static native void onDownloadPNG(String id) /*-{

View File

@ -2,12 +2,13 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.servic
import java.util.Date; 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.ChartTimeMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ServiceChartMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ServiceChartMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; 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.SeriesServiceBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
@ -56,10 +57,11 @@ public class ServiceChartBasicPanel extends SimpleContainer {
private static final String SINGLE_AXIS = "Single Axis"; private static final String SINGLE_AXIS = "Single Axis";
private EventBus eventBus; private EventBus eventBus;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel; private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu // Download Menu
private MenuItem downloadCSVItem;
private MenuItem downloadPNGItem; private MenuItem downloadPNGItem;
private MenuItem downloadJPGItem; private MenuItem downloadJPGItem;
private MenuItem downloadPDFItem; private MenuItem downloadPDFItem;
@ -80,7 +82,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
private ToggleButton toggleButton; private ToggleButton toggleButton;
public ServiceChartBasicPanel(EventBus eventBus, AccountingStateData accountingStateData) { public ServiceChartBasicPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus=eventBus; this.eventBus=eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
forceLayoutOnResize = true; forceLayoutOnResize = true;
@ -226,6 +228,9 @@ public class ServiceChartBasicPanel extends SimpleContainer {
private Menu createDownloadMenu() { private Menu createDownloadMenu() {
Menu menuDownload = new Menu(); Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG, downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24()); AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30); downloadPNGItem.setHeight(30);
@ -238,7 +243,18 @@ public class ServiceChartBasicPanel extends SimpleContainer {
downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG, downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
AccountingManagerResources.INSTANCE.accountingFileSVG24()); AccountingManagerResources.INSTANCE.accountingFileSVG24());
downloadSVGItem.setHeight(30); downloadSVGItem.setHeight(30);
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
onDownloadCSV();
}
});
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() { downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override @Override
@ -275,7 +291,8 @@ public class ServiceChartBasicPanel extends SimpleContainer {
onDownloadSVG(id); onDownloadSVG(id);
} }
}); });
menuDownload.add(downloadCSVItem);
menuDownload.add(downloadPNGItem); menuDownload.add(downloadPNGItem);
menuDownload.add(downloadJPGItem); menuDownload.add(downloadJPGItem);
menuDownload.add(downloadPDFItem); menuDownload.add(downloadPDFItem);
@ -283,6 +300,12 @@ public class ServiceChartBasicPanel extends SimpleContainer {
return menuDownload; return menuDownload;
} }
private void onDownloadCSV() {
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
accountingStateData.getAccountingType());
eventBus.fireEvent(event);
}
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick(); // chart.options.exporting.buttons.contextButton.menuItems[0].onclick();

View File

@ -3,12 +3,13 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.servic
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure; 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.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ServiceChartMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ServiceChartMeasure;
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop;
@ -55,10 +56,11 @@ public class ServiceChartTopPanel extends SimpleContainer {
.getFormat(PredefinedFormat.YEAR_MONTH_DAY); .getFormat(PredefinedFormat.YEAR_MONTH_DAY);
private EventBus eventBus; private EventBus eventBus;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel; private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu // Download Menu
private MenuItem downloadCSVItem;
private MenuItem downloadPNGItem; private MenuItem downloadPNGItem;
private MenuItem downloadJPGItem; private MenuItem downloadJPGItem;
private MenuItem downloadPDFItem; private MenuItem downloadPDFItem;
@ -86,10 +88,10 @@ public class ServiceChartTopPanel extends SimpleContainer {
private TextButton measureButton; private TextButton measureButton;
private VerticalLayoutContainer vert; private VerticalLayoutContainer vert;
public ServiceChartTopPanel(EventBus eventBus, AccountingStateData accountingStateData) { public ServiceChartTopPanel(EventBus eventBus,
this.eventBus=eventBus; AccountingClientStateData accountingStateData) {
this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
forceLayoutOnResize = true; forceLayoutOnResize = true;
create(); create();
@ -109,7 +111,8 @@ public class ServiceChartTopPanel extends SimpleContainer {
downloadButton.setMenu(createDownloadMenu()); downloadButton.setMenu(createDownloadMenu());
// Measure // Measure
measureButton = new TextButton(ServiceChartMeasure.OperationCount.getLabel(), measureButton = new TextButton(
ServiceChartMeasure.OperationCount.getLabel(),
AccountingManagerResources.INSTANCE.accountingByte24()); AccountingManagerResources.INSTANCE.accountingByte24());
measureButton.setIconAlign(IconAlign.RIGHT); measureButton.setIconAlign(IconAlign.RIGHT);
measureButton.setArrowAlign(ButtonArrowAlign.RIGHT); measureButton.setArrowAlign(ButtonArrowAlign.RIGHT);
@ -122,12 +125,11 @@ public class ServiceChartTopPanel extends SimpleContainer {
unitButton.setArrowAlign(ButtonArrowAlign.RIGHT); unitButton.setArrowAlign(ButtonArrowAlign.RIGHT);
unitButton.setMenu(createUnitMenu()); unitButton.setMenu(createUnitMenu());
unitButton.setVisible(false); unitButton.setVisible(false);
toolBar.add(downloadButton, new BoxLayoutData(new Margins(0))); toolBar.add(downloadButton, new BoxLayoutData(new Margins(0)));
toolBar.add(measureButton, new BoxLayoutData(new Margins(0))); toolBar.add(measureButton, new BoxLayoutData(new Margins(0)));
toolBar.add(unitButton, new BoxLayoutData(new Margins(0))); toolBar.add(unitButton, new BoxLayoutData(new Margins(0)));
// //
createChart(); createChart();
@ -152,6 +154,9 @@ public class ServiceChartTopPanel extends SimpleContainer {
private Menu createDownloadMenu() { private Menu createDownloadMenu() {
Menu menuDownload = new Menu(); Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG, downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24()); AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30); downloadPNGItem.setHeight(30);
@ -165,6 +170,16 @@ public class ServiceChartTopPanel extends SimpleContainer {
AccountingManagerResources.INSTANCE.accountingFileSVG24()); AccountingManagerResources.INSTANCE.accountingFileSVG24());
downloadSVGItem.setHeight(30); downloadSVGItem.setHeight(30);
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
onDownloadCSV();
}
});
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() { downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override @Override
@ -202,6 +217,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
} }
}); });
menuDownload.add(downloadCSVItem);
menuDownload.add(downloadPNGItem); menuDownload.add(downloadPNGItem);
menuDownload.add(downloadJPGItem); menuDownload.add(downloadJPGItem);
menuDownload.add(downloadPDFItem); menuDownload.add(downloadPDFItem);
@ -352,6 +368,12 @@ public class ServiceChartTopPanel extends SimpleContainer {
} }
private void onDownloadCSV() {
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
accountingStateData.getAccountingType());
eventBus.fireEvent(event);
}
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick(); // chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
public static native void onDownloadPNG(String id) /*-{ public static native void onDownloadPNG(String id) /*-{

View File

@ -8,7 +8,7 @@ import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.C
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.StorageChartMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.StorageChartMeasure;
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; 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.SeriesStorageBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
@ -55,7 +55,7 @@ public class StorageChartBasicPanel extends SimpleContainer {
.getFormat(PredefinedFormat.YEAR_MONTH_DAY); .getFormat(PredefinedFormat.YEAR_MONTH_DAY);
private EventBus eventBus; private EventBus eventBus;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel; private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu // Download Menu
@ -79,7 +79,7 @@ public class StorageChartBasicPanel extends SimpleContainer {
private VerticalLayoutContainer vert; private VerticalLayoutContainer vert;
public StorageChartBasicPanel(EventBus eventBus, public StorageChartBasicPanel(EventBus eventBus,
AccountingStateData accountingStateData) { AccountingClientStateData accountingStateData) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
forceLayoutOnResize = true; forceLayoutOnResize = true;
@ -216,7 +216,8 @@ public class StorageChartBasicPanel extends SimpleContainer {
private Menu createDownloadMenu() { private Menu createDownloadMenu() {
Menu menuDownload = new Menu(); Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV, downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingByte24()); AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG, downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24()); AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30); downloadPNGItem.setHeight(30);

View File

@ -9,7 +9,7 @@ import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.C
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.StorageChartMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.StorageChartMeasure;
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop;
@ -56,7 +56,7 @@ public class StorageChartTopPanel extends SimpleContainer {
.getFormat(PredefinedFormat.YEAR_MONTH_DAY); .getFormat(PredefinedFormat.YEAR_MONTH_DAY);
private EventBus eventBus; private EventBus eventBus;
private AccountingStateData accountingStateData; private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel; private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu // Download Menu
@ -88,7 +88,7 @@ public class StorageChartTopPanel extends SimpleContainer {
private VerticalLayoutContainer vert; private VerticalLayoutContainer vert;
public StorageChartTopPanel(EventBus eventBus, AccountingStateData accountingStateData) { public StorageChartTopPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus=eventBus; this.eventBus=eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
forceLayoutOnResize = true; forceLayoutOnResize = true;
@ -165,7 +165,8 @@ public class StorageChartTopPanel extends SimpleContainer {
private Menu createDownloadMenu() { private Menu createDownloadMenu() {
Menu menuDownload = new Menu(); Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV, downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingByte24()); AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG, downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24()); AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30); downloadPNGItem.setHeight(30);
@ -225,7 +226,8 @@ public class StorageChartTopPanel extends SimpleContainer {
onDownloadSVG(id); onDownloadSVG(id);
} }
}); });
menuDownload.add(downloadCSVItem);
menuDownload.add(downloadPNGItem); menuDownload.add(downloadPNGItem);
menuDownload.add(downloadJPGItem); menuDownload.add(downloadJPGItem);
menuDownload.add(downloadPDFItem); menuDownload.add(downloadPDFItem);

View File

@ -180,6 +180,12 @@ public interface AccountingManagerResources extends ClientBundle {
@Source("accounting-file_32.png") @Source("accounting-file_32.png")
ImageResource accountingFile32(); ImageResource accountingFile32();
@Source("accounting-file-csv_24.png")
ImageResource accountingFileCSV24();
@Source("accounting-file-csv_32.png")
ImageResource accountingFileCSV32();
@Source("accounting-file-png_24.png") @Source("accounting-file-png_24.png")
ImageResource accountingFilePNG24(); ImageResource accountingFilePNG24();

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -2,7 +2,6 @@ package org.gcube.portlets.admin.accountingmanager.client.rpc;
import java.util.ArrayList; 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.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; 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.FilterValue;
@ -81,7 +80,7 @@ public interface AccountingManagerService extends RemoteService {
* @return * @return
* @throws ServiceException * @throws ServiceException
*/ */
public ItemDescription saveCSVOnWorkspace(AccountingStateData accountingStateData) public ItemDescription saveCSVOnWorkspace(AccountingType accountingType)
throws ServiceException; throws ServiceException;

View File

@ -5,7 +5,6 @@ package org.gcube.portlets.admin.accountingmanager.client.rpc;
import java.util.ArrayList; 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.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; 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.FilterValue;
@ -77,7 +76,7 @@ public interface AccountingManagerServiceAsync {
* @param accountingStateData * @param accountingStateData
* @param callback * @param callback
*/ */
void saveCSVOnWorkspace(AccountingStateData accountingStateData, void saveCSVOnWorkspace(AccountingType accountingType,
AsyncCallback<ItemDescription> callback); AsyncCallback<ItemDescription> callback);
} }

View File

@ -0,0 +1,37 @@
package org.gcube.portlets.admin.accountingmanager.client.state;
import java.io.Serializable;
import java.util.HashMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class AccountingClientState implements Serializable {
private static final long serialVersionUID = 5993049979009321365L;
private HashMap<AccountingType, AccountingClientStateData> clientState;
public AccountingClientState() {
clientState = new HashMap<AccountingType, AccountingClientStateData>();
}
public AccountingClientStateData getState(AccountingType accountingType) {
return clientState.get(accountingType);
}
public void setState(AccountingType accountingType,
AccountingClientStateData accountingStateData) {
clientState.put(accountingType, accountingStateData);
}
@Override
public String toString() {
return "AccountingClientState [clientState=" + clientState + "]";
}
}

View File

@ -14,7 +14,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesRes
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class AccountingStateData implements Serializable { public class AccountingClientStateData implements Serializable {
private static final long serialVersionUID = -2080165745912743812L; private static final long serialVersionUID = -2080165745912743812L;
private AccountingType accountingType; private AccountingType accountingType;
@ -22,11 +22,11 @@ public class AccountingStateData implements Serializable {
private SeriesResponse seriesResponse; private SeriesResponse seriesResponse;
private ArrayList<FilterKey> availableFilterKeys; private ArrayList<FilterKey> availableFilterKeys;
public AccountingStateData() { public AccountingClientStateData() {
super(); super();
} }
public AccountingStateData(AccountingType accountingType, public AccountingClientStateData(AccountingType accountingType,
SeriesRequest seriesRequest, SeriesResponse seriesResponse, SeriesRequest seriesRequest, SeriesResponse seriesResponse,
ArrayList<FilterKey> availableFilterKeys) { ArrayList<FilterKey> availableFilterKeys) {
super(); super();
@ -70,10 +70,11 @@ public class AccountingStateData implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "AccountingStateData [accountingType=" + accountingType return "AccountingClientStateData [accountingType=" + accountingType
+ ", seriesRequest=" + seriesRequest + ", seriesResponse=" + ", seriesRequest=" + seriesRequest + ", seriesResponse="
+ seriesResponse + ", availableFilterKeys=" + seriesResponse + ", availableFilterKeys="
+ availableFilterKeys + "]"; + availableFilterKeys + "]";
} }
} }

View File

@ -1,39 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.client.state;
import java.io.Serializable;
import java.util.HashMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class AccountingState implements Serializable {
private static final long serialVersionUID = 5993049979009321365L;
private HashMap<AccountingType, AccountingStateData> clientState;
public AccountingState(){
clientState=new HashMap<AccountingType, AccountingStateData>();
}
public AccountingStateData getState(AccountingType accountingType){
return clientState.get(accountingType);
}
public void setState(AccountingType accountingType, AccountingStateData accountingStateData){
clientState.put(accountingType,accountingStateData);
}
@Override
public String toString() {
return "AccountingState [clientState=" + clientState + "]";
}
}

View File

@ -7,11 +7,11 @@ import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerService; 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.AccountingCaller;
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCallerInterface; 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.amservice.AccountingCallerTester;
import org.gcube.portlets.admin.accountingmanager.server.csv.CSVManager; import org.gcube.portlets.admin.accountingmanager.server.csv.CSVManager;
import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.server.storage.StorageUtil; import org.gcube.portlets.admin.accountingmanager.server.storage.StorageUtil;
import org.gcube.portlets.admin.accountingmanager.shared.Constants; 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.AccountingType;
@ -101,7 +101,10 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
} }
SeriesResponse seriesResponse = accountingCaller.getSeries( SeriesResponse seriesResponse = accountingCaller.getSeries(
accountingType, seriesRequest); accountingType, seriesRequest);
AccountingStateData accountingStateData = new AccountingStateData(
accountingType, seriesRequest, seriesResponse);
SessionUtil.setAccountingStateData(session, accountingType,
accountingStateData);
return seriesResponse; return seriesResponse;
} catch (ServiceException e) { } catch (ServiceException e) {
@ -179,16 +182,25 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
} }
} }
@Override @Override
public ItemDescription saveCSVOnWorkspace(AccountingStateData accountingStateData) public ItemDescription saveCSVOnWorkspace(AccountingType accountingType)
throws ServiceException { throws ServiceException {
try { try {
HttpSession session = this.getThreadLocalRequest().getSession(); HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session); ASLSession aslSession = SessionUtil.getASLSession(session);
logger.debug("SaveDataOnWorkspace(): " + accountingStateData);
CSVManager csvManager=new CSVManager(aslSession.getUsername()); logger.debug("SaveDataOnWorkspace(): " + accountingType);
ItemDescription itemDescription=csvManager.saveOnWorkspace(accountingStateData); AccountingStateData accountingStateData = SessionUtil
.getAccountingStateData(session, accountingType);
if(accountingStateData==null){
logger.error("No series present in session for thi accounting type: "+accountingType);
throw new ServiceException("No series present in session for thi accounting type: "+accountingType);
}
CSVManager csvManager = new CSVManager(aslSession.getUsername());
ItemDescription itemDescription = csvManager
.saveOnWorkspace(accountingStateData);
return itemDescription; return itemDescription;
} catch (ServiceException e) { } catch (ServiceException e) {
e.printStackTrace(); e.printStackTrace();
@ -199,8 +211,6 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
throw new ServiceException(e.getLocalizedMessage(), e); throw new ServiceException(e.getLocalizedMessage(), e);
} }
} }
@Override @Override
public String getPublicLink(ItemDescription itemDescription) public String getPublicLink(ItemDescription itemDescription)

View File

@ -0,0 +1,127 @@
package org.gcube.portlets.admin.accountingmanager.server;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.portlets.admin.accountingmanager.server.csv.CSVManager;
import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.csv.CSVDescriptor;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
* Download Folder Servlet
*
*/
public class DownloadCSVServlet extends HttpServlet {
private static final long serialVersionUID = -1838255772767180518L;
private static Logger logger = LoggerFactory
.getLogger(DownloadCSVServlet.class);
/**
* @see HttpServlet#HttpServlet()
*/
public DownloadCSVServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
createResponse(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
createResponse(request, response);
}
private void createResponse(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
try {
logger.info("DownloadCSVServlet");
HttpSession session = request.getSession();
if (session == null) {
logger.error("Error getting the session, no session valid found: "
+ session);
response.sendError(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"ERROR-Error getting the user session, no session found "
+ session);
return;
}
logger.debug("DownloadCSVServlet session id: " + session.getId());
ASLSession aslSession = SessionUtil.getASLSession(session);
String accountingType = request.getParameter(Constants.DOWNLOAD_CVS_SERVLET_ACCOUNTINGTYPE_PARAMETER);
logger.debug("Request: [accountingType=" + accountingType + "]");
AccountingStateData accountingStateData=SessionUtil.getAccountingStateData(session, AccountingType.valueOf(accountingType));
if(accountingStateData==null){
logger.error("No series present in session for thi accounting type: "+accountingType);
throw new ServletException("No series present in session for thi accounting type: "+accountingType);
}
CSVManager csvManager=new CSVManager(aslSession.getUsername());
CSVDescriptor csvDescriptor=csvManager.downloadCSV(accountingStateData);
logger.debug("CSVDescriptor: "+csvDescriptor);
response.setHeader("Content-Disposition", "attachment; filename=\""
+ csvDescriptor.getCsvModel().getFileName()+csvDescriptor.getCsvModel().getFileExtension() + "\"");
response.setContentType("text/csv");
response.setHeader("Content-Length",
String.valueOf(csvDescriptor.getPath().toFile().length()));
OutputStream out = response.getOutputStream();
Files.copy(csvDescriptor.getPath(), out);
out.flush();
out.close();
try {
Files.delete(csvDescriptor.getPath());
} 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;
} catch (Throwable e) {
logger.error("Error in DownloadFolderServlet: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new ServletException("Error:"
+ e.getLocalizedMessage(), e);
}
}
}

View File

@ -13,7 +13,10 @@ import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager; import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.admin.accountingmanager.server.state.AccountingState;
import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.shared.Constants; import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpiredException; import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpiredException;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -65,23 +68,52 @@ public class SessionUtil {
} }
public static String getToken(ASLSession aslSession) { public static String getToken(ASLSession aslSession) {
String token=null; String token = null;
if (Constants.DEBUG_MODE) { if (Constants.DEBUG_MODE) {
List<String> userRoles = new ArrayList<>(); List<String> userRoles = new ArrayList<>();
userRoles.add(Constants.DEFAULT_ROLE); userRoles.add(Constants.DEFAULT_ROLE);
/*if (aslSession.getUsername().compareTo("lucio.lelii") == 0) /*
userRoles.add("VRE-Manager");*/ * if (aslSession.getUsername().compareTo("lucio.lelii") == 0)
* userRoles.add("VRE-Manager");
*/
token = authorizationService().build().generate( token = authorizationService().build().generate(
aslSession.getUsername(), userRoles); aslSession.getUsername(), userRoles);
} else { } else {
token = aslSession.getSecurityToken(); token = aslSession.getSecurityToken();
} }
logger.info("received token: " + token); logger.info("received token: " + token);
return token; return token;
}
public static void setAccountingStateData(HttpSession httpSession,
AccountingType accountingType,
AccountingStateData accountingStateData) {
AccountingState accountingState = (AccountingState) httpSession
.getAttribute(Constants.SESSION_ACCOUNTING_STATE);
if (accountingState == null) {
accountingState = new AccountingState();
accountingState.setState(accountingType, accountingStateData);
httpSession.setAttribute(Constants.SESSION_ACCOUNTING_STATE,
accountingState);
} else {
accountingState.setState(accountingType, accountingStateData);
}
return;
} }
public static AccountingStateData getAccountingStateData(HttpSession httpSession,
AccountingType accountingType) {
AccountingState accountingState = (AccountingState) httpSession
.getAttribute(Constants.SESSION_ACCOUNTING_STATE);
if (accountingState == null) {
return null;
} else {
return accountingState.getState(accountingType);
}
}
} }

View File

@ -9,13 +9,15 @@ import java.nio.file.StandardOpenOption;
import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter; 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.CSVDataRow;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModel; import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModel;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModel4Service;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModel4Storage; 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.CSVModelBuilder;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModelDirector; import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModelDirector;
import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.server.storage.StorageUtil; import org.gcube.portlets.admin.accountingmanager.server.storage.StorageUtil;
import org.gcube.portlets.admin.accountingmanager.shared.csv.CSVDescriptor;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription; import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -53,6 +55,7 @@ public class CSVManager {
switch (accountingStateData.getAccountingType()) { switch (accountingStateData.getAccountingType()) {
case SERVICE: case SERVICE:
csvModelBuilder = new CSVModel4Service(accountingStateData);
break; break;
case STORAGE: case STORAGE:
csvModelBuilder = new CSVModel4Storage(accountingStateData); csvModelBuilder = new CSVModel4Storage(accountingStateData);
@ -128,5 +131,82 @@ public class CSVManager {
} }
} }
public CSVDescriptor downloadCSV(AccountingStateData accountingStateData) throws ServiceException {
try {
logger.debug("AccountingStateData: "+accountingStateData);
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:
csvModelBuilder = new CSVModel4Service(accountingStateData);
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!!");
}
logger.debug("CSVModelBuilder: "+csvModelBuilder);
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();
return new CSVDescriptor(tempFile, csvModel);
} catch (ServiceException e) {
throw e;
} catch (Throwable e) {
logger.error("Error downloading data: " + e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException("Error downloading data: "
+ e.getLocalizedMessage());
}
}
} }

View File

@ -1,9 +1,10 @@
package org.gcube.portlets.admin.accountingmanager.server.csv.file; package org.gcube.portlets.admin.accountingmanager.server.csv.file;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; 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.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
@ -44,10 +45,21 @@ public class CSVModel4Service extends CSVModelBuilder {
} }
String startDate = sdfFile.format(seriesRequest.getAccountingPeriod() String startDate="";
.getStartDate()); try {
String endDate = sdfFile.format(seriesRequest.getAccountingPeriod() startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getEndDate()); .getStartDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String endDate="";
try {
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getEndDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String periodType = seriesRequest.getAccountingPeriod().getPeriod() String periodType = seriesRequest.getAccountingPeriod().getPeriod()
.getLabel(); .getLabel();
@ -77,7 +89,7 @@ public class CSVModel4Service extends CSVModelBuilder {
.getSeries(); .getSeries();
for (SeriesServiceData seriesData : listData) { for (SeriesServiceData seriesData : listData) {
ArrayList<String> data = new ArrayList<>(); ArrayList<String> data = new ArrayList<>();
data.add(sdf.format(seriesData.getDate())); data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData.getOperationCount())); data.add(String.valueOf(seriesData.getOperationCount()));
data.add(String.valueOf(seriesData.getDuration())); data.add(String.valueOf(seriesData.getDuration()));
data.add(String.valueOf(seriesData.getMaxInvocationTime())); data.add(String.valueOf(seriesData.getMaxInvocationTime()));
@ -103,7 +115,7 @@ public class CSVModel4Service extends CSVModelBuilder {
for (SeriesServiceData seriesData : listData) { for (SeriesServiceData seriesData : listData) {
ArrayList<String> data = new ArrayList<>(); ArrayList<String> data = new ArrayList<>();
data.add(filterValue.getValue()); data.add(filterValue.getValue());
data.add(sdf.format(seriesData.getDate())); data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData data.add(String.valueOf(seriesData
.getOperationCount())); .getOperationCount()));
data.add(String.valueOf(seriesData.getDuration())); data.add(String.valueOf(seriesData.getDuration()));

View File

@ -1,9 +1,10 @@
package org.gcube.portlets.admin.accountingmanager.server.csv.file; package org.gcube.portlets.admin.accountingmanager.server.csv.file;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; 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.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
@ -44,10 +45,22 @@ public class CSVModel4Storage extends CSVModelBuilder {
} }
String startDate = sdfFile.format(seriesRequest.getAccountingPeriod() String startDate="";
.getStartDate()); try {
String endDate = sdfFile.format(seriesRequest.getAccountingPeriod() startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getEndDate()); .getStartDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String endDate="";
try {
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getEndDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String periodType = seriesRequest.getAccountingPeriod().getPeriod() String periodType = seriesRequest.getAccountingPeriod().getPeriod()
.getLabel(); .getLabel();
@ -76,9 +89,9 @@ public class CSVModel4Storage extends CSVModelBuilder {
.getSeries(); .getSeries();
for (SeriesStorageData seriesData : listData) { for (SeriesStorageData seriesData : listData) {
ArrayList<String> data = new ArrayList<>(); ArrayList<String> data = new ArrayList<>();
data.add(sdf.format(seriesData.getDate())); data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(sdf.format(seriesData.getOperationCount())); data.add(String.valueOf(seriesData.getOperationCount()));
data.add(sdf.format(seriesData.getDataVolume())); data.add(String.valueOf(seriesData.getDataVolume()));
CSVDataRow csvDataRow = new CSVDataRow(data); CSVDataRow csvDataRow = new CSVDataRow(data);
rows.add(csvDataRow); rows.add(csvDataRow);
} }
@ -100,9 +113,9 @@ public class CSVModel4Storage extends CSVModelBuilder {
for (SeriesStorageData seriesData : listData) { for (SeriesStorageData seriesData : listData) {
ArrayList<String> data = new ArrayList<>(); ArrayList<String> data = new ArrayList<>();
data.add(filterValue.getValue()); data.add(filterValue.getValue());
data.add(sdf.format(seriesData.getDate())); data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(sdf.format(seriesData.getOperationCount())); data.add(String.valueOf(seriesData.getOperationCount()));
data.add(sdf.format(seriesData.getDataVolume())); data.add(String.valueOf(seriesData.getDataVolume()));
CSVDataRow csvDataRow = new CSVDataRow(data); CSVDataRow csvDataRow = new CSVDataRow(data);
rows.add(csvDataRow); rows.add(csvDataRow);
} }

View File

@ -13,7 +13,9 @@ import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceExcept
*/ */
public abstract class CSVModelBuilder { public abstract class CSVModelBuilder {
protected CSVModelSpec csvModelSpec; protected CSVModelSpec csvModelSpec;
protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMM dd");
protected SimpleDateFormat sdfCSVDate = new SimpleDateFormat("yyyy/MM/dd HH:mm");
protected SimpleDateFormat sdfFile = new SimpleDateFormat("yyyyMMdd"); protected SimpleDateFormat sdfFile = new SimpleDateFormat("yyyyMMdd");
public CSVModelSpec getCSVModelSpec(){ public CSVModelSpec getCSVModelSpec(){

View File

@ -0,0 +1,40 @@
package org.gcube.portlets.admin.accountingmanager.server.state;
import java.io.Serializable;
import java.util.HashMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class AccountingState implements Serializable {
private static final long serialVersionUID = 5993049979009321365L;
private HashMap<AccountingType, AccountingStateData> state;
public AccountingState() {
state = new HashMap<AccountingType, AccountingStateData>();
}
public AccountingStateData getState(AccountingType accountingType) {
return state.get(accountingType);
}
public void setState(AccountingType accountingType,
AccountingStateData accountingStateData) {
state.put(accountingType, accountingStateData);
}
@Override
public String toString() {
return "AccountingState [state=" + state + "]";
}
}

View File

@ -0,0 +1,65 @@
package org.gcube.portlets.admin.accountingmanager.server.state;
import java.io.Serializable;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class AccountingStateData implements Serializable {
private static final long serialVersionUID = -2080165745912743812L;
private AccountingType accountingType;
private SeriesRequest seriesRequest;
private SeriesResponse seriesResponse;
public AccountingStateData() {
super();
}
public AccountingStateData(AccountingType accountingType,
SeriesRequest seriesRequest, SeriesResponse seriesResponse) {
super();
this.accountingType = accountingType;
this.seriesRequest = seriesRequest;
this.seriesResponse = seriesResponse;
}
public AccountingType getAccountingType() {
return accountingType;
}
public void setAccountingType(AccountingType accountingType) {
this.accountingType = accountingType;
}
public SeriesRequest getSeriesRequest() {
return seriesRequest;
}
public void setSeriesRequest(SeriesRequest seriesRequest) {
this.seriesRequest = seriesRequest;
}
public SeriesResponse getSeriesResponse() {
return seriesResponse;
}
public void setSeriesResponse(SeriesResponse seriesResponse) {
this.seriesResponse = seriesResponse;
}
@Override
public String toString() {
return "AccountingStateData [accountingType=" + accountingType
+ ", seriesRequest=" + seriesRequest + ", seriesResponse="
+ seriesResponse + "]";
}
}

View File

@ -23,5 +23,10 @@ public class Constants {
public static final String DEFAULT_SCOPE = "/gcube"; public static final String DEFAULT_SCOPE = "/gcube";
public static final String DEFAULT_ROLE = "OrganizationMember"; public static final String DEFAULT_ROLE = "OrganizationMember";
public static final String DOWNLOAD_CVS_SERVLET="downloadCSVServlet";
public static final String DOWNLOAD_CVS_SERVLET_ACCOUNTINGTYPE_PARAMETER = "AccountingType";
public static final String SESSION_ACCOUNTING_STATE = "ACCOUNTING_STATE";
} }

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.admin.accountingmanager.shared.csv;
import java.io.Serializable;
import java.nio.file.Path;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModel;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CSVDescriptor implements Serializable {
private static final long serialVersionUID = 4778932733041422948L;
private Path path;
private CSVModel csvModel;
public CSVDescriptor() {
super();
}
public CSVDescriptor(Path path, CSVModel csvModel) {
super();
this.path = path;
this.csvModel = csvModel;
}
public Path getPath() {
return path;
}
public void setPath(Path path) {
this.path = path;
}
public CSVModel getCsvModel() {
return csvModel;
}
public void setCsvModel(CSVModel csvModel) {
this.csvModel = csvModel;
}
@Override
public String toString() {
return "CSVDescriptor [path=" + path + ", csvModel=" + csvModel + "]";
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -29,7 +29,12 @@
<servlet-name>AccountingManagerService</servlet-name> <servlet-name>AccountingManagerService</servlet-name>
<servlet-class>org.gcube.portlets.admin.accountingmanager.server.AccountingManagerServiceImpl</servlet-class> <servlet-class>org.gcube.portlets.admin.accountingmanager.server.AccountingManagerServiceImpl</servlet-class>
</servlet> </servlet>
<!-- AccountingManagerService -->
<servlet>
<servlet-name>DownloadCSVServlet</servlet-name>
<servlet-class>org.gcube.portlets.admin.accountingmanager.server.DownloadCSVServlet</servlet-class>
</servlet>
<!-- Servlets Mapping --> <!-- Servlets Mapping -->
<!-- JUnit --> <!-- JUnit -->
@ -56,9 +61,12 @@
<url-pattern>/accountingman/ams</url-pattern> <url-pattern>/accountingman/ams</url-pattern>
</servlet-mapping> </servlet-mapping>
<!-- AccountingManagerService -->
<servlet-mapping>
<servlet-name>DownloadCSVServlet</servlet-name>
<url-pattern>/accountingman/downloadCSVServlet</url-pattern>
</servlet-mapping>
<!-- Default page to serve --> <!-- Default page to serve -->
<welcome-file-list> <welcome-file-list>