ref 12119:AccountingDashboard - Create a new Accounting Dashboard
https://support.d4science.org/issues/12119 Updated Report support git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/accounting-dashboard@169752 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5c3fef96d0
commit
ad8a2ca399
|
@ -7,6 +7,7 @@ import org.gcube.portlets.user.accountingdashboard.client.application.dialog.err
|
||||||
import org.gcube.portlets.user.accountingdashboard.client.application.dialog.info.InfoPresenter;
|
import org.gcube.portlets.user.accountingdashboard.client.application.dialog.info.InfoPresenter;
|
||||||
import org.gcube.portlets.user.accountingdashboard.client.application.dialog.monitor.MonitorPresenter;
|
import org.gcube.portlets.user.accountingdashboard.client.application.dialog.monitor.MonitorPresenter;
|
||||||
import org.gcube.portlets.user.accountingdashboard.client.application.event.HelloEvent;
|
import org.gcube.portlets.user.accountingdashboard.client.application.event.HelloEvent;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.client.application.event.ReportEvent;
|
||||||
import org.gcube.portlets.user.accountingdashboard.client.application.event.ScopeDataEvent;
|
import org.gcube.portlets.user.accountingdashboard.client.application.event.ScopeDataEvent;
|
||||||
import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardServiceAsync;
|
import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardServiceAsync;
|
||||||
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData;
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData;
|
||||||
|
@ -123,8 +124,8 @@ public class Controller {
|
||||||
public void onSuccess(ReportData reportData) {
|
public void onSuccess(ReportData reportData) {
|
||||||
logger.log(Level.FINE, "ReportData: " + reportData);
|
logger.log(Level.FINE, "ReportData: " + reportData);
|
||||||
monitorPresenter.enable(false);
|
monitorPresenter.enable(false);
|
||||||
// ScopeDataEvent event = new ScopeDataEvent(scopeData);
|
ReportEvent event = new ReportEvent(reportData);
|
||||||
// eventBus.fireEvent(event);
|
eventBus.fireEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package org.gcube.portlets.user.accountingdashboard.client.application.event;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
import com.google.gwt.event.shared.HasHandlers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ReportEvent extends GwtEvent<ReportEvent.ReportEventHandler> {
|
||||||
|
|
||||||
|
private ReportData reportData;
|
||||||
|
|
||||||
|
public interface ReportEventHandler extends EventHandler {
|
||||||
|
void onData(ReportEvent event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Type<ReportEventHandler> TYPE = new Type<>();
|
||||||
|
|
||||||
|
public ReportEvent(ReportData reportData) {
|
||||||
|
this.reportData = reportData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fire(HasHandlers source, ReportEvent event) {
|
||||||
|
source.fireEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type<ReportEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatch(ReportEventHandler handler) {
|
||||||
|
handler.onData(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReportData getReportData() {
|
||||||
|
return reportData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ReportEvent [reportData=" + reportData + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -152,8 +152,9 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
|
||||||
Date dateStart = null;
|
Date dateStart = null;
|
||||||
try {
|
try {
|
||||||
String dStart=yearS + "-" + monthS + "-01";
|
String dStart=yearS + "-" + monthS + "-01";
|
||||||
logger.fine("DateStart: "+dStart);
|
logger.fine("DateTemp1: "+dStart);
|
||||||
dateStart = dateTimeFormat.parse(dStart);
|
dateStart = dateTimeFormat.parse(dStart);
|
||||||
|
logger.fine("DateStart: "+dStart);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.SEVERE,"Error in start date: "+e.getLocalizedMessage(),e);
|
logger.log(Level.SEVERE,"Error in start date: "+e.getLocalizedMessage(),e);
|
||||||
|
|
||||||
|
@ -165,11 +166,11 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
|
||||||
Date dateEnd = null;
|
Date dateEnd = null;
|
||||||
try {
|
try {
|
||||||
String dEnd=yearE + "-" + monthE + "-01";
|
String dEnd=yearE + "-" + monthE + "-01";
|
||||||
logger.fine("DateTemp: "+dEnd);
|
logger.fine("DateTemp2: "+dEnd);
|
||||||
dateEnd = dateTimeFormat.parse(dEnd);
|
dateEnd = dateTimeFormat.parse(dEnd);
|
||||||
CalendarUtil.addMonthsToDate(dateEnd, 1);
|
CalendarUtil.addMonthsToDate(dateEnd, 1);
|
||||||
CalendarUtil.addDaysToDate(dateEnd, -1);
|
CalendarUtil.addDaysToDate(dateEnd, -1);
|
||||||
logger.fine("DateEnd: "+dEnd);
|
logger.fine("DateEnd: "+dateEnd);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.SEVERE,"Error in end date: "+e.getLocalizedMessage(),e);
|
logger.log(Level.SEVERE,"Error in end date: "+e.getLocalizedMessage(),e);
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report;
|
package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.gcube.portlets.user.accountingdashboard.client.application.controller.Controller;
|
import org.gcube.portlets.user.accountingdashboard.client.application.controller.Controller;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.client.application.event.ReportEvent;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.client.application.event.ScopeDataEvent;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
@ -16,11 +20,12 @@ import com.gwtplatform.mvp.client.View;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ReportAreaPresenter extends PresenterWidget<ReportAreaPresenter.ReportAreaView>
|
public class ReportAreaPresenter extends PresenterWidget<ReportAreaPresenter.ReportAreaView>
|
||||||
implements ReaportAreaUiHandlers {
|
implements ReportAreaUiHandlers {
|
||||||
|
|
||||||
private static Logger logger = Logger.getLogger("");
|
private static Logger logger = Logger.getLogger("");
|
||||||
|
|
||||||
interface ReportAreaView extends View, HasUiHandlers<ReportAreaPresenter> {
|
interface ReportAreaView extends View, HasUiHandlers<ReportAreaPresenter> {
|
||||||
|
void displayReportData(ReportData reportData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +48,22 @@ public class ReportAreaPresenter extends PresenterWidget<ReportAreaPresenter.Rep
|
||||||
|
|
||||||
private void bindToEvent() {
|
private void bindToEvent() {
|
||||||
|
|
||||||
|
controller.getEventBus().addHandler(ReportEvent.TYPE, new ReportEvent.ReportEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onData(ReportEvent event) {
|
||||||
|
logger.log(Level.FINE, "ReportEvent received");
|
||||||
|
getView().displayReportData(event.getReportData());
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBind() {
|
protected void onBind() {
|
||||||
super.onBind();
|
super.onBind();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import com.gwtplatform.mvp.client.UiHandlers;
|
||||||
* @author Giancarlo Panichi
|
* @author Giancarlo Panichi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface ReaportAreaUiHandlers extends UiHandlers {
|
public interface ReportAreaUiHandlers extends UiHandlers {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,12 +1,18 @@
|
||||||
package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report;
|
package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report.chartjs.Chart;
|
||||||
import org.gcube.portlets.user.accountingdashboard.client.resources.AppResources;
|
import org.gcube.portlets.user.accountingdashboard.client.resources.AppResources;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportElementData;
|
||||||
|
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.gwtplatform.mvp.client.ViewWithUiHandlers;
|
import com.gwtplatform.mvp.client.ViewWithUiHandlers;
|
||||||
|
|
||||||
|
@ -15,18 +21,16 @@ import com.gwtplatform.mvp.client.ViewWithUiHandlers;
|
||||||
* @author Giancarlo Panichi
|
* @author Giancarlo Panichi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ReportAreaView extends ViewWithUiHandlers<ReportAreaPresenter> implements ReportAreaPresenter.ReportAreaView {
|
public class ReportAreaView extends ViewWithUiHandlers<ReportAreaPresenter>
|
||||||
|
implements ReportAreaPresenter.ReportAreaView {
|
||||||
|
|
||||||
private static Logger logger = java.util.logging.Logger.getLogger("");
|
private static Logger logger = java.util.logging.Logger.getLogger("");
|
||||||
|
|
||||||
interface Binder extends UiBinder<Widget, ReportAreaView> {
|
interface Binder extends UiBinder<Widget, ReportAreaView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@UiField
|
@UiField
|
||||||
HTMLPanel periodPanel;
|
HTMLPanel reportPanel;
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private AppResources resources;
|
private AppResources resources;
|
||||||
|
|
||||||
|
@ -35,11 +39,54 @@ public class ReportAreaView extends ViewWithUiHandlers<ReportAreaPresenter> impl
|
||||||
this.resources = resources;
|
this.resources = resources;
|
||||||
init();
|
init();
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
ReportData rData=new ReportData();
|
||||||
|
ArrayList<ReportElementData> elements=new ArrayList<>();
|
||||||
|
ReportElementData reportElementData=new ReportElementData();
|
||||||
|
reportElementData.setxAxis("XAxis");
|
||||||
|
reportElementData.setyAxis("YAxis");
|
||||||
|
reportElementData.setCategory("Category");
|
||||||
|
reportElementData.setLabel("Label");
|
||||||
|
elements.add(reportElementData);
|
||||||
|
rData.setElements(elements);
|
||||||
|
|
||||||
|
displayReportData(rData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LABEL
|
||||||
|
* |
|
||||||
|
* | _
|
||||||
|
* yaxis | _ | |
|
||||||
|
* | | || |_
|
||||||
|
* | | || | |
|
||||||
|
* ---------------------------------------------------
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* *Series_label1 *Series_label2 *Series_label3
|
||||||
|
*
|
||||||
|
* xAxis
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayReportData(ReportData reportData) {
|
||||||
|
if (reportData == null) {
|
||||||
|
reportPanel.clear();
|
||||||
|
} else {
|
||||||
|
reportPanel.clear();
|
||||||
|
for (int i = 0; i < reportData.getElements().size(); i++) {
|
||||||
|
Chart chart = new Chart("report_" + i, reportData.getElements().get(i));
|
||||||
|
reportPanel.add(chart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<g:HTMLPanel>
|
<g:HTMLPanel ui:field="reportPanel"/>
|
||||||
<g:Label>Report Area</g:Label>
|
|
||||||
</g:HTMLPanel>
|
|
||||||
</ui:UiBinder>
|
</ui:UiBinder>
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report.chartjs;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportElementData;
|
||||||
|
|
||||||
|
import com.google.gwt.event.logical.shared.AttachEvent;
|
||||||
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Chart extends HTMLPanel {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private ReportElementData reportElementData;
|
||||||
|
|
||||||
|
public Chart(String name, ReportElementData reportElementData) {
|
||||||
|
super("<canvas id=" + name + "></canvas>");
|
||||||
|
this.name = name;
|
||||||
|
this.reportElementData = reportElementData;
|
||||||
|
|
||||||
|
addAttachHandler(new AttachEvent.Handler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachOrDetach(AttachEvent event) {
|
||||||
|
if (event.isAttached()) {
|
||||||
|
drawChart();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLabel() {
|
||||||
|
return reportElementData.getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCatgegory() {
|
||||||
|
return reportElementData.getCategory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getXAxisLabel() {
|
||||||
|
return reportElementData.getxAxis();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYAxisLabel() {
|
||||||
|
return reportElementData.getyAxis();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LABEL | | _ yaxis | _ | | | | || |_ | | || | |
|
||||||
|
* ---------------------------------------------------
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* *Series_label1 *Series_label2 *Series_label3
|
||||||
|
*
|
||||||
|
* xAxis
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Series[] { Series : LABEL, dataRow [] Series : LABEL, dataRow [] Series :
|
||||||
|
* LABEL, dataRow [] Series : LABEL, dataRow [] }
|
||||||
|
*/
|
||||||
|
|
||||||
|
private native void drawChart() /*-{
|
||||||
|
|
||||||
|
var name = this.@org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report.chartjs.Chart::name;
|
||||||
|
console.log('Element name: ' + name);
|
||||||
|
var element = this;
|
||||||
|
console.log('Element found: ' + element);
|
||||||
|
var canvas = $doc.getElementById(name);
|
||||||
|
console.log('Canvas: ' + canvas);
|
||||||
|
|
||||||
|
var color = Chart.helpers.color;
|
||||||
|
console.log('Color: ' + color);
|
||||||
|
var barChartData = {
|
||||||
|
labels : [ 'January', 'February', 'March', 'April', 'May', 'June',
|
||||||
|
'July' ],
|
||||||
|
datasets : [ {
|
||||||
|
label : 'Dataset 1',
|
||||||
|
backgroundColor : 'rgba(255,0,0,0.9)',
|
||||||
|
borderColor : 'rgba(255,0,0,1)',
|
||||||
|
borderWidth : 1,
|
||||||
|
data : [ 1, 2, 3, 1, 2, 3, 4 ]
|
||||||
|
}, {
|
||||||
|
label : 'Dataset 2',
|
||||||
|
backgroundColor : 'rgba(0,0,255,0.9)',
|
||||||
|
borderColor : 'rgba(0,0,255,1)',
|
||||||
|
borderWidth : 1,
|
||||||
|
data : [ 3, 4, 1, 2, 1, 2, 1 ]
|
||||||
|
} ]
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var label = this
|
||||||
|
.@org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report.chartjs.Chart::getLabel()();
|
||||||
|
|
||||||
|
var xAxisLabel = this
|
||||||
|
.@org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report.chartjs.Chart::getXAxisLabel()();
|
||||||
|
|
||||||
|
var yAxisLabel = this
|
||||||
|
.@org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report.chartjs.Chart::getYAxisLabel()();
|
||||||
|
|
||||||
|
var ctx = canvas.getContext('2d');
|
||||||
|
var chart = new Chart(ctx, {
|
||||||
|
// The type of chart we want to create
|
||||||
|
type : 'bar',
|
||||||
|
data : barChartData,
|
||||||
|
options : {
|
||||||
|
responsive : true,
|
||||||
|
legend : {
|
||||||
|
position : 'top',
|
||||||
|
},
|
||||||
|
title : {
|
||||||
|
display : true,
|
||||||
|
text : label
|
||||||
|
},
|
||||||
|
scales : {
|
||||||
|
xAxes : [ {
|
||||||
|
scaleLabel : {
|
||||||
|
display : true,
|
||||||
|
labelString : xAxisLabel
|
||||||
|
}
|
||||||
|
} ],
|
||||||
|
|
||||||
|
yAxes : [ {
|
||||||
|
scaleLabel : {
|
||||||
|
display : true,
|
||||||
|
labelString : yAxisLabel
|
||||||
|
},
|
||||||
|
ticks : {
|
||||||
|
beginAtZero : true
|
||||||
|
}
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}-*/;
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.accountingdashboard.client.resources;
|
||||||
|
|
||||||
import com.google.gwt.resources.client.ClientBundle;
|
import com.google.gwt.resources.client.ClientBundle;
|
||||||
import com.google.gwt.resources.client.CssResource;
|
import com.google.gwt.resources.client.CssResource;
|
||||||
|
import com.google.gwt.resources.client.TextResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -66,4 +67,7 @@ public interface AppResources extends ClientBundle {
|
||||||
@Source("uiData.css")
|
@Source("uiData.css")
|
||||||
uiDataCss uiDataCss();
|
uiDataCss uiDataCss();
|
||||||
|
|
||||||
|
@Source("Chart.bundle.js")
|
||||||
|
TextResource chartJS();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
10
src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/Chart.bundle.min.js
vendored
Normal file
10
src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/Chart.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.portlets.user.accountingdashboard.client.resources;
|
package org.gcube.portlets.user.accountingdashboard.client.resources;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.ScriptInjector;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +14,8 @@ public class ResourceLoader {
|
||||||
@Inject
|
@Inject
|
||||||
ResourceLoader(AppResources appResources) {
|
ResourceLoader(AppResources appResources) {
|
||||||
appResources.uiDataCss().ensureInjected();
|
appResources.uiDataCss().ensureInjected();
|
||||||
|
ScriptInjector.fromString(appResources.chartJS().getText())
|
||||||
|
.inject();
|
||||||
//scopeTreeResources.cellTreeStyle().ensureInjected();
|
//scopeTreeResources.cellTreeStyle().ensureInjected();
|
||||||
|
|
||||||
/*appResources.bootstrapCss().ensureInjected();
|
/*appResources.bootstrapCss().ensureInjected();
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboar
|
||||||
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService;
|
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService;
|
||||||
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingServiceType;
|
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingServiceType;
|
||||||
import org.gcube.portlets.user.accountingdashboard.server.util.ServiceCredentials;
|
import org.gcube.portlets.user.accountingdashboard.server.util.ServiceCredentials;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.shared.Constants;
|
||||||
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData;
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData;
|
||||||
import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData;
|
import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData;
|
||||||
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
|
||||||
|
@ -68,16 +69,21 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme
|
||||||
logger.debug("AccountingDashboardServiceImpl getScopeData()");
|
logger.debug("AccountingDashboardServiceImpl getScopeData()");
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||||
AccountingService as = new AccountingService(AccountingServiceType.PortalContex);
|
AccountingService as = null;
|
||||||
ScopeData scopeData = as.getTree(this.getThreadLocalRequest());
|
if (Constants.DEBUG_MODE) {
|
||||||
|
as = new AccountingService(AccountingServiceType.CurrentScope);
|
||||||
|
} else {
|
||||||
|
as = new AccountingService(AccountingServiceType.PortalContex);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopeData scopeData = as.getTree(this.getThreadLocalRequest());
|
||||||
return scopeData;
|
return scopeData;
|
||||||
} catch (ServiceException e) {
|
} catch (ServiceException e) {
|
||||||
logger.error(e.getLocalizedMessage(), e);
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("GetScopeData(): " + e.getLocalizedMessage(), e);
|
logger.error("GetScopeData(): " + e.getLocalizedMessage(), e);
|
||||||
throw new ServiceException("Error retrieving scope info: "+e.getLocalizedMessage(), e);
|
throw new ServiceException("Error retrieving scope info: " + e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -85,19 +91,23 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme
|
||||||
@Override
|
@Override
|
||||||
public ReportData getReport(RequestReportData requestReportData) throws ServiceException {
|
public ReportData getReport(RequestReportData requestReportData) throws ServiceException {
|
||||||
try {
|
try {
|
||||||
logger.debug("AccountingDashboardServiceImpl getReport(): "+requestReportData);
|
logger.debug("AccountingDashboardServiceImpl getReport(): " + requestReportData);
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||||
AccountingService as = new AccountingService(AccountingServiceType.PortalContex);
|
AccountingService as = null;
|
||||||
ReportData reportData = as.getReport(this.getThreadLocalRequest(),requestReportData);
|
if (Constants.DEBUG_MODE) {
|
||||||
|
as = new AccountingService(AccountingServiceType.CurrentScope);
|
||||||
|
} else {
|
||||||
|
as = new AccountingService(AccountingServiceType.PortalContex);
|
||||||
|
}
|
||||||
|
ReportData reportData = as.getReport(this.getThreadLocalRequest(), requestReportData);
|
||||||
return reportData;
|
return reportData;
|
||||||
} catch (ServiceException e) {
|
} catch (ServiceException e) {
|
||||||
logger.error(e.getLocalizedMessage(), e);
|
logger.error(e.getLocalizedMessage(), e);
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("GetReportData(): " + e.getLocalizedMessage(), e);
|
logger.error("GetReportData(): " + e.getLocalizedMessage(), e);
|
||||||
throw new ServiceException("Error retrieving report: "+e.getLocalizedMessage(), e);
|
throw new ServiceException("Error retrieving report: " + e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,8 @@ public class AccountingService {
|
||||||
Report report = dao.getReportByScope(scopeDescriptor, dateFrom, dateTo, MeasureResolution.MONTHLY);
|
Report report = dao.getReportByScope(scopeDescriptor, dateFrom, dateTo, MeasureResolution.MONTHLY);
|
||||||
|
|
||||||
logger.debug("Report: " + report);
|
logger.debug("Report: " + report);
|
||||||
ReportData reportData = new ReportData();
|
ReportDataBuilder reportDataBuilder = new ReportDataBuilder(report);
|
||||||
|
ReportData reportData = reportDataBuilder.build();
|
||||||
return reportData;
|
return reportData;
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceException("Invalid report request, " + requestReportData);
|
throw new ServiceException("Invalid report request, " + requestReportData);
|
||||||
|
@ -140,13 +141,13 @@ public class AccountingService {
|
||||||
throws ServiceException {
|
throws ServiceException {
|
||||||
try {
|
try {
|
||||||
logger.debug("ScopeDescriptor: " + scopeDescriptor);
|
logger.debug("ScopeDescriptor: " + scopeDescriptor);
|
||||||
for(ScopeDescriptor child:scopeDescriptor.getChildren()){
|
for (ScopeDescriptor child : scopeDescriptor.getChildren()) {
|
||||||
if(child.getId().compareTo(scopeData.getId())==0){
|
if (child.getId().compareTo(scopeData.getId()) == 0) {
|
||||||
return child;
|
return child;
|
||||||
} else {
|
} else {
|
||||||
if(child.hasChildren()){
|
if (child.hasChildren()) {
|
||||||
ScopeDescriptor found=searchScopeDescriptorInChildren(child, scopeData);
|
ScopeDescriptor found = searchScopeDescriptorInChildren(child, scopeData);
|
||||||
if(found!=null){
|
if (found != null) {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
package org.gcube.portlets.user.accountingdashboard.server.accounting;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.accounting.accounting.summary.access.model.Record;
|
||||||
|
import org.gcube.accounting.accounting.summary.access.model.Report;
|
||||||
|
import org.gcube.accounting.accounting.summary.access.model.ReportElement;
|
||||||
|
import org.gcube.accounting.accounting.summary.access.model.Series;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.shared.data.RecordData;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportElementData;
|
||||||
|
import org.gcube.portlets.user.accountingdashboard.shared.data.SeriesData;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ReportDataBuilder {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(ReportDataBuilder.class);
|
||||||
|
|
||||||
|
private Report report;
|
||||||
|
|
||||||
|
public ReportDataBuilder(Report report) {
|
||||||
|
this.report = report;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReportData build() {
|
||||||
|
if (report == null || report.getElements() == null) {
|
||||||
|
logger.error("Invalid report: " + report);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<ReportElementData> elements = new ArrayList<>();
|
||||||
|
for (ReportElement reportElement : report.getElements()) {
|
||||||
|
if (reportElement.getSerieses() == null) {
|
||||||
|
ReportElementData reportElementData = new ReportElementData(reportElement.getLabel(),
|
||||||
|
reportElement.getCategory(), reportElement.getXAxis(), reportElement.getYAxis(), null);
|
||||||
|
elements.add(reportElementData);
|
||||||
|
} else {
|
||||||
|
ArrayList<SeriesData> serieses = new ArrayList<>();
|
||||||
|
for (Series series : reportElement.getSerieses()) {
|
||||||
|
SeriesData seriesData = null;
|
||||||
|
if (series.getDataRow() == null) {
|
||||||
|
seriesData = new SeriesData(series.getLabel(), null);
|
||||||
|
} else {
|
||||||
|
ArrayList<RecordData> dataRow = new ArrayList<>();
|
||||||
|
for (Record record : series.getDataRow()) {
|
||||||
|
RecordData recordData = new RecordData(record.getX(), record.getY());
|
||||||
|
dataRow.add(recordData);
|
||||||
|
}
|
||||||
|
seriesData = new SeriesData(series.getLabel(), dataRow);
|
||||||
|
}
|
||||||
|
serieses.add(seriesData);
|
||||||
|
}
|
||||||
|
ReportElementData reportElementData = new ReportElementData(reportElement.getLabel(),
|
||||||
|
reportElement.getCategory(), reportElement.getXAxis(), reportElement.getYAxis(), serieses);
|
||||||
|
elements.add(reportElementData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ReportData reportData = new ReportData(elements);
|
||||||
|
logger.debug("ReportData: " + reportData);
|
||||||
|
return reportData;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ package org.gcube.portlets.user.accountingdashboard.shared;
|
||||||
*/
|
*/
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
public static final boolean DEBUG_MODE = false;
|
public static final boolean DEBUG_MODE = true;
|
||||||
public static final boolean TEST_ENABLE = false;
|
public static final boolean TEST_ENABLE = false;
|
||||||
|
|
||||||
public static final String APPLICATION_ID = "org.gcube.portlets.user.accountingdashboard.server.portlet.AccountingDashboardPortlet";
|
public static final String APPLICATION_ID = "org.gcube.portlets.user.accountingdashboard.server.portlet.AccountingDashboardPortlet";
|
||||||
|
@ -18,7 +18,7 @@ public class Constants {
|
||||||
|
|
||||||
public static final String DEFAULT_USER = "giancarlo.panichi";
|
public static final String DEFAULT_USER = "giancarlo.panichi";
|
||||||
public static final String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
|
public static final String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
|
||||||
public static final String DEFAULT_TOKEN = "";
|
public static final String DEFAULT_TOKEN = "ae1208f0-210d-47c9-9b24-d3f2dfcce05f-98187548";
|
||||||
public static final String DEFAULT_ROLE = "OrganizationMember";
|
public static final String DEFAULT_ROLE = "OrganizationMember";
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.portlets.user.accountingdashboard.shared.data;
|
package org.gcube.portlets.user.accountingdashboard.shared.data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -16,13 +16,14 @@ public class ReportElementData implements Serializable {
|
||||||
private String xAxis;
|
private String xAxis;
|
||||||
private String yAxis;
|
private String yAxis;
|
||||||
|
|
||||||
private SeriesData[] serieses;
|
private ArrayList<SeriesData> serieses;
|
||||||
|
|
||||||
public ReportElementData() {
|
public ReportElementData() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReportElementData(String label, String category, String xAxis, String yAxis, SeriesData[] serieses) {
|
public ReportElementData(String label, String category, String xAxis, String yAxis,
|
||||||
|
ArrayList<SeriesData> serieses) {
|
||||||
super();
|
super();
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
|
@ -63,18 +64,18 @@ public class ReportElementData implements Serializable {
|
||||||
this.yAxis = yAxis;
|
this.yAxis = yAxis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SeriesData[] getSerieses() {
|
public ArrayList<SeriesData> getSerieses() {
|
||||||
return serieses;
|
return serieses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSerieses(SeriesData[] serieses) {
|
public void setSerieses(ArrayList<SeriesData> serieses) {
|
||||||
this.serieses = serieses;
|
this.serieses = serieses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ReportElementData [label=" + label + ", category=" + category + ", xAxis=" + xAxis + ", yAxis=" + yAxis
|
return "ReportElementData [label=" + label + ", category=" + category + ", xAxis=" + xAxis + ", yAxis=" + yAxis
|
||||||
+ ", serieses=" + Arrays.toString(serieses) + "]";
|
+ ", serieses=" + serieses + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.portlets.user.accountingdashboard.shared.data;
|
package org.gcube.portlets.user.accountingdashboard.shared.data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -12,13 +12,13 @@ public class SeriesData implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3308676516412447011L;
|
private static final long serialVersionUID = 3308676516412447011L;
|
||||||
private String label;
|
private String label;
|
||||||
private RecordData[] dataRow;
|
private ArrayList<RecordData> dataRow;
|
||||||
|
|
||||||
public SeriesData() {
|
public SeriesData() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SeriesData(String label, RecordData[] dataRow) {
|
public SeriesData(String label, ArrayList<RecordData> dataRow) {
|
||||||
super();
|
super();
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.dataRow = dataRow;
|
this.dataRow = dataRow;
|
||||||
|
@ -32,17 +32,17 @@ public class SeriesData implements Serializable {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordData[] getDataRow() {
|
public ArrayList<RecordData> getDataRow() {
|
||||||
return dataRow;
|
return dataRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataRow(RecordData[] dataRow) {
|
public void setDataRow(ArrayList<RecordData> dataRow) {
|
||||||
this.dataRow = dataRow;
|
this.dataRow = dataRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SeriesData [label=" + label + ", dataRow=" + Arrays.toString(dataRow) + "]";
|
return "SeriesData [label=" + label + ", dataRow=" + dataRow + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue