diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java index a41632d..b8444d4 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java @@ -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() { + + @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); + } + + }); + + } + } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/event/RequestReportEvent.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/event/RequestReportEvent.java new file mode 100644 index 0000000..6ca3e4d --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/event/RequestReportEvent.java @@ -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 { + + private ScopeData scopeData; + + public interface RequestReportEventHandler extends EventHandler { + void onData(RequestReportEvent event); + } + + public static final Type TYPE = new Type<>(); + + public RequestReportEvent(ScopeData scopeData) { + this.scopeData = scopeData; + } + + public static void fire(HasHandlers source, RequestReportEvent event) { + source.fireEvent(event); + } + + @Override + public Type 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 + "]"; + } + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java index c218968..44790de 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java @@ -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 interface Binder extends UiBinder { } + + @UiField HTMLPanel periodPanel; @@ -77,18 +82,16 @@ public class FilterAreaView extends ViewWithUiHandlers 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); @@ -102,25 +105,37 @@ public class FilterAreaView extends ViewWithUiHandlers monthStart.addItem(months[i]); monthEnd.addItem(months[i]); } - + dataProvider = new ListDataProvider(); + + RequestReportEventHandler handler=new RequestReportEventHandler() { + + @Override + public void onData(RequestReportEvent event) { + //TODO + + } + }; - ScopeTreeModel scopeTreeModel=new ScopeTreeModel(dataProvider); + + 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 scopeDataList=new ArrayList<>(); + ArrayList scopeDataList = new ArrayList<>(); scopeDataList.add(scopeData); dataProvider.setList(scopeDataList); dataProvider.refresh(); dataProvider.flush(); + TreeNode root = scopeTree.getRootTreeNode(); + root.setChildOpen(root.getIndex(), true); } - } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/scopetree/ScopeTreeModel.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/scopetree/ScopeTreeModel.java index 69dff94..88d6308 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/scopetree/ScopeTreeModel.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/scopetree/ScopeTreeModel.java @@ -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 ListDataProvider 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 selectionModel = new SingleSelectionModel(); - public ScopeTreeModel(ListDataProvider dataProvider) { - this.dataProvider=dataProvider; - + private static Logger logger = Logger.getLogger(""); + + private ListDataProvider dataProvider; + + private final SingleSelectionModel selectionModel = new SingleSelectionModel<>(); + + public ScopeTreeModel(ListDataProvider 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); + + } + }); } /** @@ -42,7 +56,7 @@ public class ScopeTreeModel implements TreeViewModel { // LEVEL 0. // We passed null as the root value. Return the composers. // Create a data provider that contains the list of composers. - + // Create a cell to display a composer. Cell cell = new AbstractCell() { @Override @@ -52,8 +66,9 @@ public class ScopeTreeModel implements TreeViewModel { } } }; + // Return a node info that pairs the data provider and the cell. - return new DefaultNodeInfo(dataProvider, cell); + return new DefaultNodeInfo(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(dataProvider, cell); - } - - - /* - else if (value instanceof ScopeData) { + return new DefaultNodeInfo(dataProvider, cell, selectionModel, null); + } - // LEVEL 2 - LEAF. - // We want the children of the playlist. Return the songs. - ListDataProvider dataProvider = new ListDataProvider(((ScopeData) value).geSongs()); - // Use the shared selection model. - return new DefaultNodeInfo(dataProvider, new TextCell(), selectionModel, null); - }*/ + /* + * else if (value instanceof ScopeData) { + * + * // LEVEL 2 - LEAF. // We want the children of the playlist. Return + * the songs. ListDataProvider dataProvider = new + * ListDataProvider(((ScopeData) value).geSongs()); // Use the + * shared selection model. return new + * DefaultNodeInfo(dataProvider, new TextCell(), selectionModel, + * null); } + */ return null; } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/providers/TreatmentsProvider.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/providers/TreatmentsProvider.java deleted file mode 100644 index d2cbd70..0000000 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/providers/TreatmentsProvider.java +++ /dev/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 { - 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 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 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 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 comparator; - switch (columnSortIndex) { - case 0: - comparator = new Comparator() { - 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() { - 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() { - 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 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 - - } - -} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java index 0b18af9..a44e87f 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java @@ -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; + } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java index feeb261..51858d8 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java @@ -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; @@ -23,7 +25,7 @@ public interface AccountingDashboardServiceAsync { void hello(AsyncCallback callback); void getScopeData(AsyncCallback callback); - - + + void getReport(RequestReportData requestReportdata, AsyncCallback asyncCallback); } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java index c1a3f1e..59f694f 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java @@ -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); + } + } + } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java index c4c81e3..12b1087 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java @@ -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; @@ -80,5 +86,42 @@ public class AccountingService { return scopeData; } + + 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; + } + } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/data/ReportData.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/data/ReportData.java new file mode 100644 index 0000000..d40b8b8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/data/ReportData.java @@ -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; + + + + +} diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/data/RequestReportData.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/data/RequestReportData.java new file mode 100644 index 0000000..0ec04f7 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/data/RequestReportData.java @@ -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 + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/data/TreatmentData.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/data/TreatmentData.java deleted file mode 100644 index b0484d1..0000000 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/data/TreatmentData.java +++ /dev/null @@ -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, Comparable { - - 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 + "]"; - } - -} \ No newline at end of file