refs 4041: Accounting Manager portlet: give possibility to download raw data to users
Task-Url: https://support.d4science.org/issues/4041 Added XML and JSON download git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@129039 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f4e0d99e6f
commit
fd437a29df
31
pom.xml
31
pom.xml
|
@ -104,8 +104,6 @@
|
|||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- Logger -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@ -114,13 +112,11 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>runtime</scope>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Accounting -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
|
@ -148,10 +144,6 @@
|
|||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-dev</artifactId>
|
||||
<version>${gwtVersion}</version> </dependency> -->
|
||||
|
||||
<!-- GXT 3 -->
|
||||
<dependency>
|
||||
<groupId>com.sencha.gxt</groupId>
|
||||
|
@ -338,6 +330,14 @@
|
|||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON -->
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20160212</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- LOGGING -->
|
||||
|
@ -350,14 +350,13 @@
|
|||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>compile</scope>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>runtime</scope>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
|
|
@ -44,17 +44,18 @@
|
|||
values="en" /> <extend-property name="locale" values="it" /> <extend-property
|
||||
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
|
||||
/> <set-property-fallback name="locale" value="en" /> -->
|
||||
|
||||
<!-- <set-property name="log_DivLogger" value="ENABLED" /> <set-property
|
||||
|
||||
<!--
|
||||
<set-property name="log_DivLogger" value="ENABLED" /> <set-property
|
||||
name="log_ConsoleLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/> -->
|
||||
/> -->
|
||||
|
||||
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.AccountingMenuEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.FiltersChangeEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.StateChangeEvent;
|
||||
|
@ -203,13 +203,13 @@ public class AccountingManagerController {
|
|||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(DownloadCSVRequestEvent.TYPE,
|
||||
new DownloadCSVRequestEvent.DownloadCSVRequestEventHandler() {
|
||||
eventBus.addHandler(ExportRequestEvent.TYPE,
|
||||
new ExportRequestEvent.ExportRequestEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onDownload(DownloadCSVRequestEvent event) {
|
||||
Log.debug("Catch DownloadDataRequestEvent");
|
||||
doDownloadCSV(event);
|
||||
public void onExport(ExportRequestEvent event) {
|
||||
Log.debug("Catch ExportRequestEvent");
|
||||
doExportRequest(event);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -418,7 +418,7 @@ public class AccountingManagerController {
|
|||
|
||||
}
|
||||
|
||||
private void doSaveDataOnWorkspace(DownloadCSVRequestEvent event) {
|
||||
private void doSaveDataOnWorkspace(ExportRequestEvent event) {
|
||||
accountingMonitor = new AccountingMonitor();
|
||||
Log.debug("Call saveCSVOnWorkspace on server, params: "
|
||||
+ event.getAccountingType());
|
||||
|
@ -480,11 +480,13 @@ public class AccountingManagerController {
|
|||
});
|
||||
}
|
||||
|
||||
private void doDownloadCSV(DownloadCSVRequestEvent event) {
|
||||
private void doExportRequest(ExportRequestEvent event) {
|
||||
StringBuilder actionUrl = new StringBuilder();
|
||||
actionUrl.append(GWT.getModuleBaseURL());
|
||||
actionUrl.append(Constants.DOWNLOAD_CVS_SERVLET + "?"
|
||||
+ Constants.DOWNLOAD_CVS_SERVLET_ACCOUNTINGTYPE_PARAMETER + "="
|
||||
actionUrl.append(Constants.EXPORT_SERVLET + "?"
|
||||
+ Constants.EXPORT_SERVLET_TYPE_PARAMETER + "="
|
||||
+ event.getExportType().name()+"&"
|
||||
+ Constants.EXPORT_SERVLET_ACCOUNTING_TYPE_PARAMETER + "="
|
||||
+ event.getAccountingType().name());
|
||||
|
||||
Log.debug("Retrieved link: " + actionUrl);
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.client.event;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.google.gwt.event.shared.HasHandlers;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DownloadCSVRequestEvent extends
|
||||
GwtEvent<DownloadCSVRequestEvent.DownloadCSVRequestEventHandler> {
|
||||
|
||||
public static Type<DownloadCSVRequestEventHandler> TYPE = new Type<DownloadCSVRequestEventHandler>();
|
||||
private AccountingType accountingType;
|
||||
|
||||
public interface DownloadCSVRequestEventHandler extends EventHandler {
|
||||
void onDownload(DownloadCSVRequestEvent event);
|
||||
}
|
||||
|
||||
public interface HasDownloadCSVRequestEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addDownloadCSVRequestEventHandler(
|
||||
DownloadCSVRequestEventHandler handler);
|
||||
}
|
||||
|
||||
public DownloadCSVRequestEvent(AccountingType accountingType) {
|
||||
this.accountingType = accountingType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(DownloadCSVRequestEventHandler handler) {
|
||||
handler.onDownload(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<DownloadCSVRequestEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<DownloadCSVRequestEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source,
|
||||
DownloadCSVRequestEvent accountingMenuEvent) {
|
||||
source.fireEvent(accountingMenuEvent);
|
||||
}
|
||||
|
||||
public AccountingType getAccountingType() {
|
||||
return accountingType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DownloadCSVRequestEvent [accountingType=" + accountingType
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.client.event;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportType;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.google.gwt.event.shared.HasHandlers;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ExportRequestEvent extends
|
||||
GwtEvent<ExportRequestEvent.ExportRequestEventHandler> {
|
||||
|
||||
public static Type<ExportRequestEventHandler> TYPE = new Type<ExportRequestEventHandler>();
|
||||
private ExportType exportType;
|
||||
private AccountingType accountingType;
|
||||
|
||||
public interface ExportRequestEventHandler extends EventHandler {
|
||||
void onExport(ExportRequestEvent event);
|
||||
}
|
||||
|
||||
public interface HasExportRequestEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addExportRequestEventHandler(
|
||||
ExportRequestEventHandler handler);
|
||||
}
|
||||
|
||||
public ExportRequestEvent(ExportType exportType,
|
||||
AccountingType accountingType) {
|
||||
this.exportType=exportType;
|
||||
this.accountingType = accountingType;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(ExportRequestEventHandler handler) {
|
||||
handler.onExport(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<ExportRequestEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<ExportRequestEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source,
|
||||
ExportRequestEvent accountingMenuEvent) {
|
||||
source.fireEvent(accountingMenuEvent);
|
||||
}
|
||||
|
||||
public AccountingType getAccountingType() {
|
||||
return accountingType;
|
||||
}
|
||||
|
||||
public ExportType getExportType() {
|
||||
return exportType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExportRequestEvent [exportType=" + exportType
|
||||
+ ", accountingType=" + accountingType + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent;
|
||||
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;
|
||||
|
@ -12,6 +12,7 @@ import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientS
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel;
|
||||
|
@ -61,6 +62,8 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
|
||||
// Download Menu
|
||||
private MenuItem downloadCSVItem;
|
||||
private MenuItem downloadXMLItem;
|
||||
private MenuItem downloadJSONItem;
|
||||
private MenuItem downloadPNGItem;
|
||||
private MenuItem downloadJPGItem;
|
||||
private MenuItem downloadPDFItem;
|
||||
|
@ -231,6 +234,12 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
|
||||
AccountingManagerResources.INSTANCE.accountingFileCSV24());
|
||||
downloadCSVItem.setHeight(30);
|
||||
downloadXMLItem = new MenuItem(DownloadConstants.DOWNLOAD_XML,
|
||||
AccountingManagerResources.INSTANCE.accountingFileXML24());
|
||||
downloadXMLItem.setHeight(30);
|
||||
downloadJSONItem = new MenuItem(DownloadConstants.DOWNLOAD_JSON,
|
||||
AccountingManagerResources.INSTANCE.accountingFileJSON24());
|
||||
downloadJSONItem.setHeight(30);
|
||||
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
|
||||
AccountingManagerResources.INSTANCE.accountingFilePNG24());
|
||||
downloadPNGItem.setHeight(30);
|
||||
|
@ -253,6 +262,27 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
downloadXMLItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadXML();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadJSONItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadJSON();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
|
@ -292,6 +322,8 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
});
|
||||
|
||||
menuDownload.add(downloadCSVItem);
|
||||
menuDownload.add(downloadXMLItem);
|
||||
menuDownload.add(downloadJSONItem);
|
||||
menuDownload.add(downloadPNGItem);
|
||||
menuDownload.add(downloadJPGItem);
|
||||
menuDownload.add(downloadPDFItem);
|
||||
|
@ -301,8 +333,20 @@ public class JobChartBasicPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
private void onDownloadCSV() {
|
||||
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
|
||||
accountingStateData.getAccountingType());
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.CSV, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadXML() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.XML, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadJSON() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.JSON, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ 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.event.ExportRequestEvent;
|
||||
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;
|
||||
|
@ -13,6 +13,7 @@ import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientS
|
|||
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;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel;
|
||||
|
@ -61,6 +62,8 @@ public class JobChartTopPanel extends SimpleContainer {
|
|||
|
||||
// Download Menu
|
||||
private MenuItem downloadCSVItem;
|
||||
private MenuItem downloadXMLItem;
|
||||
private MenuItem downloadJSONItem;
|
||||
private MenuItem downloadPNGItem;
|
||||
private MenuItem downloadJPGItem;
|
||||
private MenuItem downloadPDFItem;
|
||||
|
@ -155,6 +158,12 @@ public class JobChartTopPanel extends SimpleContainer {
|
|||
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
|
||||
AccountingManagerResources.INSTANCE.accountingFileCSV24());
|
||||
downloadCSVItem.setHeight(30);
|
||||
downloadXMLItem = new MenuItem(DownloadConstants.DOWNLOAD_XML,
|
||||
AccountingManagerResources.INSTANCE.accountingFileXML24());
|
||||
downloadXMLItem.setHeight(30);
|
||||
downloadJSONItem = new MenuItem(DownloadConstants.DOWNLOAD_JSON,
|
||||
AccountingManagerResources.INSTANCE.accountingFileJSON24());
|
||||
downloadJSONItem.setHeight(30);
|
||||
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
|
||||
AccountingManagerResources.INSTANCE.accountingFilePNG24());
|
||||
downloadPNGItem.setHeight(30);
|
||||
|
@ -177,7 +186,26 @@ public class JobChartTopPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
downloadXMLItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadXML();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadJSONItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadJSON();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
|
@ -217,6 +245,8 @@ public class JobChartTopPanel extends SimpleContainer {
|
|||
});
|
||||
|
||||
menuDownload.add(downloadCSVItem);
|
||||
menuDownload.add(downloadXMLItem);
|
||||
menuDownload.add(downloadJSONItem);
|
||||
menuDownload.add(downloadPNGItem);
|
||||
menuDownload.add(downloadJPGItem);
|
||||
menuDownload.add(downloadPDFItem);
|
||||
|
@ -367,11 +397,24 @@ public class JobChartTopPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
private void onDownloadCSV() {
|
||||
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
|
||||
accountingStateData.getAccountingType());
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.CSV, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadXML() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.XML, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadJSON() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.JSON, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
|
||||
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
|
||||
|
||||
public static native void onDownloadPNG(String id) /*-{
|
||||
|
|
|
@ -2,7 +2,7 @@ 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.event.ExportRequestEvent;
|
||||
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;
|
||||
|
@ -12,6 +12,7 @@ import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientS
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel;
|
||||
|
@ -62,6 +63,8 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
|
||||
// Download Menu
|
||||
private MenuItem downloadCSVItem;
|
||||
private MenuItem downloadXMLItem;
|
||||
private MenuItem downloadJSONItem;
|
||||
private MenuItem downloadPNGItem;
|
||||
private MenuItem downloadJPGItem;
|
||||
private MenuItem downloadPDFItem;
|
||||
|
@ -231,6 +234,12 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
|
||||
AccountingManagerResources.INSTANCE.accountingFileCSV24());
|
||||
downloadCSVItem.setHeight(30);
|
||||
downloadXMLItem = new MenuItem(DownloadConstants.DOWNLOAD_XML,
|
||||
AccountingManagerResources.INSTANCE.accountingFileXML24());
|
||||
downloadXMLItem.setHeight(30);
|
||||
downloadJSONItem = new MenuItem(DownloadConstants.DOWNLOAD_JSON,
|
||||
AccountingManagerResources.INSTANCE.accountingFileJSON24());
|
||||
downloadJSONItem.setHeight(30);
|
||||
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
|
||||
AccountingManagerResources.INSTANCE.accountingFilePNG24());
|
||||
downloadPNGItem.setHeight(30);
|
||||
|
@ -255,6 +264,26 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
|
||||
});
|
||||
|
||||
downloadXMLItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadXML();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadJSONItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadJSON();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
|
@ -293,6 +322,8 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
});
|
||||
|
||||
menuDownload.add(downloadCSVItem);
|
||||
menuDownload.add(downloadXMLItem);
|
||||
menuDownload.add(downloadJSONItem);
|
||||
menuDownload.add(downloadPNGItem);
|
||||
menuDownload.add(downloadJPGItem);
|
||||
menuDownload.add(downloadPDFItem);
|
||||
|
@ -302,10 +333,23 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
private void onDownloadCSV() {
|
||||
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
|
||||
accountingStateData.getAccountingType());
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.CSV, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadXML() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.XML, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadJSON() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.JSON, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
|
||||
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ 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.event.ExportRequestEvent;
|
||||
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;
|
||||
|
@ -13,6 +13,7 @@ import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientS
|
|||
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;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel;
|
||||
|
@ -61,6 +62,8 @@ public class ServiceChartTopPanel extends SimpleContainer {
|
|||
|
||||
// Download Menu
|
||||
private MenuItem downloadCSVItem;
|
||||
private MenuItem downloadXMLItem;
|
||||
private MenuItem downloadJSONItem;
|
||||
private MenuItem downloadPNGItem;
|
||||
private MenuItem downloadJPGItem;
|
||||
private MenuItem downloadPDFItem;
|
||||
|
@ -157,6 +160,12 @@ public class ServiceChartTopPanel extends SimpleContainer {
|
|||
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
|
||||
AccountingManagerResources.INSTANCE.accountingFileCSV24());
|
||||
downloadCSVItem.setHeight(30);
|
||||
downloadXMLItem = new MenuItem(DownloadConstants.DOWNLOAD_XML,
|
||||
AccountingManagerResources.INSTANCE.accountingFileXML24());
|
||||
downloadXMLItem.setHeight(30);
|
||||
downloadJSONItem = new MenuItem(DownloadConstants.DOWNLOAD_JSON,
|
||||
AccountingManagerResources.INSTANCE.accountingFileJSON24());
|
||||
downloadJSONItem.setHeight(30);
|
||||
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
|
||||
AccountingManagerResources.INSTANCE.accountingFilePNG24());
|
||||
downloadPNGItem.setHeight(30);
|
||||
|
@ -179,6 +188,27 @@ public class ServiceChartTopPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
downloadXMLItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadXML();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadJSONItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadJSON();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
|
@ -218,6 +248,8 @@ public class ServiceChartTopPanel extends SimpleContainer {
|
|||
});
|
||||
|
||||
menuDownload.add(downloadCSVItem);
|
||||
menuDownload.add(downloadXMLItem);
|
||||
menuDownload.add(downloadJSONItem);
|
||||
menuDownload.add(downloadPNGItem);
|
||||
menuDownload.add(downloadJPGItem);
|
||||
menuDownload.add(downloadPDFItem);
|
||||
|
@ -369,10 +401,23 @@ public class ServiceChartTopPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
private void onDownloadCSV() {
|
||||
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
|
||||
accountingStateData.getAccountingType());
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.CSV, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadXML() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.XML, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadJSON() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.JSON, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
|
||||
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storag
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ByteUnitMeasure;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
|
||||
|
@ -12,6 +12,7 @@ import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientS
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel;
|
||||
|
@ -60,6 +61,8 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
|
||||
// Download Menu
|
||||
private MenuItem downloadCSVItem;
|
||||
private MenuItem downloadXMLItem;
|
||||
private MenuItem downloadJSONItem;
|
||||
private MenuItem downloadPNGItem;
|
||||
private MenuItem downloadJPGItem;
|
||||
private MenuItem downloadPDFItem;
|
||||
|
@ -218,6 +221,12 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
|
||||
AccountingManagerResources.INSTANCE.accountingFileCSV24());
|
||||
downloadCSVItem.setHeight(30);
|
||||
downloadXMLItem = new MenuItem(DownloadConstants.DOWNLOAD_XML,
|
||||
AccountingManagerResources.INSTANCE.accountingFileXML24());
|
||||
downloadXMLItem.setHeight(30);
|
||||
downloadJSONItem = new MenuItem(DownloadConstants.DOWNLOAD_JSON,
|
||||
AccountingManagerResources.INSTANCE.accountingFileJSON24());
|
||||
downloadJSONItem.setHeight(30);
|
||||
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
|
||||
AccountingManagerResources.INSTANCE.accountingFilePNG24());
|
||||
downloadPNGItem.setHeight(30);
|
||||
|
@ -240,6 +249,27 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
downloadXMLItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadXML();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadJSONItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadJSON();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
|
@ -279,6 +309,8 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
});
|
||||
|
||||
menuDownload.add(downloadCSVItem);
|
||||
menuDownload.add(downloadXMLItem);
|
||||
menuDownload.add(downloadJSONItem);
|
||||
menuDownload.add(downloadPNGItem);
|
||||
menuDownload.add(downloadJPGItem);
|
||||
menuDownload.add(downloadPDFItem);
|
||||
|
@ -288,8 +320,20 @@ public class StorageChartBasicPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
private void onDownloadCSV() {
|
||||
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
|
||||
accountingStateData.getAccountingType());
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.CSV, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadXML() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.XML, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadJSON() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.JSON, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storag
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.DownloadCSVRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ByteUnitMeasure;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
|
||||
|
@ -13,6 +13,7 @@ import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientS
|
|||
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;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel;
|
||||
|
@ -61,6 +62,8 @@ public class StorageChartTopPanel extends SimpleContainer {
|
|||
|
||||
// Download Menu
|
||||
private MenuItem downloadCSVItem;
|
||||
private MenuItem downloadXMLItem;
|
||||
private MenuItem downloadJSONItem;
|
||||
private MenuItem downloadPNGItem;
|
||||
private MenuItem downloadJPGItem;
|
||||
private MenuItem downloadPDFItem;
|
||||
|
@ -167,6 +170,12 @@ public class StorageChartTopPanel extends SimpleContainer {
|
|||
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
|
||||
AccountingManagerResources.INSTANCE.accountingFileCSV24());
|
||||
downloadCSVItem.setHeight(30);
|
||||
downloadXMLItem = new MenuItem(DownloadConstants.DOWNLOAD_XML,
|
||||
AccountingManagerResources.INSTANCE.accountingFileXML24());
|
||||
downloadXMLItem.setHeight(30);
|
||||
downloadJSONItem = new MenuItem(DownloadConstants.DOWNLOAD_JSON,
|
||||
AccountingManagerResources.INSTANCE.accountingFileJSON24());
|
||||
downloadJSONItem.setHeight(30);
|
||||
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
|
||||
AccountingManagerResources.INSTANCE.accountingFilePNG24());
|
||||
downloadPNGItem.setHeight(30);
|
||||
|
@ -190,6 +199,26 @@ public class StorageChartTopPanel extends SimpleContainer {
|
|||
|
||||
});
|
||||
|
||||
downloadXMLItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadXML();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadJSONItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
onDownloadJSON();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
|
@ -228,6 +257,8 @@ public class StorageChartTopPanel extends SimpleContainer {
|
|||
});
|
||||
|
||||
menuDownload.add(downloadCSVItem);
|
||||
menuDownload.add(downloadXMLItem);
|
||||
menuDownload.add(downloadJSONItem);
|
||||
menuDownload.add(downloadPNGItem);
|
||||
menuDownload.add(downloadJPGItem);
|
||||
menuDownload.add(downloadPDFItem);
|
||||
|
@ -341,11 +372,24 @@ public class StorageChartTopPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
private void onDownloadCSV() {
|
||||
DownloadCSVRequestEvent event = new DownloadCSVRequestEvent(
|
||||
accountingStateData.getAccountingType());
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.CSV, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadXML() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.XML, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadJSON() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.JSON, accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
|
||||
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
|
||||
|
||||
public static native void onDownloadPNG(String id) /*-{
|
||||
|
|
|
@ -9,6 +9,8 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils;
|
|||
public class DownloadConstants {
|
||||
public static final String DOWNLOAD = "Download";
|
||||
public static final String DOWNLOAD_CSV = "Download CSV";
|
||||
public static final String DOWNLOAD_XML = "Download XML";
|
||||
public static final String DOWNLOAD_JSON = "Download JSON";
|
||||
public static final String DOWNLOAD_PNG = "Download PNG Image";
|
||||
public static final String DOWNLOAD_JPG = "Download JPG Image";
|
||||
public static final String DOWNLOAD_PDF = "Download PDF Document";
|
||||
|
|
|
@ -186,6 +186,18 @@ public interface AccountingManagerResources extends ClientBundle {
|
|||
@Source("accounting-file-csv_32.png")
|
||||
ImageResource accountingFileCSV32();
|
||||
|
||||
@Source("accounting-file-xml_24.png")
|
||||
ImageResource accountingFileXML24();
|
||||
|
||||
@Source("accounting-file-xml_32.png")
|
||||
ImageResource accountingFileXML32();
|
||||
|
||||
@Source("accounting-file-json_24.png")
|
||||
ImageResource accountingFileJSON24();
|
||||
|
||||
@Source("accounting-file-json_32.png")
|
||||
ImageResource accountingFileJSON32();
|
||||
|
||||
@Source("accounting-file-png_24.png")
|
||||
ImageResource accountingFilePNG24();
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 900 B |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 904 B |
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -10,7 +10,7 @@ import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerSe
|
|||
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.export.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;
|
||||
|
|
|
@ -11,12 +11,15 @@ 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.export.CSVManager;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.JSONManager;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.XMLManager;
|
||||
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.gcube.portlets.admin.accountingmanager.shared.export.ExportDescriptor;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -25,18 +28,18 @@ 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
|
||||
* Export Servlet
|
||||
*
|
||||
*/
|
||||
public class DownloadCSVServlet extends HttpServlet {
|
||||
public class ExportServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = -1838255772767180518L;
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(DownloadCSVServlet.class);
|
||||
.getLogger(ExportServlet.class);
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public DownloadCSVServlet() {
|
||||
public ExportServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
@ -62,7 +65,7 @@ public class DownloadCSVServlet extends HttpServlet {
|
|||
private void createResponse(HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException {
|
||||
try {
|
||||
logger.info("DownloadCSVServlet");
|
||||
logger.info("ExportServlet");
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
|
@ -75,35 +78,61 @@ public class DownloadCSVServlet extends HttpServlet {
|
|||
+ session);
|
||||
return;
|
||||
}
|
||||
logger.debug("DownloadCSVServlet session id: " + session.getId());
|
||||
logger.debug("ExportServlet session id: " + session.getId());
|
||||
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
|
||||
String accountingType = request.getParameter(Constants.DOWNLOAD_CVS_SERVLET_ACCOUNTINGTYPE_PARAMETER);
|
||||
logger.debug("Request: [accountingType=" + accountingType + "]");
|
||||
String exportType = request.getParameter(Constants.EXPORT_SERVLET_TYPE_PARAMETER);
|
||||
String accountingType = request.getParameter(Constants.EXPORT_SERVLET_ACCOUNTING_TYPE_PARAMETER);
|
||||
|
||||
|
||||
logger.debug("Request: [exportType="+exportType+", 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);
|
||||
logger.error("No series present in session for this accounting type: "+accountingType);
|
||||
throw new ServletException("No series present in session for this accounting type: "+accountingType);
|
||||
}
|
||||
|
||||
CSVManager csvManager=new CSVManager(aslSession.getUsername());
|
||||
CSVDescriptor csvDescriptor=csvManager.downloadCSV(accountingStateData);
|
||||
logger.debug("CSVDescriptor: "+csvDescriptor);
|
||||
ExportType exportT=ExportType.valueOf(exportType);
|
||||
if(exportT==null){
|
||||
logger.error("Invalid Export Type Request: "+exportType);
|
||||
throw new ServletException("Invalid Export Type Request: "+exportType);
|
||||
}
|
||||
|
||||
ExportDescriptor exportDescriptor=null;
|
||||
switch(exportT){
|
||||
case CSV:
|
||||
CSVManager csvManager=new CSVManager(aslSession.getUsername());
|
||||
exportDescriptor=csvManager.download(accountingStateData);
|
||||
response.setContentType("text/csv");
|
||||
break;
|
||||
case JSON:
|
||||
JSONManager jsonManager=new JSONManager(aslSession.getUsername());
|
||||
exportDescriptor=jsonManager.download(accountingStateData);
|
||||
response.setContentType("application/json");
|
||||
break;
|
||||
case XML:
|
||||
XMLManager xmlManager=new XMLManager(aslSession.getUsername());
|
||||
exportDescriptor=xmlManager.download(accountingStateData);
|
||||
response.setContentType("text/xml");
|
||||
break;
|
||||
default:
|
||||
logger.error("Export Type not supported: "+exportType);
|
||||
throw new ServletException("Export Type not supported: "+exportType);
|
||||
}
|
||||
logger.debug("ExportDescriptor: "+exportDescriptor);
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\""
|
||||
+ csvDescriptor.getCsvModel().getFileName()+csvDescriptor.getCsvModel().getFileExtension() + "\"");
|
||||
response.setContentType("text/csv");
|
||||
+ exportDescriptor.getCsvModel().getName()+exportDescriptor.getFileExtension() + "\"");
|
||||
response.setHeader("Content-Length",
|
||||
String.valueOf(csvDescriptor.getPath().toFile().length()));
|
||||
|
||||
String.valueOf(exportDescriptor.getPath().toFile().length()));
|
||||
OutputStream out = response.getOutputStream();
|
||||
Files.copy(csvDescriptor.getPath(), out);
|
||||
Files.copy(exportDescriptor.getPath(), out);
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
try {
|
||||
Files.delete(csvDescriptor.getPath());
|
||||
Files.delete(exportDescriptor.getPath());
|
||||
} catch (IOException e) {
|
||||
logger.error("Error in deleting temp file: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
@ -115,7 +144,7 @@ public class DownloadCSVServlet extends HttpServlet {
|
|||
return;
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in DownloadFolderServlet: "
|
||||
logger.error("Error in ExportServlet: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException("Error:"
|
|
@ -1,72 +0,0 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7127656837246518599L;
|
||||
private String fileName;
|
||||
private String fileExtension;
|
||||
private ArrayList<String> header;
|
||||
private ArrayList<CSVDataRow> rows;
|
||||
|
||||
public CSVModel() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CSVModel(String fileName, ArrayList<String> header,
|
||||
ArrayList<CSVDataRow> rows) {
|
||||
super();
|
||||
this.fileName = fileName;
|
||||
this.fileExtension =".csv";
|
||||
this.header = header;
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
return fileExtension;
|
||||
}
|
||||
|
||||
public void setFileExtension(String fileExtension) {
|
||||
this.fileExtension = fileExtension;
|
||||
}
|
||||
|
||||
public ArrayList<String> getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public void setHeader(ArrayList<String> header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public ArrayList<CSVDataRow> getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(ArrayList<CSVDataRow> rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CSVModel [fileName=" + fileName + ", fileExtension="
|
||||
+ fileExtension + ", header=" + header + ", rows=" + rows + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* CSV Model Director
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVModelDirector {
|
||||
CSVModelBuilder csvModelBuilder;
|
||||
|
||||
public void setCSVModelBuilder(
|
||||
CSVModelBuilder csvModelBuilder) {
|
||||
this.csvModelBuilder = csvModelBuilder;
|
||||
}
|
||||
|
||||
public CSVModel getCSVModel() {
|
||||
return csvModelBuilder.getCSVModelSpec().getOp();
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<CSVModel> getListOfCSVModel() {
|
||||
return csvModelBuilder.getCSVModelSpec().getOps();
|
||||
|
||||
}
|
||||
|
||||
public void constructCSVModel() throws ServiceException {
|
||||
csvModelBuilder.createSpec();
|
||||
csvModelBuilder.buildOpEx();
|
||||
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* CSV Model Specification
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVModelSpec {
|
||||
private CSVModel op;
|
||||
private ArrayList<CSVModel> ops;
|
||||
|
||||
public CSVModel getOp() {
|
||||
return op;
|
||||
}
|
||||
|
||||
public void setOp(CSVModel op) {
|
||||
this.op = op;
|
||||
}
|
||||
|
||||
public ArrayList<CSVModel> getOps() {
|
||||
return ops;
|
||||
}
|
||||
|
||||
public void setOps(ArrayList<CSVModel> ops) {
|
||||
this.ops = ops;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv;
|
||||
package org.gcube.portlets.admin.accountingmanager.server.export;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -9,16 +9,16 @@ import java.nio.file.StandardOpenOption;
|
|||
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVPrinter;
|
||||
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.export.model.AccountingDataRow;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataModel;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Service;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Storage;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelDirector;
|
||||
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.export.ExportDescriptor;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class CSVManager {
|
||||
|
||||
private static final String FILE_EXTENSION = ".csv";
|
||||
private static Logger logger = LoggerFactory.getLogger(CSVManager.class);
|
||||
private String userName;
|
||||
|
||||
|
@ -51,14 +52,14 @@ public class CSVManager {
|
|||
throw new ServiceException("Accounting Type is null!");
|
||||
}
|
||||
|
||||
CSVModelBuilder csvModelBuilder = null;
|
||||
AccountingModelBuilder accountingModelBuilder = null;
|
||||
|
||||
switch (accountingStateData.getAccountingType()) {
|
||||
case SERVICE:
|
||||
csvModelBuilder = new CSVModel4Service(accountingStateData);
|
||||
accountingModelBuilder = new AccountingModel4Service(accountingStateData);
|
||||
break;
|
||||
case STORAGE:
|
||||
csvModelBuilder = new CSVModel4Storage(accountingStateData);
|
||||
accountingModelBuilder = new AccountingModel4Storage(accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
case PORTLET:
|
||||
|
@ -68,19 +69,19 @@ public class CSVManager {
|
|||
throw new ServiceException("Accounting Type not supported!!");
|
||||
}
|
||||
|
||||
CSVModelDirector director = new CSVModelDirector();
|
||||
director.setCSVModelBuilder(csvModelBuilder);
|
||||
director.constructCSVModel();
|
||||
CSVModel csvModel = director.getCSVModel();
|
||||
logger.debug("CSVModel: " + csvModel);
|
||||
AccountingModelDirector director = new AccountingModelDirector();
|
||||
director.setAccountingModelBuilder(accountingModelBuilder);
|
||||
director.constructAccountingModel();
|
||||
AccountingDataModel accountingDataModel = director.getAccountingModel();
|
||||
logger.debug("AccountingDataModel: " + accountingDataModel);
|
||||
|
||||
if (csvModel == null) {
|
||||
logger.error("CSV model created is null");
|
||||
throw new ServiceException("CSVModel created is null!");
|
||||
if (accountingDataModel == null) {
|
||||
logger.error("Accounting data model created is null");
|
||||
throw new ServiceException("Accounting data model created is null!");
|
||||
}
|
||||
|
||||
Path tempFile = Files.createTempFile(csvModel.getFileName(),
|
||||
csvModel.getFileExtension());
|
||||
Path tempFile = Files.createTempFile(accountingDataModel.getName(),
|
||||
FILE_EXTENSION);
|
||||
logger.debug("Temp File: " + tempFile.toString());
|
||||
|
||||
// Create the CSVFormat object
|
||||
|
@ -90,8 +91,8 @@ public class CSVManager {
|
|||
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(accountingDataModel.getHeader());
|
||||
for (AccountingDataRow row : accountingDataModel.getRows()) {
|
||||
printer.printRecord(row.getData());
|
||||
}
|
||||
// close the printer
|
||||
|
@ -104,8 +105,8 @@ public class CSVManager {
|
|||
try (InputStream is = Files.newInputStream(tempFile,
|
||||
StandardOpenOption.READ)) {
|
||||
itemDescription=StorageUtil.saveOnWorkspace(userName, destinationFolderId,
|
||||
csvModel.getFileName() + csvModel.getFileExtension(),
|
||||
csvModel.getFileName(), is);
|
||||
accountingDataModel.getName() + FILE_EXTENSION,
|
||||
accountingDataModel.getName(), is);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -123,9 +124,9 @@ public class CSVManager {
|
|||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error saving data: " + e.getLocalizedMessage());
|
||||
logger.error("Error saving csv data: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error saving data: "
|
||||
throw new ServiceException("Error saving csv data: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
@ -133,7 +134,7 @@ public class CSVManager {
|
|||
}
|
||||
|
||||
|
||||
public CSVDescriptor downloadCSV(AccountingStateData accountingStateData) throws ServiceException {
|
||||
public ExportDescriptor download(AccountingStateData accountingStateData) throws ServiceException {
|
||||
try {
|
||||
logger.debug("AccountingStateData: "+accountingStateData);
|
||||
if (accountingStateData == null) {
|
||||
|
@ -146,14 +147,14 @@ public class CSVManager {
|
|||
throw new ServiceException("Accounting Type is null!");
|
||||
}
|
||||
|
||||
CSVModelBuilder csvModelBuilder = null;
|
||||
AccountingModelBuilder accountindModelBuilder = null;
|
||||
|
||||
switch (accountingStateData.getAccountingType()) {
|
||||
case SERVICE:
|
||||
csvModelBuilder = new CSVModel4Service(accountingStateData);
|
||||
accountindModelBuilder = new AccountingModel4Service(accountingStateData);
|
||||
break;
|
||||
case STORAGE:
|
||||
csvModelBuilder = new CSVModel4Storage(accountingStateData);
|
||||
accountindModelBuilder = new AccountingModel4Storage(accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
case PORTLET:
|
||||
|
@ -163,20 +164,20 @@ public class CSVManager {
|
|||
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);
|
||||
logger.debug("AccountingModelBuilder: "+accountindModelBuilder);
|
||||
AccountingModelDirector director = new AccountingModelDirector();
|
||||
director.setAccountingModelBuilder(accountindModelBuilder);
|
||||
director.constructAccountingModel();
|
||||
AccountingDataModel accountingDataModel = director.getAccountingModel();
|
||||
logger.debug("AccountingDataModel: " + accountingDataModel);
|
||||
|
||||
if (csvModel == null) {
|
||||
logger.error("CSV model created is null");
|
||||
throw new ServiceException("CSVModel created is null!");
|
||||
if (accountingDataModel == null) {
|
||||
logger.error("Accounting data model created is null");
|
||||
throw new ServiceException("Accounting data model created is null!");
|
||||
}
|
||||
|
||||
Path tempFile = Files.createTempFile(csvModel.getFileName(),
|
||||
csvModel.getFileExtension());
|
||||
Path tempFile = Files.createTempFile(accountingDataModel.getName(),
|
||||
FILE_EXTENSION);
|
||||
logger.debug("Temp File: " + tempFile.toString());
|
||||
|
||||
// Create the CSVFormat object
|
||||
|
@ -186,8 +187,8 @@ public class CSVManager {
|
|||
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(accountingDataModel.getHeader());
|
||||
for (AccountingDataRow row : accountingDataModel.getRows()) {
|
||||
printer.printRecord(row.getData());
|
||||
}
|
||||
// close the printer
|
||||
|
@ -195,14 +196,14 @@ public class CSVManager {
|
|||
printStream.close();
|
||||
|
||||
|
||||
return new CSVDescriptor(tempFile, csvModel);
|
||||
return new ExportDescriptor(tempFile, accountingDataModel, FILE_EXTENSION);
|
||||
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error downloading data: " + e.getLocalizedMessage());
|
||||
logger.error("Error downloading csv data: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error downloading data: "
|
||||
throw new ServiceException("Error downloading csv data: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
|
@ -0,0 +1,241 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.export;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataModel;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataRow;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Service;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Storage;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelDirector;
|
||||
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.exception.ServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportDescriptor;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* JSON Manager
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class JSONManager {
|
||||
|
||||
private static final String FILE_EXTENSION = ".json";
|
||||
private static Logger logger = LoggerFactory.getLogger(JSONManager.class);
|
||||
private String userName;
|
||||
|
||||
public JSONManager(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public ItemDescription saveOnWorkspace(
|
||||
AccountingStateData accountingStateData) throws ServiceException {
|
||||
try {
|
||||
if (accountingStateData == null) {
|
||||
logger.error("AccountingStateData is null");
|
||||
throw new ServiceException("AccountingStateData is null!");
|
||||
}
|
||||
|
||||
if (accountingStateData.getAccountingType() == null) {
|
||||
logger.error("Accounting Type is null");
|
||||
throw new ServiceException("Accounting Type is null!");
|
||||
}
|
||||
|
||||
AccountingModelBuilder accountingModelBuilder = null;
|
||||
|
||||
switch (accountingStateData.getAccountingType()) {
|
||||
case SERVICE:
|
||||
accountingModelBuilder = new AccountingModel4Service(
|
||||
accountingStateData);
|
||||
break;
|
||||
case STORAGE:
|
||||
accountingModelBuilder = new AccountingModel4Storage(
|
||||
accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
logger.error("Accounting Type not supported!");
|
||||
throw new ServiceException("Accounting Type not supported!!");
|
||||
}
|
||||
|
||||
AccountingModelDirector director = new AccountingModelDirector();
|
||||
director.setAccountingModelBuilder(accountingModelBuilder);
|
||||
director.constructAccountingModel();
|
||||
AccountingDataModel accountingDataModel = director
|
||||
.getAccountingModel();
|
||||
logger.debug("AccountingDataModel: " + accountingDataModel);
|
||||
|
||||
if (accountingDataModel == null) {
|
||||
logger.error("Accounting data model created is null");
|
||||
throw new ServiceException(
|
||||
"Accounting data model created is null!");
|
||||
}
|
||||
|
||||
Path tempFile = Files.createTempFile(accountingDataModel.getName(),
|
||||
FILE_EXTENSION);
|
||||
logger.debug("Temp File: " + tempFile.toString());
|
||||
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
jsonObj.put("name", accountingDataModel.getName());
|
||||
JSONArray headerJSON = new JSONArray(
|
||||
accountingDataModel.getHeader());
|
||||
jsonObj.put("header", headerJSON);
|
||||
JSONArray rowsJSON = new JSONArray();
|
||||
for (AccountingDataRow accountingDataRow : accountingDataModel
|
||||
.getRows()) {
|
||||
JSONArray accountingDataRowJSON = new JSONArray(
|
||||
accountingDataRow.getData());
|
||||
JSONObject rowJSON=new JSONObject();
|
||||
rowJSON.put("data", accountingDataRowJSON);
|
||||
rowsJSON.put(rowJSON);
|
||||
}
|
||||
jsonObj.put("rows", rowsJSON);
|
||||
|
||||
logger.debug("JSONOBJ: "+jsonObj);
|
||||
|
||||
try (BufferedWriter bw = Files.newBufferedWriter(tempFile,
|
||||
Charset.defaultCharset(), StandardOpenOption.WRITE)) {
|
||||
jsonObj.write(bw);
|
||||
}
|
||||
|
||||
String destinationFolderId = StorageUtil
|
||||
.createAccountingFolderOnWorkspace(userName);
|
||||
ItemDescription itemDescription = null;
|
||||
try (InputStream is = Files.newInputStream(tempFile,
|
||||
StandardOpenOption.READ)) {
|
||||
itemDescription = StorageUtil.saveOnWorkspace(userName,
|
||||
destinationFolderId, accountingDataModel.getName()
|
||||
+ FILE_EXTENSION,
|
||||
accountingDataModel.getName(), is);
|
||||
}
|
||||
|
||||
try {
|
||||
Files.delete(tempFile);
|
||||
} catch (IOException e) {
|
||||
logger.error("Error in deleting temp file: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error deleting temp file: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
return itemDescription;
|
||||
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error saving xml data: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error saving xml data: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ExportDescriptor download(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!");
|
||||
}
|
||||
|
||||
AccountingModelBuilder accountingModelBuilder = null;
|
||||
|
||||
switch (accountingStateData.getAccountingType()) {
|
||||
case SERVICE:
|
||||
accountingModelBuilder = new AccountingModel4Service(
|
||||
accountingStateData);
|
||||
break;
|
||||
case STORAGE:
|
||||
accountingModelBuilder = new AccountingModel4Storage(
|
||||
accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
logger.error("Accounting Type not supported!");
|
||||
throw new ServiceException("Accounting Type not supported!!");
|
||||
}
|
||||
|
||||
logger.debug("AccountingModelBuilder: " + accountingModelBuilder);
|
||||
AccountingModelDirector director = new AccountingModelDirector();
|
||||
director.setAccountingModelBuilder(accountingModelBuilder);
|
||||
director.constructAccountingModel();
|
||||
AccountingDataModel accountingDataModel = director
|
||||
.getAccountingModel();
|
||||
logger.debug("AccountingDataModel: " + accountingDataModel);
|
||||
|
||||
if (accountingDataModel == null) {
|
||||
logger.error("Accounting data model created is null");
|
||||
throw new ServiceException(
|
||||
"Accounting data model created is null!");
|
||||
}
|
||||
|
||||
Path tempFile = Files.createTempFile(accountingDataModel.getName(),
|
||||
FILE_EXTENSION);
|
||||
logger.debug("Temp File: " + tempFile.toString());
|
||||
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
jsonObj.put("name", accountingDataModel.getName());
|
||||
JSONArray headerJSON = new JSONArray(
|
||||
accountingDataModel.getHeader());
|
||||
jsonObj.put("header", headerJSON);
|
||||
JSONArray rowsJSON = new JSONArray();
|
||||
for (AccountingDataRow accountingDataRow : accountingDataModel
|
||||
.getRows()) {
|
||||
JSONArray accountingDataRowJSON = new JSONArray(
|
||||
accountingDataRow.getData());
|
||||
JSONObject rowJSON=new JSONObject();
|
||||
rowJSON.put("data", accountingDataRowJSON);
|
||||
rowsJSON.put(rowJSON);
|
||||
}
|
||||
jsonObj.put("rows", rowsJSON);
|
||||
|
||||
logger.debug("JSONOBJ: "+jsonObj);
|
||||
|
||||
try (BufferedWriter bw = Files.newBufferedWriter(tempFile,
|
||||
Charset.defaultCharset(), StandardOpenOption.WRITE)) {
|
||||
jsonObj.write(bw);
|
||||
}
|
||||
|
||||
return new ExportDescriptor(tempFile, accountingDataModel,
|
||||
FILE_EXTENSION);
|
||||
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error downloading xml data: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error downloading xml data: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,208 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.export;
|
||||
|
||||
import java.beans.XMLEncoder;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataModel;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Service;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Storage;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelDirector;
|
||||
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.exception.ServiceException;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportDescriptor;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* XML Manager
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class XMLManager {
|
||||
|
||||
private static final String FILE_EXTENSION = ".xml";
|
||||
private static Logger logger = LoggerFactory.getLogger(XMLManager.class);
|
||||
private String userName;
|
||||
|
||||
public XMLManager(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public ItemDescription saveOnWorkspace(
|
||||
AccountingStateData accountingStateData) throws ServiceException {
|
||||
try {
|
||||
if (accountingStateData == null) {
|
||||
logger.error("AccountingStateData is null");
|
||||
throw new ServiceException("AccountingStateData is null!");
|
||||
}
|
||||
|
||||
if (accountingStateData.getAccountingType() == null) {
|
||||
logger.error("Accounting Type is null");
|
||||
throw new ServiceException("Accounting Type is null!");
|
||||
}
|
||||
|
||||
AccountingModelBuilder accountingModelBuilder = null;
|
||||
|
||||
switch (accountingStateData.getAccountingType()) {
|
||||
case SERVICE:
|
||||
accountingModelBuilder = new AccountingModel4Service(
|
||||
accountingStateData);
|
||||
break;
|
||||
case STORAGE:
|
||||
accountingModelBuilder = new AccountingModel4Storage(
|
||||
accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
logger.error("Accounting Type not supported!");
|
||||
throw new ServiceException("Accounting Type not supported!!");
|
||||
}
|
||||
|
||||
AccountingModelDirector director = new AccountingModelDirector();
|
||||
director.setAccountingModelBuilder(accountingModelBuilder);
|
||||
director.constructAccountingModel();
|
||||
AccountingDataModel accountingDataModel = director
|
||||
.getAccountingModel();
|
||||
logger.debug("AccountingDataModel: " + accountingDataModel);
|
||||
|
||||
if (accountingDataModel == null) {
|
||||
logger.error("Accounting data model created is null");
|
||||
throw new ServiceException(
|
||||
"Accounting data model created is null!");
|
||||
}
|
||||
|
||||
Path tempFile = Files.createTempFile(accountingDataModel.getName(),
|
||||
FILE_EXTENSION);
|
||||
logger.debug("Temp File: " + tempFile.toString());
|
||||
|
||||
try (OutputStream os = Files.newOutputStream(tempFile,
|
||||
StandardOpenOption.WRITE)) {
|
||||
XMLEncoder xmlEncoder = new XMLEncoder(os);
|
||||
xmlEncoder.writeObject(accountingDataModel);
|
||||
xmlEncoder.close();
|
||||
logger.debug("Archived:" + os);
|
||||
}
|
||||
|
||||
|
||||
String destinationFolderId = StorageUtil
|
||||
.createAccountingFolderOnWorkspace(userName);
|
||||
ItemDescription itemDescription = null;
|
||||
try (InputStream is = Files.newInputStream(tempFile,
|
||||
StandardOpenOption.READ)) {
|
||||
itemDescription = StorageUtil.saveOnWorkspace(userName,
|
||||
destinationFolderId, accountingDataModel.getName()
|
||||
+ FILE_EXTENSION,
|
||||
accountingDataModel.getName(), is);
|
||||
}
|
||||
|
||||
try {
|
||||
Files.delete(tempFile);
|
||||
} catch (IOException e) {
|
||||
logger.error("Error in deleting temp file: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error deleting temp file: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
return itemDescription;
|
||||
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error saving xml data: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error saving xml data: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ExportDescriptor download(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!");
|
||||
}
|
||||
|
||||
AccountingModelBuilder accountingModelBuilder = null;
|
||||
|
||||
switch (accountingStateData.getAccountingType()) {
|
||||
case SERVICE:
|
||||
accountingModelBuilder = new AccountingModel4Service(
|
||||
accountingStateData);
|
||||
break;
|
||||
case STORAGE:
|
||||
accountingModelBuilder = new AccountingModel4Storage(
|
||||
accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
logger.error("Accounting Type not supported!");
|
||||
throw new ServiceException("Accounting Type not supported!!");
|
||||
}
|
||||
|
||||
logger.debug("AccountingModelBuilder: " + accountingModelBuilder);
|
||||
AccountingModelDirector director = new AccountingModelDirector();
|
||||
director.setAccountingModelBuilder(accountingModelBuilder);
|
||||
director.constructAccountingModel();
|
||||
AccountingDataModel accountingDataModel = director
|
||||
.getAccountingModel();
|
||||
logger.debug("AccountingDataModel: " + accountingDataModel);
|
||||
|
||||
if (accountingDataModel == null) {
|
||||
logger.error("Accounting data model created is null");
|
||||
throw new ServiceException(
|
||||
"Accounting data model created is null!");
|
||||
}
|
||||
|
||||
Path tempFile = Files.createTempFile(accountingDataModel.getName(),
|
||||
FILE_EXTENSION);
|
||||
logger.debug("Temp File: " + tempFile.toString());
|
||||
|
||||
try (OutputStream os = Files.newOutputStream(tempFile,
|
||||
StandardOpenOption.WRITE)) {
|
||||
XMLEncoder xmlEncoder = new XMLEncoder(os);
|
||||
xmlEncoder.writeObject(accountingDataModel);
|
||||
xmlEncoder.close();
|
||||
logger.debug("Archived:" + os);
|
||||
}
|
||||
|
||||
return new ExportDescriptor(tempFile, accountingDataModel,
|
||||
FILE_EXTENSION);
|
||||
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error downloading xml data: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error downloading xml data: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.export.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Accounting Data Model
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class AccountingDataModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7127656837246518599L;
|
||||
private String name;
|
||||
private ArrayList<String> header;
|
||||
private ArrayList<AccountingDataRow> rows;
|
||||
|
||||
public AccountingDataModel() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AccountingDataModel(String name, ArrayList<String> header,
|
||||
ArrayList<AccountingDataRow> rows) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.header = header;
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ArrayList<String> getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public void setHeader(ArrayList<String> header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public ArrayList<AccountingDataRow> getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(ArrayList<AccountingDataRow> rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AccountingDataModel [name=" + name + ", header=" + header
|
||||
+ ", rows=" + rows + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,25 +1,25 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
package org.gcube.portlets.admin.accountingmanager.server.export.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Row of csv
|
||||
* Accounting data row
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVDataRow implements Serializable {
|
||||
public class AccountingDataRow implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -707694572028800959L;
|
||||
private ArrayList<String> data;
|
||||
|
||||
public CSVDataRow() {
|
||||
public AccountingDataRow() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CSVDataRow(ArrayList<String> data) {
|
||||
public AccountingDataRow(ArrayList<String> data) {
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
@ -34,7 +34,9 @@ public class CSVDataRow implements Serializable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CSVDataRow [data=" + data + "]";
|
||||
return "AccountingDataRow [data=" + data + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
package org.gcube.portlets.admin.accountingmanager.server.export.model;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -19,18 +19,18 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* CSV Model 4 Service
|
||||
* Accounting Model 4 Service
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVModel4Service extends CSVModelBuilder {
|
||||
public class AccountingModel4Service extends AccountingModelBuilder {
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(CSVModel4Service.class);
|
||||
.getLogger(AccountingModel4Service.class);
|
||||
private AccountingStateData accountingStateData;
|
||||
|
||||
public CSVModel4Service(AccountingStateData accountingStateData) {
|
||||
public AccountingModel4Service(AccountingStateData accountingStateData) {
|
||||
this.accountingStateData = accountingStateData;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class CSVModel4Service extends CSVModelBuilder {
|
|||
|
||||
String fileName = "Untitled";
|
||||
ArrayList<String> header;
|
||||
ArrayList<CSVDataRow> rows = new ArrayList<>();
|
||||
ArrayList<AccountingDataRow> rows = new ArrayList<>();
|
||||
if (seriesResponse instanceof SeriesService) {
|
||||
SeriesService seriesService = (SeriesService) seriesResponse;
|
||||
SeriesServiceDefinition definition = seriesService
|
||||
|
@ -94,7 +94,7 @@ public class CSVModel4Service extends CSVModelBuilder {
|
|||
data.add(String.valueOf(seriesData.getDuration()));
|
||||
data.add(String.valueOf(seriesData.getMaxInvocationTime()));
|
||||
data.add(String.valueOf(seriesData.getMinInvocationTime()));
|
||||
CSVDataRow csvDataRow = new CSVDataRow(data);
|
||||
AccountingDataRow csvDataRow = new AccountingDataRow(data);
|
||||
rows.add(csvDataRow);
|
||||
}
|
||||
} else {
|
||||
|
@ -123,7 +123,7 @@ public class CSVModel4Service extends CSVModelBuilder {
|
|||
.getMaxInvocationTime()));
|
||||
data.add(String.valueOf(seriesData
|
||||
.getMinInvocationTime()));
|
||||
CSVDataRow csvDataRow = new CSVDataRow(data);
|
||||
AccountingDataRow csvDataRow = new AccountingDataRow(data);
|
||||
rows.add(csvDataRow);
|
||||
}
|
||||
}
|
||||
|
@ -143,8 +143,8 @@ public class CSVModel4Service extends CSVModelBuilder {
|
|||
+ seriesResponse);
|
||||
}
|
||||
|
||||
CSVModel invocation = new CSVModel(fileName, header, rows);
|
||||
csvModelSpec.setOp(invocation);
|
||||
AccountingDataModel invocation = new AccountingDataModel(fileName, header, rows);
|
||||
accountingModelSpec.setOp(invocation);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
package org.gcube.portlets.admin.accountingmanager.server.export.model;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -19,18 +19,18 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* CSV Model 4 Storage
|
||||
* Accounting Model 4 Storage
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CSVModel4Storage extends CSVModelBuilder {
|
||||
public class AccountingModel4Storage extends AccountingModelBuilder {
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(CSVModel4Storage.class);
|
||||
.getLogger(AccountingModel4Storage.class);
|
||||
private AccountingStateData accountingStateData;
|
||||
|
||||
public CSVModel4Storage(AccountingStateData accountingStateData) {
|
||||
public AccountingModel4Storage(AccountingStateData accountingStateData) {
|
||||
this.accountingStateData = accountingStateData;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class CSVModel4Storage extends CSVModelBuilder {
|
|||
|
||||
String fileName = "Untitled";
|
||||
ArrayList<String> header;
|
||||
ArrayList<CSVDataRow> rows = new ArrayList<>();
|
||||
ArrayList<AccountingDataRow> rows = new ArrayList<>();
|
||||
if (seriesResponse instanceof SeriesStorage) {
|
||||
SeriesStorage seriesStorage = (SeriesStorage) seriesResponse;
|
||||
SeriesStorageDefinition definition = seriesStorage
|
||||
|
@ -92,7 +92,7 @@ public class CSVModel4Storage extends CSVModelBuilder {
|
|||
data.add(sdfCSVDate.format(seriesData.getDate()));
|
||||
data.add(String.valueOf(seriesData.getOperationCount()));
|
||||
data.add(String.valueOf(seriesData.getDataVolume()));
|
||||
CSVDataRow csvDataRow = new CSVDataRow(data);
|
||||
AccountingDataRow csvDataRow = new AccountingDataRow(data);
|
||||
rows.add(csvDataRow);
|
||||
}
|
||||
} else {
|
||||
|
@ -116,7 +116,7 @@ public class CSVModel4Storage extends CSVModelBuilder {
|
|||
data.add(sdfCSVDate.format(seriesData.getDate()));
|
||||
data.add(String.valueOf(seriesData.getOperationCount()));
|
||||
data.add(String.valueOf(seriesData.getDataVolume()));
|
||||
CSVDataRow csvDataRow = new CSVDataRow(data);
|
||||
AccountingDataRow csvDataRow = new AccountingDataRow(data);
|
||||
rows.add(csvDataRow);
|
||||
}
|
||||
}
|
||||
|
@ -136,8 +136,8 @@ public class CSVModel4Storage extends CSVModelBuilder {
|
|||
+ seriesResponse);
|
||||
}
|
||||
|
||||
CSVModel invocation = new CSVModel(fileName,header, rows);
|
||||
csvModelSpec.setOp(invocation);
|
||||
AccountingDataModel invocation = new AccountingDataModel(fileName,header, rows);
|
||||
accountingModelSpec.setOp(invocation);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,28 +1,28 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.csv.file;
|
||||
package org.gcube.portlets.admin.accountingmanager.server.export.model;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
/**
|
||||
* Abstract class for build CSV Model
|
||||
* Abstract class for build Accounting Model
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public abstract class CSVModelBuilder {
|
||||
protected CSVModelSpec csvModelSpec;
|
||||
public abstract class AccountingModelBuilder {
|
||||
protected AccountingModelSpec accountingModelSpec;
|
||||
|
||||
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(){
|
||||
return csvModelSpec;
|
||||
public AccountingModelSpec getAccountingModelSpec(){
|
||||
return accountingModelSpec;
|
||||
}
|
||||
public void createSpec(){
|
||||
csvModelSpec=new CSVModelSpec();
|
||||
accountingModelSpec=new AccountingModelSpec();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.export.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Accounting Model Director
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class AccountingModelDirector {
|
||||
AccountingModelBuilder accountingModelBuilder;
|
||||
|
||||
public void setAccountingModelBuilder(
|
||||
AccountingModelBuilder accountingModelBuilder) {
|
||||
this.accountingModelBuilder = accountingModelBuilder;
|
||||
}
|
||||
|
||||
public AccountingDataModel getAccountingModel() {
|
||||
return accountingModelBuilder.getAccountingModelSpec().getOp();
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<AccountingDataModel> getListOfAccountingModel() {
|
||||
return accountingModelBuilder.getAccountingModelSpec().getOps();
|
||||
|
||||
}
|
||||
|
||||
public void constructAccountingModel() throws ServiceException {
|
||||
accountingModelBuilder.createSpec();
|
||||
accountingModelBuilder.buildOpEx();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.export.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* CSV Model Specification
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class AccountingModelSpec {
|
||||
private AccountingDataModel op;
|
||||
private ArrayList<AccountingDataModel> ops;
|
||||
|
||||
public AccountingDataModel getOp() {
|
||||
return op;
|
||||
}
|
||||
|
||||
public void setOp(AccountingDataModel op) {
|
||||
this.op = op;
|
||||
}
|
||||
|
||||
public ArrayList<AccountingDataModel> getOps() {
|
||||
return ops;
|
||||
}
|
||||
|
||||
public void setOps(ArrayList<AccountingDataModel> ops) {
|
||||
this.ops = ops;
|
||||
}
|
||||
|
||||
}
|
|
@ -23,8 +23,9 @@ 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 EXPORT_SERVLET="ExportServlet";
|
||||
public static final String EXPORT_SERVLET_TYPE_PARAMETER="ExportServletType";
|
||||
public static final String EXPORT_SERVLET_ACCOUNTING_TYPE_PARAMETER = "AccountingType";
|
||||
|
||||
public static final String SESSION_ACCOUNTING_STATE = "ACCOUNTING_STATE";
|
||||
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
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 + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.shared.export;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ExportDescriptor implements Serializable {
|
||||
private static final long serialVersionUID = 4778932733041422948L;
|
||||
private Path path;
|
||||
private AccountingDataModel csvModel;
|
||||
private String fileExtension;
|
||||
|
||||
public ExportDescriptor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ExportDescriptor(Path path, AccountingDataModel csvModel, String fileExtension) {
|
||||
super();
|
||||
this.path = path;
|
||||
this.csvModel = csvModel;
|
||||
this.fileExtension=fileExtension;
|
||||
|
||||
}
|
||||
|
||||
public Path getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(Path path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public AccountingDataModel getCsvModel() {
|
||||
return csvModel;
|
||||
}
|
||||
|
||||
public void setCsvModel(AccountingDataModel csvModel) {
|
||||
this.csvModel = csvModel;
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
return fileExtension;
|
||||
}
|
||||
|
||||
public void setFileExtension(String fileExtension) {
|
||||
this.fileExtension = fileExtension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExportDescriptor [path=" + path + ", csvModel=" + csvModel
|
||||
+ ", fileExtension=" + fileExtension + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.admin.accountingmanager.shared.export;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum ExportType {
|
||||
CSV,
|
||||
JSON,
|
||||
XML;
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
<!-- Debug CSS style -->
|
||||
<!-- <set-configuration-property name="CssResource.style" value="pretty"
|
||||
/> -->
|
||||
/> -->
|
||||
|
||||
<!--<inherits name="org.moxieapps.gwt.highcharts.Highcharts"/> -->
|
||||
<inherits name='com.github.highcharts4gwt.highcharts' />
|
||||
|
@ -48,19 +48,18 @@
|
|||
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
|
||||
/> <set-property-fallback name="locale" value="en" /> -->
|
||||
|
||||
<!--
|
||||
<set-property name="log_ConsoleLogger" value="ENABLED" />
|
||||
<set-property name="log_DivLogger" value="ENABLED" />
|
||||
<set-property name="log_GWTLogger" value="ENABLED" />
|
||||
<set-property name="log_SystemLogger" value="ENABLED" /> -->
|
||||
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/> -->
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
|
||||
/> -->
|
||||
|
||||
|
||||
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
|
||||
/> -->
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
<servlet-class>org.gcube.portlets.admin.accountingmanager.server.AccountingManagerServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<!-- AccountingManagerService -->
|
||||
<!-- ExportServlet -->
|
||||
<servlet>
|
||||
<servlet-name>DownloadCSVServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.admin.accountingmanager.server.DownloadCSVServlet</servlet-class>
|
||||
<servlet-name>ExportServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.admin.accountingmanager.server.ExportServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<!-- Servlets Mapping -->
|
||||
|
@ -61,10 +61,10 @@
|
|||
<url-pattern>/accountingman/ams</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- AccountingManagerService -->
|
||||
<!-- ExportServlet -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>DownloadCSVServlet</servlet-name>
|
||||
<url-pattern>/accountingman/downloadCSVServlet</url-pattern>
|
||||
<servlet-name>ExportServlet</servlet-name>
|
||||
<url-pattern>/accountingman/ExportServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue