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"?>
<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>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</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>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -45,5 +45,5 @@
</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-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>

View File

@ -4,7 +4,7 @@
<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/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"/>
</wb-module>
</project-modules>

View File

@ -1,4 +1,8 @@
<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"
date="2016-05-01">
<Change>Added Top N Chart[Ticket #2251]</Change>

38
pom.xml
View File

@ -13,7 +13,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>accounting-manager</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<packaging>war</packaging>
@ -61,6 +61,20 @@
<profile>
<id>localRun</id>
<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 -->
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
@ -90,18 +104,7 @@
<scope>runtime</scope>
</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 -->
<dependency>
@ -211,6 +214,11 @@
<artifactId>aslcore</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<scope>provided</scope>
</dependency>
<!-- Authorization -->
@ -246,7 +254,7 @@
<artifactId>aslsocial</artifactId>
<scope>provided</scope>
</dependency>
<!-- Session Checker -->
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
@ -261,7 +269,7 @@
<scope>provided</scope>
</dependency>
<!-- Storage -->
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
@ -293,7 +301,7 @@
<artifactId>home-library-model</artifactId>
<scope>provided</scope>
</dependency>
<!-- Accounting Lib -->
<dependency>
<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.monitor.AccountingMonitor;
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.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientState;
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.StateChangeType;
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 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.SimpleEventBus;
import com.google.gwt.i18n.client.DateTimeFormat;
@ -53,7 +54,7 @@ public class AccountingManagerController {
private SimpleEventBus eventBus;
private UserInfo userInfo;
private AccountingState accountingState;
private AccountingClientState accountingState;
private AccountingType accountingType;
@SuppressWarnings("unused")
private BorderLayoutContainer mainPanel;
@ -62,8 +63,8 @@ public class AccountingManagerController {
public AccountingManagerController() {
eventBus = new SimpleEventBus();
accountingType = AccountingType.STORAGE;
accountingState = new AccountingState();
AccountingStateData accountingStateData = new AccountingStateData(
accountingState = new AccountingClientState();
AccountingClientStateData accountingStateData = new AccountingClientStateData(
accountingType, null, null, null);
accountingState.setState(accountingType, accountingStateData);
init();
@ -77,7 +78,7 @@ public class AccountingManagerController {
private void checkSession() {
// if you do not need to something when the session expire
//CheckSession.getInstance().startPolling();
// CheckSession.getInstance().startPolling();
}
private void sessionExpiredShow() {
@ -201,25 +202,24 @@ public class AccountingManagerController {
}
});
eventBus.addHandler(DownloadCSVRequestEvent.TYPE,
new DownloadCSVRequestEvent.DownloadCSVRequestEventHandler() {
@Override
public void onDownload(DownloadCSVRequestEvent event) {
Log.debug("Catch DownloadDataRequestEvent");
doSaveDataOnWorkspace(event);
doDownloadCSV(event);
}
});
eventBus.fireEvent(new UIStateEvent(UIStateType.START));
}
private void doMenuCommand(AccountingMenuEvent event) {
AccountingStateData accountingStateData = null;
AccountingClientStateData accountingStateData = null;
if (event == null || event.getAccountingType() == null) {
return;
}
@ -254,18 +254,21 @@ public class AccountingManagerController {
private void createDefaultChart(AccountingType accountingType) {
accountingMonitor = new AccountingMonitor();
Date now = new Date();
DateTimeFormat dtf=DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
String currentDate=dtf.format(now);
Date date=dtf.parse(currentDate);
Date lastMonth=new Date(date.getTime());
DateTimeFormat dtf = DateTimeFormat
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
String currentDate = dtf.format(now);
Date date = dtf.parse(currentDate);
Date lastMonth = new Date(date.getTime());
CalendarUtil.addMonthsToDate(lastMonth, -1);
SeriesRequest seriesRequest = new SeriesRequest(new AccountingPeriod(dtf.format(lastMonth),
dtf.format(date), AccountingPeriodMode.DAILY), new AccountingFilterBasic());
Log.debug("DefaultSeriesRequest: "+seriesRequest);
Log.debug("LastMoth= "+dtf.format(lastMonth)+" , date="+dtf.format(date));
SeriesRequest seriesRequest = new SeriesRequest(new AccountingPeriod(
dtf.format(lastMonth), dtf.format(date),
AccountingPeriodMode.DAILY), new AccountingFilterBasic());
Log.debug("DefaultSeriesRequest: " + seriesRequest);
Log.debug("LastMoth= " + dtf.format(lastMonth) + " , date="
+ dtf.format(date));
this.accountingType = accountingType;
AccountingStateData accountingStateData = new AccountingStateData(
AccountingClientStateData accountingStateData = new AccountingClientStateData(
accountingType, seriesRequest, null, null);
accountingState.setState(accountingType, accountingStateData);
@ -291,14 +294,13 @@ public class AccountingManagerController {
UtilsGXT3.alert("Error retrieving filter keys",
caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(ArrayList<FilterKey> result) {
Log.debug("FilterKeys: " + result);
AccountingStateData accountingStateData = accountingState
AccountingClientStateData accountingStateData = accountingState
.getState(accountingType);
accountingStateData.setAvailableFilterKeys(result);
accountingState.setState(accountingType,
@ -318,7 +320,7 @@ public class AccountingManagerController {
@Override
public void onSuccess(SeriesResponse seriesResponse) {
Log.debug("SeriesResponse: " + seriesResponse);
AccountingStateData accountingStateData = accountingState
AccountingClientStateData accountingStateData = accountingState
.getState(accountingType);
accountingStateData.setSeriesResponse(seriesResponse);
accountingState.setState(accountingType,
@ -359,7 +361,7 @@ public class AccountingManagerController {
switch (event.getFiltersChangeType()) {
case Update:
SeriesRequest seriesRequest = event.getSeriesRequest();
AccountingStateData accountingStateData = accountingState
AccountingClientStateData accountingStateData = accountingState
.getState(accountingType);
if (accountingStateData != null) {
accountingMonitor = new AccountingMonitor();
@ -387,7 +389,7 @@ public class AccountingManagerController {
@Override
public void onSuccess(SeriesResponse seriesResponse) {
Log.debug("SeriesResponse: " + seriesResponse);
AccountingStateData accountingStateData = accountingState
AccountingClientStateData accountingStateData = accountingState
.getState(accountingType);
accountingStateData.setSeriesResponse(seriesResponse);
accountingState.setState(accountingType,
@ -416,70 +418,80 @@ public class AccountingManagerController {
}
private void doSaveDataOnWorkspace(DownloadCSVRequestEvent event) {
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
public void onFailure(Throwable caught) {
accountingMonitor.hide();
if (caught instanceof SessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error:" + caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
caught.getLocalizedMessage());
caught.printStackTrace();
}
@Override
public void onFailure(Throwable caught) {
accountingMonitor.hide();
if (caught instanceof SessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error:" + caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
caught.getLocalizedMessage());
caught.printStackTrace();
}
}
}
@Override
public void onSuccess(ItemDescription result) {
Log.debug("ItemDescription: " + result);
doDownloadCSV(result);
}
});
@Override
public void onSuccess(ItemDescription result) {
Log.debug("ItemDescription: " + result);
doDownloadCSVFromWorkspace(result);
}
});
}
private void doDownloadCSV(final ItemDescription itemDescription) {
private void doDownloadCSVFromWorkspace(
final ItemDescription itemDescription) {
Log.debug("DownloadCSV from server: " + itemDescription);
AccountingManagerServiceAsync.INSTANCE.getPublicLink(itemDescription, new AsyncCallback<String>() {
AccountingManagerServiceAsync.INSTANCE.getPublicLink(itemDescription,
new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
accountingMonitor.hide();
if (caught instanceof SessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error:" + caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
caught.getLocalizedMessage());
caught.printStackTrace();
}
}
@Override
public void onFailure(Throwable caught) {
accountingMonitor.hide();
if (caught instanceof SessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error:" + caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
caught.getLocalizedMessage());
caught.printStackTrace();
}
}
@Override
public void onSuccess(String link) {
accountingMonitor.hide();
Log.debug("Retrieved link: " + link);
Window.open(link, itemDescription.getName(), "");
}
});
@Override
public void onSuccess(String link) {
accountingMonitor.hide();
Log.debug("Retrieved link: " + link);
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) {
Log.debug("Session Expired Event: " + event.getSessionExpiredType());
sessionExpiredShow();

View File

@ -1,6 +1,6 @@
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 com.google.gwt.event.shared.EventHandler;
@ -19,7 +19,7 @@ public class StateChangeEvent extends
public static Type<StateChangeEventHandler> TYPE = new Type<StateChangeEventHandler>();
private StateChangeType stateChangeType;
private AccountingStateData accountingStateData;
private AccountingClientStateData accountingStateData;
public interface StateChangeEventHandler extends EventHandler {
void onStateChange(StateChangeEvent event);
@ -31,7 +31,7 @@ public class StateChangeEvent extends
}
public StateChangeEvent(StateChangeType stateChangeType,
AccountingStateData accountingStateData) {
AccountingClientStateData accountingStateData) {
this.stateChangeType = stateChangeType;
this.accountingStateData = accountingStateData;
}
@ -59,7 +59,7 @@ public class StateChangeEvent extends
return stateChangeType;
}
public AccountingStateData getAccountingStateData() {
public AccountingClientStateData getAccountingStateData() {
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.SessionExpiredEvent;
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.resource.AccountingManagerResources;
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.utils.UtilsGXT3;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
@ -90,7 +91,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
private Grid<AccountingFilter> grid;
private ListStore<AccountingFilter> store;
private boolean addStatus;
private AccountingStateData accountingStateData;
private AccountingClientStateData accountingStateData;
private ListStore<FilterKey> storeComboFilterKey;
private ComboBox<FilterKey> comboFilterKey;
private ListStore<String> storeComboFilterValue;
@ -109,6 +110,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
private FilterKey filterKey;
private boolean cancelValue;
private AccountingMonitor accountingMonitor;
public interface FilterKeyPropertiesCombo extends PropertyAccess<FilterKey> {
@ -769,7 +771,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
Log.debug("AccountingPeriod not valid");
return;
}
accountingMonitor=new AccountingMonitor();
FilterValuesRequest requestFilterValue = new FilterValuesRequest(
filterKey, accountingStateData.getAccountingType(), event.getAccountingPeriod());
@ -779,6 +781,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
@Override
public void onFailure(Throwable caught) {
accountingMonitor.hide();
if (caught instanceof SessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
@ -794,6 +797,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
@Override
public void onSuccess(ArrayList<FilterValue> result) {
Log.debug("FilterValues: " + result);
accountingMonitor.hide();
ArrayList<String> values = new ArrayList<String>();
for (FilterValue fv : result) {
values.add(fv.getValue());

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartBasicPanel;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
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 {
private AccountingStateData accountingStateData;
private AccountingClientStateData accountingStateData;
private EventBus eventBus;
public AccountingChart4Job(EventBus eventBus, AccountingStateData accountingStateData) {
public AccountingChart4Job(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus=eventBus;
this.accountingStateData = accountingStateData;
}

View File

@ -1,6 +1,6 @@
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.exception.ChartDrawException;
@ -15,9 +15,9 @@ import com.google.gwt.event.shared.EventBus;
*/
public class AccountingChart4Portlet extends AccountingChartBuilder {
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.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.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.exception.ChartDrawException;
@ -18,10 +18,10 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
*/
public class AccountingChart4Service extends AccountingChartBuilder {
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.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.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.exception.ChartDrawException;
@ -18,10 +18,10 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
*/
public class AccountingChart4Storage extends AccountingChartBuilder {
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.accountingStateData = accountingStateData;
}

View File

@ -1,6 +1,6 @@
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.exception.ChartDrawException;
@ -15,10 +15,10 @@ import com.google.gwt.event.shared.EventBus;
*/
public class AccountingChart4Task extends AccountingChartBuilder {
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.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.TimeUnitMeasure;
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.job.SeriesJobBasic;
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 SINGLE_AXIS = "Single Axis";
private AccountingStateData accountingStateData;
private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu
@ -66,7 +66,6 @@ public class JobChartBasicPanel extends SimpleContainer {
private MenuItem downloadPDFItem;
private MenuItem downloadSVGItem;
// Time Unit Menu
private MenuItem msItem;
private MenuItem sItem;
@ -82,8 +81,9 @@ public class JobChartBasicPanel extends SimpleContainer {
private ToggleButton toggleButton;
private EventBus eventBus;
public JobChartBasicPanel(EventBus eventBus, AccountingStateData accountingStateData) {
this.eventBus=eventBus;
public JobChartBasicPanel(EventBus eventBus,
AccountingClientStateData accountingStateData) {
this.eventBus = eventBus;
this.accountingStateData = accountingStateData;
forceLayoutOnResize = true;
create();
@ -229,7 +229,8 @@ public class JobChartBasicPanel extends SimpleContainer {
Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingByte24());
AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30);
@ -243,7 +244,6 @@ public class JobChartBasicPanel extends SimpleContainer {
AccountingManagerResources.INSTANCE.accountingFileSVG24());
downloadSVGItem.setHeight(30);
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
@ -252,11 +252,8 @@ public class JobChartBasicPanel extends SimpleContainer {
}
});
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
@ -293,7 +290,7 @@ public class JobChartBasicPanel extends SimpleContainer {
onDownloadSVG(id);
}
});
menuDownload.add(downloadCSVItem);
menuDownload.add(downloadPNGItem);
menuDownload.add(downloadJPGItem);
@ -302,7 +299,6 @@ public class JobChartBasicPanel extends SimpleContainer {
return menuDownload;
}
private void onDownloadCSV() {
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
@ -419,11 +415,10 @@ public class JobChartBasicPanel extends SimpleContainer {
+ JobChartMeasure.OperationCount.getLabel() + "\","
+ " \"style\": {" + " \"color\": \"" + colors.get(1)
+ "\"" + " }" + " }" + "} , {" + " \"id\": \""
+ JobChartMeasure.Duration.name() + "\", "
+ " \"title\": {" + " \"text\": \""
+ JobChartMeasure.Duration.getLabel() + "\","
+ " \"style\": {" + " \"color\": \"" + colors.get(0)
+ "\"" + " }" + " }," + " \"labels\": {"
+ JobChartMeasure.Duration.name() + "\", " + " \"title\": {"
+ " \"text\": \"" + JobChartMeasure.Duration.getLabel()
+ "\"," + " \"style\": {" + " \"color\": \""
+ colors.get(0) + "\"" + " }" + " }," + " \"labels\": {"
+ " \"format\": \"{value} " + unitMeasureLabel + "\","
+ " \"style\": {" + " \"color\": \"" + colors.get(0)
+ "\"" + " }" + " }," + " \"opposite\": \"true\""
@ -463,8 +458,7 @@ public class JobChartBasicPanel extends SimpleContainer {
SeriesColumn seriesOperationCount = highchartsFactory
.createSeriesColumn();
seriesOperationCount
.name(JobChartMeasure.OperationCount.getLabel());
seriesOperationCount.name(JobChartMeasure.OperationCount.getLabel());
seriesOperationCount.color(colors.get(1));
seriesOperationCount.type("column");
@ -488,8 +482,8 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMaxInvocationTime.name(JobChartMeasure.MaxInvocationTime
.getLabel());
seriesMaxInvocationTime.color(colors.get(2));
seriesMaxInvocationTime
.yAxisAsString(JobChartMeasure.MaxInvocationTime.name());
seriesMaxInvocationTime.yAxisAsString(JobChartMeasure.MaxInvocationTime
.name());
ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime
.dataAsArrayNumber();
@ -502,8 +496,8 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMinInvocationTime.name(JobChartMeasure.MinInvocationTime
.getLabel());
seriesMinInvocationTime.color(colors.get(3));
seriesMinInvocationTime
.yAxisAsString(JobChartMeasure.MinInvocationTime.name());
seriesMinInvocationTime.yAxisAsString(JobChartMeasure.MinInvocationTime
.name());
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime
.dataAsArrayNumber();
@ -511,8 +505,7 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMinInvocationTime.pointInterval(interval).pointStart(
dateStart.getTime());
for (SeriesJobData seriesJobData : seriesJobBasic
.getSeries()) {
for (SeriesJobData seriesJobData : seriesJobBasic.getSeries()) {
dataOperationCount.push(seriesJobData.getOperationCount());
dataDuration.push(seriesJobData.getDuration() / unitMeasure);
dataMaxInvocationTime.push(seriesJobData.getMaxInvocationTime()
@ -593,10 +586,9 @@ public class JobChartBasicPanel extends SimpleContainer {
+ " \"text\": \""
+ JobChartMeasure.OperationCount.getLabel() + "\","
+ " \"style\": {" + " \"color\": \"" + colors.get(1)
+ "\"" + " }" + " }" + "} , {"
+ " \"id\": \"JobData\", " + " \"linkedTo\": \"0\","
+ " \"gridLineWidth\": \"0\"," + " \"title\": {"
+ " \"text\": \"\"," + " \"style\": {"
+ "\"" + " }" + " }" + "} , {" + " \"id\": \"JobData\", "
+ " \"linkedTo\": \"0\"," + " \"gridLineWidth\": \"0\","
+ " \"title\": {" + " \"text\": \"\"," + " \"style\": {"
+ " \"color\": \"" + colors.get(1) + "\"" + " }"
+ " }," + " \"labels\": {" + " \"format\": \"{value} "
+ unitMeasureLabel + "\"," + " \"style\": {"
@ -620,8 +612,7 @@ public class JobChartBasicPanel extends SimpleContainer {
SeriesColumn seriesOperationCount = highchartsFactory
.createSeriesColumn();
seriesOperationCount
.name(JobChartMeasure.OperationCount.getLabel());
seriesOperationCount.name(JobChartMeasure.OperationCount.getLabel());
seriesOperationCount.color(colors.get(1));
seriesOperationCount.type("column");
@ -634,7 +625,7 @@ public class JobChartBasicPanel extends SimpleContainer {
SeriesArea seriesDuration = highchartsFactory.createSeriesArea();
seriesDuration.name(JobChartMeasure.Duration.getLabel());
seriesDuration.color(colors.get(0));
//seriesDuration.yAxisAsString("JobData");
// seriesDuration.yAxisAsString("JobData");
ArrayNumber dataDuration = seriesDuration.dataAsArrayNumber();
@ -645,7 +636,7 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMaxInvocationTime.name(JobChartMeasure.MaxInvocationTime
.getLabel());
seriesMaxInvocationTime.color(colors.get(2));
//seriesMaxInvocationTime.yAxisAsString("JobData");
// seriesMaxInvocationTime.yAxisAsString("JobData");
ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime
.dataAsArrayNumber();
@ -658,7 +649,7 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMinInvocationTime.name(JobChartMeasure.MinInvocationTime
.getLabel());
seriesMinInvocationTime.color(colors.get(3));
//seriesMinInvocationTime.yAxisAsString("JobData");
// seriesMinInvocationTime.yAxisAsString("JobData");
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime
.dataAsArrayNumber();
@ -666,8 +657,7 @@ public class JobChartBasicPanel extends SimpleContainer {
seriesMinInvocationTime.pointInterval(interval).pointStart(
dateStart.getTime());
for (SeriesJobData seriesJobData : seriesJobBasic
.getSeries()) {
for (SeriesJobData seriesJobData : seriesJobBasic.getSeries()) {
dataOperationCount.push(seriesJobData.getOperationCount());
dataDuration.push(seriesJobData.getDuration() / unitMeasure);
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.Date;
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure;
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.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.job.SeriesJobData;
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);
private EventBus eventBus;
private AccountingStateData accountingStateData;
private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu
private MenuItem downloadCSVItem;
private MenuItem downloadPNGItem;
private MenuItem downloadJPGItem;
private MenuItem downloadPDFItem;
@ -88,7 +90,7 @@ public class JobChartTopPanel extends SimpleContainer {
private VerticalLayoutContainer vert;
public JobChartTopPanel(EventBus eventBus,
AccountingStateData accountingStateData) {
AccountingClientStateData accountingStateData) {
this.eventBus = eventBus;
this.accountingStateData = accountingStateData;
forceLayoutOnResize = true;
@ -150,6 +152,9 @@ public class JobChartTopPanel extends SimpleContainer {
private Menu createDownloadMenu() {
Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30);
@ -162,7 +167,18 @@ public class JobChartTopPanel extends SimpleContainer {
downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
AccountingManagerResources.INSTANCE.accountingFileSVG24());
downloadSVGItem.setHeight(30);
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
onDownloadCSV();
}
});
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
@ -199,7 +215,8 @@ public class JobChartTopPanel extends SimpleContainer {
onDownloadSVG(id);
}
});
menuDownload.add(downloadCSVItem);
menuDownload.add(downloadPNGItem);
menuDownload.add(downloadJPGItem);
menuDownload.add(downloadPDFItem);
@ -348,7 +365,13 @@ public class JobChartTopPanel extends SimpleContainer {
return menuUnit;
}
private void onDownloadCSV() {
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
accountingStateData.getAccountingType());
eventBus.fireEvent(event);
}
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
public static native void onDownloadPNG(String id) /*-{

View File

@ -2,12 +2,13 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.servic
import java.util.Date;
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ServiceChartMeasure;
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.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.service.SeriesServiceBasic;
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 EventBus eventBus;
private AccountingStateData accountingStateData;
private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu
private MenuItem downloadCSVItem;
private MenuItem downloadPNGItem;
private MenuItem downloadJPGItem;
private MenuItem downloadPDFItem;
@ -80,7 +82,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
private ToggleButton toggleButton;
public ServiceChartBasicPanel(EventBus eventBus, AccountingStateData accountingStateData) {
public ServiceChartBasicPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus=eventBus;
this.accountingStateData = accountingStateData;
forceLayoutOnResize = true;
@ -226,6 +228,9 @@ public class ServiceChartBasicPanel extends SimpleContainer {
private Menu createDownloadMenu() {
Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30);
@ -238,7 +243,18 @@ public class ServiceChartBasicPanel extends SimpleContainer {
downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
AccountingManagerResources.INSTANCE.accountingFileSVG24());
downloadSVGItem.setHeight(30);
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
onDownloadCSV();
}
});
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
@ -275,7 +291,8 @@ public class ServiceChartBasicPanel extends SimpleContainer {
onDownloadSVG(id);
}
});
menuDownload.add(downloadCSVItem);
menuDownload.add(downloadPNGItem);
menuDownload.add(downloadJPGItem);
menuDownload.add(downloadPDFItem);
@ -283,6 +300,12 @@ public class ServiceChartBasicPanel extends SimpleContainer {
return menuDownload;
}
private void onDownloadCSV() {
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
accountingStateData.getAccountingType());
eventBus.fireEvent(event);
}
// 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.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.ChartTimeMeasure;
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.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.service.SeriesServiceData;
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);
private EventBus eventBus;
private AccountingStateData accountingStateData;
private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu
private MenuItem downloadCSVItem;
private MenuItem downloadPNGItem;
private MenuItem downloadJPGItem;
private MenuItem downloadPDFItem;
@ -86,10 +88,10 @@ public class ServiceChartTopPanel extends SimpleContainer {
private TextButton measureButton;
private VerticalLayoutContainer vert;
public ServiceChartTopPanel(EventBus eventBus, AccountingStateData accountingStateData) {
this.eventBus=eventBus;
public ServiceChartTopPanel(EventBus eventBus,
AccountingClientStateData accountingStateData) {
this.eventBus = eventBus;
this.accountingStateData = accountingStateData;
forceLayoutOnResize = true;
create();
@ -109,7 +111,8 @@ public class ServiceChartTopPanel extends SimpleContainer {
downloadButton.setMenu(createDownloadMenu());
// Measure
measureButton = new TextButton(ServiceChartMeasure.OperationCount.getLabel(),
measureButton = new TextButton(
ServiceChartMeasure.OperationCount.getLabel(),
AccountingManagerResources.INSTANCE.accountingByte24());
measureButton.setIconAlign(IconAlign.RIGHT);
measureButton.setArrowAlign(ButtonArrowAlign.RIGHT);
@ -122,12 +125,11 @@ public class ServiceChartTopPanel extends SimpleContainer {
unitButton.setArrowAlign(ButtonArrowAlign.RIGHT);
unitButton.setMenu(createUnitMenu());
unitButton.setVisible(false);
toolBar.add(downloadButton, new BoxLayoutData(new Margins(0)));
toolBar.add(measureButton, new BoxLayoutData(new Margins(0)));
toolBar.add(unitButton, new BoxLayoutData(new Margins(0)));
//
createChart();
@ -152,6 +154,9 @@ public class ServiceChartTopPanel extends SimpleContainer {
private Menu createDownloadMenu() {
Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30);
@ -165,6 +170,16 @@ public class ServiceChartTopPanel extends SimpleContainer {
AccountingManagerResources.INSTANCE.accountingFileSVG24());
downloadSVGItem.setHeight(30);
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
onDownloadCSV();
}
});
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
@ -202,6 +217,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
}
});
menuDownload.add(downloadCSVItem);
menuDownload.add(downloadPNGItem);
menuDownload.add(downloadJPGItem);
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();
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.StorageChartMeasure;
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.storage.SeriesStorageBasic;
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);
private EventBus eventBus;
private AccountingStateData accountingStateData;
private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu
@ -79,7 +79,7 @@ public class StorageChartBasicPanel extends SimpleContainer {
private VerticalLayoutContainer vert;
public StorageChartBasicPanel(EventBus eventBus,
AccountingStateData accountingStateData) {
AccountingClientStateData accountingStateData) {
this.eventBus = eventBus;
this.accountingStateData = accountingStateData;
forceLayoutOnResize = true;
@ -216,7 +216,8 @@ public class StorageChartBasicPanel extends SimpleContainer {
private Menu createDownloadMenu() {
Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingByte24());
AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24());
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.StorageChartMeasure;
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.storage.SeriesStorageData;
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);
private EventBus eventBus;
private AccountingStateData accountingStateData;
private AccountingClientStateData accountingStateData;
private HighchartsLayoutPanel highchartsLayoutPanel;
// Download Menu
@ -88,7 +88,7 @@ public class StorageChartTopPanel extends SimpleContainer {
private VerticalLayoutContainer vert;
public StorageChartTopPanel(EventBus eventBus, AccountingStateData accountingStateData) {
public StorageChartTopPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus=eventBus;
this.accountingStateData = accountingStateData;
forceLayoutOnResize = true;
@ -165,7 +165,8 @@ public class StorageChartTopPanel extends SimpleContainer {
private Menu createDownloadMenu() {
Menu menuDownload = new Menu();
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
AccountingManagerResources.INSTANCE.accountingByte24());
AccountingManagerResources.INSTANCE.accountingFileCSV24());
downloadCSVItem.setHeight(30);
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
AccountingManagerResources.INSTANCE.accountingFilePNG24());
downloadPNGItem.setHeight(30);
@ -225,7 +226,8 @@ public class StorageChartTopPanel extends SimpleContainer {
onDownloadSVG(id);
}
});
menuDownload.add(downloadCSVItem);
menuDownload.add(downloadPNGItem);
menuDownload.add(downloadJPGItem);
menuDownload.add(downloadPDFItem);

View File

@ -180,6 +180,12 @@ public interface AccountingManagerResources extends ClientBundle {
@Source("accounting-file_32.png")
ImageResource accountingFile32();
@Source("accounting-file-csv_24.png")
ImageResource accountingFileCSV24();
@Source("accounting-file-csv_32.png")
ImageResource accountingFileCSV32();
@Source("accounting-file-png_24.png")
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 org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
@ -81,7 +80,7 @@ public interface AccountingManagerService extends RemoteService {
* @return
* @throws ServiceException
*/
public ItemDescription saveCSVOnWorkspace(AccountingStateData accountingStateData)
public ItemDescription saveCSVOnWorkspace(AccountingType accountingType)
throws ServiceException;

View File

@ -5,7 +5,6 @@ package org.gcube.portlets.admin.accountingmanager.client.rpc;
import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
@ -77,7 +76,7 @@ public interface AccountingManagerServiceAsync {
* @param accountingStateData
* @param callback
*/
void saveCSVOnWorkspace(AccountingStateData accountingStateData,
void saveCSVOnWorkspace(AccountingType accountingType,
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>
*
*/
public class AccountingStateData implements Serializable {
public class AccountingClientStateData implements Serializable {
private static final long serialVersionUID = -2080165745912743812L;
private AccountingType accountingType;
@ -22,11 +22,11 @@ public class AccountingStateData implements Serializable {
private SeriesResponse seriesResponse;
private ArrayList<FilterKey> availableFilterKeys;
public AccountingStateData() {
public AccountingClientStateData() {
super();
}
public AccountingStateData(AccountingType accountingType,
public AccountingClientStateData(AccountingType accountingType,
SeriesRequest seriesRequest, SeriesResponse seriesResponse,
ArrayList<FilterKey> availableFilterKeys) {
super();
@ -70,10 +70,11 @@ public class AccountingStateData implements Serializable {
@Override
public String toString() {
return "AccountingStateData [accountingType=" + accountingType
return "AccountingClientStateData [accountingType=" + accountingType
+ ", seriesRequest=" + seriesRequest + ", seriesResponse="
+ seriesResponse + ", 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.portlets.admin.accountingmanager.client.rpc.AccountingManagerService;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCaller;
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCallerInterface;
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCallerTester;
import org.gcube.portlets.admin.accountingmanager.server.csv.CSVManager;
import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.server.storage.StorageUtil;
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
@ -101,7 +101,10 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
}
SeriesResponse seriesResponse = accountingCaller.getSeries(
accountingType, seriesRequest);
AccountingStateData accountingStateData = new AccountingStateData(
accountingType, seriesRequest, seriesResponse);
SessionUtil.setAccountingStateData(session, accountingType,
accountingStateData);
return seriesResponse;
} catch (ServiceException e) {
@ -179,16 +182,25 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
}
}
@Override
public ItemDescription saveCSVOnWorkspace(AccountingStateData accountingStateData)
public ItemDescription saveCSVOnWorkspace(AccountingType accountingType)
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
logger.debug("SaveDataOnWorkspace(): " + accountingStateData);
CSVManager csvManager=new CSVManager(aslSession.getUsername());
ItemDescription itemDescription=csvManager.saveOnWorkspace(accountingStateData);
logger.debug("SaveDataOnWorkspace(): " + accountingType);
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;
} catch (ServiceException e) {
e.printStackTrace();
@ -199,8 +211,6 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
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.SessionManager;
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.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpiredException;
import org.slf4j.Logger;
@ -65,23 +68,52 @@ public class SessionUtil {
}
public static String getToken(ASLSession aslSession) {
String token=null;
String token = null;
if (Constants.DEBUG_MODE) {
List<String> userRoles = new ArrayList<>();
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(
aslSession.getUsername(), userRoles);
} else {
token = aslSession.getSecurityToken();
}
logger.info("received token: " + 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.CSVPrinter;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVDataRow;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModel;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModel4Service;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModel4Storage;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModelBuilder;
import org.gcube.portlets.admin.accountingmanager.server.csv.file.CSVModelDirector;
import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData;
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.workspace.ItemDescription;
import org.slf4j.Logger;
@ -53,6 +55,7 @@ public class CSVManager {
switch (accountingStateData.getAccountingType()) {
case SERVICE:
csvModelBuilder = new CSVModel4Service(accountingStateData);
break;
case STORAGE:
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;
import java.text.ParseException;
import java.util.ArrayList;
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.query.SeriesRequest;
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()
.getStartDate());
String endDate = sdfFile.format(seriesRequest.getAccountingPeriod()
.getEndDate());
String startDate="";
try {
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.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()
.getLabel();
@ -77,7 +89,7 @@ public class CSVModel4Service extends CSVModelBuilder {
.getSeries();
for (SeriesServiceData seriesData : listData) {
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.getDuration()));
data.add(String.valueOf(seriesData.getMaxInvocationTime()));
@ -103,7 +115,7 @@ public class CSVModel4Service extends CSVModelBuilder {
for (SeriesServiceData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(filterValue.getValue());
data.add(sdf.format(seriesData.getDate()));
data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData
.getOperationCount()));
data.add(String.valueOf(seriesData.getDuration()));

View File

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

View File

@ -13,7 +13,9 @@ import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceExcept
*/
public abstract class CSVModelBuilder {
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");
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_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-class>org.gcube.portlets.admin.accountingmanager.server.AccountingManagerServiceImpl</servlet-class>
</servlet>
<!-- AccountingManagerService -->
<servlet>
<servlet-name>DownloadCSVServlet</servlet-name>
<servlet-class>org.gcube.portlets.admin.accountingmanager.server.DownloadCSVServlet</servlet-class>
</servlet>
<!-- Servlets Mapping -->
<!-- JUnit -->
@ -56,9 +61,12 @@
<url-pattern>/accountingman/ams</url-pattern>
</servlet-mapping>
<!-- AccountingManagerService -->
<servlet-mapping>
<servlet-name>DownloadCSVServlet</servlet-name>
<url-pattern>/accountingman/downloadCSVServlet</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>