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 e519bbd..f2b5230 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 @@ -9,6 +9,7 @@ import org.gcube.portlets.admin.accountingmanager.client.properties.AccountingPe import org.gcube.portlets.admin.accountingmanager.client.util.UtilsGXT3; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriod; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriodMode; +import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; @@ -48,14 +49,13 @@ public class AccountingPeriodPanel extends SimpleContainer { .getFormat(PredefinedFormat.YEAR); private DateTimeFormat dtfShort = DateTimeFormat .getFormat(PredefinedFormat.DATE_SHORT); - - + private EventBus eventBus; private DateField startDate; private DateField endDate; private ListStore storeCombo; private ComboBox comboPeriodMode; - + public AccountingPeriodPanel(EventBus eventBus) { super(); Log.debug("AccountingPeriodPanel"); @@ -122,7 +122,7 @@ public class AccountingPeriodPanel extends SimpleContainer { case DAILY: case HOURLY: case MINUTELY: - case YEARLY: + case YEARLY: break; case MONTHLY: Date monthStartDate = event.getValue(); @@ -130,25 +130,20 @@ public class AccountingPeriodPanel extends SimpleContainer { startDate.setValue(monthStartDate); startDate.redraw(); break; - - /*Date yearStartDate = event.getValue(); - String currentYearS = dtfYear.format(yearStartDate); - Log.debug("YearStartSet=" + currentYearS + "-01-01"); - Date currentYearGen; - try { - currentYearGen = dtfShort.parse(currentYearS - + "-01-01"); - } catch (Exception e) { - Log.debug("Error: "+e.getLocalizedMessage()); - UtilsGXT3.alert("Attention", - "Error creating Start Date at begin of year!"); - startDate.reset(); - return; - } - Log.debug("CurrentYearGen="+dtfShort.format(currentYearGen)); - startDate.clear(); - startDate.setValue(currentYearGen); - break;*/ + + /* + * Date yearStartDate = event.getValue(); String currentYearS = + * dtfYear.format(yearStartDate); Log.debug("YearStartSet=" + + * currentYearS + "-01-01"); Date currentYearGen; try { + * currentYearGen = dtfShort.parse(currentYearS + "-01-01"); } + * catch (Exception e) { + * Log.debug("Error: "+e.getLocalizedMessage()); + * UtilsGXT3.alert("Attention", + * "Error creating Start Date at begin of year!"); + * startDate.reset(); return; } + * Log.debug("CurrentYearGen="+dtfShort.format(currentYearGen)); + * startDate.clear(); startDate.setValue(currentYearGen); break; + */ default: break; @@ -186,7 +181,7 @@ public class AccountingPeriodPanel extends SimpleContainer { case DAILY: case HOURLY: case MINUTELY: - case YEARLY: + case YEARLY: break; case MONTHLY: Date monthEndDate = event.getValue(); @@ -196,29 +191,22 @@ public class AccountingPeriodPanel extends SimpleContainer { endDate.setValue(monthEndDate); endDate.redraw(); break; - /*Date yearEndDate = event.getValue(); - String currentYearS = dtfYear.format(yearEndDate); - Log.debug("YearEndSet=" + currentYearS + "-12-31"); - Date yearEndDec; - try { - yearEndDec = dtfShort.parse(currentYearS - + "-12-31"); - } catch (Exception e) { - Log.debug("Error: "+e.getLocalizedMessage()); - UtilsGXT3.alert("Attention", - "Error creating End Date at end of year!"); - endDate.reset(); - return; - } - Log.debug("YearEndDec="+dtfShort.format(yearEndDec)); - endDate.clear(); - endDate.setValue(yearEndDec); - break;*/ + /* + * Date yearEndDate = event.getValue(); String currentYearS = + * dtfYear.format(yearEndDate); Log.debug("YearEndSet=" + + * currentYearS + "-12-31"); Date yearEndDec; try { yearEndDec = + * dtfShort.parse(currentYearS + "-12-31"); } catch (Exception + * e) { Log.debug("Error: "+e.getLocalizedMessage()); + * UtilsGXT3.alert("Attention", + * "Error creating End Date at end of year!"); endDate.reset(); + * return; } + * Log.debug("YearEndDec="+dtfShort.format(yearEndDec)); + * endDate.clear(); endDate.setValue(yearEndDec); break; + */ default: break; } - } }); @@ -251,28 +239,28 @@ public class AccountingPeriodPanel extends SimpleContainer { } }); - - eventBus.addHandler(AccountingPeriodRequestEvent.TYPE, + + eventBus.addHandler( + AccountingPeriodRequestEvent.TYPE, new AccountingPeriodRequestEvent.AccountingPeriodRequestEventHandler() { - + @Override public void onRequest(AccountingPeriodRequestEvent event) { Log.debug("Catch Event Accounting Period Request Event"); manageAccountingPeriodRequestEvent(event); - } }); - } - + private void manageAccountingPeriodRequestEvent( AccountingPeriodRequestEvent event) { - AccountingPeriod accountingPeriod=getAccountingPeriod(); - AccountingPeriodEvent accountingPeriodEvent=new AccountingPeriodEvent(accountingPeriod); + AccountingPeriod accountingPeriod = getAccountingPeriod(); + AccountingPeriodEvent accountingPeriodEvent = new AccountingPeriodEvent( + accountingPeriod); eventBus.fireEvent(accountingPeriodEvent); - + } private void addHandlersForComboPeriodMode( @@ -370,13 +358,40 @@ public class AccountingPeriodPanel extends SimpleContainer { && event.getAccountingStateData().getSeriesRequest() != null && event.getAccountingStateData().getSeriesRequest() .getAccountingPeriod() != null) { + if (event.getAccountingStateData().getAccountingType() + .compareTo(AccountingType.SPACE) == 0) { + storeCombo.clear(); + storeCombo.add(AccountingPeriodMode.DAILY); + storeCombo.add(AccountingPeriodMode.MONTHLY); + storeCombo.add(AccountingPeriodMode.YEARLY); + storeCombo.commitChanges(); + + } else { + storeCombo.clear(); + storeCombo.addAll(AccountingPeriodMode.asList()); + storeCombo.commitChanges(); + } AccountingPeriod accountingPeriod = event.getAccountingStateData() .getSeriesRequest().getAccountingPeriod(); startDate.setValue(dtf.parse(accountingPeriod.getStartDate())); endDate.setValue(dtf.parse(accountingPeriod.getEndDate())); - comboPeriodMode.setValue(accountingPeriod.getPeriod()); } else { + if (event.getAccountingStateData() != null + && event.getAccountingStateData().getAccountingType() + .compareTo(AccountingType.SPACE) == 0) { + storeCombo.clear(); + storeCombo.add(AccountingPeriodMode.DAILY); + storeCombo.add(AccountingPeriodMode.MONTHLY); + storeCombo.add(AccountingPeriodMode.YEARLY); + storeCombo.commitChanges(); + + } else { + storeCombo.clear(); + storeCombo.addAll(AccountingPeriodMode.asList()); + storeCombo.commitChanges(); + } + startDate.reset(); endDate.reset(); comboPeriodMode.reset(); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/utils/ByteUnitMeasure.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/utils/ByteUnitMeasure.java index d4ceb0b..225e99d 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/utils/ByteUnitMeasure.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/utils/ByteUnitMeasure.java @@ -19,21 +19,42 @@ public class ByteUnitMeasure { public static final String GB = "GB"; public static final String TB = "TB"; + public static long getKiloBitDimForStorage() { + return 1; + } + + public static long getMegaBitDimForStorage() { + return 1000; + } + + public static long getGigaBitDimForStorage() { + return 1000000; + } + + public static long getTeraBitDimForStorage() { + return 1000000000; + + } + public static long getKiloByteDimForStorage() { return 1; } public static long getMegaByteDimForStorage() { - return 1000; + return 1024; } public static long getGigaByteDimForStorage() { - return 1000000; + return 1048576; } public static long getTeraByteDimForStorage() { - return 1000000000; + return 1073741824; } + + + + }