diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 366448f..e6d61c1 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,7 +4,7 @@ - + uses diff --git a/distro/changelog.xml b/distro/changelog.xml index b27df34..f8d4bce 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,5 +1,7 @@ + Added to Storage Accounting more formats for DataVolume axis [Ticket #1831] + Fixed on Storage Accounting the popup validation on filters [Ticket #1832] Fixed library dependencies diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/storage/StorageChart.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/storage/StorageChart.java index fd02583..0429b23 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/storage/StorageChart.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/storage/StorageChart.java @@ -2,6 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storag import java.util.Date; +import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ByteUnitMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; @@ -44,18 +45,32 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar; */ public class StorageChart extends SimpleContainer { - private DateTimeFormat dtf=DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY); - + private static final String DATA_VOLUME_UNIT = "Data Volume Unit"; + + private DateTimeFormat dtf = DateTimeFormat + .getFormat(PredefinedFormat.YEAR_MONTH_DAY); + private AccountingStateData accountingStateData; private HighchartsLayoutPanel highchartsLayoutPanel; - // Replace Menu + // Download Menu private MenuItem downloadPNGItem; private MenuItem downloadJPGItem; private MenuItem downloadPDFItem; private MenuItem downloadSVGItem; + + // Unit Menu + private MenuItem kBItem; + private MenuItem MBItem; + private MenuItem GBItem; + private MenuItem TBItem; + ChartOptions options; + private VerticalLayoutContainer vert; + private long unitMeasure = ByteUnitMeasure.getMegaByteDimForStorage(); + private String unitMeasureLabel = ByteUnitMeasure.MB; + public StorageChart(AccountingStateData accountingStateData) { this.accountingStateData = accountingStateData; forceLayoutOnResize = true; @@ -67,25 +82,31 @@ public class StorageChart extends SimpleContainer { ToolBar toolBar = new ToolBar(); toolBar.setSpacing(2); // Download - final TextButton downloadButton = new TextButton(DownloadConstants.DOWNLOAD, - AccountingManagerResources.INSTANCE - .accountingDownload24()); + final TextButton downloadButton = new TextButton( + DownloadConstants.DOWNLOAD, + AccountingManagerResources.INSTANCE.accountingDownload24()); // downloadButton.setScale(ButtonScale.MEDIUM); downloadButton.setIconAlign(IconAlign.RIGHT); downloadButton.setArrowAlign(ButtonArrowAlign.RIGHT); downloadButton.setMenu(createDownloadMenu()); - toolBar.add(downloadButton, new BoxLayoutData(new Margins(0))); + final TextButton unitButton = new TextButton(DATA_VOLUME_UNIT, + AccountingManagerResources.INSTANCE.accountingByte24()); + unitButton.setIconAlign(IconAlign.RIGHT); + unitButton.setArrowAlign(ButtonArrowAlign.RIGHT); + unitButton.setMenu(createUnitMenu()); + toolBar.add(downloadButton, new BoxLayoutData(new Margins(0))); + toolBar.add(unitButton, new BoxLayoutData(new Margins(0))); // createChart(); - + highchartsLayoutPanel = new HighchartsLayoutPanel(); highchartsLayoutPanel.renderChart(options); // - VerticalLayoutContainer vert = new VerticalLayoutContainer(); + vert = new VerticalLayoutContainer(); vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, new Margins(0))); @@ -94,26 +115,35 @@ public class StorageChart extends SimpleContainer { } + private void updateChart() { + vert.remove(highchartsLayoutPanel); + // + createChart(); + + highchartsLayoutPanel = new HighchartsLayoutPanel(); + highchartsLayoutPanel.renderChart(options); + + vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, + new Margins(0))); + + forceLayout(); + } + private Menu createDownloadMenu() { Menu menuDownload = new Menu(); downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG, - AccountingManagerResources.INSTANCE - .accountingFilePNG24()); + AccountingManagerResources.INSTANCE.accountingFilePNG24()); downloadPNGItem.setHeight(30); downloadJPGItem = new MenuItem(DownloadConstants.DOWNLOAD_JPG, - AccountingManagerResources.INSTANCE - .accountingFileJPG24()); + AccountingManagerResources.INSTANCE.accountingFileJPG24()); downloadJPGItem.setHeight(30); downloadPDFItem = new MenuItem(DownloadConstants.DOWNLOAD_PDF, - AccountingManagerResources.INSTANCE - .accountingFilePDF24()); + AccountingManagerResources.INSTANCE.accountingFilePDF24()); downloadPDFItem.setHeight(30); downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG, - AccountingManagerResources.INSTANCE - .accountingFileSVG24()); + AccountingManagerResources.INSTANCE.accountingFileSVG24()); downloadSVGItem.setHeight(30); - - + downloadPNGItem.addSelectionHandler(new SelectionHandler() { @Override @@ -159,6 +189,65 @@ public class StorageChart extends SimpleContainer { } + private Menu createUnitMenu() { + Menu menuUnit = new Menu(); + kBItem = new MenuItem(ByteUnitMeasure.KILOBYTE); + kBItem.setHeight(30); + MBItem = new MenuItem(ByteUnitMeasure.MEGABYTE); + MBItem.setHeight(30); + GBItem = new MenuItem(ByteUnitMeasure.GIGABYTE); + GBItem.setHeight(30); + TBItem = new MenuItem(ByteUnitMeasure.TERABYTE); + TBItem.setHeight(30); + + kBItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + unitMeasure = ByteUnitMeasure.getKiloByteDimForStorage(); + unitMeasureLabel = ByteUnitMeasure.kB; + updateChart(); + } + }); + + MBItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + unitMeasure = ByteUnitMeasure.getMegaByteDimForStorage(); + unitMeasureLabel = ByteUnitMeasure.MB; + updateChart(); + } + }); + + GBItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + unitMeasure = ByteUnitMeasure.getGigaByteDimForStorage(); + unitMeasureLabel = ByteUnitMeasure.GB; + updateChart(); + } + }); + + TBItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + unitMeasure = ByteUnitMeasure.getTeraByteDimForStorage(); + unitMeasureLabel = ByteUnitMeasure.TB; + updateChart(); + } + }); + + menuUnit.add(kBItem); + menuUnit.add(MBItem); + menuUnit.add(GBItem); + menuUnit.add(TBItem); + return menuUnit; + + } + // chart.options.exporting.buttons.contextButton.menuItems[0].onclick(); public static native void onDownloadPNG(String id) /*-{ @@ -222,18 +311,19 @@ public class StorageChart extends SimpleContainer { double interval = ChartTimeMeasure .calculateInterval(accountingStateData.getSeriesRequest() .getAccountingPeriod()); - - Date dateStart=dtf.parse(accountingStateData.getSeriesRequest() + + Date dateStart = dtf.parse(accountingStateData.getSeriesRequest() .getAccountingPeriod().getStartDate()); - - dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset()*ChartTimeMeasure.MINUTE); - + + dateStart.setTime(dateStart.getTime() + + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE); + Log.debug("BuildChart DateStart: " + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL) .format(dateStart)); - HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory(); - + HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory(); + options = highchartsFactory.createChartOptions(); options.chart().zoomType("xy"); options.exporting().buttons().contextButton().enabled(false); @@ -281,13 +371,13 @@ public class StorageChart extends SimpleContainer { + " }" + " }," + " \"labels\": {" - + " \"format\": \"{value} kB\"," + + " \"format\": \"{value} " + + unitMeasureLabel + + "\"," + " \"style\": {" + " \"color\": \"" + colors.get(0) - + "\"" - + " }" - + " }," + " \"opposite\": \"true\"" + "}]"; + + "\"" + " }" + " }," + " \"opposite\": \"true\"" + "}]"; options.setFieldAsJsonObject("yAxis", multiAxis); @@ -325,7 +415,8 @@ public class StorageChart extends SimpleContainer { for (SeriesStorageData seriesStorageData : seriesStorage.getSeries()) { dataOperationCount.push(seriesStorageData.getOperationCount()); - dataDataVolume.push(seriesStorageData.getDataVolume()); + dataDataVolume + .push(seriesStorageData.getDataVolume() / unitMeasure); } options.series().addToEnd(seriesOperationCount); 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 new file mode 100644 index 0000000..dd41a1d --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/utils/ByteUnitMeasure.java @@ -0,0 +1,39 @@ +package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils; + +/** + * Note Storage Data are in kB + * + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class ByteUnitMeasure { + public static final String KILOBYTE = "KiloByte (kB)"; + public static final String MEGABYTE = "MegaByte (MB)"; + public static final String GIGABYTE = "GigaByte (GB)"; + public static final String TERABYTE = "TeraByte (TB)"; + + public static final String kB = "kB"; + public static final String MB = "MB"; + public static final String GB = "GB"; + public static final String TB = "TB"; + + public static long getKiloByteDimForStorage() { + return 1; + } + + public static long getMegaByteDimForStorage() { + return 1000; + } + + public static long getGigaByteDimForStorage() { + return 1000000; + } + + public static long getTeraByteDimForStorage() { + return 1000000000; + + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/utils/DownloadConstants.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/utils/DownloadConstants.java index dac00ac..e26c398 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/utils/DownloadConstants.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/utils/DownloadConstants.java @@ -1,5 +1,11 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils; +/** + * + * @author Giancarlo Panichi + * email: g.panichi@isti.cnr.it + * + */ public class DownloadConstants { public static final String DOWNLOAD = "Download"; public static final String DOWNLOAD_PNG = "Download PNG Image"; diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/resource/AccountingManagerResources.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/resource/AccountingManagerResources.java index 206eeb9..620a307 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/resource/AccountingManagerResources.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/resource/AccountingManagerResources.java @@ -122,9 +122,15 @@ public interface AccountingManagerResources extends ClientBundle { @Source("accounting-download_24.png") ImageResource accountingDownload24(); + @Source("accounting-byte_32.png") + ImageResource accountingByte32(); + + @Source("accounting-byte_24.png") + ImageResource accountingByte24(); + @Source("accounting-download_32.png") ImageResource accountingDownload32(); - + @Source("accounting-file_24.png") ImageResource accountingFile24(); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_24.png b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_24.png new file mode 100644 index 0000000..fd57ef1 Binary files /dev/null and b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_24.png differ diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_32.png b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_32.png new file mode 100644 index 0000000..8deac40 Binary files /dev/null and b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_32.png differ 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 b6d1945..4e6de3e 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 @@ -112,13 +112,15 @@ public class AccountingCaller { switch (filterValuesRequest.getAccountingType()) { case JOB: - //values = rrq.getPossibleValuesForKey(AggregatedJobUsageRecord.class, filterValuesRequest - // .getFilterKey().getKey()); + // values = + // rrq.getPossibleValuesForKey(AggregatedJobUsageRecord.class, + // filterValuesRequest + // .getFilterKey().getKey()); return filteValues; case PORTLET: - //values = rrq.getPossibleValuesForKey( - // AggregatedPortletUsageRecord.class, filterValuesRequest - // .getFilterKey().getKey()); + // values = rrq.getPossibleValuesForKey( + // AggregatedPortletUsageRecord.class, filterValuesRequest + // .getFilterKey().getKey()); return filteValues; case SERVICE: values = rrq.getPossibleValuesForKey( @@ -131,9 +133,9 @@ public class AccountingCaller { .getFilterKey().getKey()); break; case TASK: - //values = rrq.getPossibleValuesForKey( - // AggregatedTaskUsageRecord.class, filterValuesRequest - // .getFilterKey().getKey()); + // values = rrq.getPossibleValuesForKey( + // AggregatedTaskUsageRecord.class, filterValuesRequest + // .getFilterKey().getKey()); return filteValues; default: return filteValues; @@ -218,35 +220,12 @@ public class AccountingCaller { throw new AccountingManagerServiceException( "Error accounting type is null"); } - - /* - SimpleDateFormat stz = new SimpleDateFormat("Z"); - String timeZone=stz.format(seriesRequest.getAccountingPeriod().getStartDate()); - int tzOffSet=TimeZone.getTimeZone(timeZone).getRawOffset()-TemporalConstraint.DEFAULT_TIME_ZONE.getRawOffset(); - logger.debug("TimeZone[zone="+timeZone+", offset="+tzOffSet+"]"); - Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); - long startTime=seriesRequest.getAccountingPeriod() - .getStartDate().getTime()+tzOffSet; - startCalendar.setTimeInMillis(startTime); - - Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); - long endTime=seriesRequest.getAccountingPeriod() - .getEndDate().getTime()+tzOffSet; - endCalendar.setTimeInMillis(endTime); - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); - sdf.setTimeZone(TemporalConstraint.DEFAULT_TIME_ZONE); - logger.debug("StartCalendar: " + sdf.format(startCalendar.getTime())); - logger.debug("EndCalendar: " + sdf.format(endCalendar.getTime())); - seriesRequest.getAccountingPeriod().setStartDate( - startCalendar.getTime()); - seriesRequest.getAccountingPeriod().setEndDate(endCalendar.getTime()); - */ - - logger.debug("StartCalendar: " + seriesRequest.getAccountingPeriod().getStartDate()); - logger.debug("EndCalendar: " + seriesRequest.getAccountingPeriod().getEndDate()); - + logger.debug("StartCalendar: " + + seriesRequest.getAccountingPeriod().getStartDate()); + logger.debug("EndCalendar: " + + seriesRequest.getAccountingPeriod().getEndDate()); + switch (accountingType) { case JOB: return new AccountingQuery4Job(seriesRequest); diff --git a/src/main/resources/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_24.png b/src/main/resources/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_24.png new file mode 100644 index 0000000..fd57ef1 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_24.png differ diff --git a/src/main/resources/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_32.png b/src/main/resources/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_32.png new file mode 100644 index 0000000..8deac40 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/admin/accountingmanager/client/resource/accounting-byte_32.png differ diff --git a/templates/changelog.xml b/templates/changelog.xml index b27df34..f8d4bce 100644 --- a/templates/changelog.xml +++ b/templates/changelog.xml @@ -1,5 +1,7 @@ + Added to Storage Accounting more formats for DataVolume axis [Ticket #1831] + Fixed on Storage Accounting the popup validation on filters [Ticket #1832] Fixed library dependencies