ref 12119:AccountingDashboard - Create a new Accounting Dashboard
https://support.d4science.org/issues/12119 Updated to support Reports git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/accounting-dashboard@169726 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
519782157d
commit
4487da2f9b
|
@ -9,6 +9,8 @@ import org.gcube.portlets.user.accountingdashboard.client.application.dialog.mon
|
|||
import org.gcube.portlets.user.accountingdashboard.client.application.event.HelloEvent;
|
||||
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.shared.data.ReportData;
|
||||
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.session.UserInfo;
|
||||
|
||||
|
@ -91,7 +93,7 @@ public class Controller {
|
|||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
logger.log(Level.FINE, "Error in Hello(): ", caught);
|
||||
logger.log(Level.FINE, "Error in getTree(): ", caught);
|
||||
errorPresenter.errorMessage(caught.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
@ -104,10 +106,26 @@ public class Controller {
|
|||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void getReport(RequestReportData requestReportData) {
|
||||
service.getReport(requestReportData, new AsyncCallback<ReportData>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
logger.log(Level.FINE, "Error in getReport(): ", caught);
|
||||
errorPresenter.errorMessage(caught.getLocalizedMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ReportData reportData) {
|
||||
logger.log(Level.FINE, "ReportData: " + reportData);
|
||||
// ScopeDataEvent event = new ScopeDataEvent(scopeData);
|
||||
// eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package org.gcube.portlets.user.accountingdashboard.client.application.event;
|
||||
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
|
||||
|
||||
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 RequestReportEvent extends GwtEvent<RequestReportEvent.RequestReportEventHandler> {
|
||||
|
||||
private ScopeData scopeData;
|
||||
|
||||
public interface RequestReportEventHandler extends EventHandler {
|
||||
void onData(RequestReportEvent event);
|
||||
}
|
||||
|
||||
public static final Type<RequestReportEventHandler> TYPE = new Type<>();
|
||||
|
||||
public RequestReportEvent(ScopeData scopeData) {
|
||||
this.scopeData = scopeData;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source, RequestReportEvent event) {
|
||||
source.fireEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<RequestReportEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(RequestReportEventHandler handler) {
|
||||
handler.onData(this);
|
||||
}
|
||||
|
||||
public ScopeData getScopeData() {
|
||||
return scopeData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RequestReportEvent [scopeData=" + scopeData + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.util.logging.Logger;
|
|||
|
||||
import org.gcube.portlets.user.accountingdashboard.client.application.controller.Controller;
|
||||
import org.gcube.portlets.user.accountingdashboard.client.application.event.ScopeDataEvent;
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData;
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
@ -67,4 +68,10 @@ public class FilterAreaPresenter extends PresenterWidget<FilterAreaPresenter.Fil
|
|||
controller.getTree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getReport(RequestReportData requestReportData) {
|
||||
controller.getReport(requestReportData);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.filter;
|
||||
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData;
|
||||
|
||||
import com.gwtplatform.mvp.client.UiHandlers;
|
||||
|
||||
/**
|
||||
|
@ -9,5 +11,5 @@ import com.gwtplatform.mvp.client.UiHandlers;
|
|||
*/
|
||||
public interface FilterAreaUiHandlers extends UiHandlers {
|
||||
|
||||
|
||||
public void getReport(RequestReportData requestReportData);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.util.logging.Logger;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.gcube.portlets.user.accountingdashboard.client.application.event.RequestReportEvent;
|
||||
import org.gcube.portlets.user.accountingdashboard.client.application.event.RequestReportEvent.RequestReportEventHandler;
|
||||
import org.gcube.portlets.user.accountingdashboard.client.application.mainarea.filter.scopetree.ScopeTreeModel;
|
||||
import org.gcube.portlets.user.accountingdashboard.client.resources.AppResources;
|
||||
import org.gcube.portlets.user.accountingdashboard.client.resources.ScopeTreeResources;
|
||||
|
@ -20,6 +22,7 @@ import com.google.gwt.i18n.client.LocaleInfo;
|
|||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.cellview.client.CellTree;
|
||||
import com.google.gwt.user.cellview.client.TreeNode;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
|
@ -38,6 +41,8 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
|
|||
interface Binder extends UiBinder<Widget, FilterAreaView> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@UiField
|
||||
HTMLPanel periodPanel;
|
||||
|
||||
|
@ -78,17 +83,15 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
|
|||
yearEnd = new ListBox();
|
||||
yearEnd.setMultipleSelect(false);
|
||||
|
||||
|
||||
Date now=new Date();
|
||||
String currentYear=DateTimeFormat.getFormat(PredefinedFormat.YEAR).format(now);
|
||||
Date now = new Date();
|
||||
String currentYear = DateTimeFormat.getFormat(PredefinedFormat.YEAR).format(now);
|
||||
logger.log(Level.FINE, "Current year: " + currentYear);
|
||||
int year=Integer.parseInt(currentYear);
|
||||
for(int i=2015; i<=year;i++){
|
||||
int year = Integer.parseInt(currentYear);
|
||||
for (int i = 2015; i <= year; i++) {
|
||||
yearStart.addItem(String.valueOf(i));
|
||||
yearEnd.addItem(String.valueOf(i));
|
||||
}
|
||||
|
||||
|
||||
// returns a String array with localized names of the months
|
||||
String[] months = LocaleInfo.getCurrentLocale().getDateTimeFormatInfo().monthsFull();
|
||||
logger.log(Level.FINE, "Months: " + months.length);
|
||||
|
@ -105,22 +108,34 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
|
|||
|
||||
dataProvider = new ListDataProvider<ScopeData>();
|
||||
|
||||
ScopeTreeModel scopeTreeModel=new ScopeTreeModel(dataProvider);
|
||||
RequestReportEventHandler handler=new RequestReportEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onData(RequestReportEvent event) {
|
||||
//TODO
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ScopeTreeModel scopeTreeModel = new ScopeTreeModel(dataProvider,handler);
|
||||
ScopeTreeResources scopeTreeResources = GWT.create(ScopeTreeResources.class);
|
||||
scopeTree=new CellTree(scopeTreeModel, null,scopeTreeResources);
|
||||
scopeTree = new CellTree(scopeTreeModel, null, scopeTreeResources);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayScopeData(ScopeData scopeData) {
|
||||
ArrayList<ScopeData> scopeDataList=new ArrayList<>();
|
||||
ArrayList<ScopeData> scopeDataList = new ArrayList<>();
|
||||
scopeDataList.add(scopeData);
|
||||
dataProvider.setList(scopeDataList);
|
||||
dataProvider.refresh();
|
||||
dataProvider.flush();
|
||||
TreeNode root = scopeTree.getRootTreeNode();
|
||||
root.setChildOpen(root.getIndex(), true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,35 +1,49 @@
|
|||
package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.filter.scopetree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.gcube.portlets.user.accountingdashboard.client.application.event.RequestReportEvent;
|
||||
import org.gcube.portlets.user.accountingdashboard.client.application.event.RequestReportEvent.RequestReportEventHandler;
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
|
||||
|
||||
import com.google.gwt.cell.client.AbstractCell;
|
||||
import com.google.gwt.cell.client.Cell;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
import com.google.gwt.view.client.TreeViewModel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*/
|
||||
public class ScopeTreeModel implements TreeViewModel {
|
||||
|
||||
private static Logger logger = Logger.getLogger("");
|
||||
|
||||
private ListDataProvider<ScopeData> dataProvider;
|
||||
|
||||
/**
|
||||
* This selection model is shared across all leaf nodes. A selection model
|
||||
* can also be shared across all nodes in the tree, or each set of child
|
||||
* nodes can have its own instance. This gives you flexibility to determine
|
||||
* how nodes are selected.
|
||||
*/
|
||||
//private final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>();
|
||||
private final SingleSelectionModel<ScopeData> selectionModel = new SingleSelectionModel<>();
|
||||
|
||||
public ScopeTreeModel(ListDataProvider<ScopeData> dataProvider) {
|
||||
this.dataProvider=dataProvider;
|
||||
public ScopeTreeModel(ListDataProvider<ScopeData> dataProvider, final RequestReportEventHandler handler) {
|
||||
this.dataProvider = dataProvider;
|
||||
|
||||
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
|
||||
|
||||
@Override
|
||||
public void onSelectionChange(SelectionChangeEvent event) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
SingleSelectionModel noSelectionModel = (SingleSelectionModel) event.getSource();
|
||||
ScopeData scopeDataSelected = (ScopeData) noSelectionModel.getSelectedObject();
|
||||
logger.fine("Selected: " + scopeDataSelected);
|
||||
RequestReportEvent requestEvent = new RequestReportEvent(scopeDataSelected);
|
||||
handler.onData(requestEvent);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,8 +66,9 @@ public class ScopeTreeModel implements TreeViewModel {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Return a node info that pairs the data provider and the cell.
|
||||
return new DefaultNodeInfo<ScopeData>(dataProvider, cell);
|
||||
return new DefaultNodeInfo<ScopeData>(dataProvider, cell, selectionModel, null);
|
||||
} else if (value instanceof ScopeData) {
|
||||
// LEVEL 1.
|
||||
// We want the children of the composer. Return the playlists.
|
||||
|
@ -68,19 +83,19 @@ public class ScopeTreeModel implements TreeViewModel {
|
|||
}
|
||||
}
|
||||
};
|
||||
return new DefaultNodeInfo<ScopeData>(dataProvider, cell);
|
||||
return new DefaultNodeInfo<ScopeData>(dataProvider, cell, selectionModel, null);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
else if (value instanceof ScopeData) {
|
||||
|
||||
// LEVEL 2 - LEAF.
|
||||
// We want the children of the playlist. Return the songs.
|
||||
ListDataProvider<String> dataProvider = new ListDataProvider<String>(((ScopeData) value).geSongs());
|
||||
// Use the shared selection model.
|
||||
return new DefaultNodeInfo<String>(dataProvider, new TextCell(), selectionModel, null);
|
||||
}*/
|
||||
* else if (value instanceof ScopeData) {
|
||||
*
|
||||
* // LEVEL 2 - LEAF. // We want the children of the playlist. Return
|
||||
* the songs. ListDataProvider<String> dataProvider = new
|
||||
* ListDataProvider<String>(((ScopeData) value).geSongs()); // Use the
|
||||
* shared selection model. return new
|
||||
* DefaultNodeInfo<String>(dataProvider, new TextCell(), selectionModel,
|
||||
* null); }
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,181 +0,0 @@
|
|||
package org.gcube.portlets.user.accountingdashboard.client.application.providers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.gcube.portlets.user.accountingdashboard.client.application.controller.Controller;
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.data.TreatmentData;
|
||||
|
||||
import com.google.gwt.view.client.AsyncDataProvider;
|
||||
import com.google.gwt.view.client.HasData;
|
||||
import com.google.gwt.view.client.Range;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*/
|
||||
public class TreatmentsProvider extends AsyncDataProvider<TreatmentData> {
|
||||
private static Logger logger = java.util.logging.Logger.getLogger("");
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Controller controller;
|
||||
private int start;
|
||||
private int length;
|
||||
private int columnSortIndex;
|
||||
private boolean ascending = false;
|
||||
private String id;
|
||||
private ArrayList<TreatmentData> list;
|
||||
|
||||
@Inject
|
||||
public TreatmentsProvider(String id, Controller controller) {
|
||||
this.id = id;
|
||||
this.controller = controller;
|
||||
list = new ArrayList<>();
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
private void bindEvents() {
|
||||
/*
|
||||
* EventBus eventBus = controller.getEventBus();
|
||||
* eventBus.addHandler(DatasetsEvent.TYPE, new
|
||||
* DatasetsEvent.DatasetsEventHandler() {
|
||||
*
|
||||
* @Override public void onDatasets(DatasetsEvent event) {
|
||||
* update(event.getList());
|
||||
*
|
||||
* } });
|
||||
*/
|
||||
}
|
||||
|
||||
private void update(ArrayList<TreatmentData> list) {
|
||||
|
||||
logger.log(Level.FINE, "Treatments Data Display is empty: " + getDataDisplays().isEmpty());
|
||||
|
||||
logger.log(Level.FINE, "Show=[Start=" + start + ", Length=" + length + "]");
|
||||
|
||||
int limits = start + length;
|
||||
if (limits > list.size()) {
|
||||
limits = list.size();
|
||||
if (limits < start) {
|
||||
start = limits;
|
||||
}
|
||||
}
|
||||
|
||||
List<TreatmentData> dataInRange = new ArrayList<>();
|
||||
if (list != null && list.size() > 1) {
|
||||
if (columnSortIndex > -1) {
|
||||
logger.log(Level.FINE, "ColumnSortIndex: " + columnSortIndex);
|
||||
logger.log(Level.FINE, "Ascending: " + ascending);
|
||||
Comparator<TreatmentData> comparator;
|
||||
switch (columnSortIndex) {
|
||||
case 0:
|
||||
comparator = new Comparator<TreatmentData>() {
|
||||
public int compare(TreatmentData d1, TreatmentData d2) {
|
||||
if (d1 == d2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int diff = -1;
|
||||
if (d1 != null) {
|
||||
if (d1.getTreatmentType() != null) {
|
||||
diff = ((d2 != null) && (d2.getTreatmentType() != null))
|
||||
? d1.getTreatmentType().compareTo(d2.getTreatmentType()) : 1;
|
||||
}
|
||||
}
|
||||
return ascending ? -diff : diff;
|
||||
}
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
comparator = new Comparator<TreatmentData>() {
|
||||
public int compare(TreatmentData d1, TreatmentData d2) {
|
||||
if (d1 == d2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int diff = -1;
|
||||
if (d1 != null) {
|
||||
if (d1.getNumberOfTreatments() != null) {
|
||||
diff = ((d2 != null) && (d2.getNumberOfTreatments() != null))
|
||||
? d1.getNumberOfTreatments().compareTo(d2.getNumberOfTreatments()) : 1;
|
||||
}
|
||||
}
|
||||
return ascending ? -diff : diff;
|
||||
}
|
||||
};
|
||||
break;
|
||||
default:
|
||||
comparator = new Comparator<TreatmentData>() {
|
||||
public int compare(TreatmentData d1, TreatmentData d2) {
|
||||
if (d1 == d2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int diff = -1;
|
||||
if (d1 != null) {
|
||||
if (d1.getTreatmentType() != null) {
|
||||
diff = ((d2 != null) && (d2.getTreatmentType() != null))
|
||||
? d1.getTreatmentType().compareTo(d2.getTreatmentType()) : 1;
|
||||
}
|
||||
}
|
||||
return ascending ? -diff : diff;
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
Collections.sort(list, comparator);
|
||||
|
||||
}
|
||||
|
||||
dataInRange = list.subList(start, limits);
|
||||
} else {
|
||||
dataInRange = list;
|
||||
}
|
||||
this.updateRowCount(list.size(), true);
|
||||
this.updateRowData(start, dataInRange);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRangeChanged(HasData<TreatmentData> display) {
|
||||
Range range = display.getVisibleRange();
|
||||
start = range.getStart();
|
||||
length = range.getLength();
|
||||
logger.log(Level.FINE, "Treatmentss Provider Range Change: [start=" + start + ", length=" + length + "]");
|
||||
retrieveData();
|
||||
}
|
||||
|
||||
public void onSortChanged(int start, int length, int columnSortIndex, boolean ascending) {
|
||||
logger.log(Level.FINE, "Treatments Provider Sort: [start=" + start + ", length=" + length + "]");
|
||||
this.start = start;
|
||||
this.length = length;
|
||||
this.columnSortIndex = columnSortIndex;
|
||||
this.ascending = ascending;
|
||||
retrieveData();
|
||||
}
|
||||
|
||||
public void onRefreshTreatments() {
|
||||
logger.log(Level.FINE, "Treatments Provider Refresh");
|
||||
retrieveData();
|
||||
}
|
||||
|
||||
private void retrieveData() {
|
||||
logger.log(Level.FINE, "Treatments Provider: " + id);
|
||||
update(list);
|
||||
// controller.getDatasets(productId);
|
||||
|
||||
}
|
||||
|
||||
public void addNewTreatment() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.user.accountingdashboard.client.rpc;
|
||||
|
||||
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.ScopeData;
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException;
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
|
||||
|
@ -26,6 +28,6 @@ public interface AccountingDashboardService extends RemoteService {
|
|||
|
||||
public ScopeData getScopeData() throws ServiceException;
|
||||
|
||||
|
||||
public ReportData getReport(RequestReportData requestReportdata) throws ServiceException;
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.accountingdashboard.client.rpc;
|
||||
|
||||
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.ScopeData;
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
|
||||
|
||||
|
@ -24,6 +26,6 @@ public interface AccountingDashboardServiceAsync {
|
|||
|
||||
void getScopeData(AsyncCallback<ScopeData> callback);
|
||||
|
||||
|
||||
void getReport(RequestReportData requestReportdata, AsyncCallback<ReportData> asyncCallback);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ 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.AccountingServiceType;
|
||||
import org.gcube.portlets.user.accountingdashboard.server.util.ServiceCredentials;
|
||||
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.ScopeData;
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException;
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
|
||||
|
@ -80,4 +82,23 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportData getReport(RequestReportData requestReportData) throws ServiceException {
|
||||
try {
|
||||
logger.debug("AccountingDashboardServiceImpl getReport(): "+requestReportData);
|
||||
@SuppressWarnings("unused")
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
AccountingService as = new AccountingService(AccountingServiceType.PortalContex);
|
||||
ReportData reportData = as.getReport(requestReportData);
|
||||
|
||||
return reportData;
|
||||
} catch (ServiceException e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("GetReportData(): " + e.getLocalizedMessage(), e);
|
||||
throw new ServiceException("Error retrieving report: "+e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,17 @@
|
|||
package org.gcube.portlets.user.accountingdashboard.server.accounting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.data.access.accounting.summary.access.AccountingDao;
|
||||
import org.gcube.data.access.accounting.summary.access.model.MeasureResolution;
|
||||
import org.gcube.data.access.accounting.summary.access.model.Report;
|
||||
import org.gcube.data.access.accounting.summary.access.model.ScopeDescriptor;
|
||||
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.ScopeData;
|
||||
import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -81,4 +87,41 @@ public class AccountingService {
|
|||
|
||||
}
|
||||
|
||||
public ReportData getReport(RequestReportData requestReportData) throws ServiceException {
|
||||
try {
|
||||
logger.debug("AccountingService GetReport()");
|
||||
|
||||
ScopeDescriptor scopeDescriptor=searchScopeDescriptor(requestReportData.getScopeData());
|
||||
|
||||
int yearFrom=Integer.parseInt(requestReportData.getYearFrom());
|
||||
int monthFrom=Integer.parseInt(requestReportData.getMonthFrom());
|
||||
|
||||
int yearTo=Integer.parseInt(requestReportData.getYearTo());
|
||||
int monthTo=Integer.parseInt(requestReportData.getMonthTo());
|
||||
|
||||
|
||||
|
||||
Date from=new GregorianCalendar(yearFrom, monthFrom, 1).getTime();
|
||||
Date to=new GregorianCalendar(yearTo, monthTo, 1).getTime();
|
||||
|
||||
|
||||
Report report = dao.getReportByScope(scopeDescriptor, from, to,MeasureResolution.MONTHLY);
|
||||
|
||||
logger.debug("Report: " + report);
|
||||
ReportData reportData=new ReportData();
|
||||
|
||||
return reportData;
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error retrieving Tree: " + e.getLocalizedMessage(), e);
|
||||
throw new ServiceException("Error retrieving Tree: " + e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private ScopeDescriptor searchScopeDescriptor(ScopeData scopeData){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.gcube.portlets.user.accountingdashboard.shared.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*/
|
||||
public class ReportData implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2420024317463146907L;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package org.gcube.portlets.user.accountingdashboard.shared.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*/
|
||||
public class RequestReportData implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7428707426843173730L;
|
||||
private ScopeData scopeData;
|
||||
private String yearFrom;
|
||||
private String monthFrom;
|
||||
private String yearTo;
|
||||
private String monthTo;
|
||||
|
||||
public RequestReportData() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RequestReportData(ScopeData scopeData, String yearFrom, String monthFrom, String yearTo, String monthTo) {
|
||||
super();
|
||||
this.scopeData = scopeData;
|
||||
this.yearFrom = yearFrom;
|
||||
this.monthFrom = monthFrom;
|
||||
this.yearTo = yearTo;
|
||||
this.monthTo = monthTo;
|
||||
}
|
||||
|
||||
public ScopeData getScopeData() {
|
||||
return scopeData;
|
||||
}
|
||||
|
||||
public void setScopeData(ScopeData scopeData) {
|
||||
this.scopeData = scopeData;
|
||||
}
|
||||
|
||||
public String getYearFrom() {
|
||||
return yearFrom;
|
||||
}
|
||||
|
||||
public void setYearFrom(String yearFrom) {
|
||||
this.yearFrom = yearFrom;
|
||||
}
|
||||
|
||||
public String getMonthFrom() {
|
||||
return monthFrom;
|
||||
}
|
||||
|
||||
public void setMonthFrom(String monthFrom) {
|
||||
this.monthFrom = monthFrom;
|
||||
}
|
||||
|
||||
public String getYearTo() {
|
||||
return yearTo;
|
||||
}
|
||||
|
||||
public void setYearTo(String yearTo) {
|
||||
this.yearTo = yearTo;
|
||||
}
|
||||
|
||||
public String getMonthTo() {
|
||||
return monthTo;
|
||||
}
|
||||
|
||||
public void setMonthTo(String monthTo) {
|
||||
this.monthTo = monthTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RequestReport [scopeData=" + scopeData + ", yearFrom=" + yearFrom + ", monthFrom=" + monthFrom
|
||||
+ ", yearTo=" + yearTo + ", monthTo=" + monthTo + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package org.gcube.portlets.user.accountingdashboard.shared.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TreatmentData implements Serializable, Comparator<TreatmentData>, Comparable<TreatmentData> {
|
||||
|
||||
private static final long serialVersionUID = -8445665293115680236L;
|
||||
private int id;
|
||||
private String treatmentType;
|
||||
private Integer numberOfTreatments;
|
||||
|
||||
public TreatmentData() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TreatmentData(int id, String treatmentType, Integer numberOfTreatments) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.treatmentType = treatmentType;
|
||||
this.numberOfTreatments = numberOfTreatments;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTreatmentType() {
|
||||
return treatmentType;
|
||||
}
|
||||
|
||||
public void setTreatmentType(String treatmentType) {
|
||||
this.treatmentType = treatmentType;
|
||||
}
|
||||
|
||||
public Integer getNumberOfTreatments() {
|
||||
return numberOfTreatments;
|
||||
}
|
||||
|
||||
public void setNumberOfTreatments(Integer numberOfTreatments) {
|
||||
this.numberOfTreatments = numberOfTreatments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(TreatmentData o1, TreatmentData o2) {
|
||||
if (o1 == null) {
|
||||
return -1;
|
||||
} else {
|
||||
if (o2 == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return (o1.getId() < o2.getId()) ? -1 : ((o1.getId() == o2.getId()) ? 0 : 1);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TreatmentData o) {
|
||||
return compare(this, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TreatmentData [id=" + id + ", treatmentType=" + treatmentType + ", numberOfTreatments="
|
||||
+ numberOfTreatments + "]";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue