diff --git a/.classpath b/.classpath index dde1fed..cddc194 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -45,5 +45,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index ecbb20a..05c213d 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,5 @@ - + diff --git a/CHANGELOG.md b/CHANGELOG.md index 10598f4..55795ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm # Changelog for "accounting-manager" +## [v1.15.0-SNAPSHOT] - 2021-11-30 + +### Features + +- Improve query support of the new persistence [#21354] + + ## [v1.14.0] - 2021-06-28 ### Fixes diff --git a/changelog.xml b/changelog.xml index 9541355..aabc4be 100644 --- a/changelog.xml +++ b/changelog.xml @@ -1,4 +1,8 @@ + + Improve query support of the new persistence [#21354] + Fixed display errors generated in Root scope [#21729] diff --git a/pom.xml b/pom.xml index 8aba4ec..f02821a 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 4.0.0 org.gcube.portlets.admin accounting-manager - 1.14.0 + 1.15.0-SNAPSHOT war @@ -108,7 +108,7 @@ org.gcube.accounting accounting-lib - [4.0.0,5.0.0-SNAPSHOT) + provided @@ -235,6 +235,13 @@ compile + + + org.gcube.data.publishing + document-store-lib + provided + + org.gcube.accounting @@ -246,14 +253,7 @@ org.gcube.accounting accounting-analytics - [3.0.0,4.0.0-SNAPSHOT) - - - - - org.gcube.data.publishing - document-store-lib - provided + [4.0.0-SNAPSHOT,5.0.0-SNAPSHOT) @@ -261,7 +261,7 @@ org.gcube.accounting accounting-analytics-persistence-postgresql - [1.0.0,2.0.0-SNAPSHOT) + [2.0.0-SNAPSHOT,3.0.0-SNAPSHOT) runtime diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/AccountingManagerController.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/AccountingManagerController.java index ed3ec4c..364bbca 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/AccountingManagerController.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/AccountingManagerController.java @@ -430,7 +430,8 @@ public class AccountingManagerController { AccountingClientStateData accountingStateData = accountingState.getState(accountingType); SeriesRequest seriesRequest = null; - + Context defaultContext=new Context(); + switch (accountingType) { case JOB: case PORTLET: @@ -439,9 +440,8 @@ public class AccountingManagerController { case TASK: seriesRequest = new SeriesRequest( new AccountingPeriod(dtf.format(lastMonth), dtf.format(date), AccountingPeriodMode.DAILY), - new AccountingFilterBasic()); + new AccountingFilterBasic(defaultContext)); Log.debug("DefaultSeriesRequest: " + seriesRequest); - break; case SPACE: accountingStateData.setAvailableSpaces(spaces); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/ActiveFiltersPanel.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/ActiveFiltersPanel.java index e70ff5a..51c04ee 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/ActiveFiltersPanel.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/ActiveFiltersPanel.java @@ -9,8 +9,7 @@ import org.gcube.portlets.admin.accountingmanager.client.event.SessionExpiredEve import org.gcube.portlets.admin.accountingmanager.client.event.StateChangeEvent; import org.gcube.portlets.admin.accountingmanager.client.monitor.AccountingMonitor; import org.gcube.portlets.admin.accountingmanager.client.properties.AccountingFilterProperties; -import org.gcube.portlets.admin.accountingmanager.client.properties.GenresDataProperties; -import org.gcube.portlets.admin.accountingmanager.client.properties.GenresDataPropertiesCombo; +import org.gcube.portlets.admin.accountingmanager.client.properties.ContextDataProperties; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerServiceAsync; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData; @@ -18,17 +17,15 @@ import org.gcube.portlets.admin.accountingmanager.client.type.SessionExpiredType import org.gcube.portlets.admin.accountingmanager.client.util.UtilsGXT3; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterDefinition; -import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterSpaces; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; +import org.gcube.portlets.admin.accountingmanager.shared.data.ContextData; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesResponse; -import org.gcube.portlets.admin.accountingmanager.shared.data.GenresData; -import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces; import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpiredException; import com.allen_sauer.gwt.log.client.Log; @@ -106,16 +103,16 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar; */ public class ActiveFiltersPanel extends SimpleContainer { - private static final int TOP_NUMBER_DEFAULT = 5; - private static final int TOP_NUMBER_MAX = 10; + private static final int TOP_NUMBER_DEFAULT = 10; + private static final int TOP_NUMBER_MAX = 50; private static final int TOP_NUMBER_MIN = 1; private EventBus eventBus; private Grid gridFilter; private ListStore storeFilter; - private Grid gridGenres; - private ListStore storeGenres; - private CheckBoxSelectionModel smGenres; - private ColumnConfig labelGenresCol; + private Grid gridScopes; + private ListStore storeScopes; + private CheckBoxSelectionModel smScopes; + private ColumnConfig labelScopesCol; private boolean addStatus; private AccountingClientStateData accountingStateData; private ListStore storeComboFilterKey; @@ -128,16 +125,12 @@ public class ActiveFiltersPanel extends SimpleContainer { private FieldLabel comboChartTypeLabel; private ListStore storeComboChartType; private ComboBox comboChartType; - private ListStore storeComboScope; - private ComboBox comboScope; - private FieldLabel comboScopeLabel; private ListStore storeComboTopFilterKey; private ComboBox comboTopFilterKey; private FieldLabel comboTopFilterKeyLabel; private ToolBar toolBar; - // private CheckBox showOthers; + private FieldLabel showOthersLabel; - private FieldLabel noContextLabel; private IntegerSpinnerField topNumber; private FieldLabel topNumberLabel; @@ -149,10 +142,6 @@ public class ActiveFiltersPanel extends SimpleContainer { private Radio showOthersNo; private ToggleGroup showOthersToggle; - private Radio noContextYes; - private Radio noContextNo; - private ToggleGroup noContextToggle; - public interface FilterKeyPropertiesCombo extends PropertyAccess { @Path("id") @@ -162,17 +151,6 @@ public class ActiveFiltersPanel extends SimpleContainer { } - /* - * public interface FilterValuePropertiesCombo extends - * PropertyAccess { - * - * @Path("id") ModelKeyProvider id(); - * - * LabelProvider value(); - * - * } - */ - interface FilterKeyTemplates extends XTemplates { @XTemplate("{value}") SafeHtml format(String value); @@ -297,11 +275,8 @@ public class ActiveFiltersPanel extends SimpleContainer { comboFilterKey.setTriggerAction(TriggerAction.ALL); addHandlersForComboFilterKey(filterKeyPropertiesCombo.key()); - // Value - /* - * FilterValuePropertiesCombo filterValuePropertiesCombo = GWT - * .create(FilterValuePropertiesCombo.class); - */ + // Filter Value + storeComboFilterValue = new ListStore(new ModelKeyProvider() { @Override @@ -414,8 +389,46 @@ public class ActiveFiltersPanel extends SimpleContainer { toolBar = new ToolBar(); toolBar.add(addButton, new BoxLayoutData(new Margins(0))); - // ChartTypeSelection + // Grid Context + ContextDataProperties propsScopeData = GWT.create(ContextDataProperties.class); + IdentityValueProvider identity = new IdentityValueProvider(); + smScopes = new CheckBoxSelectionModel(identity); + + labelScopesCol = new ColumnConfig(propsScopeData.label(), 356, "Scope"); + + labelScopesCol.setCell(new AbstractCell() { + + @Override + public void render(Context context, String value, SafeHtmlBuilder sb) { + sb.appendHtmlConstant("" + SafeHtmlUtils.htmlEscape(value) + ""); + + } + + }); + + List> lcolumnsScopes = new ArrayList>(); + lcolumnsScopes.add(smScopes.getColumn()); + lcolumnsScopes.add(labelScopesCol); + ColumnModel cmContextData = new ColumnModel(lcolumnsScopes); + + storeScopes = new ListStore(propsScopeData.id()); + + gridScopes = new Grid(storeScopes, cmContextData); + + sm.setSelectionMode(SelectionMode.MULTI); + gridScopes.setHeight("130px"); + gridScopes.setSelectionModel(smScopes); + gridScopes.getView().setStripeRows(true); + gridScopes.getView().setColumnLines(true); + gridScopes.getView().setAutoFill(true); + gridScopes.setBorders(true); + gridScopes.setColumnReordering(false); + gridScopes.getView().setAutoExpandColumn(labelScopesCol); + gridScopes.getView().setSortingEnabled(true); + + // ChartTypeSelection storeComboChartType = new ListStore(new ModelKeyProvider() { @Override @@ -435,75 +448,41 @@ public class ActiveFiltersPanel extends SimpleContainer { }; - // /Grid Context - GenresDataProperties propsGenresData = GWT.create(GenresDataProperties.class); - - IdentityValueProvider identity = new IdentityValueProvider(); - smGenres = new CheckBoxSelectionModel(identity); - - labelGenresCol = new ColumnConfig(propsGenresData.label(), 356, "Genres"); - - labelGenresCol.setCell(new AbstractCell() { - - @Override - public void render(Context context, String value, SafeHtmlBuilder sb) { - sb.appendHtmlConstant("" + SafeHtmlUtils.htmlEscape(value) + ""); - - } - - }); - - List> lGenres = new ArrayList>(); - lGenres.add(smGenres.getColumn()); - lGenres.add(labelGenresCol); - ColumnModel cmGenresData = new ColumnModel(lGenres); - - storeGenres = new ListStore(propsGenresData.id()); - - gridGenres = new Grid(storeGenres, cmGenresData); - - sm.setSelectionMode(SelectionMode.MULTI); - gridGenres.setHeight("130px"); - gridGenres.setSelectionModel(smGenres); - gridGenres.getView().setStripeRows(true); - gridGenres.getView().setColumnLines(true); - gridGenres.getView().setAutoFill(true); - gridGenres.setBorders(true); - gridGenres.setColumnReordering(false); - gridGenres.getView().setAutoExpandColumn(labelGenresCol); - gridGenres.getView().setSortingEnabled(true); - - // / - comboChartType = new ComboBox<>(storeComboChartType, comboChartTypeLabelProvider); comboChartType.setClearValueOnParseError(false); comboChartType.setEditable(false); comboChartType.setForceSelection(true); - // comboFilterValue.setAllowBlank(false); comboChartType.setValue(ChartType.Basic); - // comboFilterValue.setFinishEditOnEnter(false); - // comboFilterValue.setAutoValidate(true); - // comboFilterValue.addValidator(new EmptyValidator()); comboChartType.setTriggerAction(TriggerAction.ALL); addHandlersForComboChartType(comboChartTypeLabelProvider); comboChartTypeLabel = new FieldLabel(comboChartType, "Chart"); - // TODO ScopeCombo for Top and Basic - GenresDataPropertiesCombo genresDataPropertiesCombo = GWT.create(GenresDataPropertiesCombo.class); - - storeComboScope = new ListStore(genresDataPropertiesCombo.id()); - comboScope = new ComboBox(storeComboScope, genresDataPropertiesCombo.label()); - comboScope.setClearValueOnParseError(false); - //comboScope.setEditable(false); - comboScope.setTypeAhead(true); - comboScope.setTriggerAction(TriggerAction.ALL); - - comboScope.getListView().addStyleName(AccountingManagerResources.INSTANCE.accountingManagerCSS().getScopeListView()); - - addHandlersForComboScope(genresDataPropertiesCombo.label()); - - comboScopeLabel = new FieldLabel(comboScope, "Scope"); + /* + * ScopeCombo for Top and Basic GenresDataPropertiesCombo + * scopeDataPropertiesCombo = + * GWT.create(GenresDataPropertiesCombo.class); + * + * storeComboScope = new + * ListStore(scopeDataPropertiesCombo.id()); + * + * comboScope = new ComboBox(storeComboScope, + * scopeDataPropertiesCombo.label()); + * + * comboScope.setClearValueOnParseError(false); + * + * comboScope.setTypeAhead(true); + * + * comboScope.setTriggerAction(TriggerAction.ALL); + * + * comboScope.getListView() + * .addStyleName(AccountingManagerResources.INSTANCE. + * accountingManagerCSS().getScopeListView()); + * + * addHandlersForComboScope(scopeDataPropertiesCombo.label()); + * + * comboScopeLabel = new FieldLabel(comboScope, "Scope"); + * + */ // FileterKeyCombo for Top Chart storeComboTopFilterKey = new ListStore(filterKeyPropertiesCombo.id()); @@ -547,36 +526,6 @@ public class ActiveFiltersPanel extends SimpleContainer { showOthersLabel = new FieldLabel(hp, "Show Others"); - // TODO NoContext Flag - noContextYes = new Radio(); - noContextYes.setBoxLabel("Yes"); - - noContextNo = new Radio(); - noContextNo.setBoxLabel("No"); - noContextNo.setValue(true); - - noContextToggle = new ToggleGroup(); - noContextToggle.add(noContextYes); - noContextToggle.add(noContextNo); - - noContextToggle.addValueChangeHandler(new ValueChangeHandler>() { - - @Override - public void onValueChange(ValueChangeEvent> event) { - ToggleGroup group = (ToggleGroup) event.getSource(); - Radio radio = (Radio) group.getValue(); - Log.debug("No Context selected: " + radio.getBoxLabel()); - } - }); - - HBoxLayoutContainer hpNoContext = new HBoxLayoutContainer(); - hpNoContext.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); - hpNoContext.setPack(BoxLayoutPack.START); - hpNoContext.add(noContextYes, new BoxLayoutData(new Margins(0))); - hpNoContext.add(noContextNo, new BoxLayoutData(new Margins(0))); - - noContextLabel = new FieldLabel(hpNoContext, "No Context"); - // topNumber = new IntegerSpinnerField(); topNumber.setMaxValue(TOP_NUMBER_MAX); @@ -591,10 +540,8 @@ public class ActiveFiltersPanel extends SimpleContainer { // // VerticalLayoutContainer vlc = new VerticalLayoutContainer(); - vlc.add(comboChartTypeLabel, new VerticalLayoutData(1, -1, new Margins(0))); - vlc.add(comboScopeLabel, new VerticalLayoutData(1, -1, new Margins(0))); - vlc.add(gridGenres, new VerticalLayoutData(1, -1, new Margins(0))); - vlc.add(noContextLabel, new VerticalLayoutData(1, -1, new Margins(0))); + vlc.add(gridScopes, new VerticalLayoutData(1, -1, new Margins(0))); + vlc.add(comboChartTypeLabel, new VerticalLayoutData(1, -1, new Margins(10,0,0,0))); vlc.add(comboTopFilterKeyLabel, new VerticalLayoutData(1, -1, new Margins(0))); vlc.add(showOthersLabel, new VerticalLayoutData(1, -1, new Margins(0))); vlc.add(topNumberLabel, new VerticalLayoutData(1, -1, new Margins(0))); @@ -602,16 +549,15 @@ public class ActiveFiltersPanel extends SimpleContainer { vlc.add(gridFilter, new VerticalLayoutData(1, 1, new Margins(0))); FieldSet fieldSet = new FieldSet(); - fieldSet.setHeight("360px"); + //fieldSet.setHeight("360px"); + fieldSet.setHeight("480px"); fieldSet.setHeadingHtml("Active Filters"); fieldSet.setCollapsible(false); fieldSet.add(vlc); add(fieldSet, new MarginData(0)); comboChartTypeLabel.setVisible(false); - comboScopeLabel.setVisible(false); - gridGenres.setVisible(false); - noContextLabel.setVisible(false); + gridScopes.setVisible(false); comboTopFilterKeyLabel.setVisible(false); showOthersLabel.setVisible(false); topNumberLabel.setVisible(false); @@ -727,11 +673,8 @@ public class ActiveFiltersPanel extends SimpleContainer { case Top: changeActiveFiltersForTop(); break; - case Context: - changeActiveFiltersForContext(); - break; case Spaces: - changeActiveFiltersForSpaces(); + // changeActiveFiltersForSpaces(); break; default: @@ -747,28 +690,55 @@ public class ActiveFiltersPanel extends SimpleContainer { .getSeriesRequest().getAccountingFilterDefinition() instanceof AccountingFilterBasic) { AccountingFilterBasic accountingFilterBasic = (AccountingFilterBasic) accountingStateData.getSeriesRequest() .getAccountingFilterDefinition(); - - if (accountingStateData.getAvailableContext().getContexts() != null + if (accountingStateData.getAvailableContext() != null + && accountingStateData.getAvailableContext().getContexts() != null && !accountingStateData.getAvailableContext().getContexts().isEmpty()) { - ArrayList scopesAvailables = accountingStateData.getAvailableContext().getContexts(); - ArrayList scopes = new ArrayList<>(); - for (String scopeAvailable : scopesAvailables) { - scopes.add(new GenresData(scopeAvailable)); - } - storeComboScope.clear(); - storeComboScope.addAll(scopes); - storeComboScope.commitChanges(); - if (accountingFilterBasic.getScope() != null && !accountingFilterBasic.getScope().isEmpty()) { - comboScope.setValue(new GenresData(accountingFilterBasic.getScope())); + if (accountingFilterBasic.getContext() != null + && accountingFilterBasic.getContext().getContexts() != null + && !accountingFilterBasic.getContext().getContexts().isEmpty()) { + ArrayList contexts = accountingStateData.getAvailableContext().getContexts(); + ArrayList scopes = new ArrayList(); + for (String context : contexts) { + ContextData contextData = new ContextData(context); + scopes.add(contextData); + } + storeScopes.clear(); + storeScopes.addAll(scopes); + storeScopes.commitChanges(); + + smScopes.deselectAll(); + + if (accountingFilterBasic.getContext().getContexts() == null + || accountingFilterBasic.getContext().getContexts().isEmpty()) { + } else { + ArrayList selected = new ArrayList<>(); + for (String c : accountingFilterBasic.getContext().getContexts()) { + for (ContextData contextData : storeScopes.getAll()) { + if (c.compareTo(contextData.getContextData()) == 0) { + selected.add(contextData); + break; + } + } + } + if (!selected.isEmpty()) { + if (selected.size() == storeScopes.getAll().size()) { + smScopes.selectAll(); + } else { + smScopes.select(selected, false); + } + } + } + + smScopes.refresh(); + } else { - comboScope.setValue(storeComboScope.get(0)); + repopulatesContexts(); } + } else { - storeComboScope.clear(); - storeComboScope.commitChanges(); + resetContexts(); } - if (accountingFilterBasic.getFilters() != null) { List filters = accountingFilterBasic.getFilters(); @@ -787,66 +757,23 @@ public class ActiveFiltersPanel extends SimpleContainer { seq = 0; } - if (accountingStateData.getRootScope()) { - noContextToggle.reset(); - if (accountingFilterBasic.isNoContext()) { - noContextYes.setValue(true); - } else { - noContextNo.setValue(true); - } - noContextLabel.setVisible(true); - } else { - noContextToggle.reset(); - noContextNo.setValue(true); - noContextLabel.setVisible(false); - } - } else { + reconfigureContext(); storeFilter.clear(); storeFilter.commitChanges(); seq = 0; - if (accountingStateData.getAvailableContext().getContexts() != null - && !accountingStateData.getAvailableContext().getContexts().isEmpty()) { - - ArrayList scopesAvailables = accountingStateData.getAvailableContext().getContexts(); - ArrayList scopes = new ArrayList<>(); - for (String scopeAvailable : scopesAvailables) { - scopes.add(new GenresData(scopeAvailable)); - } - - storeComboScope.clear(); - storeComboScope.addAll(scopes); - storeComboScope.commitChanges(); - comboScope.setValue(storeComboScope.get(0)); - - } else { - storeComboScope.clear(); - storeComboScope.commitChanges(); - } - - - if (accountingStateData.getRootScope()) { - noContextToggle.reset(); - noContextNo.setValue(true); - noContextLabel.setVisible(true); - } else { - noContextToggle.reset(); - noContextNo.setValue(true); - noContextLabel.setVisible(false); - } - } + gridScopes.setVisible(true); + labelScopesCol.setHeader("Scope"); + gridScopes.getView().refresh(true); comboChartType.setValue(ChartType.Basic); - comboScopeLabel.setVisible(true); - gridGenres.setVisible(false); comboTopFilterKey.reset(); comboTopFilterKeyLabel.setVisible(false); showOthersToggle.reset(); showOthersNo.setValue(true); showOthersLabel.setVisible(false); - topNumber.reset(); topNumberLabel.setVisible(false); forceLayout(); @@ -860,28 +787,55 @@ public class ActiveFiltersPanel extends SimpleContainer { AccountingFilterTop accountingFilterTop = (AccountingFilterTop) accountingStateData.getSeriesRequest() .getAccountingFilterDefinition(); - if (accountingStateData.getAvailableContext().getContexts() != null + if (accountingStateData.getAvailableContext() != null + && accountingStateData.getAvailableContext().getContexts() != null && !accountingStateData.getAvailableContext().getContexts().isEmpty()) { - ArrayList scopesAvailables = accountingStateData.getAvailableContext().getContexts(); - ArrayList scopes = new ArrayList<>(); - for (String scopeAvailable : scopesAvailables) { - scopes.add(new GenresData(scopeAvailable)); - } - storeComboScope.clear(); - storeComboScope.addAll(scopes); - storeComboScope.commitChanges(); - if (accountingFilterTop.getScope() != null && !accountingFilterTop.getScope().isEmpty()) { - comboScope.setValue(new GenresData(accountingFilterTop.getScope())); + if (accountingFilterTop.getContext() != null && accountingFilterTop.getContext().getContexts() != null + && !accountingFilterTop.getContext().getContexts().isEmpty()) { + ArrayList contexts = accountingStateData.getAvailableContext().getContexts(); + ArrayList scopes = new ArrayList(); + for (String context : contexts) { + ContextData contextData = new ContextData(context); + scopes.add(contextData); + } + storeScopes.clear(); + storeScopes.addAll(scopes); + storeScopes.commitChanges(); + + smScopes.deselectAll(); + + if (accountingFilterTop.getContext().getContexts() == null + || accountingFilterTop.getContext().getContexts().isEmpty()) { + } else { + ArrayList selected = new ArrayList<>(); + for (String c : accountingFilterTop.getContext().getContexts()) { + for (ContextData contextData : storeScopes.getAll()) { + if (c.compareTo(contextData.getContextData()) == 0) { + selected.add(contextData); + break; + } + } + } + if (!selected.isEmpty()) { + if (selected.size() == storeScopes.getAll().size()) { + smScopes.selectAll(); + } else { + smScopes.select(selected, false); + } + } + } + + smScopes.refresh(); + } else { - comboScope.setValue(storeComboScope.get(0)); + repopulatesContexts(); } + } else { - storeComboScope.clear(); - storeComboScope.commitChanges(); - comboScope.reset(); + resetContexts(); } - + if (accountingFilterTop.getFilterKey() != null) { comboTopFilterKey.setValue(accountingFilterTop.getFilterKey()); topNumber.setValue(accountingFilterTop.getTopNumber()); @@ -919,23 +873,23 @@ public class ActiveFiltersPanel extends SimpleContainer { if (accountingStateData.getAvailableContext().getContexts() != null && !accountingStateData.getAvailableContext().getContexts().isEmpty()) { - ArrayList scopesAvailables = accountingStateData.getAvailableContext().getContexts(); - ArrayList scopes = new ArrayList<>(); - for (String scopeAvailable : scopesAvailables) { - scopes.add(new GenresData(scopeAvailable)); + ArrayList contexts = accountingStateData.getAvailableContext().getContexts(); + ArrayList scopes = new ArrayList<>(); + for (String context : contexts) { + scopes.add(new ContextData(context)); } - storeComboScope.clear(); - storeComboScope.addAll(scopes); - storeComboScope.commitChanges(); - comboScope.setValue(storeComboScope.get(0)); + + storeScopes.clear(); + storeScopes.addAll(scopes); + storeScopes.commitChanges(); + smScopes.deselectAll(); } else { - storeComboScope.clear(); - storeComboScope.commitChanges(); - comboScope.reset(); + storeScopes.clear(); + storeScopes.commitChanges(); + smScopes.deselectAll(); } - comboScopeLabel.setVisible(true); comboTopFilterKey.reset(); showOthersToggle.reset(); showOthersNo.setValue(true); @@ -947,116 +901,16 @@ public class ActiveFiltersPanel extends SimpleContainer { } + gridScopes.setVisible(true); + labelScopesCol.setHeader("Scope"); + gridScopes.getView().refresh(true); comboChartType.setValue(ChartType.Top); - gridGenres.setVisible(false); comboTopFilterKeyLabel.setVisible(true); showOthersLabel.setVisible(true); - noContextToggle.reset(); - noContextNo.setValue(true); - noContextLabel.setVisible(false); topNumberLabel.setVisible(true); forceLayout(); } - private void changeActiveFiltersForContext() { - if (accountingStateData.getSeriesRequest() != null - && accountingStateData.getSeriesRequest().getAccountingFilterDefinition() != null && accountingStateData - .getSeriesRequest().getAccountingFilterDefinition() instanceof AccountingFilterContext) { - AccountingFilterContext accountingFilterContext = (AccountingFilterContext) accountingStateData - .getSeriesRequest().getAccountingFilterDefinition(); - if (accountingStateData.getAvailableContext() != null - && accountingStateData.getAvailableContext().getContexts() != null - && !accountingStateData.getAvailableContext().getContexts().isEmpty()) { - - if (accountingFilterContext.getContext() != null - && accountingFilterContext.getContext().getContexts() != null - && !accountingFilterContext.getContext().getContexts().isEmpty()) { - ArrayList contexts = accountingStateData.getAvailableContext().getContexts(); - ArrayList genres = new ArrayList(); - for (String context : contexts) { - GenresData genresData = new GenresData(context); - genres.add(genresData); - } - storeGenres.clear(); - storeGenres.addAll(genres); - storeGenres.commitChanges(); - - smGenres.deselectAll(); - - if (accountingFilterContext.getContext().getContexts() == null - || accountingFilterContext.getContext().getContexts().isEmpty()) { - } else { - ArrayList selected = new ArrayList<>(); - for (String c : accountingFilterContext.getContext().getContexts()) { - for (GenresData genresData : storeGenres.getAll()) { - if (c.compareTo(genresData.getGenre()) == 0) { - selected.add(genresData); - break; - } - } - } - if (!selected.isEmpty()) { - if (selected.size() == storeGenres.getAll().size()) { - smGenres.selectAll(); - } else { - smGenres.select(selected, false); - } - } - } - - smGenres.refresh(); - - } else { - repopulatesContexts(); - } - - } else { - resetContexts(); - } - - if (accountingFilterContext.getFilters() != null) { - List filters = accountingFilterContext.getFilters(); - storeFilter.clear(); - storeFilter.addAll(filters); - seq = 0; - for (AccountingFilter filter : filters) { - if (filter.getId() > seq) { - seq = filter.getId(); - } - } - storeFilter.commitChanges(); - } else { - storeFilter.clear(); - storeFilter.commitChanges(); - seq = 0; - } - - } else { - reconfigureContext(); - storeFilter.clear(); - storeFilter.commitChanges(); - seq = 0; - - } - comboChartType.setValue(ChartType.Context); - comboScopeLabel.setVisible(false); - gridGenres.setVisible(true); - labelGenresCol.setHeader("Scope"); - gridGenres.getView().refresh(true); - comboTopFilterKey.reset(); - comboTopFilterKeyLabel.setVisible(false); - showOthersToggle.reset(); - showOthersNo.setValue(true); - showOthersLabel.setVisible(false); - noContextToggle.reset(); - noContextNo.setValue(true); - noContextLabel.setVisible(false); - topNumber.reset(); - topNumberLabel.setVisible(false); - forceLayout(); - - } - private void reconfigureContext() { if (accountingStateData.getAvailableContext() != null && accountingStateData.getAvailableContext().getContexts() != null @@ -1068,155 +922,104 @@ public class ActiveFiltersPanel extends SimpleContainer { } private void resetContexts() { - storeGenres.clear(); - storeGenres.commitChanges(); - smGenres.deselectAll(); - smGenres.refresh(); + storeScopes.clear(); + storeScopes.commitChanges(); + smScopes.deselectAll(); + smScopes.refresh(); } private void repopulatesContexts() { ArrayList contexts = accountingStateData.getAvailableContext().getContexts(); - ArrayList genres = new ArrayList(); + ArrayList contextList = new ArrayList(); for (String context : contexts) { - GenresData genresData = new GenresData(context); - genres.add(genresData); + ContextData contextData = new ContextData(context); + contextList.add(contextData); } - storeGenres.clear(); - storeGenres.addAll(genres); - storeGenres.commitChanges(); - smGenres.selectAll(); - smGenres.refresh(); + storeScopes.clear(); + storeScopes.addAll(contextList); + storeScopes.commitChanges(); + smScopes.selectAll(); + smScopes.refresh(); } - private void changeActiveFiltersForSpaces() { - if (accountingStateData.getSeriesRequest() != null - && accountingStateData.getSeriesRequest().getAccountingFilterDefinition() != null && accountingStateData - .getSeriesRequest().getAccountingFilterDefinition() instanceof AccountingFilterSpaces) { - AccountingFilterSpaces accountingFilterSapces = (AccountingFilterSpaces) accountingStateData - .getSeriesRequest().getAccountingFilterDefinition(); - if (accountingStateData.getAvailableSpaces() != null - && accountingStateData.getAvailableSpaces().getSpacesList() != null - && !accountingStateData.getAvailableSpaces().getSpacesList().isEmpty()) { - - if (accountingFilterSapces.getSpaces() != null - && accountingFilterSapces.getSpaces().getSpacesList() != null - && !accountingFilterSapces.getSpaces().getSpacesList().isEmpty()) { - ArrayList spacesList = accountingStateData.getAvailableSpaces().getSpacesList(); - ArrayList genres = new ArrayList(); - for (String space : spacesList) { - GenresData genresData = new GenresData(space); - genres.add(genresData); - } - storeGenres.clear(); - storeGenres.addAll(genres); - storeGenres.commitChanges(); - - smGenres.deselectAll(); - - if (accountingFilterSapces.getSpaces().getSpacesList() == null - || accountingFilterSapces.getSpaces().getSpacesList().isEmpty()) { - } else { - ArrayList selected = new ArrayList<>(); - for (String s : accountingFilterSapces.getSpaces().getSpacesList()) { - for (GenresData genresData : storeGenres.getAll()) { - if (s.compareTo(genresData.getGenre()) == 0) { - selected.add(genresData); - break; - } - } - } - if (!selected.isEmpty()) { - if (selected.size() == storeGenres.getAll().size()) { - smGenres.selectAll(); - } else { - smGenres.select(selected, false); - } - } - } - - smGenres.refresh(); - - } else { - repopulatesSpaces(); - } - - } else { - resetSpaces(); - } - - if (accountingFilterSapces.getFilters() != null) { - List filters = accountingFilterSapces.getFilters(); - storeFilter.clear(); - storeFilter.addAll(filters); - seq = 0; - for (AccountingFilter filter : filters) { - if (filter.getId() > seq) { - seq = filter.getId(); - } - } - storeFilter.commitChanges(); - } else { - storeFilter.clear(); - storeFilter.commitChanges(); - seq = 0; - } - - } else { - reconfigureSpaces(); - storeFilter.clear(); - storeFilter.commitChanges(); - seq = 0; - - } - comboChartType.setValue(ChartType.Spaces); - comboScopeLabel.setVisible(false); - gridGenres.setVisible(true); - labelGenresCol.setHeader("Space"); - gridGenres.getView().refresh(true); - comboTopFilterKey.reset(); - comboTopFilterKeyLabel.setVisible(false); - showOthersToggle.reset(); - showOthersNo.setValue(true); - showOthersLabel.setVisible(false); - noContextToggle.reset(); - noContextNo.setValue(true); - noContextLabel.setVisible(false); - topNumber.reset(); - topNumberLabel.setVisible(false); - forceLayout(); - - } - - private void reconfigureSpaces() { - if (accountingStateData.getAvailableSpaces() != null - && accountingStateData.getAvailableSpaces().getSpacesList() != null - && !accountingStateData.getAvailableSpaces().getSpacesList().isEmpty()) { - repopulatesSpaces(); - } else { - resetSpaces(); - } - } - - private void resetSpaces() { - storeGenres.clear(); - storeGenres.commitChanges(); - smGenres.deselectAll(); - smGenres.refresh(); - } - - private void repopulatesSpaces() { - ArrayList spaces = accountingStateData.getAvailableSpaces().getSpacesList(); - ArrayList genres = new ArrayList(); - for (String space : spaces) { - GenresData genresData = new GenresData(space); - genres.add(genresData); - } - storeGenres.clear(); - storeGenres.addAll(genres); - storeGenres.commitChanges(); - smGenres.selectAll(); - smGenres.refresh(); - } + /* + * private void changeActiveFiltersForSpaces() { if + * (accountingStateData.getSeriesRequest() != null && + * accountingStateData.getSeriesRequest().getAccountingFilterDefinition() != + * null && accountingStateData + * .getSeriesRequest().getAccountingFilterDefinition() instanceof + * AccountingFilterSpaces) { AccountingFilterSpaces accountingFilterSapces = + * (AccountingFilterSpaces) accountingStateData + * .getSeriesRequest().getAccountingFilterDefinition(); if + * (accountingStateData.getAvailableSpaces() != null && + * accountingStateData.getAvailableSpaces().getSpacesList() != null && + * !accountingStateData.getAvailableSpaces().getSpacesList().isEmpty()) { + * + * if (accountingFilterSapces.getSpaces() != null && + * accountingFilterSapces.getSpaces().getSpacesList() != null && + * !accountingFilterSapces.getSpaces().getSpacesList().isEmpty()) { + * ArrayList spacesList = + * accountingStateData.getAvailableSpaces().getSpacesList(); + * ArrayList spaces = new ArrayList<>(); for (String space : + * spacesList) { SpacesData spacesData = new SpacesData(space); + * spaces.add(spacesData); } storeSpaces.clear(); + * storeSpaces.addAll(spaces); storeSpaces.commitChanges(); + * + * smSpaces.deselectAll(); + * + * if (accountingFilterSapces.getSpaces().getSpacesList() == null || + * accountingFilterSapces.getSpaces().getSpacesList().isEmpty()) { } else { + * ArrayList selected = new ArrayList<>(); for (String s : + * accountingFilterSapces.getSpaces().getSpacesList()) { for (SpacesData + * spacesData : storeSpaces.getAll()) { if + * (s.compareTo(spacesData.getSpace()) == 0) { selected.add(spacesData); + * break; } } } if (!selected.isEmpty()) { if (selected.size() == + * storeSpaces.getAll().size()) { smSpaces.selectAll(); } else { + * smSpaces.select(selected, false); } } } + * + * smSpaces.refresh(); + * + * } else { repopulatesSpaces(); } + * + * } else { resetSpaces(); } + * + * if (accountingFilterSapces.getFilters() != null) { List + * filters = accountingFilterSapces.getFilters(); storeFilter.clear(); + * storeFilter.addAll(filters); seq = 0; for (AccountingFilter filter : + * filters) { if (filter.getId() > seq) { seq = filter.getId(); } } + * storeFilter.commitChanges(); } else { storeFilter.clear(); + * storeFilter.commitChanges(); seq = 0; } + * + * } else { reconfigureSpaces(); storeFilter.clear(); + * storeFilter.commitChanges(); seq = 0; + * + * } gridScopes.setVisible(false); labelScopesCol.setHeader("Space"); + * gridScopes.getView().refresh(true); + * comboChartType.setValue(ChartType.Spaces); comboTopFilterKey.reset(); + * comboTopFilterKeyLabel.setVisible(false); showOthersToggle.reset(); + * showOthersNo.setValue(true); showOthersLabel.setVisible(false); + * topNumber.reset(); topNumberLabel.setVisible(false); forceLayout(); + * + * } + * + * private void reconfigureSpaces() { if + * (accountingStateData.getAvailableSpaces() != null && + * accountingStateData.getAvailableSpaces().getSpacesList() != null && + * !accountingStateData.getAvailableSpaces().getSpacesList().isEmpty()) { + * repopulatesSpaces(); } else { resetSpaces(); } } + * + * private void resetSpaces() { storeScopes.clear(); + * storeScopes.commitChanges(); smScopes.deselectAll(); smScopes.refresh(); + * } + * + * private void repopulatesSpaces() { ArrayList spaces = + * accountingStateData.getAvailableSpaces().getSpacesList(); + * ArrayList genres = new ArrayList(); for (String + * space : spaces) { ScopeData genresData = new ScopeData(space); + * genres.add(genresData); } storeScopes.clear(); + * storeScopes.addAll(genres); storeScopes.commitChanges(); + * smScopes.selectAll(); smScopes.refresh(); } + */ public AccountingFilterDefinition getActiveFilters() { try { @@ -1227,10 +1030,8 @@ public class ActiveFiltersPanel extends SimpleContainer { return getActiveFiltersForBasic(); case Top: return getActiveFiltersForTop(); - case Context: - return getActiveFiltersForContext(); - case Spaces: - return getActiveFiltersForSpaces(); + //case Spaces: + // return getActiveFiltersForSpaces(); default: return null; @@ -1246,25 +1047,19 @@ public class ActiveFiltersPanel extends SimpleContainer { // TODO private AccountingFilterDefinition getActiveFiltersForBasic() { - String scope = null; - if (comboScopeLabel != null && comboScopeLabel.isVisible()) { - GenresData genresData = comboScope.getCurrentValue(); - if (genresData != null) { - scope = genresData.getLabel(); + ArrayList contextsSelected = new ArrayList(); + if (storeScopes != null && storeScopes.size() > 0 && smScopes != null) { + List selected = smScopes.getSelectedItems(); + for (ContextData cd : selected) { + contextsSelected.add(cd.getContextData()); } } - Log.debug("Scope selected: " + scope); + Context context = new Context(contextsSelected); - Boolean noContextValue = false; - if (noContextLabel != null && noContextLabel.isVisible()) { - noContextValue = noContextYes.getValue(); - } else { - noContextValue = false; - } - Log.debug("noContextValue: " + noContextValue); + Log.debug("Context selected: " + context); if (storeFilter == null || storeFilter.size() <= 0) { - return new AccountingFilterBasic(scope, noContextValue); + return new AccountingFilterBasic(context); } else { List filtersActives = storeFilter.getAll(); ArrayList filtersReady = new ArrayList(); @@ -1275,32 +1070,35 @@ public class ActiveFiltersPanel extends SimpleContainer { } if (filtersReady.size() > 0) { - return new AccountingFilterBasic(scope, filtersReady, noContextValue); + return new AccountingFilterBasic(context, filtersReady); } else { - return new AccountingFilterBasic(scope, noContextValue); + return new AccountingFilterBasic(context); } } } private AccountingFilterDefinition getActiveFiltersForTop() { - String scope = null; - if (comboScopeLabel != null && comboScopeLabel.isVisible()) { - GenresData genresData = comboScope.getCurrentValue(); - if (genresData != null) { - scope = genresData.getLabel(); + ArrayList contextsSelected = new ArrayList(); + if (storeScopes != null && storeScopes.size() > 0 && smScopes != null) { + List selected = smScopes.getSelectedItems(); + for (ContextData cd : selected) { + contextsSelected.add(cd.getContextData()); } } - Log.debug("Scope selected: " + scope); + Context context = new Context(contextsSelected); + + Log.debug("Context selected: " + context); + Boolean showOthersValue = showOthersYes.getValue(); Integer topN = topNumber.getCurrentValue(); FilterKey filterKey = comboTopFilterKey.getCurrentValue(); if (filterKey == null) { - return new AccountingFilterTop(scope, showOthersValue, topN); + return new AccountingFilterTop(context, showOthersValue, topN); } else { if (storeFilter == null || storeFilter.size() <= 0) { - return new AccountingFilterTop(scope, filterKey, null, showOthersValue, topN); + return new AccountingFilterTop(context, filterKey, null, showOthersValue, topN); } else { List filtersActives = storeFilter.getAll(); ArrayList filtersReady = new ArrayList(); @@ -1310,9 +1108,9 @@ public class ActiveFiltersPanel extends SimpleContainer { } } if (filtersReady.size() > 0) { - return new AccountingFilterTop(scope, filterKey, filtersReady, showOthersValue, topN); + return new AccountingFilterTop(context, filterKey, filtersReady, showOthersValue, topN); } else { - return new AccountingFilterTop(scope, filterKey, null, showOthersValue, topN); + return new AccountingFilterTop(context, filterKey, null, showOthersValue, topN); } } @@ -1320,42 +1118,19 @@ public class ActiveFiltersPanel extends SimpleContainer { } - private AccountingFilterDefinition getActiveFiltersForContext() { - ArrayList contextsSelected = new ArrayList(); - if (storeGenres != null && storeGenres.size() > 0 && smGenres != null) { - List selected = smGenres.getSelectedItems(); - for (GenresData cd : selected) { - contextsSelected.add(cd.getGenre()); - } - } - org.gcube.portlets.admin.accountingmanager.shared.data.Context context = new org.gcube.portlets.admin.accountingmanager.shared.data.Context( - contextsSelected); - - List filtersActives = storeFilter.getAll(); - ArrayList filtersReady = new ArrayList(); - for (AccountingFilter filter : filtersActives) { - if (filter.getFilterValue() != null && !filter.getFilterValue().isEmpty()) { - filtersReady.add(filter); - } - } - if (filtersReady.size() > 0) { - return new AccountingFilterContext(context, filtersReady); - } else { - return new AccountingFilterContext(context, null); - } - - } - + /* private AccountingFilterDefinition getActiveFiltersForSpaces() { ArrayList spacesSelected = new ArrayList(); - if (storeGenres != null && storeGenres.size() > 0 && smGenres != null) { - List selected = smGenres.getSelectedItems(); - for (GenresData cd : selected) { - spacesSelected.add(cd.getGenre()); + if (storeSpaces != null && storeSpaces.size() > 0 && smSpaces != null) { + List selected = smSpaces.getSelectedItems(); + for (SpacesData cd : selected) { + spacesSelected.add(cd.getSpace()); } } Spaces spaces = new Spaces(spacesSelected); - + + Log.debug("Spaces selected: " + spaces); + List filtersActives = storeFilter.getAll(); ArrayList filtersReady = new ArrayList(); for (AccountingFilter filter : filtersActives) { @@ -1369,7 +1144,7 @@ public class ActiveFiltersPanel extends SimpleContainer { return new AccountingFilterSpaces(spaces, null); } - } + }*/ private void addNewFilter(SelectEvent event) { List filtersSet = storeFilter.getAll(); @@ -1564,24 +1339,11 @@ public class ActiveFiltersPanel extends SimpleContainer { } switch (chartType) { case Basic: - comboScopeLabel.setVisible(true); - gridGenres.setVisible(false); comboTopFilterKey.reset(); comboTopFilterKeyLabel.setVisible(false); showOthersToggle.reset(); showOthersNo.setValue(true); showOthersLabel.setVisible(false); - - if (accountingStateData.getRootScope()) { - noContextToggle.reset(); - noContextNo.setValue(true); - noContextLabel.setVisible(true); - } else { - noContextToggle.reset(); - noContextNo.setValue(true); - noContextLabel.setVisible(false); - } - topNumber.reset(); topNumberLabel.setVisible(false); storeFilter.clear(); @@ -1590,8 +1352,6 @@ public class ActiveFiltersPanel extends SimpleContainer { forceLayout(); break; case Top: - comboScopeLabel.setVisible(true); - gridGenres.setVisible(false); comboTopFilterKey.reset(); if (accountingStateData != null && accountingStateData.getAvailableFilterKeys() != null && accountingStateData.getAvailableFilterKeys().size() > 0) { @@ -1601,10 +1361,6 @@ public class ActiveFiltersPanel extends SimpleContainer { showOthersToggle.reset(); showOthersNo.setValue(true); showOthersLabel.setVisible(true); - noContextToggle.reset(); - noContextYes.setValue(false); - noContextNo.setValue(true); - noContextLabel.setVisible(false); topNumber.reset(); topNumber.setValue(TOP_NUMBER_DEFAULT); topNumberLabel.setVisible(true); @@ -1613,50 +1369,25 @@ public class ActiveFiltersPanel extends SimpleContainer { seq = 0; forceLayout(); break; - case Context: - reconfigureContext(); - comboScopeLabel.setVisible(false); - gridGenres.setVisible(true); - labelGenresCol.setHeader("Scope"); - gridGenres.getView().refresh(true); - comboTopFilterKey.reset(); - comboTopFilterKeyLabel.setVisible(false); - showOthersToggle.reset(); - showOthersNo.setValue(true); - showOthersLabel.setVisible(false); - noContextToggle.reset(); - noContextYes.setValue(false); - noContextNo.setValue(true); - noContextLabel.setVisible(false); - topNumber.reset(); - topNumberLabel.setVisible(false); - storeFilter.clear(); - storeFilter.commitChanges(); - seq = 0; - forceLayout(); - break; + /* case Spaces: reconfigureSpaces(); comboScopeLabel.setVisible(false); - gridGenres.setVisible(true); - labelGenresCol.setHeader("Space"); - gridGenres.getView().refresh(true); + gridScopes.setVisible(true); + labelScopesCol.setHeader("Space"); + gridScopes.getView().refresh(true); comboTopFilterKey.reset(); comboTopFilterKeyLabel.setVisible(false); showOthersToggle.reset(); showOthersNo.setValue(true); showOthersLabel.setVisible(false); - noContextToggle.reset(); - noContextYes.setValue(false); - noContextNo.setValue(true); - noContextLabel.setVisible(false); topNumber.reset(); topNumberLabel.setVisible(false); storeFilter.clear(); storeFilter.commitChanges(); seq = 0; forceLayout(); - break; + break;*/ default: break; @@ -1680,18 +1411,4 @@ public class ActiveFiltersPanel extends SimpleContainer { seq = 0; } - private void addHandlersForComboScope(final LabelProvider labelProvider) { - comboScope.addSelectionHandler(new SelectionHandler() { - public void onSelection(SelectionEvent event) { - Log.debug("Scope selected: " + event.getSelectedItem()); - updateScope(event.getSelectedItem()); - } - - }); - } - - private void updateScope(GenresData selectedFilterKey) { - - } - } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Job.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Job.java index 8646eb1..a700476 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Job.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Job.java @@ -1,7 +1,6 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartBasicPanel; -import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartContextPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartTopPanel; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; @@ -13,7 +12,7 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer; /** * Accounting Chart 4 Job * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ @@ -22,8 +21,7 @@ public class AccountingChart4Job extends AccountingChartBuilder { private AccountingClientStateData accountingStateData; private EventBus eventBus; - public AccountingChart4Job(EventBus eventBus, - AccountingClientStateData accountingStateData) { + public AccountingChart4Job(EventBus eventBus, AccountingClientStateData accountingStateData) { this.eventBus = eventBus; this.accountingStateData = accountingStateData; } @@ -32,10 +30,8 @@ public class AccountingChart4Job extends AccountingChartBuilder { public void buildChart() throws ChartDrawException { AccountingChartPanel accountingChartPanel = null; - if (accountingStateData == null - || accountingStateData.getAccountingType() == null - || accountingStateData.getSeriesRequest() == null - || accountingStateData.getSeriesResponse() == null) { + if (accountingStateData == null || accountingStateData.getAccountingType() == null + || accountingStateData.getSeriesRequest() == null || accountingStateData.getSeriesResponse() == null) { accountingChartSpec.setChart(accountingChartPanel); return; } @@ -55,25 +51,18 @@ public class AccountingChart4Job extends AccountingChartBuilder { private SimpleContainer createJobChartPanel() throws ChartDrawException { - if (accountingStateData == null - || accountingStateData.getSeriesRequest() == null - || accountingStateData.getSeriesRequest() - .getAccountingFilterDefinition() == null - || accountingStateData.getSeriesRequest() - .getAccountingFilterDefinition().getChartType() == null) { + if (accountingStateData == null || accountingStateData.getSeriesRequest() == null + || accountingStateData.getSeriesRequest().getAccountingFilterDefinition() == null + || accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType() == null) { return null; } - switch (accountingStateData.getSeriesRequest() - .getAccountingFilterDefinition().getChartType()) { + switch (accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType()) { case Top: return new JobChartTopPanel(eventBus, accountingStateData); case Basic: return new JobChartBasicPanel(eventBus, accountingStateData); - case Context: - return new JobChartContextPanel(eventBus, accountingStateData); - default: return null; } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Service.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Service.java index 6db438b..ec9cb3f 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Service.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Service.java @@ -1,7 +1,6 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartBasicPanel; -import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartContextPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartTopPanel; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; @@ -13,17 +12,16 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer; /** * Accounting Chart 4 Service * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ public class AccountingChart4Service extends AccountingChartBuilder { private EventBus eventBus; private AccountingClientStateData accountingStateData; - public AccountingChart4Service(EventBus eventBus, AccountingClientStateData accountingStateData) { - this.eventBus=eventBus; + this.eventBus = eventBus; this.accountingStateData = accountingStateData; } @@ -31,10 +29,8 @@ public class AccountingChart4Service extends AccountingChartBuilder { public void buildChart() throws ChartDrawException { AccountingChartPanel accountingChartPanel = null; - if (accountingStateData == null - || accountingStateData.getAccountingType() == null - || accountingStateData.getSeriesRequest() == null - || accountingStateData.getSeriesResponse() == null) { + if (accountingStateData == null || accountingStateData.getAccountingType() == null + || accountingStateData.getSeriesRequest() == null || accountingStateData.getSeriesResponse() == null) { accountingChartSpec.setChart(accountingChartPanel); return; } @@ -52,28 +48,20 @@ public class AccountingChart4Service extends AccountingChartBuilder { } - private SimpleContainer createServiceChartPanel() - throws ChartDrawException { + private SimpleContainer createServiceChartPanel() throws ChartDrawException { - if (accountingStateData == null - || accountingStateData.getSeriesRequest() == null - || accountingStateData.getSeriesRequest() - .getAccountingFilterDefinition() == null - || accountingStateData.getSeriesRequest() - .getAccountingFilterDefinition().getChartType() == null) { + if (accountingStateData == null || accountingStateData.getSeriesRequest() == null + || accountingStateData.getSeriesRequest().getAccountingFilterDefinition() == null + || accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType() == null) { return null; } - switch (accountingStateData.getSeriesRequest() - .getAccountingFilterDefinition().getChartType()) { + switch (accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType()) { case Top: - return new ServiceChartTopPanel(eventBus,accountingStateData); + return new ServiceChartTopPanel(eventBus, accountingStateData); case Basic: return new ServiceChartBasicPanel(eventBus, accountingStateData); - case Context: - return new ServiceChartContextPanel(eventBus, accountingStateData); - default: return null; diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Storage.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Storage.java index 0b2cb46..f70fe7f 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Storage.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Storage.java @@ -1,7 +1,6 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartBasicPanel; -import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartContextPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartTopPanel; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; @@ -13,7 +12,7 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer; /** * Accounting Chart 4 Storage * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ @@ -21,8 +20,7 @@ public class AccountingChart4Storage extends AccountingChartBuilder { private EventBus eventBus; private AccountingClientStateData accountingStateData; - public AccountingChart4Storage(EventBus eventBus, - AccountingClientStateData accountingStateData) { + public AccountingChart4Storage(EventBus eventBus, AccountingClientStateData accountingStateData) { this.eventBus = eventBus; this.accountingStateData = accountingStateData; } @@ -31,10 +29,8 @@ public class AccountingChart4Storage extends AccountingChartBuilder { public void buildChart() throws ChartDrawException { AccountingChartPanel accountingChartPanel = null; - if (accountingStateData == null - || accountingStateData.getAccountingType() == null - || accountingStateData.getSeriesRequest() == null - || accountingStateData.getSeriesResponse() == null) { + if (accountingStateData == null || accountingStateData.getAccountingType() == null + || accountingStateData.getSeriesRequest() == null || accountingStateData.getSeriesResponse() == null) { accountingChartSpec.setChart(accountingChartPanel); return; } @@ -54,25 +50,18 @@ public class AccountingChart4Storage extends AccountingChartBuilder { private SimpleContainer createStorageChartPanel() throws ChartDrawException { - if (accountingStateData == null - || accountingStateData.getSeriesRequest() == null - || accountingStateData.getSeriesRequest() - .getAccountingFilterDefinition() == null - || accountingStateData.getSeriesRequest() - .getAccountingFilterDefinition().getChartType() == null) { + if (accountingStateData == null || accountingStateData.getSeriesRequest() == null + || accountingStateData.getSeriesRequest().getAccountingFilterDefinition() == null + || accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType() == null) { return null; } - switch (accountingStateData.getSeriesRequest() - .getAccountingFilterDefinition().getChartType()) { + switch (accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType()) { case Top: return new StorageChartTopPanel(eventBus, accountingStateData); case Basic: return new StorageChartBasicPanel(eventBus, accountingStateData); - case Context: - return new StorageChartContextPanel(eventBus, accountingStateData); - default: return null; diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/AccountingFilterProperties.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/AccountingFilterProperties.java index 70cacfa..8af6ab0 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/AccountingFilterProperties.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/AccountingFilterProperties.java @@ -9,8 +9,7 @@ import com.sencha.gxt.data.shared.PropertyAccess; /** * - * @author giancarlo - * email: g.panichi@isti.cnr.it + * @author Giancarlo Panichi * */ public interface AccountingFilterProperties extends diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/AccountingPeriodModePropertiesCombo.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/AccountingPeriodModePropertiesCombo.java index 6241279..5325e59 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/AccountingPeriodModePropertiesCombo.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/AccountingPeriodModePropertiesCombo.java @@ -9,12 +9,10 @@ import com.sencha.gxt.data.shared.PropertyAccess; /** * - * @author giancarlo - * email: g.panichi@isti.cnr.it - * + * @author Giancarlo Panichi + * */ -public interface AccountingPeriodModePropertiesCombo extends - PropertyAccess { +public interface AccountingPeriodModePropertiesCombo extends PropertyAccess { @Path("id") ModelKeyProvider id(); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/GenresDataProperties.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/ContextDataProperties.java similarity index 50% rename from src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/GenresDataProperties.java rename to src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/ContextDataProperties.java index 08cfbf2..082f1a7 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/GenresDataProperties.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/properties/ContextDataProperties.java @@ -1,6 +1,6 @@ package org.gcube.portlets.admin.accountingmanager.client.properties; -import org.gcube.portlets.admin.accountingmanager.shared.data.GenresData; +import org.gcube.portlets.admin.accountingmanager.shared.data.ContextData; import com.google.gwt.editor.client.Editor.Path; import com.sencha.gxt.core.client.ValueProvider; @@ -9,13 +9,14 @@ import com.sencha.gxt.data.shared.PropertyAccess; /** * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ -public interface GenresDataProperties extends PropertyAccess { - @Path("genre") - ModelKeyProvider id(); +public interface ContextDataProperties extends PropertyAccess { - ValueProvider label(); + @Path("contextData") + ModelKeyProvider id(); + + ValueProvider label(); } 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 76156fc..3f16bfb 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,11 +3,10 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice; import java.util.ArrayList; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandBasic; -import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandContext; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetFilterKeys; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetFilterValues; -import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandSpaces; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetSpaces; +import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandSpaces; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandTop; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Job; @@ -18,15 +17,14 @@ import org.gcube.portlets.admin.accountingmanager.server.amservice.query.Account import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Task; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryBasic; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryBuilder; -import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryContext; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryDirector; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuerySpaces; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryTop; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; -import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesResponse; +import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -102,11 +100,6 @@ public class AccountingCaller implements AccountingCallerInterface { AccountingCommandTop accountingCommandTop = new AccountingCommandTop( accountingQueryTop, accountingType); return accountingCommandTop.execute(); - case Context: - AccountingQueryContext accountingQueryContext = (AccountingQueryContext) query; - AccountingCommandContext accountingCommandContext = new AccountingCommandContext( - accountingQueryContext, accountingType); - return accountingCommandContext.execute(); case Spaces: AccountingQuerySpaces accountingQuerySpace = (AccountingQuerySpaces) query; AccountingCommandSpaces accountingCommandSpace = new AccountingCommandSpaces( diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCallerTester.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCallerTester.java index 4a6dc21..50bcd4d 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCallerTester.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCallerTester.java @@ -12,12 +12,11 @@ import java.util.List; import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; -import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces; -import org.gcube.portlets.admin.accountingmanager.shared.data.Context; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesResponse; +import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; @@ -25,27 +24,21 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesSer import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesSpace; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceSpaces; import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceDataSpaces; import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceDefinition; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceSpaces; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop; @@ -229,26 +222,6 @@ public class AccountingCallerTester implements AccountingCallerInterface { accountingFilterTop.getTopNumber(), seriesJobDataTopList); break; - case Context: - // AccountingFilterContext accountingFilterContext = - // (AccountingFilterContext) seriesRequest - // .getAccountingFilterDefinition(); - ArrayList seriesJobDataContextList = new ArrayList<>(); - ArrayList contexts = new ArrayList<>(); - - for (int i = 0; i < 20; i++) { - String scope = new String("VRE " + i); - contexts.add(scope); - SeriesJobDataContext seriesJobDataContext = new SeriesJobDataContext( - scope, seriesJobData); - seriesJobDataContextList.add(seriesJobDataContext); - } - - Context context = new Context(contexts); - serieJobDefinition = new SeriesJobContext(context, - seriesJobDataContextList); - - break; default: break; @@ -407,25 +380,6 @@ public class AccountingCallerTester implements AccountingCallerInterface { accountingFilterTop.getTopNumber(), seriesServiceDataTopList); break; - case Context: - // AccountingFilterContext accountingFilterContext = - // (AccountingFilterContext) seriesRequest - // .getAccountingFilterDefinition(); - ArrayList seriesServiceDataContextList = new ArrayList<>(); - ArrayList contexts = new ArrayList<>(); - - for (int i = 0; i < 20; i++) { - String scope = new String("VRE " + i); - contexts.add(scope); - SeriesServiceDataContext seriesServiceDataContext = new SeriesServiceDataContext( - scope, seriesServiceData); - seriesServiceDataContextList - .add(seriesServiceDataContext); - } - - Context context = new Context(contexts); - serieServiceDefinition = new SeriesServiceContext( - context, seriesServiceDataContextList); default: break; @@ -479,8 +433,6 @@ public class AccountingCallerTester implements AccountingCallerInterface { .getChartType()) { case Basic: case Top: - case Context: - break; case Spaces: // AccountingFilterContext accountingFilterContext = // (AccountingFilterContext) seriesRequest @@ -576,27 +528,6 @@ public class AccountingCallerTester implements AccountingCallerInterface { accountingFilterTop.getTopNumber(), seriesStorageDataTopList); break; - case Context: - // AccountingFilterContext accountingFilterContext = - // (AccountingFilterContext) seriesRequest - // .getAccountingFilterDefinition(); - ArrayList seriesStorageDataContextList = new ArrayList<>(); - ArrayList contexts = new ArrayList<>(); - - for (int i = 0; i < 20; i++) { - String scope = new String("VRE " + i); - contexts.add(scope); - SeriesStorageDataContext seriesStorageDataContext = new SeriesStorageDataContext( - scope, seriesStorageData); - seriesStorageDataContextList - .add(seriesStorageDataContext); - } - - Context context = new Context(contexts); - serieStorageDefinition = new SeriesStorageContext( - context, seriesStorageDataContextList); - - break; default: break; diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandBasic.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandBasic.java index 8601461..4afbe39 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandBasic.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandBasic.java @@ -2,6 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice.command; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashSet; import java.util.List; import java.util.SortedMap; @@ -43,27 +44,31 @@ public class AccountingCommandBasic implements AccountingCommand public SeriesResponse execute() throws ServiceException { try { - if (accountingQueryBasic.getScope() != null && !accountingQueryBasic.getScope().isEmpty()) { - AccountingPersistenceQueryFactory.getForcedQueryScope().set(accountingQueryBasic.getScope()); - } + //if (accountingQueryBasic.getScope() != null) { + // AccountingPersistenceQueryFactory.getForcedQueryScope().set(accountingQueryBasic.getScope()); + //} AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance(); SortedMap sm = null; - if (accountingQueryBasic.isNoContext()) { - logger.debug("Execute NoContextTimeSeries()"); - sm = apq.getNoContextTimeSeries(accountingQueryBasic.getType(), - accountingQueryBasic.getTemporalConstraint(), accountingQueryBasic.getFilters(), true); - } else { - logger.debug("Execute TimeSeries()"); - sm = apq.getTimeSeries(accountingQueryBasic.getType(), accountingQueryBasic.getTemporalConstraint(), - accountingQueryBasic.getFilters(), true); - + logger.debug("Execute Basic()"); + apq.setRequestedRecords(accountingQueryBasic.getType()); + HashSet ctx=null; + if(accountingQueryBasic.getContext()!=null&&accountingQueryBasic.getContext().getContexts()!=null + &&!accountingQueryBasic.getContext().getContexts().isEmpty()){ + ctx=new HashSet(accountingQueryBasic.getContext().getContexts()); } + apq.setContexts(ctx); + apq.setTemporalConstraint(accountingQueryBasic.getTemporalConstraint()); + apq.setFilters(accountingQueryBasic.getFilters()); + sm=apq.getTimeSeries(true); + + //sm = apq.getTimeSeries(accountingQueryBasic.getType(), accountingQueryBasic.getTemporalConstraint(), + // accountingQueryBasic.getFilters(), true); - if (accountingQueryBasic.getScope() != null && !accountingQueryBasic.getScope().isEmpty()) { - AccountingPersistenceQueryFactory.getForcedQueryScope().remove(); - } + //if (accountingQueryBasic.getScope() != null) { + // AccountingPersistenceQueryFactory.getForcedQueryScope().remove(); + //} if (sm == null || sm.values() == null) { throw new ServiceException("Error retrieving info: sorted map is null!"); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetFilterValues.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetFilterValues.java index 9e4702f..14b3aa0 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetFilterValues.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetFilterValues.java @@ -27,19 +27,16 @@ import org.slf4j.LoggerFactory; /** * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ -public class AccountingCommandGetFilterValues implements - AccountingCommand { - private static final Logger logger = LoggerFactory - .getLogger(AccountingCommandGetFilterValues.class); +public class AccountingCommandGetFilterValues implements AccountingCommand { + private static final Logger logger = LoggerFactory.getLogger(AccountingCommandGetFilterValues.class); private SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMMMM dd"); private FilterValuesRequest filterValuesRequest; - public AccountingCommandGetFilterValues( - FilterValuesRequest filterValuesRequest) { + public AccountingCommandGetFilterValues(FilterValuesRequest filterValuesRequest) { this.filterValuesRequest = filterValuesRequest; } @@ -47,14 +44,11 @@ public class AccountingCommandGetFilterValues implements @Override public FilterValuesResponse execute() throws ServiceException { try { - logger.debug("getFilterValue(): [FilterValueRequest=" - + filterValuesRequest + "]"); + logger.debug("getFilterValue(): [FilterValueRequest=" + filterValuesRequest + "]"); FilterValuesResponse filterValuesResponse = null; - if (filterValuesRequest == null - || filterValuesRequest.getAccountingType() == null + if (filterValuesRequest == null || filterValuesRequest.getAccountingType() == null || filterValuesRequest.getFilterKey() == null) { - filterValuesResponse = new FilterValuesResponse( - new ArrayList()); + filterValuesResponse = new FilterValuesResponse(new ArrayList()); return filterValuesResponse; } @@ -62,24 +56,19 @@ public class AccountingCommandGetFilterValues implements Set values; - AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory - .getInstance(); + AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance(); - Calendar startCalendar = GregorianCalendar - .getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); + Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); try { - startCalendar.setTime(sdf.parse(filterValuesRequest - .getAccountingPeriod().getStartDate())); + startCalendar.setTime(sdf.parse(filterValuesRequest.getAccountingPeriod().getStartDate())); } catch (ParseException e) { e.printStackTrace(); throw new ServiceException("Start Date not valid!"); } - Calendar endCalendar = GregorianCalendar - .getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); + Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); try { - endCalendar.setTime(sdf.parse(filterValuesRequest - .getAccountingPeriod().getEndDate())); + endCalendar.setTime(sdf.parse(filterValuesRequest.getAccountingPeriod().getEndDate())); } catch (ParseException e) { e.printStackTrace(); throw new ServiceException("End Date not valid!"); @@ -90,19 +79,18 @@ public class AccountingCommandGetFilterValues implements endCalendar.set(GregorianCalendar.SECOND, 59); endCalendar.set(GregorianCalendar.MILLISECOND, 999); - TemporalConstraint tc = new TemporalConstraint( - startCalendar.getTimeInMillis(), + TemporalConstraint tc = new TemporalConstraint(startCalendar.getTimeInMillis(), endCalendar.getTimeInMillis(), - PeriodModeMap.getMode(filterValuesRequest - .getAccountingPeriod().getPeriod())); + PeriodModeMap.getMode(filterValuesRequest.getAccountingPeriod().getPeriod())); List filters = new ArrayList<>(); switch (filterValuesRequest.getAccountingType()) { case JOB: - values = apq.getFilterValues(AggregatedJobUsageRecord.class, - tc, filters, filterValuesRequest.getFilterKey() - .getKey()); + apq.setRequestedRecords(AggregatedJobUsageRecord.class); + apq.setTemporalConstraint(tc); + apq.setFilters(filters); + values = apq.getFilterValues(filterValuesRequest.getFilterKey().getKey()); break; case PORTLET: // values = rrq.getPossibleValuesForKey( @@ -111,14 +99,16 @@ public class AccountingCommandGetFilterValues implements filterValuesResponse = new FilterValuesResponse(filterValues); return filterValuesResponse; case SERVICE: - values = apq.getFilterValues( - AggregatedServiceUsageRecord.class, tc, filters, - filterValuesRequest.getFilterKey().getKey()); + apq.setRequestedRecords(AggregatedServiceUsageRecord.class); + apq.setTemporalConstraint(tc); + apq.setFilters(filters); + values = apq.getFilterValues(filterValuesRequest.getFilterKey().getKey()); break; case STORAGE: - values = apq.getFilterValues( - AggregatedStorageUsageRecord.class, tc, filters, - filterValuesRequest.getFilterKey().getKey()); + apq.setRequestedRecords(AggregatedStorageUsageRecord.class); + apq.setTemporalConstraint(tc); + apq.setFilters(filters); + values = apq.getFilterValues(filterValuesRequest.getFilterKey().getKey()); break; case TASK: // values = rrq.getPossibleValuesForKey( @@ -127,9 +117,10 @@ public class AccountingCommandGetFilterValues implements filterValuesResponse = new FilterValuesResponse(filterValues); return filterValuesResponse; case SPACE: - values = apq.getFilterValues( - AggregatedStorageStatusRecord.class, tc, filters, - filterValuesRequest.getFilterKey().getKey()); + apq.setRequestedRecords(AggregatedStorageStatusRecord.class); + apq.setTemporalConstraint(tc); + apq.setFilters(filters); + values = apq.getFilterValues(filterValuesRequest.getFilterKey().getKey()); break; default: filterValuesResponse = new FilterValuesResponse(filterValues); @@ -145,8 +136,7 @@ public class AccountingCommandGetFilterValues implements filterValuesResponse = new FilterValuesResponse(filterValues); return filterValuesResponse; } catch (Throwable e) { - logger.error("Error in AccountingCommandGetFilterValues(): " - + e.getLocalizedMessage()); + logger.error("Error in AccountingCommandGetFilterValues(): " + e.getLocalizedMessage()); e.printStackTrace(); throw new ServiceException("No values available!"); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetSpaces.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetSpaces.java index 67d50be..b9db5ce 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetSpaces.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetSpaces.java @@ -3,8 +3,10 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice.command; import java.util.ArrayList; import java.util.SortedSet; +import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory; +import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord; import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.slf4j.Logger; @@ -26,10 +28,14 @@ public class AccountingCommandGetSpaces implements AccountingCommand { public Spaces execute() throws ServiceException { try { logger.debug("getSpaces()"); - SortedSet keys = null; + SortedSet keys = null; AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance(); - - keys = apq.getSpaceProvidersIds(); + + //TODO the library must implement this interface + keys = apq.getFilterValues(AggregatedStorageStatusRecord.DATA_TYPE); + + + //keys = apq.getSpaceProvidersIds(); logger.debug("AccountingPersistenceQuery.getSpaces: " + keys); ArrayList spaceList = new ArrayList<>(); @@ -37,9 +43,9 @@ public class AccountingCommandGetSpaces implements AccountingCommand { if (keys == null || keys.isEmpty()) { logger.error("Spaces have not keys: {}", keys); } else { - for (String key : keys) { - if (key != null && !key.isEmpty()) { - spaceList.add(key); + for (NumberedFilter key : keys) { + if (key != null ) { + spaceList.add(key.getValue()); } } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandSpaces.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandSpaces.java index 2506803..6ab54fb 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandSpaces.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandSpaces.java @@ -1,9 +1,11 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice.command; import java.util.Calendar; +import java.util.HashSet; import java.util.SortedMap; import org.gcube.accounting.analytics.Filter; +import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuerySpaces; @@ -46,7 +48,7 @@ public class AccountingCommandSpaces implements logger.debug("Query Spaces: " + accountingQuerySpaces.getSpaces()); - SortedMap> spaceSM; + SortedMap> spaceSM; Spaces spaces = accountingQuerySpaces.getSpaces(); @@ -54,10 +56,16 @@ public class AccountingCommandSpaces implements throw new ServiceException( "Error retrieving Spaces param: null!"); } - - spaceSM = apq.getSpaceTimeSeries(accountingQuerySpaces.getType(), - accountingQuerySpaces.getTemporalConstraint(), - accountingQuerySpaces.getFilters(), spaces.getSpacesList()); + + apq.setRequestedRecords(accountingQuerySpaces.getType()); + apq.setTemporalConstraint(accountingQuerySpaces.getTemporalConstraint()); + apq.setFilters(accountingQuerySpaces.getFilters()); + spaceSM = apq.getSpaceTimeSeries(new HashSet(spaces.getSpacesList())); + + + //spaceSM = apq.getSpaceTimeSeries(accountingQuerySpaces.getType(), + // accountingQuerySpaces.getTemporalConstraint(), + // accountingQuerySpaces.getFilters(), spaces.getSpacesList()); if (spaceSM == null) { throw new ServiceException( @@ -93,7 +101,7 @@ public class AccountingCommandSpaces implements private SeriesResponseBuilder getSeriesResponseBuilder( AccountingType accountingType, Spaces spaces, - SortedMap> spaceSM) + SortedMap> spaceSM) throws ServiceException { if (accountingType == null) { throw new ServiceException("Error accounting type is null"); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandTop.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandTop.java index a32a90d..6930e4c 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandTop.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandTop.java @@ -1,6 +1,7 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice.command; import java.util.Calendar; +import java.util.HashSet; import java.util.SortedMap; import org.gcube.accounting.analytics.Info; @@ -42,28 +43,38 @@ public class AccountingCommandTop implements AccountingCommand { public SeriesResponse execute() throws ServiceException { try { - if (accountingQueryTop.getScope() != null && !accountingQueryTop.getScope().isEmpty()) { - AccountingPersistenceQueryFactory.getForcedQueryScope().set(accountingQueryTop.getScope()); - } + //if (accountingQueryTop.getScope() != null && !accountingQueryTop.getScope().isEmpty()) { + // AccountingPersistenceQueryFactory.getForcedQueryScope().set(accountingQueryTop.getScope()); + //} AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance(); logger.debug("Query TopValues: " + accountingQueryTop.getFilterKey().getKey()); SortedMap> topSM; - + + logger.debug("Execute Top()"); + apq.setRequestedRecords(accountingQueryTop.getType()); + + HashSet ctx=null; + if(accountingQueryTop.getContext()!=null&&accountingQueryTop.getContext().getContexts()!=null + &&!accountingQueryTop.getContext().getContexts().isEmpty()){ + ctx=new HashSet(accountingQueryTop.getContext().getContexts()); + } + apq.setContexts(ctx); + apq.setTemporalConstraint(accountingQueryTop.getTemporalConstraint()); + apq.setFilters(accountingQueryTop.getFilters()); + if (accountingQueryTop.getShowOthers()) { - topSM = apq.getTopValues(accountingQueryTop.getType(), accountingQueryTop.getTemporalConstraint(), - accountingQueryTop.getFilters(), accountingQueryTop.getFilterKey().getKey(), null, true, 0); + topSM = apq.getTopValues(accountingQueryTop.getFilterKey().getKey(), null, true, 0); } else { - topSM = apq.getTopValues(accountingQueryTop.getType(), accountingQueryTop.getTemporalConstraint(), - accountingQueryTop.getFilters(), accountingQueryTop.getFilterKey().getKey(), null, true, + topSM = apq.getTopValues(accountingQueryTop.getFilterKey().getKey(), null, true, accountingQueryTop.getTopNumber()); } - if (accountingQueryTop.getScope() != null && !accountingQueryTop.getScope().isEmpty()) { - AccountingPersistenceQueryFactory.getForcedQueryScope().remove(); - } + //if (accountingQueryTop.getScope() != null && !accountingQueryTop.getScope().isEmpty()) { + // AccountingPersistenceQueryFactory.getForcedQueryScope().remove(); + //} if (topSM == null) { throw new ServiceException("Error retrieving info for top: sorted map is null!"); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Job.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Job.java index 6d3f04c..7b22c53 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Job.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Job.java @@ -11,7 +11,6 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -77,8 +76,8 @@ public class AccountingQuery4Job extends AccountingQueryBuilder { filters.add(filter); } } - invocation = new AccountingQueryBasic(AggregatedJobUsageRecord.class, accountingFilterBasic.getScope(), - accountingFilterBasic.isNoContext(), temporalConstraint, filters); + invocation = new AccountingQueryBasic(AggregatedJobUsageRecord.class, + accountingFilterBasic.getContext(), temporalConstraint, filters); } else { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) { @@ -93,28 +92,12 @@ public class AccountingQuery4Job extends AccountingQueryBuilder { filters.add(filter); } } - invocation = new AccountingQueryTop(AggregatedJobUsageRecord.class, accountingFilterTop.getScope(), + invocation = new AccountingQueryTop(AggregatedJobUsageRecord.class, accountingFilterTop.getContext(), accountingFilterTop.getFilterKey(), accountingFilterTop.getShowOthers(), accountingFilterTop.getTopNumber(), temporalConstraint, filters); } else { - if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { - AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest - .getAccountingFilterDefinition(); - accountingFilters = accountingFilterContext.getFilters(); - filters = new ArrayList(); - if (accountingFilters != null) { - for (AccountingFilter accountigFilters : accountingFilters) { - Filter filter = new Filter(accountigFilters.getFilterKey().getKey(), - accountigFilters.getFilterValue()); - filters.add(filter); - } - } - invocation = new AccountingQueryContext(AggregatedJobUsageRecord.class, - accountingFilterContext.getContext(), temporalConstraint, filters); - } else { logger.error("Invalid Request: " + seriesRequest); throw new ServiceException("Invalid Request!"); - } } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Portlet.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Portlet.java index 0168787..5fc25a4 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Portlet.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Portlet.java @@ -11,7 +11,6 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedPortletUsageRecord; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -77,8 +76,7 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder { } } invocation = new AccountingQueryBasic(AggregatedPortletUsageRecord.class, - accountingFilterBasic.getScope(), accountingFilterBasic.isNoContext(), temporalConstraint, - filters); + accountingFilterBasic.getContext(), temporalConstraint, filters); } else { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) { @@ -94,28 +92,12 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder { } } invocation = new AccountingQueryTop(AggregatedPortletUsageRecord.class, - accountingFilterTop.getScope(), accountingFilterTop.getFilterKey(), + accountingFilterTop.getContext(), accountingFilterTop.getFilterKey(), accountingFilterTop.getShowOthers(), accountingFilterTop.getTopNumber(), temporalConstraint, filters); } else { - if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { - AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest - .getAccountingFilterDefinition(); - accountingFilters = accountingFilterContext.getFilters(); - filters = new ArrayList(); - if (accountingFilters != null) { - for (AccountingFilter accountigFilters : accountingFilters) { - Filter filter = new Filter(accountigFilters.getFilterKey().getKey(), - accountigFilters.getFilterValue()); - filters.add(filter); - } - } - invocation = new AccountingQueryContext(AggregatedPortletUsageRecord.class, - accountingFilterContext.getContext(), temporalConstraint, filters); - } else { - logger.error("Invalid Request: " + seriesRequest); - throw new ServiceException("Invalid Request!"); - } + logger.error("Invalid Request: " + seriesRequest); + throw new ServiceException("Invalid Request!"); } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Service.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Service.java index a3f9796..de3dacf 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Service.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Service.java @@ -11,7 +11,6 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -78,8 +77,7 @@ public class AccountingQuery4Service extends AccountingQueryBuilder { } } invocation = new AccountingQueryBasic(AggregatedServiceUsageRecord.class, - accountingFilterBasic.getScope(), accountingFilterBasic.isNoContext(), temporalConstraint, - filters); + accountingFilterBasic.getContext(), temporalConstraint, filters); } else { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) { @@ -95,28 +93,12 @@ public class AccountingQuery4Service extends AccountingQueryBuilder { } } invocation = new AccountingQueryTop(AggregatedServiceUsageRecord.class, - accountingFilterTop.getScope(), accountingFilterTop.getFilterKey(), + accountingFilterTop.getContext(), accountingFilterTop.getFilterKey(), accountingFilterTop.getShowOthers(), accountingFilterTop.getTopNumber(), temporalConstraint, filters); } else { - if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { - AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest - .getAccountingFilterDefinition(); - accountingFilters = accountingFilterContext.getFilters(); - filters = new ArrayList(); - if (accountingFilters != null) { - for (AccountingFilter accountigFilters : accountingFilters) { - Filter filter = new Filter(accountigFilters.getFilterKey().getKey(), - accountigFilters.getFilterValue()); - filters.add(filter); - } - } - invocation = new AccountingQueryContext(AggregatedServiceUsageRecord.class, - accountingFilterContext.getContext(), temporalConstraint, filters); - } else { - logger.error("Invalid Request: " + seriesRequest); - throw new ServiceException("Invalid Request!"); - } + logger.error("Invalid Request: " + seriesRequest); + throw new ServiceException("Invalid Request!"); } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Storage.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Storage.java index 8c71b6c..b73ce95 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Storage.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Storage.java @@ -11,7 +11,6 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -78,8 +77,7 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder { } } invocation = new AccountingQueryBasic(AggregatedStorageUsageRecord.class, - accountingFilterBasic.getScope(), accountingFilterBasic.isNoContext(), temporalConstraint, - filters); + accountingFilterBasic.getContext(), temporalConstraint, filters); } else { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) { @@ -95,28 +93,12 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder { } } invocation = new AccountingQueryTop(AggregatedStorageUsageRecord.class, - accountingFilterTop.getScope(), accountingFilterTop.getFilterKey(), + accountingFilterTop.getContext(), accountingFilterTop.getFilterKey(), accountingFilterTop.getShowOthers(), accountingFilterTop.getTopNumber(), temporalConstraint, filters); } else { - if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { - AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest - .getAccountingFilterDefinition(); - accountingFilters = accountingFilterContext.getFilters(); - filters = new ArrayList(); - if (accountingFilters != null) { - for (AccountingFilter accountigFilters : accountingFilters) { - Filter filter = new Filter(accountigFilters.getFilterKey().getKey(), - accountigFilters.getFilterValue()); - filters.add(filter); - } - } - invocation = new AccountingQueryContext(AggregatedStorageUsageRecord.class, - accountingFilterContext.getContext(), temporalConstraint, filters); - } else { - logger.error("Invalid Request: " + seriesRequest); - throw new ServiceException("Invalid Request!"); - } + logger.error("Invalid Request: " + seriesRequest); + throw new ServiceException("Invalid Request!"); } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Task.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Task.java index 7e00f41..5a61edf 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Task.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Task.java @@ -7,11 +7,9 @@ import java.util.GregorianCalendar; import org.gcube.accounting.analytics.Filter; import org.gcube.accounting.analytics.TemporalConstraint; -//import org.gcube.accounting.datamodel.aggregation.AggregatedTaskUsageRecord; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -21,13 +19,12 @@ import org.slf4j.LoggerFactory; /** * Accounting Query 4 Task * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ public class AccountingQuery4Task extends AccountingQueryBuilder { - protected static Logger logger = LoggerFactory - .getLogger(AccountingQuery4Task.class); + protected static Logger logger = LoggerFactory.getLogger(AccountingQuery4Task.class); private SeriesRequest seriesRequest; public AccountingQuery4Task(SeriesRequest seriesRequest) { @@ -36,21 +33,17 @@ public class AccountingQuery4Task extends AccountingQueryBuilder { @Override public void buildOpEx() throws ServiceException { - Calendar startCalendar = GregorianCalendar - .getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); + Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); try { - startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod() - .getStartDate())); + startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate())); } catch (ParseException e) { e.printStackTrace(); throw new ServiceException("Start Date not valid!"); } - Calendar endCalendar = GregorianCalendar - .getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); + Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); try { - endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod() - .getEndDate())); + endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate())); } catch (ParseException e) { e.printStackTrace(); throw new ServiceException("End Date not valid!"); @@ -62,17 +55,14 @@ public class AccountingQuery4Task extends AccountingQueryBuilder { endCalendar.set(GregorianCalendar.MILLISECOND, 999); @SuppressWarnings("unused") - TemporalConstraint temporalConstraint = new TemporalConstraint( - startCalendar.getTimeInMillis(), endCalendar.getTimeInMillis(), - PeriodModeMap.getMode(seriesRequest.getAccountingPeriod() - .getPeriod())); + TemporalConstraint temporalConstraint = new TemporalConstraint(startCalendar.getTimeInMillis(), + endCalendar.getTimeInMillis(), PeriodModeMap.getMode(seriesRequest.getAccountingPeriod().getPeriod())); ArrayList filters = null; ArrayList accountingFilters = null; AccountingQuery invocation = null; - if (seriesRequest != null - && seriesRequest.getAccountingFilterDefinition() != null) { + if (seriesRequest != null && seriesRequest.getAccountingFilterDefinition() != null) { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterBasic) { AccountingFilterBasic accountingFilterBasic = (AccountingFilterBasic) seriesRequest .getAccountingFilterDefinition(); @@ -80,16 +70,16 @@ public class AccountingQuery4Task extends AccountingQueryBuilder { filters = new ArrayList(); if (accountingFilters != null) { for (AccountingFilter accountigFilters : accountingFilters) { - Filter filter = new Filter(accountigFilters - .getFilterKey().getKey(), + Filter filter = new Filter(accountigFilters.getFilterKey().getKey(), accountigFilters.getFilterValue()); filters.add(filter); } } - /*invocation = new AccountingQueryBasic( - AggregatedTaskUsageRecord.class, temporalConstraint, - filters, accountingFilterBasic.isNoContext()); - */ + /* + * invocation = new AccountingQueryBasic( + * AggregatedTaskUsageRecord.class, temporalConstraint, filters, + * accountingFilterBasic.isNoContext()); + */ } else { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) { AccountingFilterTop accountingFilterTop = (AccountingFilterTop) seriesRequest @@ -98,42 +88,22 @@ public class AccountingQuery4Task extends AccountingQueryBuilder { filters = new ArrayList(); if (accountingFilters != null) { for (AccountingFilter accountigFilters : accountingFilters) { - Filter filter = new Filter(accountigFilters - .getFilterKey().getKey(), + Filter filter = new Filter(accountigFilters.getFilterKey().getKey(), accountigFilters.getFilterValue()); filters.add(filter); } } - /*invocation = new AccountingQueryTop( - AggregatedTaskUsageRecord.class, - accountingFilterTop.getFilterKey(), - accountingFilterTop.getShowOthers(), - accountingFilterTop.getTopNumber(), - temporalConstraint, filters);*/ + /* + * invocation = new AccountingQueryTop( + * AggregatedTaskUsageRecord.class, + * accountingFilterTop.getFilterKey(), + * accountingFilterTop.getShowOthers(), + * accountingFilterTop.getTopNumber(), temporalConstraint, + * filters); + */ } else { - if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { - AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest - .getAccountingFilterDefinition(); - accountingFilters = accountingFilterContext.getFilters(); - filters = new ArrayList(); - if (accountingFilters != null) { - for (AccountingFilter accountigFilters : accountingFilters) { - Filter filter = new Filter(accountigFilters - .getFilterKey().getKey(), - accountigFilters.getFilterValue()); - filters.add(filter); - } - } - /*invocation = new AccountingQueryContext( - AggregatedTaskUsageRecord.class, - accountingFilterContext.getContext(), - temporalConstraint, - filters);*/ - } else { - logger.error("Invalid Request: " + seriesRequest); - throw new ServiceException( - "Invalid Request!"); - } + logger.error("Invalid Request: " + seriesRequest); + throw new ServiceException("Invalid Request!"); } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryBasic.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryBasic.java index 7c8f733..1184ae2 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryBasic.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryBasic.java @@ -6,6 +6,7 @@ import org.gcube.accounting.analytics.Filter; import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.datamodel.AggregatedUsageRecord; import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; /** * @@ -15,20 +16,18 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; */ public class AccountingQueryBasic extends AccountingQuery { private Class> type; - private String scope; - private boolean noContext; + private Context context; private TemporalConstraint temporalConstraint; private ArrayList filters; - public AccountingQueryBasic(Class> type, String scope, boolean noContext, + public AccountingQueryBasic(Class> type, Context context, TemporalConstraint temporalConstraint, ArrayList filters) { super(); chartType = ChartType.Basic; this.type = type; this.temporalConstraint = temporalConstraint; - this.scope = scope; + this.context = context; this.filters = filters; - this.noContext = noContext; } public Class> getType() { @@ -47,12 +46,13 @@ public class AccountingQueryBasic extends AccountingQuery { this.temporalConstraint = temporalConstraint; } - public String getScope() { - return scope; + + public Context getContext() { + return context; } - public void setScope(String scope) { - this.scope = scope; + public void setContext(Context context) { + this.context = context; } public ArrayList getFilters() { @@ -63,18 +63,10 @@ public class AccountingQueryBasic extends AccountingQuery { this.filters = filters; } - public boolean isNoContext() { - return noContext; - } - - public void setNoContext(boolean noContext) { - this.noContext = noContext; - } - @Override public String toString() { - return "AccountingQueryBasic [type=" + type + ", temporalConstraint=" + temporalConstraint + ", scope=" + scope - + ", filters=" + filters + ", noContext=" + noContext + "]"; + return "AccountingQueryBasic [type=" + type + ", context=" + context + ", temporalConstraint=" + + temporalConstraint + ", filters=" + filters + "]"; } } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryTop.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryTop.java index 394c8ec..85f4326 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryTop.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryTop.java @@ -6,6 +6,7 @@ import org.gcube.accounting.analytics.Filter; import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.datamodel.AggregatedUsageRecord; import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; /** @@ -16,19 +17,19 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; */ public class AccountingQueryTop extends AccountingQuery { private Class> type; - private String scope; + private Context context; private FilterKey filterKey; private Integer topNumber; private Boolean showOthers; private TemporalConstraint temporalConstraint; private ArrayList filters; - public AccountingQueryTop(Class> type, String scope, FilterKey filterKey, + public AccountingQueryTop(Class> type, Context context, FilterKey filterKey, Boolean showOthers, Integer topNumber, TemporalConstraint temporalConstraint, ArrayList filters) { super(); chartType = ChartType.Top; this.type = type; - this.scope = scope; + this.context = context; this.temporalConstraint = temporalConstraint; this.filters = filters; this.filterKey = filterKey; @@ -43,13 +44,13 @@ public class AccountingQueryTop extends AccountingQuery { public void setType(Class> type) { this.type = type; } - - public String getScope() { - return scope; + + public Context getContext() { + return context; } - public void setScope(String scope) { - this.scope = scope; + public void setContext(Context context) { + this.context = context; } public TemporalConstraint getTemporalConstraint() { @@ -94,9 +95,10 @@ public class AccountingQueryTop extends AccountingQuery { @Override public String toString() { - return "AccountingQueryTop [type=" + type + ", scope=" + scope + ", filterKey=" + filterKey + ", topNumber=" + return "AccountingQueryTop [type=" + type + ", context=" + context + ", filterKey=" + filterKey + ", topNumber=" + topNumber + ", showOthers=" + showOthers + ", temporalConstraint=" + temporalConstraint + ", filters=" - + filters + "]"; + + filters + ", chartType=" + chartType + "]"; } + } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobBasic.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobBasic.java index ae716a8..d61df82 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobBasic.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobBasic.java @@ -5,11 +5,11 @@ import java.util.List; import org.gcube.accounting.analytics.Info; import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; +import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,14 +39,15 @@ public class SeriesResponse4JobBasic extends SeriesResponseBuilder { ArrayList series = new ArrayList(); for (Info info : infos) { - JSONObject jso = info.getValue(); - Long duration = jso.getLong(AggregatedJobUsageRecord.DURATION); + JsonNode jso = info.getValue(); + + Long duration = jso.get(AggregatedJobUsageRecord.DURATION).asLong(); Long operationCount = jso - .getLong(AggregatedJobUsageRecord.OPERATION_COUNT); + .get(AggregatedJobUsageRecord.OPERATION_COUNT).asLong(); Long maxInvocationTime = jso - .getLong(AggregatedJobUsageRecord.MAX_INVOCATION_TIME); + .get(AggregatedJobUsageRecord.MAX_INVOCATION_TIME).asLong(); Long minInvocationTime = jso - .getLong(AggregatedJobUsageRecord.MIN_INVOCATION_TIME); + .get(AggregatedJobUsageRecord.MIN_INVOCATION_TIME).asLong(); series.add(new SeriesJobData(info.getCalendar().getTime(), operationCount, duration, maxInvocationTime, diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobTop.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobTop.java index 25f4ba9..10728cb 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobTop.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobTop.java @@ -7,13 +7,13 @@ import java.util.SortedMap; import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; +import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,15 +55,15 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder { ArrayList series = new ArrayList<>(); SortedMap infos = topSM.get(topValue); for (Info info : infos.values()) { - JSONObject jso = info.getValue(); + JsonNode jso = info.getValue(); Long duration = jso - .getLong(AggregatedServiceUsageRecord.DURATION); + .get(AggregatedServiceUsageRecord.DURATION).asLong(); Long operationCount = jso - .getLong(AggregatedServiceUsageRecord.OPERATION_COUNT); + .get(AggregatedServiceUsageRecord.OPERATION_COUNT).asLong(); Long maxInvocationTime = jso - .getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); + .get(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME).asLong(); Long minInvocationTime = jso - .getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); + .get(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME).asLong(); series.add(new SeriesJobData(info.getCalendar() .getTime(), operationCount, duration, diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4PortletTop.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4PortletTop.java index d35c622..eaadcd7 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4PortletTop.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4PortletTop.java @@ -7,13 +7,13 @@ import java.util.SortedMap; import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.datamodel.aggregation.AggregatedPortletUsageRecord; +import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesPortlet; import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletTop; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,11 +53,11 @@ public class SeriesResponse4PortletTop extends SeriesResponseBuilder { ArrayList series = new ArrayList<>(); SortedMap infos = topSM.get(topValue); for (Info info : infos.values()) { - JSONObject jso = info.getValue(); + JsonNode jso = info.getValue(); // Long duration = // jso.getLong(AggregatedPortletUsageRecord.DURATION); Long operationCount = jso - .getLong(AggregatedPortletUsageRecord.OPERATION_COUNT); + .get(AggregatedPortletUsageRecord.OPERATION_COUNT).asLong(); // Long maxInvocationTime = // jso.getLong(AggregatedPortletUsageRecord.MAX_INVOCATION_TIME); // Long minInvocationTime = diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceBasic.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceBasic.java index 7aff2c1..428a3ec 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceBasic.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceBasic.java @@ -5,11 +5,11 @@ import java.util.List; import org.gcube.accounting.analytics.Info; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; +import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,15 +39,15 @@ public class SeriesResponse4ServiceBasic extends SeriesResponseBuilder { ArrayList series = new ArrayList(); for (Info info : infos) { - JSONObject jso = info.getValue(); + JsonNode jso = info.getValue(); Long duration = jso - .getLong(AggregatedServiceUsageRecord.DURATION); + .get(AggregatedServiceUsageRecord.DURATION).asLong(); Long operationCount = jso - .getLong(AggregatedServiceUsageRecord.OPERATION_COUNT); + .get(AggregatedServiceUsageRecord.OPERATION_COUNT).asLong(); Long maxInvocationTime = jso - .getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); + .get(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME).asLong(); Long minInvocationTime = jso - .getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); + .get(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME).asLong(); series.add(new SeriesServiceData(info.getCalendar().getTime(), operationCount, duration, maxInvocationTime, diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceTop.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceTop.java index 2b52aab..8bcebd3 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceTop.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceTop.java @@ -7,13 +7,13 @@ import java.util.SortedMap; import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; +import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,15 +53,15 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder { ArrayList series = new ArrayList<>(); SortedMap infos = topSM.get(topValue); for (Info info : infos.values()) { - JSONObject jso = info.getValue(); + JsonNode jso = info.getValue(); Long duration = jso - .getLong(AggregatedServiceUsageRecord.DURATION); + .get(AggregatedServiceUsageRecord.DURATION).asLong(); Long operationCount = jso - .getLong(AggregatedServiceUsageRecord.OPERATION_COUNT); + .get(AggregatedServiceUsageRecord.OPERATION_COUNT).asLong(); Long maxInvocationTime = jso - .getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); + .get(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME).asLong(); Long minInvocationTime = jso - .getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); + .get(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME).asLong(); series.add(new SeriesServiceData(info.getCalendar() .getTime(), operationCount, duration, diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4SpaceSpaces.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4SpaceSpaces.java index 5b92744..b410d5e 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4SpaceSpaces.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4SpaceSpaces.java @@ -5,6 +5,10 @@ import java.util.Calendar; import java.util.SortedMap; import org.gcube.accounting.analytics.Filter; +import org.gcube.accounting.analytics.Info; +import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; +import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord; +import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesSpace; import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceSpaces; @@ -25,10 +29,10 @@ public class SeriesResponse4SpaceSpaces extends SeriesResponseBuilder { protected static Logger logger = LoggerFactory .getLogger(SeriesResponse4SpaceSpaces.class); private Spaces spaces; - private SortedMap> spaceSM; + private SortedMap> spaceSM; public SeriesResponse4SpaceSpaces(Spaces spaces, - SortedMap> spaceSM) { + SortedMap> spaceSM) { this.spaces = spaces; this.spaceSM = spaceSM; } @@ -46,11 +50,13 @@ public class SeriesResponse4SpaceSpaces extends SeriesResponseBuilder { for (Filter spaceValue : spaceSM.keySet()) { ArrayList series = new ArrayList<>(); - SortedMap infos = spaceSM.get(spaceValue); + SortedMap infos = spaceSM.get(spaceValue); for (Calendar calendar : infos.keySet()) { - Long value = infos.get(calendar); - if(value==null){ - value=0L; + Info info = infos.get(calendar); + Long value=0L; + if(info!=null){ + JsonNode jso=info.getValue(); + value=jso.get(AggregatedStorageStatusRecord.DATA_VOLUME).asLong(); } series.add(new SeriesSpaceData(calendar.getTime(), value)); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageBasic.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageBasic.java index 465681e..24b0a8f 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageBasic.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageBasic.java @@ -5,11 +5,11 @@ import java.util.List; import org.gcube.accounting.analytics.Info; import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; +import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,10 +39,10 @@ public class SeriesResponse4StorageBasic extends SeriesResponseBuilder { ArrayList series=new ArrayList(); for (Info info : infos) { - JSONObject jso = info.getValue(); - Long dataVolume = jso.getLong(AggregatedStorageUsageRecord.DATA_VOLUME); + JsonNode jso = info.getValue(); + Long dataVolume = jso.get(AggregatedStorageUsageRecord.DATA_VOLUME).asLong(); Long operationCount = jso - .getLong(AggregatedStorageUsageRecord.OPERATION_COUNT); + .get(AggregatedStorageUsageRecord.OPERATION_COUNT).asLong(); series.add(new SeriesStorageData(info.getCalendar().getTime(), dataVolume, operationCount)); } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageTop.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageTop.java index f342151..ed25107 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageTop.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageTop.java @@ -7,13 +7,13 @@ import java.util.SortedMap; import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; +import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,11 +54,11 @@ public class SeriesResponse4StorageTop extends SeriesResponseBuilder { ArrayList series = new ArrayList<>(); SortedMap infos = topSM.get(topValue); for (Info info : infos.values()) { - JSONObject jso = info.getValue(); + JsonNode jso = info.getValue(); Long dataVolume = jso - .getLong(AggregatedStorageUsageRecord.DATA_VOLUME); + .get(AggregatedStorageUsageRecord.DATA_VOLUME).asLong(); Long operationCount = jso - .getLong(AggregatedStorageUsageRecord.OPERATION_COUNT); + .get(AggregatedStorageUsageRecord.OPERATION_COUNT).asLong(); series.add(new SeriesStorageData(info.getCalendar() .getTime(), dataVolume, operationCount)); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4TaskTop.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4TaskTop.java index b5d58f0..581aa36 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4TaskTop.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4TaskTop.java @@ -6,6 +6,7 @@ import java.util.SortedMap; import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.NumberedFilter; +import org.gcube.com.fasterxml.jackson.databind.JsonNode; //import org.gcube.accounting.datamodel.aggregation.AggregatedTaskUsageRecord; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesTask; @@ -13,7 +14,6 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.Seri import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskTop; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +54,7 @@ public class SeriesResponse4TaskTop extends SeriesResponseBuilder { SortedMap infos = topSM.get(topValue); for (Info info : infos.values()) { @SuppressWarnings("unused") - JSONObject jso = info.getValue(); + JsonNode jso = info.getValue(); // Long duration = // jso.getLong(AggregatedTaskUsageRecord.DURATION); //Long operationCount = jso diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Job.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Job.java index 26ad7ec..0aab0ef 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Job.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Job.java @@ -10,9 +10,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesReques import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop; @@ -23,13 +21,12 @@ import org.slf4j.LoggerFactory; /** * Accounting Model 4 Job * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ public class AccountingModel4Job extends AccountingModelBuilder { - protected static Logger logger = LoggerFactory - .getLogger(AccountingModel4Job.class); + protected static Logger logger = LoggerFactory.getLogger(AccountingModel4Job.class); private AccountingStateData accountingStateData; public AccountingModel4Job(AccountingStateData accountingStateData) { @@ -42,35 +39,30 @@ public class AccountingModel4Job extends AccountingModelBuilder { if (seriesRequest == null) { logger.error("Error series request is null"); - throw new ServiceException( - "Error series request is null"); + throw new ServiceException("Error series request is null"); } - String startDate=""; + String startDate = ""; try { - startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() - .getStartDate())); + startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate())); } catch (ParseException e) { e.printStackTrace(); } - - String endDate=""; + + String endDate = ""; try { - endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() - .getEndDate())); + endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate())); } catch (ParseException e) { e.printStackTrace(); } - String periodType = seriesRequest.getAccountingPeriod().getPeriod() - .getLabel(); + String periodType = seriesRequest.getAccountingPeriod().getPeriod().getLabel(); SeriesResponse seriesResponse = accountingStateData.getSeriesResponse(); if (seriesResponse == null) { logger.error("Error series response is null"); - throw new ServiceException( - "Error series response is null"); + throw new ServiceException("Error series response is null"); } String fileName = "Untitled"; @@ -78,17 +70,13 @@ public class AccountingModel4Job extends AccountingModelBuilder { ArrayList rows = new ArrayList<>(); if (seriesResponse instanceof SeriesJob) { SeriesJob seriesService = (SeriesJob) seriesResponse; - SeriesJobDefinition definition = seriesService - .getSeriesJobDefinition(); + SeriesJobDefinition definition = seriesService.getSeriesJobDefinition(); if (definition instanceof SeriesJobBasic) { SeriesJobBasic seriesJobBasic = (SeriesJobBasic) definition; - fileName = "Job_" + periodType + "_" + startDate + "_" - + endDate; - header = new ArrayList<>(Arrays.asList(new String[] { "Date", - "Operation Count", "Duration", "Max Invocation", - "Min Invocation" })); - ArrayList listData = seriesJobBasic - .getSeries(); + fileName = "Job_" + periodType + "_" + startDate + "_" + endDate; + header = new ArrayList<>(Arrays.asList( + new String[] { "Date", "Operation Count", "Duration", "Max Invocation", "Min Invocation" })); + ArrayList listData = seriesJobBasic.getSeries(); for (SeriesJobData seriesData : listData) { ArrayList data = new ArrayList<>(); data.add(sdfCSVDate.format(seriesData.getDate())); @@ -102,76 +90,35 @@ public class AccountingModel4Job extends AccountingModelBuilder { } else { if (definition instanceof SeriesJobTop) { SeriesJobTop seriesJobTop = (SeriesJobTop) definition; - fileName = "JobTop_" + periodType + "_" + startDate - + "_" + endDate; - header = new ArrayList<>(Arrays.asList(new String[] { - "Value", "Date", "Operation Count", "Duration", - "Max Invocation", "Min Invocation" })); - ArrayList listDataTop = seriesJobTop - .getSeriesJobDataTopList(); + fileName = "JobTop_" + periodType + "_" + startDate + "_" + endDate; + header = new ArrayList<>(Arrays.asList(new String[] { "Value", "Date", "Operation Count", + "Duration", "Max Invocation", "Min Invocation" })); + ArrayList listDataTop = seriesJobTop.getSeriesJobDataTopList(); for (SeriesJobDataTop seriesDataTop : listDataTop) { - FilterValue filterValue = seriesDataTop - .getFilterValue(); - ArrayList listData = seriesDataTop - .getSeries(); + FilterValue filterValue = seriesDataTop.getFilterValue(); + ArrayList listData = seriesDataTop.getSeries(); for (SeriesJobData seriesData : listData) { ArrayList data = new ArrayList<>(); data.add(filterValue.getValue()); data.add(sdfCSVDate.format(seriesData.getDate())); - data.add(String.valueOf(seriesData - .getOperationCount())); + data.add(String.valueOf(seriesData.getOperationCount())); data.add(String.valueOf(seriesData.getDuration())); - data.add(String.valueOf(seriesData - .getMaxInvocationTime())); - data.add(String.valueOf(seriesData - .getMinInvocationTime())); + data.add(String.valueOf(seriesData.getMaxInvocationTime())); + data.add(String.valueOf(seriesData.getMinInvocationTime())); AccountingDataRow csvDataRow = new AccountingDataRow(data); rows.add(csvDataRow); } } } else { - if (definition instanceof SeriesJobContext) { - SeriesJobContext seriesJobContext = (SeriesJobContext) definition; - fileName = "JobContext_" + periodType + "_" + startDate - + "_" + endDate; - header = new ArrayList<>(Arrays.asList(new String[] { - "Value", "Date", "Operation Count", "Duration", - "Max Invocation", "Min Invocation" })); - ArrayList listDataContext = seriesJobContext - .getSeriesJobDataContextList(); - for (SeriesJobDataContext seriesDataContext : listDataContext) { - ArrayList listData = seriesDataContext - .getSeries(); - for (SeriesJobData seriesData : listData) { - ArrayList data = new ArrayList<>(); - data.add(seriesDataContext.getContext()); - data.add(sdfCSVDate.format(seriesData.getDate())); - data.add(String.valueOf(seriesData - .getOperationCount())); - data.add(String.valueOf(seriesData.getDuration())); - data.add(String.valueOf(seriesData - .getMaxInvocationTime())); - data.add(String.valueOf(seriesData - .getMinInvocationTime())); - AccountingDataRow csvDataRow = new AccountingDataRow(data); - rows.add(csvDataRow); - } - } - } else { - logger.error("Unsupported Serie Definition for Job: " - + definition); - throw new ServiceException( - "Unsupported Serie Definition for Job: " - + definition); - } + + logger.error("Unsupported Serie Definition for Job: " + definition); + throw new ServiceException("Unsupported Serie Definition for Job: " + definition); + } } } else { - logger.error("Job not support this serie response: " - + seriesResponse); - throw new ServiceException( - "Job not support this serie response: " - + seriesResponse); + logger.error("Job not support this serie response: " + seriesResponse); + throw new ServiceException("Job not support this serie response: " + seriesResponse); } AccountingDataModel invocation = new AccountingDataModel(fileName, header, rows); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Service.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Service.java index 361f51b..9791fc8 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Service.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Service.java @@ -10,9 +10,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesReques import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop; @@ -23,13 +21,12 @@ import org.slf4j.LoggerFactory; /** * Accounting Model 4 Service * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ public class AccountingModel4Service extends AccountingModelBuilder { - protected static Logger logger = LoggerFactory - .getLogger(AccountingModel4Service.class); + protected static Logger logger = LoggerFactory.getLogger(AccountingModel4Service.class); private AccountingStateData accountingStateData; public AccountingModel4Service(AccountingStateData accountingStateData) { @@ -42,35 +39,30 @@ public class AccountingModel4Service extends AccountingModelBuilder { if (seriesRequest == null) { logger.error("Error series request is null"); - throw new ServiceException( - "Error series request is null"); + throw new ServiceException("Error series request is null"); } - String startDate=""; + String startDate = ""; try { - startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() - .getStartDate())); + startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate())); } catch (ParseException e) { e.printStackTrace(); } - - String endDate=""; + + String endDate = ""; try { - endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() - .getEndDate())); + endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate())); } catch (ParseException e) { e.printStackTrace(); } - String periodType = seriesRequest.getAccountingPeriod().getPeriod() - .getLabel(); + String periodType = seriesRequest.getAccountingPeriod().getPeriod().getLabel(); SeriesResponse seriesResponse = accountingStateData.getSeriesResponse(); if (seriesResponse == null) { logger.error("Error series response is null"); - throw new ServiceException( - "Error series response is null"); + throw new ServiceException("Error series response is null"); } String fileName = "Untitled"; @@ -78,17 +70,13 @@ public class AccountingModel4Service extends AccountingModelBuilder { ArrayList rows = new ArrayList<>(); if (seriesResponse instanceof SeriesService) { SeriesService seriesService = (SeriesService) seriesResponse; - SeriesServiceDefinition definition = seriesService - .getSerieServiceDefinition(); + SeriesServiceDefinition definition = seriesService.getSerieServiceDefinition(); if (definition instanceof SeriesServiceBasic) { SeriesServiceBasic seriesServiceBasic = (SeriesServiceBasic) definition; - fileName = "Service_" + periodType + "_" + startDate + "_" - + endDate; - header = new ArrayList<>(Arrays.asList(new String[] { "Date", - "Operation Count", "Duration", "Max Invocation", - "Min Invocation" })); - ArrayList listData = seriesServiceBasic - .getSeries(); + fileName = "Service_" + periodType + "_" + startDate + "_" + endDate; + header = new ArrayList<>(Arrays.asList( + new String[] { "Date", "Operation Count", "Duration", "Max Invocation", "Min Invocation" })); + ArrayList listData = seriesServiceBasic.getSeries(); for (SeriesServiceData seriesData : listData) { ArrayList data = new ArrayList<>(); data.add(sdfCSVDate.format(seriesData.getDate())); @@ -102,76 +90,33 @@ public class AccountingModel4Service extends AccountingModelBuilder { } else { if (definition instanceof SeriesServiceTop) { SeriesServiceTop seriesServiceTop = (SeriesServiceTop) definition; - fileName = "ServiceTop_" + periodType + "_" + startDate - + "_" + endDate; - header = new ArrayList<>(Arrays.asList(new String[] { - "Value", "Date", "Operation Count", "Duration", - "Max Invocation", "Min Invocation" })); - ArrayList listDataTop = seriesServiceTop - .getSeriesServiceDataTopList(); + fileName = "ServiceTop_" + periodType + "_" + startDate + "_" + endDate; + header = new ArrayList<>(Arrays.asList(new String[] { "Value", "Date", "Operation Count", + "Duration", "Max Invocation", "Min Invocation" })); + ArrayList listDataTop = seriesServiceTop.getSeriesServiceDataTopList(); for (SeriesServiceDataTop seriesDataTop : listDataTop) { - FilterValue filterValue = seriesDataTop - .getFilterValue(); - ArrayList listData = seriesDataTop - .getSeries(); + FilterValue filterValue = seriesDataTop.getFilterValue(); + ArrayList listData = seriesDataTop.getSeries(); for (SeriesServiceData seriesData : listData) { ArrayList data = new ArrayList<>(); data.add(filterValue.getValue()); data.add(sdfCSVDate.format(seriesData.getDate())); - data.add(String.valueOf(seriesData - .getOperationCount())); + data.add(String.valueOf(seriesData.getOperationCount())); data.add(String.valueOf(seriesData.getDuration())); - data.add(String.valueOf(seriesData - .getMaxInvocationTime())); - data.add(String.valueOf(seriesData - .getMinInvocationTime())); + data.add(String.valueOf(seriesData.getMaxInvocationTime())); + data.add(String.valueOf(seriesData.getMinInvocationTime())); AccountingDataRow csvDataRow = new AccountingDataRow(data); rows.add(csvDataRow); } } } else { - if (definition instanceof SeriesServiceContext) { - SeriesServiceContext seriesServiceContext = (SeriesServiceContext) definition; - fileName = "ServiceContext_" + periodType + "_" + startDate - + "_" + endDate; - header = new ArrayList<>(Arrays.asList(new String[] { - "Value", "Date", "Operation Count", "Duration", - "Max Invocation", "Min Invocation" })); - ArrayList listDataContext = seriesServiceContext - .getSeriesServiceDataContextList(); - for (SeriesServiceDataContext seriesDataContext : listDataContext) { - ArrayList listData = seriesDataContext - .getSeries(); - for (SeriesServiceData seriesData : listData) { - ArrayList data = new ArrayList<>(); - data.add(seriesDataContext.getContext()); - data.add(sdfCSVDate.format(seriesData.getDate())); - data.add(String.valueOf(seriesData - .getOperationCount())); - data.add(String.valueOf(seriesData.getDuration())); - data.add(String.valueOf(seriesData - .getMaxInvocationTime())); - data.add(String.valueOf(seriesData - .getMinInvocationTime())); - AccountingDataRow csvDataRow = new AccountingDataRow(data); - rows.add(csvDataRow); - } - } - } else { - logger.error("Unsupported Serie Definition for Service: " - + definition); - throw new ServiceException( - "Unsupported Serie Definition for Service: " - + definition); - } + logger.error("Unsupported Serie Definition for Service: " + definition); + throw new ServiceException("Unsupported Serie Definition for Service: " + definition); } } } else { - logger.error("Service not support this serie response: " - + seriesResponse); - throw new ServiceException( - "Service not support this serie response: " - + seriesResponse); + logger.error("Service not support this serie response: " + seriesResponse); + throw new ServiceException("Service not support this serie response: " + seriesResponse); } AccountingDataModel invocation = new AccountingDataModel(fileName, header, rows); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Storage.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Storage.java index 9d7c065..ef9b95b 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Storage.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/export/model/AccountingModel4Storage.java @@ -10,9 +10,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesReques import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataContext; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop; @@ -23,13 +21,12 @@ import org.slf4j.LoggerFactory; /** * Accounting Model 4 Storage * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ public class AccountingModel4Storage extends AccountingModelBuilder { - protected static Logger logger = LoggerFactory - .getLogger(AccountingModel4Storage.class); + protected static Logger logger = LoggerFactory.getLogger(AccountingModel4Storage.class); private AccountingStateData accountingStateData; public AccountingModel4Storage(AccountingStateData accountingStateData) { @@ -42,36 +39,31 @@ public class AccountingModel4Storage extends AccountingModelBuilder { if (seriesRequest == null) { logger.error("Error series request is null"); - throw new ServiceException( - "Error series request is null"); + throw new ServiceException("Error series request is null"); } - String startDate=""; + String startDate = ""; try { - startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() - .getStartDate())); + startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate())); } catch (ParseException e) { e.printStackTrace(); } - - String endDate=""; + + String endDate = ""; try { - endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() - .getEndDate())); + endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate())); } catch (ParseException e) { e.printStackTrace(); } - - String periodType = seriesRequest.getAccountingPeriod().getPeriod() - .getLabel(); + + String periodType = seriesRequest.getAccountingPeriod().getPeriod().getLabel(); SeriesResponse seriesResponse = accountingStateData.getSeriesResponse(); if (seriesResponse == null) { logger.error("Error series response is null"); - throw new ServiceException( - "Error series response is null"); + throw new ServiceException("Error series response is null"); } String fileName = "Untitled"; @@ -79,16 +71,12 @@ public class AccountingModel4Storage extends AccountingModelBuilder { ArrayList rows = new ArrayList<>(); if (seriesResponse instanceof SeriesStorage) { SeriesStorage seriesStorage = (SeriesStorage) seriesResponse; - SeriesStorageDefinition definition = seriesStorage - .getSeriesStorageDefinition(); + SeriesStorageDefinition definition = seriesStorage.getSeriesStorageDefinition(); if (definition instanceof SeriesStorageBasic) { SeriesStorageBasic seriesStorageBasic = (SeriesStorageBasic) definition; - fileName = "Storage_" + periodType + "_" + startDate + "_" - + endDate; - header = new ArrayList<>(Arrays.asList(new String[] { "Date", - "Operation Count", "Data Volume" })); - ArrayList listData = seriesStorageBasic - .getSeries(); + fileName = "Storage_" + periodType + "_" + startDate + "_" + endDate; + header = new ArrayList<>(Arrays.asList(new String[] { "Date", "Operation Count", "Data Volume" })); + ArrayList listData = seriesStorageBasic.getSeries(); for (SeriesStorageData seriesData : listData) { ArrayList data = new ArrayList<>(); data.add(sdfCSVDate.format(seriesData.getDate())); @@ -100,18 +88,13 @@ public class AccountingModel4Storage extends AccountingModelBuilder { } else { if (definition instanceof SeriesStorageTop) { SeriesStorageTop seriesStorageTop = (SeriesStorageTop) definition; - fileName = "StorageTop_" + periodType + "_" + startDate - + "_" + endDate; + fileName = "StorageTop_" + periodType + "_" + startDate + "_" + endDate; header = new ArrayList<>( - Arrays.asList(new String[] { "Value", "Date", - "Operation Count", "Data Volume" })); - ArrayList listDataTop = seriesStorageTop - .getSeriesStorageDataTopList(); + Arrays.asList(new String[] { "Value", "Date", "Operation Count", "Data Volume" })); + ArrayList listDataTop = seriesStorageTop.getSeriesStorageDataTopList(); for (SeriesStorageDataTop seriesDataTop : listDataTop) { - FilterValue filterValue = seriesDataTop - .getFilterValue(); - ArrayList listData = seriesDataTop - .getSeries(); + FilterValue filterValue = seriesDataTop.getFilterValue(); + ArrayList listData = seriesDataTop.getSeries(); for (SeriesStorageData seriesData : listData) { ArrayList data = new ArrayList<>(); data.add(filterValue.getValue()); @@ -123,46 +106,16 @@ public class AccountingModel4Storage extends AccountingModelBuilder { } } } else { - if (definition instanceof SeriesStorageContext) { - SeriesStorageContext seriesStorageContext = (SeriesStorageContext) definition; - fileName = "StorageContext_" + periodType + "_" + startDate - + "_" + endDate; - header = new ArrayList<>( - Arrays.asList(new String[] { "Value", "Date", - "Operation Count", "Data Volume" })); - ArrayList listDataContext = seriesStorageContext - .getSeriesStorageDataContextList(); - for (SeriesStorageDataContext seriesDataContext : listDataContext) { - ArrayList listData = seriesDataContext - .getSeries(); - for (SeriesStorageData seriesData : listData) { - ArrayList data = new ArrayList<>(); - data.add(seriesDataContext.getContext()); - data.add(sdfCSVDate.format(seriesData.getDate())); - data.add(String.valueOf(seriesData.getOperationCount())); - data.add(String.valueOf(seriesData.getDataVolume())); - AccountingDataRow csvDataRow = new AccountingDataRow(data); - rows.add(csvDataRow); - } - } - } else { - logger.error("Unsupported Serie Definition for Storage: " - + definition); - throw new ServiceException( - "Unsupported Serie Definition for Storage: " - + definition); - } + logger.error("Unsupported Serie Definition for Storage: " + definition); + throw new ServiceException("Unsupported Serie Definition for Storage: " + definition); } } } else { - logger.error("Storage not support this serie response: " - + seriesResponse); - throw new ServiceException( - "Storage not support this serie response: " - + seriesResponse); + logger.error("Storage not support this serie response: " + seriesResponse); + throw new ServiceException("Storage not support this serie response: " + seriesResponse); } - AccountingDataModel invocation = new AccountingDataModel(fileName,header, rows); + AccountingDataModel invocation = new AccountingDataModel(fileName, header, rows); accountingModelSpec.setOp(invocation); } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterBasic.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterBasic.java index e71e69d..10f8050 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterBasic.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterBasic.java @@ -5,55 +5,36 @@ import java.util.ArrayList; /** * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ -public class AccountingFilterBasic extends AccountingFilterDefinition implements - Serializable { +public class AccountingFilterBasic extends AccountingFilterDefinition implements Serializable { private static final long serialVersionUID = -6805006183397381154L; private ArrayList filters; - private String scope; - private Boolean noContext; + private Context context; public AccountingFilterBasic() { super(); this.chartType = ChartType.Basic; - noContext = false; filters = null; - scope=null; + context = null; } - - public AccountingFilterBasic(String scope, boolean noContenxt) { + + public AccountingFilterBasic(Context context) { super(); chartType = ChartType.Basic; this.filters = null; - this.scope=scope; - this.noContext = noContenxt; - } - - - public AccountingFilterBasic(String scope, ArrayList filters, - boolean noContenxt) { - super(); - chartType = ChartType.Basic; - this.scope=scope; - this.filters = filters; - this.noContext = noContenxt; + this.context = context; } - - public String getScope() { - return scope; - } - - public void setScope(String scope) { - this.scope = scope; - } - - public Boolean getNoContext() { - return noContext; + + public AccountingFilterBasic(Context context, ArrayList filters) { + super(); + chartType = ChartType.Basic; + this.filters = filters; + this.context = context; } public ArrayList getFilters() { @@ -64,20 +45,18 @@ public class AccountingFilterBasic extends AccountingFilterDefinition implements this.filters = filters; } - public boolean isNoContext() { - return noContext; + public Context getContext() { + return context; } - public void setNoContext(Boolean noContext) { - this.noContext = noContext; + public void setContext(Context context) { + this.context = context; } @Override public String toString() { - return "AccountingFilterBasic [filters=" + filters + ", scope=" + scope + ", noContext=" + noContext - + ", chartType=" + chartType + "]"; + return "AccountingFilterBasic [filters=" + filters + ", context=" + context + ", chartType=" + chartType + "]"; } - } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterTop.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterTop.java index 905f668..8c33e6d 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterTop.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterTop.java @@ -5,15 +5,14 @@ import java.util.ArrayList; /** * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ -public class AccountingFilterTop extends AccountingFilterDefinition implements - Serializable { +public class AccountingFilterTop extends AccountingFilterDefinition implements Serializable { private static final long serialVersionUID = -6805006183397381154L; - private String scope; + private Context context; private FilterKey filterKey; private Boolean showOthers; private Integer topNumber; @@ -22,32 +21,30 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements public AccountingFilterTop() { super(); this.chartType = ChartType.Top; - scope=null; + context = null; showOthers = false; topNumber = 5; filterKey = null; filters = null; } - - public AccountingFilterTop(String scope, Boolean showOthers,Integer topNumber) { + + public AccountingFilterTop(Context context, Boolean showOthers, Integer topNumber) { super(); this.chartType = ChartType.Top; - this.scope=scope; + this.context = context; this.showOthers = showOthers; this.topNumber = topNumber; filterKey = null; filters = null; } - - public AccountingFilterTop(String scope, FilterKey filterKey, - ArrayList filters, Boolean showOthers, - Integer topNumber) { + public AccountingFilterTop(Context context, FilterKey filterKey, ArrayList filters, + Boolean showOthers, Integer topNumber) { super(); chartType = ChartType.Top; - this.scope=scope; + this.context = context; this.filterKey = filterKey; this.filters = filters; this.showOthers = showOthers; @@ -55,12 +52,12 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements } - public String getScope() { - return scope; + public Context getContext() { + return context; } - public void setScope(String scope) { - this.scope = scope; + public void setContext(Context context) { + this.context = context; } public FilterKey getFilterKey() { @@ -97,10 +94,10 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements @Override public String toString() { - return "AccountingFilterTop [scope=" + scope + ", filterKey=" + filterKey + ", showOthers=" + showOthers + return "AccountingFilterTop [context=" + context + ", filterKey=" + filterKey + ", showOthers=" + showOthers + ", topNumber=" + topNumber + ", filters=" + filters + ", chartType=" + chartType + "]"; } - + } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ChartType.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ChartType.java index 73ea81c..149f4e6 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ChartType.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ChartType.java @@ -14,7 +14,7 @@ import java.util.List; public enum ChartType { - Basic("Basic"), Top("Top"), Context("Context"), Spaces("Spaces"); + Basic("Basic"), Top("Top"), Spaces("Spaces"); /** * diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/GenresData.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ScopeData.java similarity index 100% rename from src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/GenresData.java rename to src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ScopeData.java diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/Genres.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ScopesInfo.java similarity index 100% rename from src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/Genres.java rename to src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ScopesInfo.java