diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index f25c36f..43242c5 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,6 +4,9 @@ + + uses + diff --git a/accountingman.launch b/accountingman.launch index 9b8786a..072cba8 100644 --- a/accountingman.launch +++ b/accountingman.launch @@ -1,13 +1,16 @@ - - - - - - - - - - + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 368fc15..1943f1b 100644 --- a/pom.xml +++ b/pom.xml @@ -95,6 +95,8 @@ ${gwtVersion} + + @@ -105,14 +107,27 @@ ${gxtVersion} + + + org.gcube.portlets.admin + accounting-manager-theme + [0.0.1-SNAPSHOT, + 2.0.0-SNAPSHOT) + + + com.google.gwt + gwt-dev + + + - - - - + + com.sencha.gxt @@ -126,8 +141,6 @@ 0.0.7 - @@ -195,15 +208,8 @@ [0.2.0-SNAPSHOT,1.0.0-SNAPSHOT) - - - com.sencha.gxt - gxt-theme-neptune - 3.1.1 - + diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/AccountingPeriodPanel.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/AccountingPeriodPanel.java index b7c4d0a..3934964 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/AccountingPeriodPanel.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/AccountingPeriodPanel.java @@ -88,9 +88,7 @@ public class AccountingPeriodPanel extends SimpleContainer { FieldLabel startDateLabel = new FieldLabel(startDate, "Start Date"); endDate = new DateField(); - endDate.addValidator(new MaxDateValidator(new Date())); endDate.addValidator(new EmptyValidator()); - endDate.addParseErrorHandler(new ParseErrorEvent.ParseErrorHandler() { @Override public void onParseError(ParseErrorEvent event) { @@ -125,7 +123,7 @@ public class AccountingPeriodPanel extends SimpleContainer { comboPeriodMode.setTriggerAction(TriggerAction.ALL); comboPeriodMode.setValue(AccountingPeriodMode.DAILY); addHandlersForComboPeriodMode(props.label()); - + Log.debug("ComboPeriodMode created"); FieldLabel periodModeLabel = new FieldLabel(comboPeriodMode, @@ -158,23 +156,26 @@ public class AccountingPeriodPanel extends SimpleContainer { } }); } - - + private void addHandlersForComboPeriodMode( final LabelProvider labelProvider) { - comboPeriodMode.addSelectionHandler(new SelectionHandler() { - public void onSelection(SelectionEvent event) { - Info.display( - "Aggregation", - "You selected " - + (event.getSelectedItem() == null ? "nothing" - : labelProvider.getLabel(event - .getSelectedItem()) + "!")); - Log.debug("ComboPeriodMode selected: " + event.getSelectedItem()); - - } + comboPeriodMode + .addSelectionHandler(new SelectionHandler() { + public void onSelection( + SelectionEvent event) { + Info.display( + "Aggregation", + "You selected " + + (event.getSelectedItem() == null ? "nothing" + : labelProvider.getLabel(event + .getSelectedItem()) + + "!")); + Log.debug("ComboPeriodMode selected: " + + event.getSelectedItem()); - }); + } + + }); } private void doStateChangeCommand(StateChangeEvent event) { @@ -195,12 +196,15 @@ public class AccountingPeriodPanel extends SimpleContainer { } private void onRestoreStateChange(StateChangeEvent event) { - if (event.getAccountingStateData()!=null&&event.getAccountingStateData().getSeriesRequest() != null - && event.getAccountingStateData().getSeriesRequest().getAccountingPeriod() != null) { - AccountingPeriod accountingPeriod = event.getAccountingStateData().getSeriesRequest() - .getAccountingPeriod(); + if (event.getAccountingStateData() != null + && event.getAccountingStateData().getSeriesRequest() != null + && event.getAccountingStateData().getSeriesRequest() + .getAccountingPeriod() != null) { + AccountingPeriod accountingPeriod = event.getAccountingStateData() + .getSeriesRequest().getAccountingPeriod(); startDate.setValue(accountingPeriod.getStartDate()); endDate.setValue(accountingPeriod.getEndDate()); + comboPeriodMode.setValue(accountingPeriod.getPeriod()); } else { startDate.reset(); @@ -213,31 +217,51 @@ public class AccountingPeriodPanel extends SimpleContainer { } public AccountingPeriod getAccountingPeriod() { + try { + if (startDate.validate() && endDate.validate()) { - Date startD = startDate.getCurrentValue(); - Date endD = endDate.getCurrentValue(); - if (startD.compareTo(endD) <= 0) { - if (comboPeriodMode.validate() - && comboPeriodMode.getCurrentValue() != null) { - AccountingPeriod accountingPeriod = new AccountingPeriod( - startD, endD, comboPeriodMode.getCurrentValue()); - return accountingPeriod; + if (endDate.getCurrentValue().compareTo(new Date()) <= 0) { + + Date startD = startDate.getCurrentValue(); + Date endD = endDate.getCurrentValue(); + if (startD.compareTo(endD) <= 0) { + if (comboPeriodMode.validate() + && comboPeriodMode.getCurrentValue() != null) { + AccountingPeriod accountingPeriod = new AccountingPeriod( + startD, endD, comboPeriodMode.getCurrentValue()); + return accountingPeriod; + } else { + UtilsGXT3.alert("Attention", + "Select a valid aggregation mode!"); + return null; + } } else { - UtilsGXT3.alert("Attention", - "Select a valid aggregation mode!"); + UtilsGXT3 + .alert("Attention", + "The start date must be less than or equal to the end date!"); return null; } + } else { + String endD=DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date()); UtilsGXT3 .alert("Attention", - "The start date must be less than or equal to the end date!"); + "The end date must be "+endD+" or earlier!"); return null; } } else { return null; } - + + } catch(Throwable e){ + Log.error(e.getLocalizedMessage()); + e.printStackTrace(); + UtilsGXT3 + .alert("Attention", + e.getLocalizedMessage()); + return null; + } } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java index 788d1b9..0fd1935 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java @@ -3,8 +3,7 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice; import java.util.List; import org.gcube.accounting.analytics.Info; -import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery; -import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory; +import org.gcube.accounting.analytics.ResourceRecordQuery; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Job; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Portlet; @@ -45,9 +44,9 @@ public class AccountingCaller { SeriesRequest seriesRequest) throws AccountingManagerServiceException { try { - logger.debug("getSeries(): [AccountingType="+accountingType+" , seriesRequest=" + seriesRequest+"]"); - AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory - .getInstance(); + logger.debug("getSeries(): [AccountingType=" + accountingType + + " , seriesRequest=" + seriesRequest + "]"); + ResourceRecordQuery rrq = new ResourceRecordQuery(); AccountingQueryBuilder queryBuilder = getAccountQueryBuilder( accountingType, seriesRequest); @@ -62,14 +61,14 @@ public class AccountingCaller { "Error in invocation: Operation not supported"); } - List infos = apq.query(query.getType(), + List infos = rrq.getInfo(query.getType(), query.getTemporalConstraint(), null); if (infos == null) { throw new AccountingManagerServiceException( "Error retrieving list of info: list is null!"); } logger.debug("Retrieved Infos"); - + SeriesResponseBuilder seriesResponseBuilder = getSeriesResponseBuilder( accountingType, infos);