ref 8397:Accounting Manager - Add the Spaces management
https://support.d4science.org/issues/8397 Changed for Space unit measure from bit to byte git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@148343 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
84aa4bea75
commit
a53bbfeea7
|
@ -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.client.util.UtilsGXT3;
|
||||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriod;
|
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.AccountingPeriodMode;
|
||||||
|
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -48,14 +49,13 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
||||||
.getFormat(PredefinedFormat.YEAR);
|
.getFormat(PredefinedFormat.YEAR);
|
||||||
private DateTimeFormat dtfShort = DateTimeFormat
|
private DateTimeFormat dtfShort = DateTimeFormat
|
||||||
.getFormat(PredefinedFormat.DATE_SHORT);
|
.getFormat(PredefinedFormat.DATE_SHORT);
|
||||||
|
|
||||||
|
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
private DateField startDate;
|
private DateField startDate;
|
||||||
private DateField endDate;
|
private DateField endDate;
|
||||||
private ListStore<AccountingPeriodMode> storeCombo;
|
private ListStore<AccountingPeriodMode> storeCombo;
|
||||||
private ComboBox<AccountingPeriodMode> comboPeriodMode;
|
private ComboBox<AccountingPeriodMode> comboPeriodMode;
|
||||||
|
|
||||||
public AccountingPeriodPanel(EventBus eventBus) {
|
public AccountingPeriodPanel(EventBus eventBus) {
|
||||||
super();
|
super();
|
||||||
Log.debug("AccountingPeriodPanel");
|
Log.debug("AccountingPeriodPanel");
|
||||||
|
@ -122,7 +122,7 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
||||||
case DAILY:
|
case DAILY:
|
||||||
case HOURLY:
|
case HOURLY:
|
||||||
case MINUTELY:
|
case MINUTELY:
|
||||||
case YEARLY:
|
case YEARLY:
|
||||||
break;
|
break;
|
||||||
case MONTHLY:
|
case MONTHLY:
|
||||||
Date monthStartDate = event.getValue();
|
Date monthStartDate = event.getValue();
|
||||||
|
@ -130,25 +130,20 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
||||||
startDate.setValue(monthStartDate);
|
startDate.setValue(monthStartDate);
|
||||||
startDate.redraw();
|
startDate.redraw();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*Date yearStartDate = event.getValue();
|
/*
|
||||||
String currentYearS = dtfYear.format(yearStartDate);
|
* Date yearStartDate = event.getValue(); String currentYearS =
|
||||||
Log.debug("YearStartSet=" + currentYearS + "-01-01");
|
* dtfYear.format(yearStartDate); Log.debug("YearStartSet=" +
|
||||||
Date currentYearGen;
|
* currentYearS + "-01-01"); Date currentYearGen; try {
|
||||||
try {
|
* currentYearGen = dtfShort.parse(currentYearS + "-01-01"); }
|
||||||
currentYearGen = dtfShort.parse(currentYearS
|
* catch (Exception e) {
|
||||||
+ "-01-01");
|
* Log.debug("Error: "+e.getLocalizedMessage());
|
||||||
} catch (Exception e) {
|
* UtilsGXT3.alert("Attention",
|
||||||
Log.debug("Error: "+e.getLocalizedMessage());
|
* "Error creating Start Date at begin of year!");
|
||||||
UtilsGXT3.alert("Attention",
|
* startDate.reset(); return; }
|
||||||
"Error creating Start Date at begin of year!");
|
* Log.debug("CurrentYearGen="+dtfShort.format(currentYearGen));
|
||||||
startDate.reset();
|
* startDate.clear(); startDate.setValue(currentYearGen); break;
|
||||||
return;
|
*/
|
||||||
}
|
|
||||||
Log.debug("CurrentYearGen="+dtfShort.format(currentYearGen));
|
|
||||||
startDate.clear();
|
|
||||||
startDate.setValue(currentYearGen);
|
|
||||||
break;*/
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -186,7 +181,7 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
||||||
case DAILY:
|
case DAILY:
|
||||||
case HOURLY:
|
case HOURLY:
|
||||||
case MINUTELY:
|
case MINUTELY:
|
||||||
case YEARLY:
|
case YEARLY:
|
||||||
break;
|
break;
|
||||||
case MONTHLY:
|
case MONTHLY:
|
||||||
Date monthEndDate = event.getValue();
|
Date monthEndDate = event.getValue();
|
||||||
|
@ -196,29 +191,22 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
||||||
endDate.setValue(monthEndDate);
|
endDate.setValue(monthEndDate);
|
||||||
endDate.redraw();
|
endDate.redraw();
|
||||||
break;
|
break;
|
||||||
/*Date yearEndDate = event.getValue();
|
/*
|
||||||
String currentYearS = dtfYear.format(yearEndDate);
|
* Date yearEndDate = event.getValue(); String currentYearS =
|
||||||
Log.debug("YearEndSet=" + currentYearS + "-12-31");
|
* dtfYear.format(yearEndDate); Log.debug("YearEndSet=" +
|
||||||
Date yearEndDec;
|
* currentYearS + "-12-31"); Date yearEndDec; try { yearEndDec =
|
||||||
try {
|
* dtfShort.parse(currentYearS + "-12-31"); } catch (Exception
|
||||||
yearEndDec = dtfShort.parse(currentYearS
|
* e) { Log.debug("Error: "+e.getLocalizedMessage());
|
||||||
+ "-12-31");
|
* UtilsGXT3.alert("Attention",
|
||||||
} catch (Exception e) {
|
* "Error creating End Date at end of year!"); endDate.reset();
|
||||||
Log.debug("Error: "+e.getLocalizedMessage());
|
* return; }
|
||||||
UtilsGXT3.alert("Attention",
|
* Log.debug("YearEndDec="+dtfShort.format(yearEndDec));
|
||||||
"Error creating End Date at end of year!");
|
* endDate.clear(); endDate.setValue(yearEndDec); break;
|
||||||
endDate.reset();
|
*/
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.debug("YearEndDec="+dtfShort.format(yearEndDec));
|
|
||||||
endDate.clear();
|
|
||||||
endDate.setValue(yearEndDec);
|
|
||||||
break;*/
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -251,28 +239,28 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
eventBus.addHandler(AccountingPeriodRequestEvent.TYPE,
|
eventBus.addHandler(
|
||||||
|
AccountingPeriodRequestEvent.TYPE,
|
||||||
new AccountingPeriodRequestEvent.AccountingPeriodRequestEventHandler() {
|
new AccountingPeriodRequestEvent.AccountingPeriodRequestEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequest(AccountingPeriodRequestEvent event) {
|
public void onRequest(AccountingPeriodRequestEvent event) {
|
||||||
Log.debug("Catch Event Accounting Period Request Event");
|
Log.debug("Catch Event Accounting Period Request Event");
|
||||||
manageAccountingPeriodRequestEvent(event);
|
manageAccountingPeriodRequestEvent(event);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void manageAccountingPeriodRequestEvent(
|
private void manageAccountingPeriodRequestEvent(
|
||||||
AccountingPeriodRequestEvent event) {
|
AccountingPeriodRequestEvent event) {
|
||||||
AccountingPeriod accountingPeriod=getAccountingPeriod();
|
AccountingPeriod accountingPeriod = getAccountingPeriod();
|
||||||
AccountingPeriodEvent accountingPeriodEvent=new AccountingPeriodEvent(accountingPeriod);
|
AccountingPeriodEvent accountingPeriodEvent = new AccountingPeriodEvent(
|
||||||
|
accountingPeriod);
|
||||||
eventBus.fireEvent(accountingPeriodEvent);
|
eventBus.fireEvent(accountingPeriodEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addHandlersForComboPeriodMode(
|
private void addHandlersForComboPeriodMode(
|
||||||
|
@ -370,13 +358,40 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
||||||
&& event.getAccountingStateData().getSeriesRequest() != null
|
&& event.getAccountingStateData().getSeriesRequest() != null
|
||||||
&& event.getAccountingStateData().getSeriesRequest()
|
&& event.getAccountingStateData().getSeriesRequest()
|
||||||
.getAccountingPeriod() != null) {
|
.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()
|
AccountingPeriod accountingPeriod = event.getAccountingStateData()
|
||||||
.getSeriesRequest().getAccountingPeriod();
|
.getSeriesRequest().getAccountingPeriod();
|
||||||
startDate.setValue(dtf.parse(accountingPeriod.getStartDate()));
|
startDate.setValue(dtf.parse(accountingPeriod.getStartDate()));
|
||||||
endDate.setValue(dtf.parse(accountingPeriod.getEndDate()));
|
endDate.setValue(dtf.parse(accountingPeriod.getEndDate()));
|
||||||
|
|
||||||
comboPeriodMode.setValue(accountingPeriod.getPeriod());
|
comboPeriodMode.setValue(accountingPeriod.getPeriod());
|
||||||
} else {
|
} 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();
|
startDate.reset();
|
||||||
endDate.reset();
|
endDate.reset();
|
||||||
comboPeriodMode.reset();
|
comboPeriodMode.reset();
|
||||||
|
|
|
@ -19,21 +19,42 @@ public class ByteUnitMeasure {
|
||||||
public static final String GB = "GB";
|
public static final String GB = "GB";
|
||||||
public static final String TB = "TB";
|
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() {
|
public static long getKiloByteDimForStorage() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getMegaByteDimForStorage() {
|
public static long getMegaByteDimForStorage() {
|
||||||
return 1000;
|
return 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getGigaByteDimForStorage() {
|
public static long getGigaByteDimForStorage() {
|
||||||
return 1000000;
|
return 1048576;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getTeraByteDimForStorage() {
|
public static long getTeraByteDimForStorage() {
|
||||||
return 1000000000;
|
return 1073741824;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue