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/accountingman.gwt.xml b/src/main/java/org/gcube/portlets/admin/accountingmanager/accountingman.gwt.xml
index e566422..772a767 100644
--- a/src/main/java/org/gcube/portlets/admin/accountingmanager/accountingman.gwt.xml
+++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/accountingman.gwt.xml
@@ -46,7 +46,8 @@
-
@@ -56,8 +57,7 @@
-
-
+
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..59e196b 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=availableContext;
+
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..0fe780b 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,26 +9,25 @@ 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;
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.Constants;
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.NoScopeSelectedException;
import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpiredException;
import com.allen_sauer.gwt.log.client.Log;
@@ -39,21 +38,17 @@ import com.google.gwt.editor.client.Editor.Path;
import com.google.gwt.editor.client.EditorError;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
-import com.google.gwt.event.logical.shared.ValueChangeEvent;
-import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.google.gwt.user.client.ui.HasValue;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.IdentityValueProvider;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.XTemplates;
import com.sencha.gxt.core.client.util.Margins;
-import com.sencha.gxt.core.client.util.ToggleGroup;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.ModelKeyProvider;
@@ -66,9 +61,6 @@ import com.sencha.gxt.dnd.core.client.GridDropTarget;
import com.sencha.gxt.widget.core.client.button.ButtonBar;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
-import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
-import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
-import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
@@ -85,10 +77,11 @@ import com.sencha.gxt.widget.core.client.form.ComboBox;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.FieldSet;
import com.sencha.gxt.widget.core.client.form.IntegerSpinnerField;
-import com.sencha.gxt.widget.core.client.form.Radio;
import com.sencha.gxt.widget.core.client.form.StringComboBox;
import com.sencha.gxt.widget.core.client.form.error.DefaultEditorError;
import com.sencha.gxt.widget.core.client.form.validator.EmptyValidator;
+import com.sencha.gxt.widget.core.client.form.validator.MaxNumberValidator;
+import com.sencha.gxt.widget.core.client.form.validator.MinNumberValidator;
import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
@@ -96,6 +89,8 @@ import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
import com.sencha.gxt.widget.core.client.grid.GridSelectionModel;
import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
+import com.sencha.gxt.widget.core.client.grid.filters.GridFilters;
+import com.sencha.gxt.widget.core.client.grid.filters.StringFilter;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/**
@@ -106,16 +101,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_MIN = 1;
+ private static final String CONTEXT = "Context";
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 StringFilter scopeFilter;
+
private boolean addStatus;
private AccountingClientStateData accountingStateData;
private ListStore storeComboFilterKey;
@@ -128,16 +123,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 FieldLabel showOthersLabel;
private IntegerSpinnerField topNumber;
private FieldLabel topNumberLabel;
@@ -145,13 +136,9 @@ public class ActiveFiltersPanel extends SimpleContainer {
private boolean cancelValue;
private AccountingMonitor accountingMonitor;
- private Radio showOthersYes;
- private Radio showOthersNo;
- private ToggleGroup showOthersToggle;
-
- private Radio noContextYes;
- private Radio noContextNo;
- private ToggleGroup noContextToggle;
+ // private Radio showOthersYes;
+ // private Radio showOthersNo;
+ // private ToggleGroup showOthersToggle;
public interface FilterKeyPropertiesCombo extends PropertyAccess {
@@ -162,17 +149,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 +273,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 +387,61 @@ 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, CONTEXT);
+
+ 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);
+
+ // gridScopes.setStateful(true);
+ // gridScopes.setStateId("gridScopesDefault");
+
+ scopeFilter = new StringFilter(propsScopeData.label());
+
+ GridFilters gridScopesFilters = new GridFilters();
+ gridScopesFilters.initPlugin(gridScopes);
+ gridScopesFilters.setLocal(true);
+ gridScopesFilters.addFilter(scopeFilter);
+
+ // GridFilterStateHandler handler = new
+ // GridFilterStateHandler(gridScopes,
+ // gridScopesFilters);
+ // handler.loadState();
+
+ // ChartTypeSelection
storeComboChartType = new ListStore(new ModelKeyProvider() {
@Override
@@ -435,76 +461,15 @@ 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");
-
// FileterKeyCombo for Top Chart
storeComboTopFilterKey = new ListStore(filterKeyPropertiesCombo.id());
@@ -517,103 +482,71 @@ public class ActiveFiltersPanel extends SimpleContainer {
comboTopFilterKeyLabel = new FieldLabel(comboTopFilterKey, "Key");
- // ShowOthers
- showOthersYes = new Radio();
- showOthersYes.setBoxLabel("Yes");
-
- showOthersNo = new Radio();
- showOthersNo.setBoxLabel("No");
- showOthersNo.setValue(true);
-
- showOthersToggle = new ToggleGroup();
- showOthersToggle.add(showOthersYes);
- showOthersToggle.add(showOthersNo);
-
- showOthersToggle.addValueChangeHandler(new ValueChangeHandler>() {
-
- @Override
- public void onValueChange(ValueChangeEvent> event) {
- ToggleGroup group = (ToggleGroup) event.getSource();
- Radio radio = (Radio) group.getValue();
- Log.debug("ShowOthers selected: " + radio.getBoxLabel());
- }
- });
-
- HBoxLayoutContainer hp = new HBoxLayoutContainer();
- hp.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
- hp.setPack(BoxLayoutPack.START);
- hp.add(showOthersYes, new BoxLayoutData(new Margins(0)));
- hp.add(showOthersNo, new BoxLayoutData(new Margins(0)));
-
- 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");
+ /*
+ * ShowOthers showOthersYes = new Radio();
+ * showOthersYes.setBoxLabel("Yes");
+ *
+ * showOthersNo = new Radio(); showOthersNo.setBoxLabel("No");
+ * showOthersNo.setValue(true);
+ *
+ * showOthersToggle = new ToggleGroup();
+ * showOthersToggle.add(showOthersYes);
+ * showOthersToggle.add(showOthersNo);
+ *
+ * showOthersToggle.addValueChangeHandler(new
+ * ValueChangeHandler>() {
+ *
+ * @Override public void
+ * onValueChange(ValueChangeEvent> event) {
+ * ToggleGroup group = (ToggleGroup) event.getSource(); Radio radio =
+ * (Radio) group.getValue(); Log.debug("ShowOthers selected: " +
+ * radio.getBoxLabel()); } });
+ *
+ * HBoxLayoutContainer hp = new HBoxLayoutContainer();
+ * hp.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
+ * hp.setPack(BoxLayoutPack.START); hp.add(showOthersYes, new
+ * BoxLayoutData(new Margins(0))); hp.add(showOthersNo, new
+ * BoxLayoutData(new Margins(0)));
+ *
+ * showOthersLabel = new FieldLabel(hp, "Show Others");
+ */
//
topNumber = new IntegerSpinnerField();
- topNumber.setMaxValue(TOP_NUMBER_MAX);
- topNumber.setMinValue(TOP_NUMBER_MIN);
+ topNumber.setMaxValue(Constants.TOP_NUMBER_MAX);
+ topNumber.setMinValue(Constants.TOP_NUMBER_MIN);
topNumber.setAllowNegative(false);
topNumber.setAllowBlank(false);
- topNumber.setValue(TOP_NUMBER_DEFAULT);
- topNumber.setEditable(false);
+ topNumber.setValue(Constants.TOP_NUMBER_DEFAULT);
+ topNumber.setEditable(true);
+ topNumber.addValidator(new MinNumberValidator(Constants.TOP_NUMBER_MIN));
+ topNumber.addValidator(new MaxNumberValidator(Constants.TOP_NUMBER_MAX));
topNumberLabel = new FieldLabel(topNumber, "Number");
// //
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(showOthersLabel, new VerticalLayoutData(1, -1, new
+ // Margins(0)));
vlc.add(topNumberLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(gridFilter, new VerticalLayoutData(1, 1, new Margins(0)));
FieldSet fieldSet = new FieldSet();
- fieldSet.setHeight("360px");
+ fieldSet.setHeight("450px");
fieldSet.setHeadingHtml("Active Filters");
fieldSet.setCollapsible(false);
fieldSet.add(vlc);
add(fieldSet, new MarginData(0));
+ gridScopes.setVisible(false);
comboChartTypeLabel.setVisible(false);
- comboScopeLabel.setVisible(false);
- gridGenres.setVisible(false);
- noContextLabel.setVisible(false);
comboTopFilterKeyLabel.setVisible(false);
- showOthersLabel.setVisible(false);
+ // showOthersLabel.setVisible(false);
topNumberLabel.setVisible(false);
}
@@ -727,11 +660,8 @@ public class ActiveFiltersPanel extends SimpleContainer {
case Top:
changeActiveFiltersForTop();
break;
- case Context:
- changeActiveFiltersForContext();
- break;
case Spaces:
- changeActiveFiltersForSpaces();
+ // changeActiveFiltersForSpaces();
break;
default:
@@ -742,33 +672,76 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
private void changeActiveFiltersForBasic() {
+ Log.debug("ChangeActiveFiltersForBasic");
if (accountingStateData.getSeriesRequest() != null
&& accountingStateData.getSeriesRequest().getAccountingFilterDefinition() != null && accountingStateData
.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.setEnableFilters(false);
+ storeScopes.addAll(scopes);
+ storeScopes.commitChanges();
+
+ Log.debug("ScopeFilterActive: " + accountingFilterBasic.getScopeFilterActive());
+ if (accountingFilterBasic.getScopeFilterActive() != null
+ && !accountingFilterBasic.getScopeFilterActive().isEmpty()) {
+ scopeFilter.setValue(accountingFilterBasic.getScopeFilterActive());
+ scopeFilter.setActive(true, false);
+ storeScopes.setEnableFilters(true);
+ storeScopes.commitChanges();
+
+ } else {
+ scopeFilter.setValue(null);
+ scopeFilter.setActive(false, false);
+ }
+
+ smScopes.deselectAll();
+
+ if (accountingFilterBasic.getContext().getContexts() != null
+ && !accountingFilterBasic.getContext().getContexts().isEmpty()) {
+ 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()) {
+ Log.debug("Select All Scope");
+ smScopes.selectAll();
+ } else {
+ Log.debug("Select Scope: " + selected);
+ 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 +760,24 @@ 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(CONTEXT);
+ 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);
-
+ // showOthersToggle.reset();
+ // showOthersNo.setValue(true);
+ // showOthersLabel.setVisible(false);
topNumber.reset();
topNumberLabel.setVisible(false);
forceLayout();
@@ -854,34 +785,77 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
private void changeActiveFiltersForTop() {
+ Log.debug("ChangeActiveFiltersForTop");
if (accountingStateData.getSeriesRequest() != null
&& accountingStateData.getSeriesRequest().getAccountingFilterDefinition() != null && accountingStateData
.getSeriesRequest().getAccountingFilterDefinition() instanceof AccountingFilterTop) {
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.setEnableFilters(false);
+ storeScopes.addAll(scopes);
+ storeScopes.commitChanges();
+
+ Log.debug("ScopeFilterActive: " + accountingFilterTop.getScopeFilterActive());
+ if (accountingFilterTop.getScopeFilterActive() != null
+ && !accountingFilterTop.getScopeFilterActive().isEmpty()) {
+ scopeFilter.setValue(accountingFilterTop.getScopeFilterActive());
+ scopeFilter.setActive(true, false);
+ storeScopes.setEnableFilters(true);
+ storeScopes.commitChanges();
+ } else {
+ scopeFilter.setValue(null);
+ scopeFilter.setActive(false, false);
+ }
+
+ smScopes.deselectAll();
+
+ if (accountingFilterTop.getContext().getContexts() != null
+ && !accountingFilterTop.getContext().getContexts().isEmpty()) {
+ 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()) {
+ Log.debug("Select All Scope");
+ smScopes.selectAll();
+ } else {
+ Log.debug("Select Scope: " + selected);
+ 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());
@@ -906,10 +880,10 @@ public class ActiveFiltersPanel extends SimpleContainer {
} else {
comboTopFilterKey.reset();
- showOthersToggle.reset();
- showOthersNo.setValue(true);
+ // showOthersToggle.reset();
+ // showOthersNo.setValue(true);
topNumber.reset();
- topNumber.setValue(TOP_NUMBER_DEFAULT);
+ topNumber.setValue(Constants.TOP_NUMBER_DEFAULT);
storeFilter.clear();
storeFilter.commitChanges();
seq = 0;
@@ -919,144 +893,49 @@ 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.setEnableFilters(false);
+ storeScopes.addAll(scopes);
+ storeScopes.commitChanges();
} else {
- storeComboScope.clear();
- storeComboScope.commitChanges();
- comboScope.reset();
+ storeScopes.clear();
+ storeScopes.setEnableFilters(false);
+ storeScopes.commitChanges();
}
- comboScopeLabel.setVisible(true);
+ scopeFilter.setValue(null);
+ scopeFilter.setActive(false, false);
+
+ smScopes.deselectAll();
+
comboTopFilterKey.reset();
- showOthersToggle.reset();
- showOthersNo.setValue(true);
+ // showOthersToggle.reset();
+ // showOthersNo.setValue(true);
topNumber.reset();
- topNumber.setValue(TOP_NUMBER_DEFAULT);
+ topNumber.setValue(Constants.TOP_NUMBER_DEFAULT);
storeFilter.clear();
storeFilter.commitChanges();
seq = 0;
}
+ gridScopes.setVisible(true);
+ labelScopesCol.setHeader(CONTEXT);
+ 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);
+ // showOthersLabel.setVisible(true);
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 +947,109 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
private void resetContexts() {
- storeGenres.clear();
- storeGenres.commitChanges();
- smGenres.deselectAll();
- smGenres.refresh();
+ storeScopes.clear();
+ storeScopes.commitChanges();
+ scopeFilter.setValue(null);
+ scopeFilter.setActive(false, false);
+ 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();
- }
-
- 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();
+ storeScopes.clear();
+ storeScopes.addAll(contextList);
+ storeScopes.commitChanges();
+ scopeFilter.setValue(null);
+ scopeFilter.setActive(false, false);
+ smScopes.selectAll();
+ smScopes.refresh();
}
- 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,15 +1060,16 @@ 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;
}
+ } catch (NoScopeSelectedException e) {
+ UtilsGXT3.alert("Attention", e.getLocalizedMessage());
+ return null;
} catch (Throwable e) {
Log.error(e.getLocalizedMessage());
e.printStackTrace();
@@ -1245,26 +1079,35 @@ 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();
+ private AccountingFilterDefinition getActiveFiltersForBasic() throws NoScopeSelectedException {
+ 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);
- Boolean noContextValue = false;
- if (noContextLabel != null && noContextLabel.isVisible()) {
- noContextValue = noContextYes.getValue();
- } else {
- noContextValue = false;
+ if (contextsSelected.isEmpty()) {
+ String msg = "No Scope selected! Please, select a Scope.";
+ Log.info(msg);
+ throw new NoScopeSelectedException(msg);
}
- Log.debug("noContextValue: " + noContextValue);
+
+ Context context = new Context(contextsSelected);
+
+ Log.debug("Context selected: " + context);
+
+ String scopeFilterActive = null;
+
+ if (scopeFilter.isActive()) {
+ scopeFilterActive = (String) scopeFilter.getValue();
+ }
+
+ Log.debug("Scope Filter Active: " + scopeFilterActive);
if (storeFilter == null || storeFilter.size() <= 0) {
- return new AccountingFilterBasic(scope, noContextValue);
+ return new AccountingFilterBasic(context, scopeFilterActive);
} else {
List filtersActives = storeFilter.getAll();
ArrayList filtersReady = new ArrayList();
@@ -1275,32 +1118,66 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
if (filtersReady.size() > 0) {
- return new AccountingFilterBasic(scope, filtersReady, noContextValue);
+ return new AccountingFilterBasic(context, scopeFilterActive, filtersReady);
} else {
- return new AccountingFilterBasic(scope, noContextValue);
+ return new AccountingFilterBasic(context, scopeFilterActive);
}
}
}
- private AccountingFilterDefinition getActiveFiltersForTop() {
- String scope = null;
- if (comboScopeLabel != null && comboScopeLabel.isVisible()) {
- GenresData genresData = comboScope.getCurrentValue();
- if (genresData != null) {
- scope = genresData.getLabel();
+ private AccountingFilterDefinition getActiveFiltersForTop() throws NoScopeSelectedException {
+ 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);
- Boolean showOthersValue = showOthersYes.getValue();
+ if (contextsSelected.isEmpty()) {
+ String msg = "No Scope selected! Please, select a Scope.";
+ Log.info(msg);
+ throw new NoScopeSelectedException(msg);
+ }
+
+ Context context = new Context(contextsSelected);
+
+ Log.debug("Context selected: " + context);
+
+ String scopeFilterActive = null;
+
+ if (scopeFilter.isActive()) {
+ scopeFilterActive = (String) scopeFilter.getValue();
+ }
+ Log.debug("Scope Filter Active: " + scopeFilterActive);
+
+ // Boolean showOthersValue = showOthersYes.getValue();
Integer topN = topNumber.getCurrentValue();
+ if(topN!=null){
+ if(topNConstants.TOP_NUMBER_MAX){
+ topN=Constants.TOP_NUMBER_MAX;
+ topNumber.setValue(topN, true, true);
+ topNumber.clearInvalid();
+ }
+ }
+ } else {
+ topN=Constants.TOP_NUMBER_DEFAULT;
+ topNumber.setValue(topN, true, true);
+ topNumber.clearInvalid();
+ }
+
FilterKey filterKey = comboTopFilterKey.getCurrentValue();
if (filterKey == null) {
- return new AccountingFilterTop(scope, showOthersValue, topN);
+ return new AccountingFilterTop(context, scopeFilterActive, topN);
} else {
if (storeFilter == null || storeFilter.size() <= 0) {
- return new AccountingFilterTop(scope, filterKey, null, showOthersValue, topN);
+ return new AccountingFilterTop(context, scopeFilterActive, filterKey, null, topN);
} else {
List filtersActives = storeFilter.getAll();
ArrayList filtersReady = new ArrayList();
@@ -1310,9 +1187,11 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
}
if (filtersReady.size() > 0) {
- return new AccountingFilterTop(scope, filterKey, filtersReady, showOthersValue, topN);
+ return new AccountingFilterTop(context, scopeFilterActive, filterKey,
+ filtersReady, topN);
} else {
- return new AccountingFilterTop(scope, filterKey, null, showOthersValue, topN);
+ return new AccountingFilterTop(context, scopeFilterActive, filterKey,
+ null, topN);
}
}
@@ -1320,59 +1199,30 @@ 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());
- }
- }
- Spaces spaces = new Spaces(spacesSelected);
-
- 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 AccountingFilterSpaces(spaces, filtersReady);
- } else {
- return new AccountingFilterSpaces(spaces, null);
- }
-
- }
+ /*
+ * private AccountingFilterDefinition getActiveFiltersForSpaces() {
+ * ArrayList spacesSelected = new ArrayList(); 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) { if (filter.getFilterValue() != null &&
+ * !filter.getFilterValue().isEmpty()) { filtersReady.add(filter); } } if
+ * (filtersReady.size() > 0) { return new AccountingFilterSpaces(spaces,
+ * filtersReady); } else { return new AccountingFilterSpaces(spaces, null);
+ * }
+ *
+ * }
+ */
private void addNewFilter(SelectEvent event) {
- List filtersSet = storeFilter.getAll();
+ // List filtersSet = storeFilter.getAll();
FilterKey fk = null;
if (accountingStateData == null || accountingStateData.getAvailableFilterKeys() == null
@@ -1384,9 +1234,10 @@ public class ActiveFiltersPanel extends SimpleContainer {
accountingStateData.getAvailableFilterKeys());
List removableFilterKeys = new ArrayList();
- for (AccountingFilter filterSet : filtersSet) {
- removableFilterKeys.add(filterSet.getFilterKey());
- }
+ /*
+ * for (AccountingFilter filterSet : filtersSet) {
+ * removableFilterKeys.add(filterSet.getFilterKey()); }
+ */
if (comboChartType.getCurrentValue() != null
&& comboChartType.getCurrentValue().compareTo(ChartType.Top) == 0) {
@@ -1398,14 +1249,6 @@ public class ActiveFiltersPanel extends SimpleContainer {
remainingFilterKeys.removeAll(removableFilterKeys);
if (remainingFilterKeys.size() > 0) {
- /*
- * if (comboChartType.getCurrentValue() != null &&
- * comboChartType.getCurrentValue().compareTo( ChartType.Top) ==
- * 0) { if(!(store.getAll().size()<2)){
- * UtilsGXT3.info("Attention",
- * "You can add at most 2 filters for top chart!"); return; } }
- */
- // fk = remainingFilterKeys.get(0);
fk = new FilterKey("");
seq++;
AccountingFilter newAccountingFilter = new AccountingFilter(seq, fk, "");
@@ -1494,7 +1337,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
int rowIndex = cell.getRow();
AccountingFilter editingFilter = storeFilter.get(rowIndex);
- List filtersSet = storeFilter.getAll();
+ // List filtersSet = storeFilter.getAll();
List remainingFilterKeys = null;
if (accountingStateData == null || accountingStateData.getAvailableFilterKeys() == null) {
@@ -1513,11 +1356,12 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
}
- for (AccountingFilter filterSet : filtersSet) {
- if (filterSet.getFilterKey().getKey().compareTo(editingFilter.getFilterKey().getKey()) != 0) {
- setFilterKeys.add(filterSet.getFilterKey());
- }
- }
+ /*
+ * for (AccountingFilter filterSet : filtersSet) { if
+ * (filterSet.getFilterKey().getKey().compareTo(editingFilter.
+ * getFilterKey().getKey()) != 0) {
+ * setFilterKeys.add(filterSet.getFilterKey()); } }
+ */
remainingFilterKeys.removeAll(setFilterKeys);
@@ -1564,24 +1408,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);
- }
-
+ //showOthersToggle.reset();
+ //showOthersNo.setValue(true);
+ //showOthersLabel.setVisible(false);
topNumber.reset();
topNumberLabel.setVisible(false);
storeFilter.clear();
@@ -1590,73 +1421,33 @@ 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) {
comboTopFilterKey.setValue(accountingStateData.getAvailableFilterKeys().get(0));
}
comboTopFilterKeyLabel.setVisible(true);
- showOthersToggle.reset();
- showOthersNo.setValue(true);
- showOthersLabel.setVisible(true);
- noContextToggle.reset();
- noContextYes.setValue(false);
- noContextNo.setValue(true);
- noContextLabel.setVisible(false);
+ //showOthersToggle.reset();
+ //showOthersNo.setValue(true);
+ //showOthersLabel.setVisible(true);
topNumber.reset();
- topNumber.setValue(TOP_NUMBER_DEFAULT);
+ topNumber.setValue(Constants.TOP_NUMBER_DEFAULT);
topNumberLabel.setVisible(true);
storeFilter.clear();
storeFilter.commitChanges();
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);
- 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);
+ * gridScopes.setVisible(true); labelScopesCol.setHeader("Space");
+ * gridScopes.getView().refresh(true); comboTopFilterKey.reset();
+ * comboTopFilterKeyLabel.setVisible(false); showOthersToggle.reset();
+ * showOthersNo.setValue(true); showOthersLabel.setVisible(false);
+ * topNumber.reset(); topNumberLabel.setVisible(false);
+ * storeFilter.clear(); storeFilter.commitChanges(); seq = 0;
+ * forceLayout(); break;
+ */
default:
break;
@@ -1680,18 +1471,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/filters/FiltersPanel.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/FiltersPanel.java
index f45ef38..61b1a9e 100644
--- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/FiltersPanel.java
+++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/filters/FiltersPanel.java
@@ -92,7 +92,7 @@ public class FiltersPanel extends FramedPanel {
AccountingFilterDefinition accountingFilterDefinition = activeFiltersPanel
.getActiveFilters();
- if (accountingPeriod != null) {
+ if (accountingPeriod != null && accountingFilterDefinition!=null) {
SeriesRequest seriesRequest = new SeriesRequest(accountingPeriod,
accountingFilterDefinition);
Log.debug("UpdateChart: " + seriesRequest);
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/maindata/charts/job/JobChartContextPanel.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/job/JobChartContextPanel.java
deleted file mode 100644
index 0ea1338..0000000
--- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/job/JobChartContextPanel.java
+++ /dev/null
@@ -1,1003 +0,0 @@
-package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job;
-
-import java.util.ArrayList;
-import java.util.Date;
-
-import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent;
-import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartDateTimeData;
-import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
-import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
-import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure;
-import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
-import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
-import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
-import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriodMode;
-import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
-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.export.ExportType;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel;
-import com.github.highcharts4gwt.model.array.api.Array;
-import com.github.highcharts4gwt.model.array.api.ArrayNumber;
-import com.github.highcharts4gwt.model.array.api.ArrayString;
-import com.github.highcharts4gwt.model.factory.api.HighchartsOptionFactory;
-import com.github.highcharts4gwt.model.factory.jso.JsoHighchartsOptionFactory;
-import com.github.highcharts4gwt.model.highcharts.option.api.ChartOptions;
-import com.github.highcharts4gwt.model.highcharts.option.api.SeriesColumn;
-import com.github.highcharts4gwt.model.highcharts.option.api.seriescolumn.Data;
-import com.google.gwt.event.logical.shared.SelectionEvent;
-import com.google.gwt.event.logical.shared.SelectionHandler;
-import com.google.gwt.event.shared.EventBus;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
-import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
-import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
-import com.sencha.gxt.core.client.util.Margins;
-import com.sencha.gxt.widget.core.client.button.TextButton;
-import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
-import com.sencha.gxt.widget.core.client.container.MarginData;
-import com.sencha.gxt.widget.core.client.container.SimpleContainer;
-import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
-import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
-import com.sencha.gxt.widget.core.client.menu.Item;
-import com.sencha.gxt.widget.core.client.menu.Menu;
-import com.sencha.gxt.widget.core.client.menu.MenuItem;
-import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
-
-/**
- *
- * @author Giancarlo Panichi
- *
- *
- */
-public class JobChartContextPanel extends SimpleContainer {
- private static final int MAX_NUMBER_OF_CONTEXT = 20;
-
- private static final String TIME_UNIT = "Time Unit";
- // private static final String MEASURE_TYPE = "Measure";
-
- private DateTimeFormat dtf = DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
-
- private EventBus eventBus;
- private AccountingClientStateData accountingStateData;
- private HighchartsLayoutPanel highchartsLayoutPanel;
-
- // Download Menu
- private MenuItem downloadCSVItem;
- private MenuItem downloadXMLItem;
- private MenuItem downloadJSONItem;
- private MenuItem downloadPNGItem;
- private MenuItem downloadJPGItem;
- private MenuItem downloadPDFItem;
- private MenuItem downloadSVGItem;
-
- // Measure Menu
- private MenuItem operationCountItem;
- private MenuItem durationItem;
- private MenuItem maxInvocationTimeItem;
- private MenuItem minInvocationTimeItem;
-
- // Time Unit Menu
- private MenuItem msItem;
- private MenuItem sItem;
- private MenuItem mItem;
- private MenuItem hItem;
-
- private long unitMeasure = TimeUnitMeasure.getMilliseconds();
- private String unitMeasureLabel = TimeUnitMeasure.MS;
- private TextButton unitButton;
-
- private ChartOptions options;
-
- private JobChartMeasure measure = JobChartMeasure.OperationCount;
- private TextButton measureButton;
-
- private VerticalLayoutContainer vert;
-
- public JobChartContextPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
- this.eventBus = eventBus;
- this.accountingStateData = accountingStateData;
- forceLayoutOnResize = true;
- create();
-
- }
-
- private void create() {
- ToolBar toolBar = new ToolBar();
- toolBar.setSpacing(2);
- // Download
- final TextButton downloadButton = new TextButton(DownloadConstants.DOWNLOAD,
- AccountingManagerResources.INSTANCE.accountingDownload24());
- // downloadButton.setScale(ButtonScale.MEDIUM);
- downloadButton.setIconAlign(IconAlign.RIGHT);
- downloadButton.setArrowAlign(ButtonArrowAlign.RIGHT);
- downloadButton.setMenu(createDownloadMenu());
-
- // Measure
- measureButton = new TextButton(JobChartMeasure.OperationCount.getLabel(),
- AccountingManagerResources.INSTANCE.accountingByte24());
- measureButton.setIconAlign(IconAlign.RIGHT);
- measureButton.setArrowAlign(ButtonArrowAlign.RIGHT);
- measureButton.setMenu(createMeasureMenu());
-
- // Unit
- unitButton = new TextButton(TIME_UNIT, AccountingManagerResources.INSTANCE.accountingUnitms24());
- unitButton.setIconAlign(IconAlign.RIGHT);
- unitButton.setArrowAlign(ButtonArrowAlign.RIGHT);
- unitButton.setMenu(createUnitMenu());
- unitButton.setVisible(false);
-
- toolBar.add(downloadButton, new BoxLayoutData(new Margins(0)));
- toolBar.add(measureButton, new BoxLayoutData(new Margins(0)));
- toolBar.add(unitButton, new BoxLayoutData(new Margins(0)));
-
- //
- createChart();
-
- highchartsLayoutPanel = new HighchartsLayoutPanel();
- highchartsLayoutPanel.renderChart(options);
-
- //
- vert = new VerticalLayoutContainer();
- vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
- vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, new Margins(0)));
-
- add(vert, new MarginData(0));
-
- }
-
- private void updateChart() {
- createChart();
- highchartsLayoutPanel.renderChart(options);
- forceLayout();
- }
-
- private Menu createDownloadMenu() {
- Menu menuDownload = new Menu();
- downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
- AccountingManagerResources.INSTANCE.accountingFileCSV24());
- downloadCSVItem.setHeight(30);
- downloadXMLItem = new MenuItem(DownloadConstants.DOWNLOAD_XML,
- AccountingManagerResources.INSTANCE.accountingFileXML24());
- downloadXMLItem.setHeight(30);
- downloadJSONItem = new MenuItem(DownloadConstants.DOWNLOAD_JSON,
- AccountingManagerResources.INSTANCE.accountingFileJSON24());
- downloadJSONItem.setHeight(30);
- downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
- AccountingManagerResources.INSTANCE.accountingFilePNG24());
- downloadPNGItem.setHeight(30);
- downloadJPGItem = new MenuItem(DownloadConstants.DOWNLOAD_JPG,
- AccountingManagerResources.INSTANCE.accountingFileJPG24());
- downloadJPGItem.setHeight(30);
- downloadPDFItem = new MenuItem(DownloadConstants.DOWNLOAD_PDF,
- AccountingManagerResources.INSTANCE.accountingFilePDF24());
- downloadPDFItem.setHeight(30);
- downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
- AccountingManagerResources.INSTANCE.accountingFileSVG24());
- downloadSVGItem.setHeight(30);
-
- downloadCSVItem.addSelectionHandler(new SelectionHandler- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- onDownloadCSV();
-
- }
-
- });
-
- downloadXMLItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- onDownloadXML();
-
- }
-
- });
-
- downloadJSONItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- onDownloadJSON();
-
- }
-
- });
-
- downloadPNGItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- String id = highchartsLayoutPanel.getElement().getId();
- onDownloadPNG(id);
-
- }
- });
-
- downloadJPGItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- String id = highchartsLayoutPanel.getElement().getId();
- onDownloadJPG(id);
- }
- });
-
- downloadPDFItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- String id = highchartsLayoutPanel.getElement().getId();
- onDownloadPDF(id);
- }
- });
-
- downloadSVGItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- String id = highchartsLayoutPanel.getElement().getId();
- onDownloadSVG(id);
- }
- });
-
- menuDownload.add(downloadCSVItem);
- menuDownload.add(downloadXMLItem);
- menuDownload.add(downloadJSONItem);
- menuDownload.add(downloadPNGItem);
- menuDownload.add(downloadJPGItem);
- menuDownload.add(downloadPDFItem);
- menuDownload.add(downloadSVGItem);
- return menuDownload;
-
- }
-
- private Menu createMeasureMenu() {
- Menu menuMeasure = new Menu();
- // TODO
- durationItem = new MenuItem(JobChartMeasure.Duration.getLabel());
- durationItem.setHeight(30);
- operationCountItem = new MenuItem(JobChartMeasure.OperationCount.getLabel());
- operationCountItem.setHeight(30);
- maxInvocationTimeItem = new MenuItem(JobChartMeasure.MaxInvocationTime.getLabel());
- maxInvocationTimeItem.setHeight(30);
- minInvocationTimeItem = new MenuItem(JobChartMeasure.MinInvocationTime.getLabel());
- minInvocationTimeItem.setHeight(30);
-
- durationItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- measureButton.setText(JobChartMeasure.Duration.getLabel());
- measure = JobChartMeasure.Duration;
- unitButton.setVisible(true);
- updateChart();
- }
- });
-
- operationCountItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- measureButton.setText(JobChartMeasure.OperationCount.getLabel());
- measure = JobChartMeasure.OperationCount;
- unitButton.setVisible(false);
- updateChart();
- }
- });
-
- maxInvocationTimeItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- measureButton.setText(JobChartMeasure.MaxInvocationTime.getLabel());
- measure = JobChartMeasure.MaxInvocationTime;
- unitButton.setVisible(true);
- updateChart();
- }
- });
-
- minInvocationTimeItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- measureButton.setText(JobChartMeasure.MinInvocationTime.getLabel());
- measure = JobChartMeasure.MinInvocationTime;
- unitButton.setVisible(true);
- updateChart();
- }
- });
-
- menuMeasure.add(durationItem);
- menuMeasure.add(maxInvocationTimeItem);
- menuMeasure.add(minInvocationTimeItem);
- menuMeasure.add(operationCountItem);
-
- return menuMeasure;
-
- }
-
- private Menu createUnitMenu() {
- Menu menuUnit = new Menu();
- msItem = new MenuItem(TimeUnitMeasure.MILLISECONDS, AccountingManagerResources.INSTANCE.accountingUnitms24());
- msItem.setHeight(30);
- sItem = new MenuItem(TimeUnitMeasure.SECONDS, AccountingManagerResources.INSTANCE.accountingUnits24());
- sItem.setHeight(30);
- mItem = new MenuItem(TimeUnitMeasure.MINUTES, AccountingManagerResources.INSTANCE.accountingUnitm24());
- mItem.setHeight(30);
- hItem = new MenuItem(TimeUnitMeasure.HOURS, AccountingManagerResources.INSTANCE.accountingUnith24());
- hItem.setHeight(30);
-
- msItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- unitMeasure = TimeUnitMeasure.getMilliseconds();
- unitMeasureLabel = TimeUnitMeasure.MS;
- unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitms24());
- updateChart();
- }
- });
-
- sItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- unitMeasure = TimeUnitMeasure.getSeconds();
- unitMeasureLabel = TimeUnitMeasure.S;
- unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnits24());
- updateChart();
- }
- });
-
- mItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- unitMeasure = TimeUnitMeasure.getMinutes();
- unitMeasureLabel = TimeUnitMeasure.M;
- unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitm24());
- updateChart();
- }
- });
-
- hItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- unitMeasure = TimeUnitMeasure.getHours();
- unitMeasureLabel = TimeUnitMeasure.H;
- unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnith24());
- updateChart();
- }
- });
-
- menuUnit.add(msItem);
- menuUnit.add(sItem);
- menuUnit.add(mItem);
- menuUnit.add(hItem);
- return menuUnit;
-
- }
-
- private void onDownloadCSV() {
- ExportRequestEvent event = new ExportRequestEvent(ExportType.CSV, accountingStateData.getAccountingType());
- eventBus.fireEvent(event);
- }
-
- private void onDownloadXML() {
- ExportRequestEvent event = new ExportRequestEvent(ExportType.XML, accountingStateData.getAccountingType());
- eventBus.fireEvent(event);
- }
-
- private void onDownloadJSON() {
- ExportRequestEvent event = new ExportRequestEvent(ExportType.JSON, accountingStateData.getAccountingType());
- eventBus.fireEvent(event);
- }
-
- // chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
-
- public static native void onDownloadPNG(String id) /*-{
- console.log(id);
- var chart = $wnd
- .jQuery('#' + id)
- .highcharts(
- this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartContextPanel::options);
- console.log(chart);
- chart.exportChart();
-
- }-*/;
-
- public static native void onDownloadJPG(String id) /*-{
- console.log(id);
- var chart = $wnd
- .jQuery('#' + id)
- .highcharts(
- this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartContextPanel::options);
- console.log(chart);
- chart.exportChart({
- type : 'image/jpeg'
- });
-
- }-*/;
-
- public static native void onDownloadPDF(String id) /*-{
- console.log(id);
- var chart = $wnd
- .jQuery('#' + id)
- .highcharts(
- this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartContextPanel::options);
- console.log(chart);
- chart.exportChart({
- type : 'application/pdf'
- });
-
- }-*/;
-
- public static native void onDownloadSVG(String id) /*-{
- console.log(id);
- var chart = $wnd
- .jQuery('#' + id)
- .highcharts(
- this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartContextPanel::options);
- console.log(chart);
- chart.exportChart({
- type : 'image/svg+xml'
- });
-
- }-*/;
-
- private void createChart() {
- SeriesJob seriesJob = (SeriesJob) accountingStateData.getSeriesResponse();
-
- if (!(seriesJob.getSeriesJobDefinition() instanceof SeriesJobContext)) {
- Log.debug("Invalid SeriesJobContext!");
- return;
- }
- SeriesJobContext seriesJobContext = (SeriesJobContext) seriesJob.getSeriesJobDefinition();
-
- HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
-
- options = highchartsFactory.createChartOptions();
- options.chart().zoomType("xy");
- options.exporting().buttons().contextButton().enabled(false);
- options.exporting().filename("AccountingJobContext");
- options.title().text("Accounting Job Context");
-
- /*
- * options.subtitle().text("Click and drag in the plot area to zoom in"
- * );
- */
-
- ArrayString colors = options.colors();
- // colors.setValue(0, "#cc0038");
- // colors.setValue(1, "#32cd32");
-
- // yAxis
- options.setFieldAsJsonObject("yAxis", retrieveYAxis(colors));
-
- options.plotOptions().setFieldAsJsonObject("column",
- "{ " + "\"stacking\": \"normal\"," + "\"dataLabels\": { " + " \"enabled\": \"true\","
- + " \"color\": \"white\", " + " \"style\": {"
- + " \"textShadow\": \"0 0 3px black\"" + " }" + " }" + " }");
-
- ArrayList seriesColumn = new ArrayList<>();
- /*
- * if (seriesJobContext.getShowOthers()) {
- * createSeriesColumnShowOthers(seriesJobContext, highchartsFactory,
- * colors, seriesColumn); } else {
- */
- createSeriesColumnSimple(seriesJobContext, highchartsFactory, colors, seriesColumn);
- /* } */
-
- for (SeriesColumn serie : seriesColumn) {
- options.series().addToEnd(serie);
- }
-
- options.chart().showAxes(true);
-
- options.legend().enabled(true);
- return;
- }
-
- private void createSeriesColumnShowOthers(SeriesJobContext seriesJobContext,
- HighchartsOptionFactory highchartsFactory, ArrayString colors, ArrayList seriesColumn) {
- Log.debug("Series ShowOthers");
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.DAILY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.HOURLY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.MINUTELY) == 0) {
-
- double minRange = ChartTimeMeasure
- .calculateMinRange(accountingStateData.getSeriesRequest().getAccountingPeriod());
-
- double interval = ChartTimeMeasure
- .calculateInterval(accountingStateData.getSeriesRequest().getAccountingPeriod());
-
- Date dateStart = dtf.parse(accountingStateData.getSeriesRequest().getAccountingPeriod().getStartDate());
-
- dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
-
- Log.debug("BuildChart DateStart: "
- + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(dateStart));
-
- // xAxis
- options.xAxis().type("datetime");
- options.xAxis().minRange(minRange);
- options.tooltip().xDateFormat("Selected Data");
-
- int i = 0;
- for (; i < seriesJobContext.getSeriesJobDataContextList().size() && i < MAX_NUMBER_OF_CONTEXT; i++) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name(seriesJobContext.getSeriesJobDataContextList().get(i).getContext());
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- ArrayNumber data = seriesColumnData.dataAsArrayNumber();
-
- for (SeriesJobData seriesJobData : seriesJobContext.getSeriesJobDataContextList().get(i).getSeries()) {
- switch (measure) {
- case Duration:
- data.push(seriesJobData.getDuration() / unitMeasure);
- break;
- case MaxInvocationTime:
- data.push(seriesJobData.getMaxInvocationTime() / unitMeasure);
- break;
- case MinInvocationTime:
- data.push(seriesJobData.getMinInvocationTime() / unitMeasure);
- break;
- case OperationCount:
- data.push(seriesJobData.getOperationCount());
- break;
- default:
- data.push(seriesJobData.getDuration() / unitMeasure);
- break;
-
- }
-
- }
-
- seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
- seriesColumn.add(seriesColumnData);
-
- }
-
- if (i < seriesJobContext.getSeriesJobDataContextList().size()) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name("Others");
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- ArrayList othersData = new ArrayList<>();
- for (int j = i; j < seriesJobContext.getSeriesJobDataContextList().size(); j++) {
- Long value;
- for (int k = 0; k < seriesJobContext.getSeriesJobDataContextList().get(j).getSeries().size(); k++) {
- SeriesJobData seriesJobData = seriesJobContext.getSeriesJobDataContextList().get(j).getSeries()
- .get(k);
- if (j == i) {
- switch (measure) {
- case Duration:
- othersData.add(seriesJobData.getDuration() / unitMeasure);
- break;
- case MaxInvocationTime:
- othersData.add(seriesJobData.getMaxInvocationTime() / unitMeasure);
- break;
- case MinInvocationTime:
- othersData.add(seriesJobData.getMinInvocationTime() / unitMeasure);
- break;
- case OperationCount:
- othersData.add(seriesJobData.getOperationCount());
- break;
- default:
- othersData.add(seriesJobData.getDuration() / unitMeasure);
- break;
- }
- } else {
- switch (measure) {
- case Duration:
- value = (seriesJobData.getDuration() / unitMeasure) + othersData.get(k);
- othersData.set(k, value);
- break;
- case MaxInvocationTime:
- value = (seriesJobData.getMaxInvocationTime() / unitMeasure) + othersData.get(k);
- othersData.set(k, value);
- break;
- case MinInvocationTime:
- value = (seriesJobData.getMinInvocationTime() / unitMeasure) + othersData.get(k);
- othersData.set(k, value);
- break;
- case OperationCount:
- value = seriesJobData.getOperationCount() + othersData.get(k);
- othersData.set(k, value);
- break;
- default:
- value = (seriesJobData.getDuration() / unitMeasure) + othersData.get(k);
- othersData.set(k, value);
- break;
-
- }
-
- }
-
- }
- }
-
- ArrayNumber data = seriesColumnData.dataAsArrayNumber();
-
- for (Long value : othersData) {
- data.push(value);
- }
-
- seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
- seriesColumn.add(seriesColumnData);
-
- }
- } else {
- // xAxis
- options.xAxis().type("datetime");
-
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.MONTHLY) == 0) {
- // options.tooltip().xDateFormat("%b, %Y");
- options.tooltip().xDateFormat("Selected Data");
-
- } else {
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.YEARLY) == 0) {
- // options.tooltip().xDateFormat("%Y");
- options.tooltip().xDateFormat("Selected Data");
-
- } else {
- options.tooltip().xDateFormat("Selected Data");
- }
-
- }
-
- int i = 0;
- for (; i < seriesJobContext.getSeriesJobDataContextList().size() && i < MAX_NUMBER_OF_CONTEXT; i++) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name(seriesJobContext.getSeriesJobDataContextList().get(i).getContext());
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- Array arrayData = seriesColumnData.dataAsArrayObject();
-
- for (SeriesJobData seriesJobData : seriesJobContext.getSeriesJobDataContextList().get(i).getSeries()) {
- long dateFrom1970 = seriesJobData.getDate().getTime();
-
- Log.debug("SeriersJobData: " + seriesJobData.getDate());
- Log.debug("SeriersJobData: " + dateFrom1970);
-
- Data data = highchartsFactory.createSeriesColumnData();
-
- switch (measure) {
- case Duration:
- data.x(dateFrom1970);
- data.y(seriesJobData.getDuration() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case MaxInvocationTime:
- data.x(dateFrom1970);
- data.y(seriesJobData.getMaxInvocationTime() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case MinInvocationTime:
- data.x(dateFrom1970);
- data.y(seriesJobData.getMinInvocationTime() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case OperationCount:
- data.x(dateFrom1970);
- data.y(seriesJobData.getOperationCount());
- arrayData.addToEnd(data);
- break;
- default:
- data.x(dateFrom1970);
- data.y(seriesJobData.getDuration() / unitMeasure);
- arrayData.addToEnd(data);
- break;
-
- }
-
- }
-
- seriesColumn.add(seriesColumnData);
-
- }
-
- if (i < seriesJobContext.getSeriesJobDataContextList().size()) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name("Others");
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- ArrayList othersData = new ArrayList<>();
- for (int j = i; j < seriesJobContext.getSeriesJobDataContextList().size(); j++) {
- ChartDateTimeData chartDateTimeData;
- for (int k = 0; k < seriesJobContext.getSeriesJobDataContextList().get(j).getSeries().size(); k++) {
- SeriesJobData seriesJobData = seriesJobContext.getSeriesJobDataContextList().get(j).getSeries()
- .get(k);
- if (j == i) {
- switch (measure) {
- case Duration:
- chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
- seriesJobData.getDuration() / unitMeasure);
- othersData.add(chartDateTimeData);
- break;
- case MaxInvocationTime:
- chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
- seriesJobData.getMaxInvocationTime() / unitMeasure);
- othersData.add(chartDateTimeData);
- break;
- case MinInvocationTime:
- chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
- seriesJobData.getMinInvocationTime() / unitMeasure);
- othersData.add(chartDateTimeData);
- break;
- case OperationCount:
- chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
- seriesJobData.getOperationCount());
- othersData.add(chartDateTimeData);
- break;
- default:
- chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
- seriesJobData.getDuration() / unitMeasure);
- othersData.add(chartDateTimeData);
- break;
- }
- } else {
- switch (measure) {
- case Duration:
- chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
- (seriesJobData.getDuration() / unitMeasure) + othersData.get(k).getValue());
- othersData.set(k, chartDateTimeData);
- break;
- case MaxInvocationTime:
- chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
- (seriesJobData.getMaxInvocationTime() / unitMeasure)
- + othersData.get(k).getValue());
- othersData.set(k, chartDateTimeData);
- break;
- case MinInvocationTime:
- chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
- (seriesJobData.getMinInvocationTime() / unitMeasure)
- + othersData.get(k).getValue());
- othersData.set(k, chartDateTimeData);
- break;
- case OperationCount:
- chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
- seriesJobData.getOperationCount() + othersData.get(k).getValue());
- othersData.set(k, chartDateTimeData);
- break;
- default:
- chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
- (seriesJobData.getDuration() / unitMeasure) + othersData.get(k).getValue());
- othersData.set(k, chartDateTimeData);
- break;
-
- }
-
- }
-
- }
- }
-
- Array arrayData = seriesColumnData.dataAsArrayObject();
-
- for (ChartDateTimeData chartDateTimeData : othersData) {
- long dateFrom1970 = chartDateTimeData.getDate().getTime();
-
- Log.debug("SeriersOthersData: " + chartDateTimeData.getDate());
- Log.debug("SeriersOthersData: " + dateFrom1970);
-
- Data data = highchartsFactory.createSeriesColumnData();
-
- data.x(dateFrom1970);
- data.y(chartDateTimeData.getValue());
- arrayData.addToEnd(data);
-
- }
-
- seriesColumn.add(seriesColumnData);
-
- }
- }
- }
-
- private void createSeriesColumnSimple(SeriesJobContext seriesJobContext, HighchartsOptionFactory highchartsFactory,
- ArrayString colors, ArrayList seriesColumn) {
- Log.debug("Series Simple");
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.DAILY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.HOURLY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.MINUTELY) == 0) {
-
- double minRange = ChartTimeMeasure
- .calculateMinRange(accountingStateData.getSeriesRequest().getAccountingPeriod());
-
- double interval = ChartTimeMeasure
- .calculateInterval(accountingStateData.getSeriesRequest().getAccountingPeriod());
-
- Date dateStart = dtf.parse(accountingStateData.getSeriesRequest().getAccountingPeriod().getStartDate());
-
- dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
-
- Log.debug("BuildChart DateStart: "
- + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(dateStart));
-
- // xAxis
- options.xAxis().type("datetime");
- options.xAxis().minRange(minRange);
- options.tooltip().xDateFormat("Selected Data");
-
- for (int i = 0; i < seriesJobContext.getSeriesJobDataContextList().size(); i++) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name(seriesJobContext.getSeriesJobDataContextList().get(i).getContext());
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- ArrayNumber data = seriesColumnData.dataAsArrayNumber();
-
- for (SeriesJobData seriesJobData : seriesJobContext.getSeriesJobDataContextList().get(i).getSeries()) {
- switch (measure) {
- case Duration:
- data.push(seriesJobData.getDuration() / unitMeasure);
- break;
- case MaxInvocationTime:
- data.push(seriesJobData.getMaxInvocationTime() / unitMeasure);
- break;
- case MinInvocationTime:
- data.push(seriesJobData.getMinInvocationTime() / unitMeasure);
- break;
- case OperationCount:
- data.push(seriesJobData.getOperationCount());
- break;
- default:
- data.push(seriesJobData.getDuration() / unitMeasure);
- break;
-
- }
-
- }
-
- seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
- seriesColumn.add(seriesColumnData);
-
- }
- } else {
- // xAxis
- options.xAxis().type("datetime");
-
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.MONTHLY) == 0) {
- // options.tooltip().xDateFormat("%b, %Y");
- options.tooltip().xDateFormat("Selected Data");
-
- } else {
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.YEARLY) == 0) {
- // options.tooltip().xDateFormat("%Y");
- options.tooltip().xDateFormat("Selected Data");
-
- } else {
- options.tooltip().xDateFormat("Selected Data");
- }
-
- }
-
- for (int i = 0; i < seriesJobContext.getSeriesJobDataContextList().size(); i++) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name(seriesJobContext.getSeriesJobDataContextList().get(i).getContext());
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- Array arrayData = seriesColumnData.dataAsArrayObject();
-
- for (SeriesJobData seriesJobData : seriesJobContext.getSeriesJobDataContextList().get(i).getSeries()) {
- long dateFrom1970 = seriesJobData.getDate().getTime();
-
- Log.debug("SeriersJobData: " + seriesJobData.getDate());
- Log.debug("SeriersJobData: " + dateFrom1970);
-
- Data data = highchartsFactory.createSeriesColumnData();
-
- switch (measure) {
- case Duration:
- data.x(dateFrom1970);
- data.y(seriesJobData.getDuration() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case MaxInvocationTime:
- data.x(dateFrom1970);
- data.y(seriesJobData.getMaxInvocationTime() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case MinInvocationTime:
- data.x(dateFrom1970);
- data.y(seriesJobData.getMinInvocationTime() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case OperationCount:
- data.x(dateFrom1970);
- data.y(seriesJobData.getOperationCount());
- arrayData.addToEnd(data);
- break;
- default:
- data.x(dateFrom1970);
- data.y(seriesJobData.getDuration() / unitMeasure);
- arrayData.addToEnd(data);
- break;
-
- }
-
- }
-
- seriesColumn.add(seriesColumnData);
-
- }
-
- }
- }
-
- private String retrieveYAxis(ArrayString colors) {
- switch (measure) {
- case Duration:
- return "[{" + " \"id\": \"" + JobChartMeasure.Duration.name() + "\"," + " \"labels\": {"
- + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }," + " \"stackLabels\": {"
- + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
- + JobChartMeasure.Duration.getLabel() + "\"," + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
- case MaxInvocationTime:
- return "[{" + " \"id\": \"" + JobChartMeasure.MaxInvocationTime.name() + "\"," + " \"labels\": {"
- + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }," + " \"stackLabels\": {"
- + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
- + JobChartMeasure.MaxInvocationTime.getLabel() + "\"," + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
- case MinInvocationTime:
- return "[{" + " \"id\": \"" + JobChartMeasure.MinInvocationTime.name() + "\"," + " \"labels\": {"
- + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }," + " \"stackLabels\": {"
- + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
- + JobChartMeasure.MinInvocationTime.getLabel() + "\"," + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
- case OperationCount:
- return "[{" + " \"id\": \"" + JobChartMeasure.OperationCount.name() + "\"," + " \"labels\": { "
- + " \"format\": \"{value}\"," + " \"style\": { " + " \"color\": \"" + colors.get(1)
- + "\"" + " }" + " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"style\": {"
- + " \"fontWeight\": \"bold\"," + " \"color\": \"gray\"" + " } " + " },"
- + " \"title\": { " + " \"text\": \"" + JobChartMeasure.OperationCount.getLabel() + "\","
- + " \"style\": {" + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }" + "}]";
-
- default:
- return "[{" + " \"id\": \"" + JobChartMeasure.Duration.name() + "\"," + " \"labels\": {"
- + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }," + " \"stackLabels\": {"
- + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
- + JobChartMeasure.Duration.getLabel() + "\"," + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
-
- }
-
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/job/JobChartTopPanel.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/job/JobChartTopPanel.java
index 94fd86d..184cc46 100644
--- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/job/JobChartTopPanel.java
+++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/job/JobChartTopPanel.java
@@ -6,6 +6,7 @@ import java.util.Date;
import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartDateTimeData;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
+import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ColorsPalette;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
@@ -57,8 +58,7 @@ public class JobChartTopPanel extends SimpleContainer {
private static final String TIME_UNIT = "Time Unit";
// private static final String MEASURE_TYPE = "Measure";
- private DateTimeFormat dtf = DateTimeFormat
- .getFormat(PredefinedFormat.YEAR_MONTH_DAY);
+ private DateTimeFormat dtf = DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
private EventBus eventBus;
private AccountingClientStateData accountingStateData;
@@ -96,8 +96,7 @@ public class JobChartTopPanel extends SimpleContainer {
private VerticalLayoutContainer vert;
- public JobChartTopPanel(EventBus eventBus,
- AccountingClientStateData accountingStateData) {
+ public JobChartTopPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus = eventBus;
this.accountingStateData = accountingStateData;
forceLayoutOnResize = true;
@@ -109,8 +108,7 @@ public class JobChartTopPanel extends SimpleContainer {
ToolBar toolBar = new ToolBar();
toolBar.setSpacing(2);
// Download
- final TextButton downloadButton = new TextButton(
- DownloadConstants.DOWNLOAD,
+ final TextButton downloadButton = new TextButton(DownloadConstants.DOWNLOAD,
AccountingManagerResources.INSTANCE.accountingDownload24());
// downloadButton.setScale(ButtonScale.MEDIUM);
downloadButton.setIconAlign(IconAlign.RIGHT);
@@ -125,8 +123,7 @@ public class JobChartTopPanel extends SimpleContainer {
measureButton.setMenu(createMeasureMenu());
// Unit
- unitButton = new TextButton(TIME_UNIT,
- AccountingManagerResources.INSTANCE.accountingUnitms24());
+ unitButton = new TextButton(TIME_UNIT, AccountingManagerResources.INSTANCE.accountingUnitms24());
unitButton.setIconAlign(IconAlign.RIGHT);
unitButton.setArrowAlign(ButtonArrowAlign.RIGHT);
unitButton.setMenu(createUnitMenu());
@@ -145,8 +142,7 @@ public class JobChartTopPanel extends SimpleContainer {
//
vert = new VerticalLayoutContainer();
vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
- vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1,
- new Margins(0)));
+ vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, new Margins(0)));
add(vert, new MarginData(0));
@@ -265,14 +261,11 @@ public class JobChartTopPanel extends SimpleContainer {
// TODO
durationItem = new MenuItem(JobChartMeasure.Duration.getLabel());
durationItem.setHeight(30);
- operationCountItem = new MenuItem(
- JobChartMeasure.OperationCount.getLabel());
+ operationCountItem = new MenuItem(JobChartMeasure.OperationCount.getLabel());
operationCountItem.setHeight(30);
- maxInvocationTimeItem = new MenuItem(
- JobChartMeasure.MaxInvocationTime.getLabel());
+ maxInvocationTimeItem = new MenuItem(JobChartMeasure.MaxInvocationTime.getLabel());
maxInvocationTimeItem.setHeight(30);
- minInvocationTimeItem = new MenuItem(
- JobChartMeasure.MinInvocationTime.getLabel());
+ minInvocationTimeItem = new MenuItem(JobChartMeasure.MinInvocationTime.getLabel());
minInvocationTimeItem.setHeight(30);
durationItem.addSelectionHandler(new SelectionHandler
- () {
@@ -301,8 +294,7 @@ public class JobChartTopPanel extends SimpleContainer {
@Override
public void onSelection(SelectionEvent
- event) {
- measureButton.setText(JobChartMeasure.MaxInvocationTime
- .getLabel());
+ measureButton.setText(JobChartMeasure.MaxInvocationTime.getLabel());
measure = JobChartMeasure.MaxInvocationTime;
unitButton.setVisible(true);
updateChart();
@@ -313,8 +305,7 @@ public class JobChartTopPanel extends SimpleContainer {
@Override
public void onSelection(SelectionEvent
- event) {
- measureButton.setText(JobChartMeasure.MinInvocationTime
- .getLabel());
+ measureButton.setText(JobChartMeasure.MinInvocationTime.getLabel());
measure = JobChartMeasure.MinInvocationTime;
unitButton.setVisible(true);
updateChart();
@@ -332,17 +323,13 @@ public class JobChartTopPanel extends SimpleContainer {
private Menu createUnitMenu() {
Menu menuUnit = new Menu();
- msItem = new MenuItem(TimeUnitMeasure.MILLISECONDS,
- AccountingManagerResources.INSTANCE.accountingUnitms24());
+ msItem = new MenuItem(TimeUnitMeasure.MILLISECONDS, AccountingManagerResources.INSTANCE.accountingUnitms24());
msItem.setHeight(30);
- sItem = new MenuItem(TimeUnitMeasure.SECONDS,
- AccountingManagerResources.INSTANCE.accountingUnits24());
+ sItem = new MenuItem(TimeUnitMeasure.SECONDS, AccountingManagerResources.INSTANCE.accountingUnits24());
sItem.setHeight(30);
- mItem = new MenuItem(TimeUnitMeasure.MINUTES,
- AccountingManagerResources.INSTANCE.accountingUnitm24());
+ mItem = new MenuItem(TimeUnitMeasure.MINUTES, AccountingManagerResources.INSTANCE.accountingUnitm24());
mItem.setHeight(30);
- hItem = new MenuItem(TimeUnitMeasure.HOURS,
- AccountingManagerResources.INSTANCE.accountingUnith24());
+ hItem = new MenuItem(TimeUnitMeasure.HOURS, AccountingManagerResources.INSTANCE.accountingUnith24());
hItem.setHeight(30);
msItem.addSelectionHandler(new SelectionHandler
- () {
@@ -351,8 +338,7 @@ public class JobChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent
- event) {
unitMeasure = TimeUnitMeasure.getMilliseconds();
unitMeasureLabel = TimeUnitMeasure.MS;
- unitButton.setIcon(AccountingManagerResources.INSTANCE
- .accountingUnitms24());
+ unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitms24());
updateChart();
}
});
@@ -363,8 +349,7 @@ public class JobChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent
- event) {
unitMeasure = TimeUnitMeasure.getSeconds();
unitMeasureLabel = TimeUnitMeasure.S;
- unitButton.setIcon(AccountingManagerResources.INSTANCE
- .accountingUnits24());
+ unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnits24());
updateChart();
}
});
@@ -375,8 +360,7 @@ public class JobChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent
- event) {
unitMeasure = TimeUnitMeasure.getMinutes();
unitMeasureLabel = TimeUnitMeasure.M;
- unitButton.setIcon(AccountingManagerResources.INSTANCE
- .accountingUnitm24());
+ unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitm24());
updateChart();
}
});
@@ -387,8 +371,7 @@ public class JobChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent
- event) {
unitMeasure = TimeUnitMeasure.getHours();
unitMeasureLabel = TimeUnitMeasure.H;
- unitButton.setIcon(AccountingManagerResources.INSTANCE
- .accountingUnith24());
+ unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnith24());
updateChart();
}
});
@@ -402,20 +385,17 @@ public class JobChartTopPanel extends SimpleContainer {
}
private void onDownloadCSV() {
- ExportRequestEvent event = new ExportRequestEvent(ExportType.CSV,
- accountingStateData.getAccountingType());
+ ExportRequestEvent event = new ExportRequestEvent(ExportType.CSV, accountingStateData.getAccountingType());
eventBus.fireEvent(event);
}
private void onDownloadXML() {
- ExportRequestEvent event = new ExportRequestEvent(ExportType.XML,
- accountingStateData.getAccountingType());
+ ExportRequestEvent event = new ExportRequestEvent(ExportType.XML, accountingStateData.getAccountingType());
eventBus.fireEvent(event);
}
private void onDownloadJSON() {
- ExportRequestEvent event = new ExportRequestEvent(ExportType.JSON,
- accountingStateData.getAccountingType());
+ ExportRequestEvent event = new ExportRequestEvent(ExportType.JSON, accountingStateData.getAccountingType());
eventBus.fireEvent(event);
}
@@ -472,15 +452,13 @@ public class JobChartTopPanel extends SimpleContainer {
}-*/;
private void createChart() {
- SeriesJob seriesJob = (SeriesJob) accountingStateData
- .getSeriesResponse();
+ SeriesJob seriesJob = (SeriesJob) accountingStateData.getSeriesResponse();
if (!(seriesJob.getSeriesJobDefinition() instanceof SeriesJobTop)) {
Log.debug("Invalid SeriesJobTop!");
return;
}
- SeriesJobTop seriesJobTop = (SeriesJobTop) seriesJob
- .getSeriesJobDefinition();
+ SeriesJobTop seriesJobTop = (SeriesJobTop) seriesJob.getSeriesJobDefinition();
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
@@ -491,32 +469,28 @@ public class JobChartTopPanel extends SimpleContainer {
options.title().text("Accounting Job Top");
/*
- * options.subtitle().text("Click and drag in the plot area to zoom in");
+ * options.subtitle().text("Click and drag in the plot area to zoom in"
+ * );
*/
+ ColorsPalette colorsPalette=new ColorsPalette();
ArrayString colors = options.colors();
+ colors=colorsPalette.getColorsPalette(colors);
+ options.colors(colors);
+
// colors.setValue(0, "#cc0038");
// colors.setValue(1, "#32cd32");
// yAxis
options.setFieldAsJsonObject("yAxis", retrieveYAxis(colors));
- options.plotOptions().setFieldAsJsonObject(
- "column",
- "{ " + "\"stacking\": \"normal\"," + "\"dataLabels\": { "
- + " \"enabled\": \"true\","
+ options.plotOptions().setFieldAsJsonObject("column",
+ "{ " + "\"stacking\": \"normal\"," + "\"dataLabels\": { " + " \"enabled\": \"true\","
+ " \"color\": \"white\", " + " \"style\": {"
- + " \"textShadow\": \"0 0 3px black\"" + " }"
- + " }" + " }");
+ + " \"textShadow\": \"0 0 3px black\"" + " }" + " }" + " }");
ArrayList seriesColumn = new ArrayList<>();
- if (seriesJobTop.getShowOthers()) {
- createSeriesColumnShowOthers(seriesJobTop, highchartsFactory,
- colors, seriesColumn);
- } else {
- createSeriesColumnSimple(seriesJobTop, highchartsFactory, colors,
- seriesColumn);
- }
+ createSeriesColumnSimple(seriesJobTop, highchartsFactory, colors, seriesColumn);
for (SeriesColumn serie : seriesColumn) {
options.series().addToEnd(serie);
@@ -528,35 +502,28 @@ public class JobChartTopPanel extends SimpleContainer {
return;
}
- private void createSeriesColumnShowOthers(SeriesJobTop seriesJobTop,
- HighchartsOptionFactory highchartsFactory, ArrayString colors,
- ArrayList seriesColumn) {
+ private void createSeriesColumnShowOthers(SeriesJobTop seriesJobTop, HighchartsOptionFactory highchartsFactory,
+ ArrayString colors, ArrayList seriesColumn) {
Log.debug("Series ShowOthers");
- if (accountingStateData.getSeriesRequest().getAccountingPeriod()
- .getPeriod().compareTo(AccountingPeriodMode.DAILY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod()
- .getPeriod().compareTo(AccountingPeriodMode.HOURLY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod()
- .getPeriod().compareTo(AccountingPeriodMode.MINUTELY) == 0) {
+ if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
+ .compareTo(AccountingPeriodMode.DAILY) == 0
+ || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
+ .compareTo(AccountingPeriodMode.HOURLY) == 0
+ || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
+ .compareTo(AccountingPeriodMode.MINUTELY) == 0) {
double minRange = ChartTimeMeasure
- .calculateMinRange(accountingStateData.getSeriesRequest()
- .getAccountingPeriod());
+ .calculateMinRange(accountingStateData.getSeriesRequest().getAccountingPeriod());
double interval = ChartTimeMeasure
- .calculateInterval(accountingStateData.getSeriesRequest()
- .getAccountingPeriod());
+ .calculateInterval(accountingStateData.getSeriesRequest().getAccountingPeriod());
- Date dateStart = dtf.parse(accountingStateData.getSeriesRequest()
- .getAccountingPeriod().getStartDate());
+ Date dateStart = dtf.parse(accountingStateData.getSeriesRequest().getAccountingPeriod().getStartDate());
- dateStart.setTime(dateStart.getTime()
- + ChartTimeMeasure.timeZoneOffset()
- * ChartTimeMeasure.MINUTE);
+ dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
Log.debug("BuildChart DateStart: "
- + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL)
- .format(dateStart));
+ + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(dateStart));
// xAxis
options.xAxis().type("datetime");
@@ -564,31 +531,25 @@ public class JobChartTopPanel extends SimpleContainer {
options.tooltip().xDateFormat("Selected Data");
int i = 0;
- for (; i < seriesJobTop.getSeriesJobDataTopList().size()
- && i < seriesJobTop.getTopNumber(); i++) {
- SeriesColumn seriesColumnData = highchartsFactory
- .createSeriesColumn();
+ for (; i < seriesJobTop.getSeriesJobDataTopList().size() && i < seriesJobTop.getTopNumber(); i++) {
+ SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
- seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList()
- .get(i).getFilterValue().getValue());
+ seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList().get(i).getFilterValue().getValue());
seriesColumnData.color(colors.get(i));
seriesColumnData.type("column");
ArrayNumber data = seriesColumnData.dataAsArrayNumber();
- for (SeriesJobData seriesJobData : seriesJobTop
- .getSeriesJobDataTopList().get(i).getSeries()) {
+ for (SeriesJobData seriesJobData : seriesJobTop.getSeriesJobDataTopList().get(i).getSeries()) {
switch (measure) {
case Duration:
data.push(seriesJobData.getDuration() / unitMeasure);
break;
case MaxInvocationTime:
- data.push(seriesJobData.getMaxInvocationTime()
- / unitMeasure);
+ data.push(seriesJobData.getMaxInvocationTime() / unitMeasure);
break;
case MinInvocationTime:
- data.push(seriesJobData.getMinInvocationTime()
- / unitMeasure);
+ data.push(seriesJobData.getMinInvocationTime() / unitMeasure);
break;
case OperationCount:
data.push(seriesJobData.getOperationCount());
@@ -601,77 +562,61 @@ public class JobChartTopPanel extends SimpleContainer {
}
- seriesColumnData.pointInterval(interval).pointStart(
- dateStart.getTime());
+ seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
seriesColumn.add(seriesColumnData);
}
if (i < seriesJobTop.getSeriesJobDataTopList().size()) {
- SeriesColumn seriesColumnData = highchartsFactory
- .createSeriesColumn();
+ SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
seriesColumnData.name("Others");
seriesColumnData.color(colors.get(i));
seriesColumnData.type("column");
ArrayList othersData = new ArrayList<>();
- for (int j = i; j < seriesJobTop.getSeriesJobDataTopList()
- .size(); j++) {
+ for (int j = i; j < seriesJobTop.getSeriesJobDataTopList().size(); j++) {
Long value;
- for (int k = 0; k < seriesJobTop.getSeriesJobDataTopList()
- .get(j).getSeries().size(); k++) {
- SeriesJobData seriesJobData = seriesJobTop
- .getSeriesJobDataTopList().get(j).getSeries()
- .get(k);
+ for (int k = 0; k < seriesJobTop.getSeriesJobDataTopList().get(j).getSeries().size(); k++) {
+ SeriesJobData seriesJobData = seriesJobTop.getSeriesJobDataTopList().get(j).getSeries().get(k);
if (j == i) {
switch (measure) {
case Duration:
- othersData.add(seriesJobData.getDuration()
- / unitMeasure);
+ othersData.add(seriesJobData.getDuration() / unitMeasure);
break;
case MaxInvocationTime:
- othersData.add(seriesJobData
- .getMaxInvocationTime() / unitMeasure);
+ othersData.add(seriesJobData.getMaxInvocationTime() / unitMeasure);
break;
case MinInvocationTime:
- othersData.add(seriesJobData
- .getMinInvocationTime() / unitMeasure);
+ othersData.add(seriesJobData.getMinInvocationTime() / unitMeasure);
break;
case OperationCount:
- othersData.add(seriesJobData
- .getOperationCount());
+ othersData.add(seriesJobData.getOperationCount());
break;
default:
- othersData.add(seriesJobData.getDuration()
- / unitMeasure);
+ othersData.add(seriesJobData.getDuration() / unitMeasure);
break;
}
} else {
switch (measure) {
case Duration:
- value = (seriesJobData.getDuration() / unitMeasure)
- + othersData.get(k);
+ value = (seriesJobData.getDuration() / unitMeasure) + othersData.get(k);
othersData.set(k, value);
break;
case MaxInvocationTime:
- value = (seriesJobData.getMaxInvocationTime() / unitMeasure)
- + othersData.get(k);
+ value = (seriesJobData.getMaxInvocationTime() / unitMeasure) + othersData.get(k);
othersData.set(k, value);
break;
case MinInvocationTime:
- value = (seriesJobData.getMinInvocationTime() / unitMeasure)
- + othersData.get(k);
+ value = (seriesJobData.getMinInvocationTime() / unitMeasure) + othersData.get(k);
othersData.set(k, value);
break;
case OperationCount:
- value = seriesJobData.getOperationCount()
- + othersData.get(k);
+ value = seriesJobData.getOperationCount() + othersData.get(k);
othersData.set(k, value);
break;
default:
- value = (seriesJobData.getDuration() / unitMeasure)
- + othersData.get(k);
+ value = (seriesJobData.getDuration() / unitMeasure) + othersData.get(k);
othersData.set(k, value);
break;
@@ -688,8 +633,7 @@ public class JobChartTopPanel extends SimpleContainer {
data.push(value);
}
- seriesColumnData.pointInterval(interval).pointStart(
- dateStart.getTime());
+ seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
seriesColumn.add(seriesColumnData);
}
@@ -697,16 +641,15 @@ public class JobChartTopPanel extends SimpleContainer {
// xAxis
options.xAxis().type("datetime");
- if (accountingStateData.getSeriesRequest().getAccountingPeriod()
- .getPeriod().compareTo(AccountingPeriodMode.MONTHLY) == 0) {
- //options.tooltip().xDateFormat("%b, %Y");
+ if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
+ .compareTo(AccountingPeriodMode.MONTHLY) == 0) {
+ // options.tooltip().xDateFormat("%b, %Y");
options.tooltip().xDateFormat("Selected Data");
} else {
- if (accountingStateData.getSeriesRequest()
- .getAccountingPeriod().getPeriod()
+ if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.compareTo(AccountingPeriodMode.YEARLY) == 0) {
- //options.tooltip().xDateFormat("%Y");
+ // options.tooltip().xDateFormat("%Y");
options.tooltip().xDateFormat("Selected Data");
} else {
@@ -716,20 +659,16 @@ public class JobChartTopPanel extends SimpleContainer {
}
int i = 0;
- for (; i < seriesJobTop.getSeriesJobDataTopList().size()
- && i < seriesJobTop.getTopNumber(); i++) {
- SeriesColumn seriesColumnData = highchartsFactory
- .createSeriesColumn();
+ for (; i < seriesJobTop.getSeriesJobDataTopList().size() && i < seriesJobTop.getTopNumber(); i++) {
+ SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
- seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList()
- .get(i).getFilterValue().getValue());
+ seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList().get(i).getFilterValue().getValue());
seriesColumnData.color(colors.get(i));
seriesColumnData.type("column");
Array arrayData = seriesColumnData.dataAsArrayObject();
- for (SeriesJobData seriesJobData : seriesJobTop
- .getSeriesJobDataTopList().get(i).getSeries()) {
+ for (SeriesJobData seriesJobData : seriesJobTop.getSeriesJobDataTopList().get(i).getSeries()) {
long dateFrom1970 = seriesJobData.getDate().getTime();
Log.debug("SeriersJobData: " + seriesJobData.getDate());
@@ -745,14 +684,12 @@ public class JobChartTopPanel extends SimpleContainer {
break;
case MaxInvocationTime:
data.x(dateFrom1970);
- data.y(seriesJobData.getMaxInvocationTime()
- / unitMeasure);
+ data.y(seriesJobData.getMaxInvocationTime() / unitMeasure);
arrayData.addToEnd(data);
break;
case MinInvocationTime:
data.x(dateFrom1970);
- data.y(seriesJobData.getMinInvocationTime()
- / unitMeasure);
+ data.y(seriesJobData.getMinInvocationTime() / unitMeasure);
arrayData.addToEnd(data);
break;
case OperationCount:
@@ -775,94 +712,72 @@ public class JobChartTopPanel extends SimpleContainer {
}
if (i < seriesJobTop.getSeriesJobDataTopList().size()) {
- SeriesColumn seriesColumnData = highchartsFactory
- .createSeriesColumn();
+ SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
seriesColumnData.name("Others");
seriesColumnData.color(colors.get(i));
seriesColumnData.type("column");
ArrayList othersData = new ArrayList<>();
- for (int j = i; j < seriesJobTop.getSeriesJobDataTopList()
- .size(); j++) {
+ for (int j = i; j < seriesJobTop.getSeriesJobDataTopList().size(); j++) {
ChartDateTimeData chartDateTimeData;
- for (int k = 0; k < seriesJobTop.getSeriesJobDataTopList()
- .get(j).getSeries().size(); k++) {
- SeriesJobData seriesJobData = seriesJobTop
- .getSeriesJobDataTopList().get(j).getSeries()
- .get(k);
+ for (int k = 0; k < seriesJobTop.getSeriesJobDataTopList().get(j).getSeries().size(); k++) {
+ SeriesJobData seriesJobData = seriesJobTop.getSeriesJobDataTopList().get(j).getSeries().get(k);
if (j == i) {
switch (measure) {
case Duration:
- chartDateTimeData = new ChartDateTimeData(
- seriesJobData.getDate(),
- seriesJobData.getDuration()
- / unitMeasure);
+ chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
+ seriesJobData.getDuration() / unitMeasure);
othersData.add(chartDateTimeData);
break;
case MaxInvocationTime:
- chartDateTimeData = new ChartDateTimeData(
- seriesJobData.getDate(),
- seriesJobData.getMaxInvocationTime()
- / unitMeasure);
+ chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
+ seriesJobData.getMaxInvocationTime() / unitMeasure);
othersData.add(chartDateTimeData);
break;
case MinInvocationTime:
- chartDateTimeData = new ChartDateTimeData(
- seriesJobData.getDate(),
- seriesJobData.getMinInvocationTime()
- / unitMeasure);
+ chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
+ seriesJobData.getMinInvocationTime() / unitMeasure);
othersData.add(chartDateTimeData);
break;
case OperationCount:
- chartDateTimeData = new ChartDateTimeData(
- seriesJobData.getDate(),
+ chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getOperationCount());
othersData.add(chartDateTimeData);
break;
default:
- chartDateTimeData = new ChartDateTimeData(
- seriesJobData.getDate(),
- seriesJobData.getDuration()
- / unitMeasure);
+ chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
+ seriesJobData.getDuration() / unitMeasure);
othersData.add(chartDateTimeData);
break;
}
} else {
switch (measure) {
case Duration:
- chartDateTimeData = new ChartDateTimeData(
- seriesJobData.getDate(),
- (seriesJobData.getDuration() / unitMeasure)
- + othersData.get(k).getValue());
+ chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
+ (seriesJobData.getDuration() / unitMeasure) + othersData.get(k).getValue());
othersData.set(k, chartDateTimeData);
break;
case MaxInvocationTime:
- chartDateTimeData = new ChartDateTimeData(
- seriesJobData.getDate(),
+ chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
(seriesJobData.getMaxInvocationTime() / unitMeasure)
+ othersData.get(k).getValue());
othersData.set(k, chartDateTimeData);
break;
case MinInvocationTime:
- chartDateTimeData = new ChartDateTimeData(
- seriesJobData.getDate(),
+ chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
(seriesJobData.getMinInvocationTime() / unitMeasure)
+ othersData.get(k).getValue());
othersData.set(k, chartDateTimeData);
break;
case OperationCount:
- chartDateTimeData = new ChartDateTimeData(
- seriesJobData.getDate(),
- seriesJobData.getOperationCount()
- + othersData.get(k).getValue());
+ chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
+ seriesJobData.getOperationCount() + othersData.get(k).getValue());
othersData.set(k, chartDateTimeData);
break;
default:
- chartDateTimeData = new ChartDateTimeData(
- seriesJobData.getDate(),
- (seriesJobData.getDuration() / unitMeasure)
- + othersData.get(k).getValue());
+ chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
+ (seriesJobData.getDuration() / unitMeasure) + othersData.get(k).getValue());
othersData.set(k, chartDateTimeData);
break;
@@ -878,8 +793,7 @@ public class JobChartTopPanel extends SimpleContainer {
for (ChartDateTimeData chartDateTimeData : othersData) {
long dateFrom1970 = chartDateTimeData.getDate().getTime();
- Log.debug("SeriersOthersData: "
- + chartDateTimeData.getDate());
+ Log.debug("SeriersOthersData: " + chartDateTimeData.getDate());
Log.debug("SeriersOthersData: " + dateFrom1970);
Data data = highchartsFactory.createSeriesColumnData();
@@ -896,65 +810,53 @@ public class JobChartTopPanel extends SimpleContainer {
}
}
- private void createSeriesColumnSimple(SeriesJobTop seriesJobTop,
- HighchartsOptionFactory highchartsFactory, ArrayString colors,
- ArrayList seriesColumn) {
+ private void createSeriesColumnSimple(SeriesJobTop seriesJobTop, HighchartsOptionFactory highchartsFactory,
+ ArrayString colors, ArrayList seriesColumn) {
Log.debug("Series Simple");
- if (accountingStateData.getSeriesRequest().getAccountingPeriod()
- .getPeriod().compareTo(AccountingPeriodMode.DAILY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod()
- .getPeriod().compareTo(AccountingPeriodMode.HOURLY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod()
- .getPeriod().compareTo(AccountingPeriodMode.MINUTELY) == 0) {
+ if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
+ .compareTo(AccountingPeriodMode.DAILY) == 0
+ || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
+ .compareTo(AccountingPeriodMode.HOURLY) == 0
+ || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
+ .compareTo(AccountingPeriodMode.MINUTELY) == 0) {
double minRange = ChartTimeMeasure
- .calculateMinRange(accountingStateData.getSeriesRequest()
- .getAccountingPeriod());
+ .calculateMinRange(accountingStateData.getSeriesRequest().getAccountingPeriod());
double interval = ChartTimeMeasure
- .calculateInterval(accountingStateData.getSeriesRequest()
- .getAccountingPeriod());
+ .calculateInterval(accountingStateData.getSeriesRequest().getAccountingPeriod());
- Date dateStart = dtf.parse(accountingStateData.getSeriesRequest()
- .getAccountingPeriod().getStartDate());
+ Date dateStart = dtf.parse(accountingStateData.getSeriesRequest().getAccountingPeriod().getStartDate());
- dateStart.setTime(dateStart.getTime()
- + ChartTimeMeasure.timeZoneOffset()
- * ChartTimeMeasure.MINUTE);
+ dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
Log.debug("BuildChart DateStart: "
- + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL)
- .format(dateStart));
+ + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(dateStart));
// xAxis
options.xAxis().type("datetime");
options.xAxis().minRange(minRange);
options.tooltip().xDateFormat("Selected Data");
-
- for (int i = 0; i < seriesJobTop.getSeriesJobDataTopList().size(); i++) {
- SeriesColumn seriesColumnData = highchartsFactory
- .createSeriesColumn();
- seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList()
- .get(i).getFilterValue().getValue());
+ for (int i = 0; i < seriesJobTop.getSeriesJobDataTopList().size(); i++) {
+ SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
+
+ seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList().get(i).getFilterValue().getValue());
seriesColumnData.color(colors.get(i));
seriesColumnData.type("column");
ArrayNumber data = seriesColumnData.dataAsArrayNumber();
- for (SeriesJobData seriesJobData : seriesJobTop
- .getSeriesJobDataTopList().get(i).getSeries()) {
+ for (SeriesJobData seriesJobData : seriesJobTop.getSeriesJobDataTopList().get(i).getSeries()) {
switch (measure) {
case Duration:
data.push(seriesJobData.getDuration() / unitMeasure);
break;
case MaxInvocationTime:
- data.push(seriesJobData.getMaxInvocationTime()
- / unitMeasure);
+ data.push(seriesJobData.getMaxInvocationTime() / unitMeasure);
break;
case MinInvocationTime:
- data.push(seriesJobData.getMinInvocationTime()
- / unitMeasure);
+ data.push(seriesJobData.getMinInvocationTime() / unitMeasure);
break;
case OperationCount:
data.push(seriesJobData.getOperationCount());
@@ -967,8 +869,7 @@ public class JobChartTopPanel extends SimpleContainer {
}
- seriesColumnData.pointInterval(interval).pointStart(
- dateStart.getTime());
+ seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
seriesColumn.add(seriesColumnData);
}
@@ -976,16 +877,15 @@ public class JobChartTopPanel extends SimpleContainer {
// xAxis
options.xAxis().type("datetime");
- if (accountingStateData.getSeriesRequest().getAccountingPeriod()
- .getPeriod().compareTo(AccountingPeriodMode.MONTHLY) == 0) {
- //options.tooltip().xDateFormat("%b, %Y");
+ if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
+ .compareTo(AccountingPeriodMode.MONTHLY) == 0) {
+ // options.tooltip().xDateFormat("%b, %Y");
options.tooltip().xDateFormat("Selected Data");
} else {
- if (accountingStateData.getSeriesRequest()
- .getAccountingPeriod().getPeriod()
+ if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.compareTo(AccountingPeriodMode.YEARLY) == 0) {
- //options.tooltip().xDateFormat("%Y");
+ // options.tooltip().xDateFormat("%Y");
options.tooltip().xDateFormat("Selected Data");
} else {
@@ -995,18 +895,15 @@ public class JobChartTopPanel extends SimpleContainer {
}
for (int i = 0; i < seriesJobTop.getSeriesJobDataTopList().size(); i++) {
- SeriesColumn seriesColumnData = highchartsFactory
- .createSeriesColumn();
+ SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
- seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList()
- .get(i).getFilterValue().getValue());
+ seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList().get(i).getFilterValue().getValue());
seriesColumnData.color(colors.get(i));
seriesColumnData.type("column");
Array arrayData = seriesColumnData.dataAsArrayObject();
- for (SeriesJobData seriesJobData : seriesJobTop
- .getSeriesJobDataTopList().get(i).getSeries()) {
+ for (SeriesJobData seriesJobData : seriesJobTop.getSeriesJobDataTopList().get(i).getSeries()) {
long dateFrom1970 = seriesJobData.getDate().getTime();
Log.debug("SeriersJobData: " + seriesJobData.getDate());
@@ -1022,14 +919,12 @@ public class JobChartTopPanel extends SimpleContainer {
break;
case MaxInvocationTime:
data.x(dateFrom1970);
- data.y(seriesJobData.getMaxInvocationTime()
- / unitMeasure);
+ data.y(seriesJobData.getMaxInvocationTime() / unitMeasure);
arrayData.addToEnd(data);
break;
case MinInvocationTime:
data.x(dateFrom1970);
- data.y(seriesJobData.getMinInvocationTime()
- / unitMeasure);
+ data.y(seriesJobData.getMinInvocationTime() / unitMeasure);
arrayData.addToEnd(data);
break;
case OperationCount:
@@ -1057,68 +952,45 @@ public class JobChartTopPanel extends SimpleContainer {
private String retrieveYAxis(ArrayString colors) {
switch (measure) {
case Duration:
- return "[{" + " \"id\": \"" + JobChartMeasure.Duration.name()
- + "\"," + " \"labels\": {" + " \"format\": \"{value} "
- + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }"
- + " }," + " \"stackLabels\": {" + " \"enabled\": \"true\","
- + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " },"
- + " \"title\": { " + " \"text\": \""
- + JobChartMeasure.Duration.getLabel() + "\","
- + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
+ return "[{" + " \"id\": \"" + JobChartMeasure.Duration.name() + "\"," + " \"labels\": {"
+ + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
+ + " \"color\": \"#434348\"" + " }" + " }," + " \"stackLabels\": {"
+ + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
+ + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
+ + JobChartMeasure.Duration.getLabel() + "\"," + " \"style\": {" + " \"color\": \"#434348\""
+ + " }" + " }" + "}]";
case MaxInvocationTime:
- return "[{" + " \"id\": \""
- + JobChartMeasure.MaxInvocationTime.name() + "\","
- + " \"labels\": {" + " \"format\": \"{value} "
- + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }"
- + " }," + " \"stackLabels\": {" + " \"enabled\": \"true\","
- + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " },"
- + " \"title\": { " + " \"text\": \""
- + JobChartMeasure.MaxInvocationTime.getLabel() + "\","
- + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
+ return "[{" + " \"id\": \"" + JobChartMeasure.MaxInvocationTime.name() + "\"," + " \"labels\": {"
+ + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
+ + " \"color\": \"#434348\"" + " }" + " }," + " \"stackLabels\": {"
+ + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
+ + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
+ + JobChartMeasure.MaxInvocationTime.getLabel() + "\"," + " \"style\": {" + " \"color\": \"#434348\""
+ + " }" + " }" + "}]";
case MinInvocationTime:
- return "[{" + " \"id\": \""
- + JobChartMeasure.MinInvocationTime.name() + "\","
- + " \"labels\": {" + " \"format\": \"{value} "
- + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }"
- + " }," + " \"stackLabels\": {" + " \"enabled\": \"true\","
- + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " },"
- + " \"title\": { " + " \"text\": \""
- + JobChartMeasure.MinInvocationTime.getLabel() + "\","
- + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
+ return "[{" + " \"id\": \"" + JobChartMeasure.MinInvocationTime.name() + "\"," + " \"labels\": {"
+ + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
+ + " \"color\": \"#434348\"" + " }" + " }," + " \"stackLabels\": {"
+ + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
+ + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
+ + JobChartMeasure.MinInvocationTime.getLabel() + "\"," + " \"style\": {" + " \"color\": \"#434348\""
+ + " }" + " }" + "}]";
case OperationCount:
- return "[{" + " \"id\": \"" + JobChartMeasure.OperationCount.name()
- + "\"," + " \"labels\": { "
- + " \"format\": \"{value}\"," + " \"style\": { "
- + " \"color\": \"" + colors.get(1) + "\"" + " }"
- + " }," + " \"stackLabels\": {" + " \"enabled\": \"true\","
- + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " },"
- + " \"title\": { " + " \"text\": \""
- + JobChartMeasure.OperationCount.getLabel() + "\","
- + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
+ return "[{" + " \"id\": \"" + JobChartMeasure.OperationCount.name() + "\"," + " \"labels\": { "
+ + " \"format\": \"{value}\"," + " \"style\": { " + " \"color\": \"#434348\""
+ + " }" + " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"style\": {"
+ + " \"fontWeight\": \"bold\"," + " \"color\": \"gray\"" + " } " + " },"
+ + " \"title\": { " + " \"text\": \"" + JobChartMeasure.OperationCount.getLabel() + "\","
+ + " \"style\": {" + " \"color\": \"#434348\"" + " }" + " }" + "}]";
default:
- return "[{" + " \"id\": \"" + JobChartMeasure.Duration.name()
- + "\"," + " \"labels\": {" + " \"format\": \"{value} "
- + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }"
- + " }," + " \"stackLabels\": {" + " \"enabled\": \"true\","
- + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " },"
- + " \"title\": { " + " \"text\": \""
- + JobChartMeasure.Duration.getLabel() + "\","
- + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
+ return "[{" + " \"id\": \"" + JobChartMeasure.Duration.name() + "\"," + " \"labels\": {"
+ + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
+ + " \"color\": \"#434348\"" + " }" + " }," + " \"stackLabels\": {"
+ + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
+ + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
+ + JobChartMeasure.Duration.getLabel() + "\"," + " \"style\": {" + " \"color\": \"#434348\""
+ + " }" + " }" + "}]";
}
diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/service/ServiceChartContextPanel.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/service/ServiceChartContextPanel.java
deleted file mode 100644
index 6c1397a..0000000
--- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/service/ServiceChartContextPanel.java
+++ /dev/null
@@ -1,1010 +0,0 @@
-package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service;
-
-import java.util.ArrayList;
-import java.util.Date;
-
-import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent;
-import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartDateTimeData;
-import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
-import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
-import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ServiceChartMeasure;
-import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
-import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
-import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
-import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriodMode;
-import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
-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.export.ExportType;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel;
-import com.github.highcharts4gwt.model.array.api.Array;
-import com.github.highcharts4gwt.model.array.api.ArrayNumber;
-import com.github.highcharts4gwt.model.array.api.ArrayString;
-import com.github.highcharts4gwt.model.factory.api.HighchartsOptionFactory;
-import com.github.highcharts4gwt.model.factory.jso.JsoHighchartsOptionFactory;
-import com.github.highcharts4gwt.model.highcharts.option.api.ChartOptions;
-import com.github.highcharts4gwt.model.highcharts.option.api.SeriesColumn;
-import com.github.highcharts4gwt.model.highcharts.option.api.seriescolumn.Data;
-import com.google.gwt.event.logical.shared.SelectionEvent;
-import com.google.gwt.event.logical.shared.SelectionHandler;
-import com.google.gwt.event.shared.EventBus;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
-import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
-import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
-import com.sencha.gxt.core.client.util.Margins;
-import com.sencha.gxt.widget.core.client.button.TextButton;
-import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
-import com.sencha.gxt.widget.core.client.container.MarginData;
-import com.sencha.gxt.widget.core.client.container.SimpleContainer;
-import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
-import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
-import com.sencha.gxt.widget.core.client.menu.Item;
-import com.sencha.gxt.widget.core.client.menu.Menu;
-import com.sencha.gxt.widget.core.client.menu.MenuItem;
-import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
-
-/**
- *
- * @author Giancarlo Panichi
- *
- *
- */
-public class ServiceChartContextPanel extends SimpleContainer {
- private static final int MAX_NUMBER_OF_CONTEXT = 20;
-
- private static final String TIME_UNIT = "Time Unit";
- // private static final String MEASURE_TYPE = "Measure";
-
- private DateTimeFormat dtf = DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
-
- private EventBus eventBus;
- private AccountingClientStateData accountingStateData;
- private HighchartsLayoutPanel highchartsLayoutPanel;
-
- // Download Menu
- private MenuItem downloadCSVItem;
- private MenuItem downloadXMLItem;
- private MenuItem downloadJSONItem;
- private MenuItem downloadPNGItem;
- private MenuItem downloadJPGItem;
- private MenuItem downloadPDFItem;
- private MenuItem downloadSVGItem;
-
- // Measure Menu
- private MenuItem operationCountItem;
- private MenuItem durationItem;
- private MenuItem maxInvocationTimeItem;
- private MenuItem minInvocationTimeItem;
-
- // Time Unit Menu
- private MenuItem msItem;
- private MenuItem sItem;
- private MenuItem mItem;
- private MenuItem hItem;
-
- private long unitMeasure = TimeUnitMeasure.getMilliseconds();
- private String unitMeasureLabel = TimeUnitMeasure.MS;
- private TextButton unitButton;
-
- private ChartOptions options;
-
- private ServiceChartMeasure measure = ServiceChartMeasure.OperationCount;
- private TextButton measureButton;
-
- private VerticalLayoutContainer vert;
-
- public ServiceChartContextPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
- this.eventBus = eventBus;
- this.accountingStateData = accountingStateData;
- forceLayoutOnResize = true;
- create();
-
- }
-
- private void create() {
- ToolBar toolBar = new ToolBar();
- toolBar.setSpacing(2);
- // Download
- final TextButton downloadButton = new TextButton(DownloadConstants.DOWNLOAD,
- AccountingManagerResources.INSTANCE.accountingDownload24());
- // downloadButton.setScale(ButtonScale.MEDIUM);
- downloadButton.setIconAlign(IconAlign.RIGHT);
- downloadButton.setArrowAlign(ButtonArrowAlign.RIGHT);
- downloadButton.setMenu(createDownloadMenu());
-
- // Measure
- measureButton = new TextButton(ServiceChartMeasure.OperationCount.getLabel(),
- AccountingManagerResources.INSTANCE.accountingByte24());
- measureButton.setIconAlign(IconAlign.RIGHT);
- measureButton.setArrowAlign(ButtonArrowAlign.RIGHT);
- measureButton.setMenu(createMeasureMenu());
-
- // Unit
- unitButton = new TextButton(TIME_UNIT, AccountingManagerResources.INSTANCE.accountingUnitms24());
- unitButton.setIconAlign(IconAlign.RIGHT);
- unitButton.setArrowAlign(ButtonArrowAlign.RIGHT);
- unitButton.setMenu(createUnitMenu());
- unitButton.setVisible(false);
-
- toolBar.add(downloadButton, new BoxLayoutData(new Margins(0)));
- toolBar.add(measureButton, new BoxLayoutData(new Margins(0)));
- toolBar.add(unitButton, new BoxLayoutData(new Margins(0)));
-
- //
- createChart();
-
- highchartsLayoutPanel = new HighchartsLayoutPanel();
- highchartsLayoutPanel.renderChart(options);
-
- //
- vert = new VerticalLayoutContainer();
- vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
- vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, new Margins(0)));
-
- add(vert, new MarginData(0));
-
- }
-
- private void updateChart() {
- createChart();
- highchartsLayoutPanel.renderChart(options);
- forceLayout();
- }
-
- private Menu createDownloadMenu() {
- Menu menuDownload = new Menu();
- downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
- AccountingManagerResources.INSTANCE.accountingFileCSV24());
- downloadCSVItem.setHeight(30);
- downloadXMLItem = new MenuItem(DownloadConstants.DOWNLOAD_XML,
- AccountingManagerResources.INSTANCE.accountingFileXML24());
- downloadXMLItem.setHeight(30);
- downloadJSONItem = new MenuItem(DownloadConstants.DOWNLOAD_JSON,
- AccountingManagerResources.INSTANCE.accountingFileJSON24());
- downloadJSONItem.setHeight(30);
- downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
- AccountingManagerResources.INSTANCE.accountingFilePNG24());
- downloadPNGItem.setHeight(30);
- downloadJPGItem = new MenuItem(DownloadConstants.DOWNLOAD_JPG,
- AccountingManagerResources.INSTANCE.accountingFileJPG24());
- downloadJPGItem.setHeight(30);
- downloadPDFItem = new MenuItem(DownloadConstants.DOWNLOAD_PDF,
- AccountingManagerResources.INSTANCE.accountingFilePDF24());
- downloadPDFItem.setHeight(30);
- downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
- AccountingManagerResources.INSTANCE.accountingFileSVG24());
- downloadSVGItem.setHeight(30);
-
- downloadCSVItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- onDownloadCSV();
-
- }
-
- });
-
- downloadXMLItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- onDownloadXML();
-
- }
-
- });
-
- downloadJSONItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- onDownloadJSON();
-
- }
-
- });
-
- downloadPNGItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- String id = highchartsLayoutPanel.getElement().getId();
- onDownloadPNG(id);
-
- }
- });
-
- downloadJPGItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- String id = highchartsLayoutPanel.getElement().getId();
- onDownloadJPG(id);
- }
- });
-
- downloadPDFItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- String id = highchartsLayoutPanel.getElement().getId();
- onDownloadPDF(id);
- }
- });
-
- downloadSVGItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- String id = highchartsLayoutPanel.getElement().getId();
- onDownloadSVG(id);
- }
- });
-
- menuDownload.add(downloadCSVItem);
- menuDownload.add(downloadXMLItem);
- menuDownload.add(downloadJSONItem);
- menuDownload.add(downloadPNGItem);
- menuDownload.add(downloadJPGItem);
- menuDownload.add(downloadPDFItem);
- menuDownload.add(downloadSVGItem);
- return menuDownload;
-
- }
-
- private Menu createMeasureMenu() {
- Menu menuMeasure = new Menu();
- // TODO
- durationItem = new MenuItem(ServiceChartMeasure.Duration.getLabel());
- durationItem.setHeight(30);
- operationCountItem = new MenuItem(ServiceChartMeasure.OperationCount.getLabel());
- operationCountItem.setHeight(30);
- maxInvocationTimeItem = new MenuItem(ServiceChartMeasure.MaxInvocationTime.getLabel());
- maxInvocationTimeItem.setHeight(30);
- minInvocationTimeItem = new MenuItem(ServiceChartMeasure.MinInvocationTime.getLabel());
- minInvocationTimeItem.setHeight(30);
-
- durationItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- measureButton.setText(ServiceChartMeasure.Duration.getLabel());
- measure = ServiceChartMeasure.Duration;
- unitButton.setVisible(true);
- updateChart();
- }
- });
-
- operationCountItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- measureButton.setText(ServiceChartMeasure.OperationCount.getLabel());
- measure = ServiceChartMeasure.OperationCount;
- unitButton.setVisible(false);
- updateChart();
- }
- });
-
- maxInvocationTimeItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- measureButton.setText(ServiceChartMeasure.MaxInvocationTime.getLabel());
- measure = ServiceChartMeasure.MaxInvocationTime;
- unitButton.setVisible(true);
- updateChart();
- }
- });
-
- minInvocationTimeItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- measureButton.setText(ServiceChartMeasure.MinInvocationTime.getLabel());
- measure = ServiceChartMeasure.MinInvocationTime;
- unitButton.setVisible(true);
- updateChart();
- }
- });
-
- menuMeasure.add(durationItem);
- menuMeasure.add(maxInvocationTimeItem);
- menuMeasure.add(minInvocationTimeItem);
- menuMeasure.add(operationCountItem);
-
- return menuMeasure;
-
- }
-
- private Menu createUnitMenu() {
- Menu menuUnit = new Menu();
- msItem = new MenuItem(TimeUnitMeasure.MILLISECONDS, AccountingManagerResources.INSTANCE.accountingUnitms24());
- msItem.setHeight(30);
- sItem = new MenuItem(TimeUnitMeasure.SECONDS, AccountingManagerResources.INSTANCE.accountingUnits24());
- sItem.setHeight(30);
- mItem = new MenuItem(TimeUnitMeasure.MINUTES, AccountingManagerResources.INSTANCE.accountingUnitm24());
- mItem.setHeight(30);
- hItem = new MenuItem(TimeUnitMeasure.HOURS, AccountingManagerResources.INSTANCE.accountingUnith24());
- hItem.setHeight(30);
-
- msItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- unitMeasure = TimeUnitMeasure.getMilliseconds();
- unitMeasureLabel = TimeUnitMeasure.MS;
- unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitms24());
- updateChart();
- }
- });
-
- sItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- unitMeasure = TimeUnitMeasure.getSeconds();
- unitMeasureLabel = TimeUnitMeasure.S;
- unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnits24());
- updateChart();
- }
- });
-
- mItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- unitMeasure = TimeUnitMeasure.getMinutes();
- unitMeasureLabel = TimeUnitMeasure.M;
- unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitm24());
- updateChart();
- }
- });
-
- hItem.addSelectionHandler(new SelectionHandler
- () {
-
- @Override
- public void onSelection(SelectionEvent
- event) {
- unitMeasure = TimeUnitMeasure.getHours();
- unitMeasureLabel = TimeUnitMeasure.H;
- unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnith24());
- updateChart();
- }
- });
-
- menuUnit.add(msItem);
- menuUnit.add(sItem);
- menuUnit.add(mItem);
- menuUnit.add(hItem);
- return menuUnit;
-
- }
-
- private void onDownloadCSV() {
- ExportRequestEvent event = new ExportRequestEvent(ExportType.CSV, accountingStateData.getAccountingType());
- eventBus.fireEvent(event);
- }
-
- private void onDownloadXML() {
- ExportRequestEvent event = new ExportRequestEvent(ExportType.XML, accountingStateData.getAccountingType());
- eventBus.fireEvent(event);
- }
-
- private void onDownloadJSON() {
- ExportRequestEvent event = new ExportRequestEvent(ExportType.JSON, accountingStateData.getAccountingType());
- eventBus.fireEvent(event);
- }
-
- // chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
-
- public static native void onDownloadPNG(String id) /*-{
- console.log(id);
- var chart = $wnd
- .jQuery('#' + id)
- .highcharts(
- this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartContextPanel::options);
- console.log(chart);
- chart.exportChart();
-
- }-*/;
-
- public static native void onDownloadJPG(String id) /*-{
- console.log(id);
- var chart = $wnd
- .jQuery('#' + id)
- .highcharts(
- this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartContextPanel::options);
- console.log(chart);
- chart.exportChart({
- type : 'image/jpeg'
- });
-
- }-*/;
-
- public static native void onDownloadPDF(String id) /*-{
- console.log(id);
- var chart = $wnd
- .jQuery('#' + id)
- .highcharts(
- this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartContextPanel::options);
- console.log(chart);
- chart.exportChart({
- type : 'application/pdf'
- });
-
- }-*/;
-
- public static native void onDownloadSVG(String id) /*-{
- console.log(id);
- var chart = $wnd
- .jQuery('#' + id)
- .highcharts(
- this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartContextPanel::options);
- console.log(chart);
- chart.exportChart({
- type : 'image/svg+xml'
- });
-
- }-*/;
-
- private void createChart() {
- SeriesService seriesService = (SeriesService) accountingStateData.getSeriesResponse();
-
- if (!(seriesService.getSerieServiceDefinition() instanceof SeriesServiceContext)) {
- Log.debug("Invalid SeriesServiceContext!");
- return;
- }
- SeriesServiceContext seriesServiceContext = (SeriesServiceContext) seriesService.getSerieServiceDefinition();
-
- HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
-
- options = highchartsFactory.createChartOptions();
- options.chart().zoomType("xy");
- options.exporting().buttons().contextButton().enabled(false);
- options.exporting().filename("AccountingServiceContext");
- options.title().text("Accounting Service Context");
-
- /*
- * options.subtitle().text("Click and drag in the plot area to zoom in"
- * );
- */
-
- ArrayString colors = options.colors();
- // colors.setValue(0, "#cc0038");
- // colors.setValue(1, "#32cd32");
-
- // yAxis
- options.setFieldAsJsonObject("yAxis", retrieveYAxis(colors));
-
- options.plotOptions().setFieldAsJsonObject("column",
- "{ " + "\"stacking\": \"normal\"," + "\"dataLabels\": { " + " \"enabled\": \"true\","
- + " \"color\": \"white\", " + " \"style\": {"
- + " \"textShadow\": \"0 0 3px black\"" + " }" + " }" + " }");
-
- ArrayList seriesColumn = new ArrayList<>();
- /*
- * if (seriesServiceContext.getShowOthers()) {
- * createSeriesColumnShowOthers(seriesServiceContext, highchartsFactory,
- * colors, seriesColumn); } else {
- */
- createSeriesColumnSimple(seriesServiceContext, highchartsFactory, colors, seriesColumn);
- /* } */
- for (SeriesColumn serie : seriesColumn) {
- options.series().addToEnd(serie);
- }
-
- options.chart().showAxes(true);
-
- options.legend().enabled(true);
- return;
- }
-
- private void createSeriesColumnShowOthers(SeriesServiceContext seriesServiceContext,
- HighchartsOptionFactory highchartsFactory, ArrayString colors, ArrayList seriesColumn) {
- Log.debug("Series ShowOthers");
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.DAILY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.HOURLY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.MINUTELY) == 0) {
-
- double minRange = ChartTimeMeasure
- .calculateMinRange(accountingStateData.getSeriesRequest().getAccountingPeriod());
-
- double interval = ChartTimeMeasure
- .calculateInterval(accountingStateData.getSeriesRequest().getAccountingPeriod());
-
- Date dateStart = dtf.parse(accountingStateData.getSeriesRequest().getAccountingPeriod().getStartDate());
-
- dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
-
- Log.debug("BuildChart DateStart: "
- + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(dateStart));
-
- // xAxis
- options.xAxis().type("datetime");
- options.xAxis().minRange(minRange);
- options.tooltip().xDateFormat("Selected Data");
-
- int i = 0;
- for (; i < seriesServiceContext.getSeriesServiceDataContextList().size()
- && i < MAX_NUMBER_OF_CONTEXT; i++) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name(seriesServiceContext.getSeriesServiceDataContextList().get(i).getContext());
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- ArrayNumber data = seriesColumnData.dataAsArrayNumber();
-
- for (SeriesServiceData seriesServiceData : seriesServiceContext.getSeriesServiceDataContextList().get(i)
- .getSeries()) {
- switch (measure) {
- case Duration:
- data.push(seriesServiceData.getDuration() / unitMeasure);
- break;
- case MaxInvocationTime:
- data.push(seriesServiceData.getMaxInvocationTime() / unitMeasure);
- break;
- case MinInvocationTime:
- data.push(seriesServiceData.getMinInvocationTime() / unitMeasure);
- break;
- case OperationCount:
- data.push(seriesServiceData.getOperationCount());
- break;
- default:
- data.push(seriesServiceData.getDuration() / unitMeasure);
- break;
-
- }
-
- }
-
- seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
- seriesColumn.add(seriesColumnData);
-
- }
-
- if (i < seriesServiceContext.getSeriesServiceDataContextList().size()) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name("Others");
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- ArrayList othersData = new ArrayList<>();
- for (int j = i; j < seriesServiceContext.getSeriesServiceDataContextList().size(); j++) {
- Long value;
- for (int k = 0; k < seriesServiceContext.getSeriesServiceDataContextList().get(j).getSeries()
- .size(); k++) {
- SeriesServiceData seriesServiceData = seriesServiceContext.getSeriesServiceDataContextList()
- .get(j).getSeries().get(k);
- if (j == i) {
- switch (measure) {
- case Duration:
- othersData.add(seriesServiceData.getDuration() / unitMeasure);
- break;
- case MaxInvocationTime:
- othersData.add(seriesServiceData.getMaxInvocationTime() / unitMeasure);
- break;
- case MinInvocationTime:
- othersData.add(seriesServiceData.getMinInvocationTime() / unitMeasure);
- break;
- case OperationCount:
- othersData.add(seriesServiceData.getOperationCount());
- break;
- default:
- othersData.add(seriesServiceData.getDuration() / unitMeasure);
- break;
- }
- } else {
- switch (measure) {
- case Duration:
- value = (seriesServiceData.getDuration() / unitMeasure) + othersData.get(k);
- othersData.set(k, value);
- break;
- case MaxInvocationTime:
- value = (seriesServiceData.getMaxInvocationTime() / unitMeasure) + othersData.get(k);
- othersData.set(k, value);
- break;
- case MinInvocationTime:
- value = (seriesServiceData.getMinInvocationTime() / unitMeasure) + othersData.get(k);
- othersData.set(k, value);
- break;
- case OperationCount:
- value = seriesServiceData.getOperationCount() + othersData.get(k);
- othersData.set(k, value);
- break;
- default:
- value = (seriesServiceData.getDuration() / unitMeasure) + othersData.get(k);
- othersData.set(k, value);
- break;
-
- }
-
- }
-
- }
- }
-
- ArrayNumber data = seriesColumnData.dataAsArrayNumber();
-
- for (Long value : othersData) {
- data.push(value);
- }
-
- seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
- seriesColumn.add(seriesColumnData);
-
- }
- } else {
- // xAxis
- options.xAxis().type("datetime");
-
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.MONTHLY) == 0) {
- // options.tooltip().xDateFormat("%b, %Y");
- options.tooltip().xDateFormat("Selected Data");
-
- } else {
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.YEARLY) == 0) {
- // options.tooltip().xDateFormat("%Y");
- options.tooltip().xDateFormat("Selected Data");
-
- } else {
- options.tooltip().xDateFormat("Selected Data");
- }
-
- }
-
- int i = 0;
- for (; i < seriesServiceContext.getSeriesServiceDataContextList().size()
- && i < MAX_NUMBER_OF_CONTEXT; i++) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name(seriesServiceContext.getSeriesServiceDataContextList().get(i).getContext());
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- Array arrayData = seriesColumnData.dataAsArrayObject();
-
- for (SeriesServiceData seriesServiceData : seriesServiceContext.getSeriesServiceDataContextList().get(i)
- .getSeries()) {
- long dateFrom1970 = seriesServiceData.getDate().getTime();
-
- Log.debug("SeriersServiceData: " + seriesServiceData.getDate());
- Log.debug("SeriersServiceData: " + dateFrom1970);
-
- Data data = highchartsFactory.createSeriesColumnData();
-
- switch (measure) {
- case Duration:
- data.x(dateFrom1970);
- data.y(seriesServiceData.getDuration() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case MaxInvocationTime:
- data.x(dateFrom1970);
- data.y(seriesServiceData.getMaxInvocationTime() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case MinInvocationTime:
- data.x(dateFrom1970);
- data.y(seriesServiceData.getMinInvocationTime() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case OperationCount:
- data.x(dateFrom1970);
- data.y(seriesServiceData.getOperationCount());
- arrayData.addToEnd(data);
- break;
- default:
- data.x(dateFrom1970);
- data.y(seriesServiceData.getDuration() / unitMeasure);
- arrayData.addToEnd(data);
- break;
-
- }
-
- }
-
- seriesColumn.add(seriesColumnData);
-
- }
-
- if (i < seriesServiceContext.getSeriesServiceDataContextList().size()) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name("Others");
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- ArrayList othersData = new ArrayList<>();
- for (int j = i; j < seriesServiceContext.getSeriesServiceDataContextList().size(); j++) {
- ChartDateTimeData chartDateTimeData;
- for (int k = 0; k < seriesServiceContext.getSeriesServiceDataContextList().get(j).getSeries()
- .size(); k++) {
- SeriesServiceData seriesServiceData = seriesServiceContext.getSeriesServiceDataContextList()
- .get(j).getSeries().get(k);
- if (j == i) {
- switch (measure) {
- case Duration:
- chartDateTimeData = new ChartDateTimeData(seriesServiceData.getDate(),
- seriesServiceData.getDuration() / unitMeasure);
- othersData.add(chartDateTimeData);
- break;
- case MaxInvocationTime:
- chartDateTimeData = new ChartDateTimeData(seriesServiceData.getDate(),
- seriesServiceData.getMaxInvocationTime() / unitMeasure);
- othersData.add(chartDateTimeData);
- break;
- case MinInvocationTime:
- chartDateTimeData = new ChartDateTimeData(seriesServiceData.getDate(),
- seriesServiceData.getMinInvocationTime() / unitMeasure);
- othersData.add(chartDateTimeData);
- break;
- case OperationCount:
- chartDateTimeData = new ChartDateTimeData(seriesServiceData.getDate(),
- seriesServiceData.getOperationCount());
- othersData.add(chartDateTimeData);
- break;
- default:
- chartDateTimeData = new ChartDateTimeData(seriesServiceData.getDate(),
- seriesServiceData.getDuration() / unitMeasure);
- othersData.add(chartDateTimeData);
- break;
- }
- } else {
- switch (measure) {
- case Duration:
- chartDateTimeData = new ChartDateTimeData(seriesServiceData.getDate(),
- (seriesServiceData.getDuration() / unitMeasure) + othersData.get(k).getValue());
- othersData.set(k, chartDateTimeData);
- break;
- case MaxInvocationTime:
- chartDateTimeData = new ChartDateTimeData(seriesServiceData.getDate(),
- (seriesServiceData.getMaxInvocationTime() / unitMeasure)
- + othersData.get(k).getValue());
- othersData.set(k, chartDateTimeData);
- break;
- case MinInvocationTime:
- chartDateTimeData = new ChartDateTimeData(seriesServiceData.getDate(),
- (seriesServiceData.getMinInvocationTime() / unitMeasure)
- + othersData.get(k).getValue());
- othersData.set(k, chartDateTimeData);
- break;
- case OperationCount:
- chartDateTimeData = new ChartDateTimeData(seriesServiceData.getDate(),
- seriesServiceData.getOperationCount() + othersData.get(k).getValue());
- othersData.set(k, chartDateTimeData);
- break;
- default:
- chartDateTimeData = new ChartDateTimeData(seriesServiceData.getDate(),
- (seriesServiceData.getDuration() / unitMeasure) + othersData.get(k).getValue());
- othersData.set(k, chartDateTimeData);
- break;
-
- }
-
- }
-
- }
- }
-
- Array arrayData = seriesColumnData.dataAsArrayObject();
-
- for (ChartDateTimeData chartDateTimeData : othersData) {
- long dateFrom1970 = chartDateTimeData.getDate().getTime();
-
- Log.debug("SeriersOthersData: " + chartDateTimeData.getDate());
- Log.debug("SeriersOthersData: " + dateFrom1970);
-
- Data data = highchartsFactory.createSeriesColumnData();
-
- data.x(dateFrom1970);
- data.y(chartDateTimeData.getValue());
- arrayData.addToEnd(data);
-
- }
-
- seriesColumn.add(seriesColumnData);
-
- }
-
- }
- }
-
- private void createSeriesColumnSimple(SeriesServiceContext seriesServiceContext,
- HighchartsOptionFactory highchartsFactory, ArrayString colors, ArrayList seriesColumn) {
- Log.debug("Series Simple");
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.DAILY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.HOURLY) == 0
- || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.MINUTELY) == 0) {
-
- double minRange = ChartTimeMeasure
- .calculateMinRange(accountingStateData.getSeriesRequest().getAccountingPeriod());
-
- double interval = ChartTimeMeasure
- .calculateInterval(accountingStateData.getSeriesRequest().getAccountingPeriod());
-
- Date dateStart = dtf.parse(accountingStateData.getSeriesRequest().getAccountingPeriod().getStartDate());
-
- dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
-
- Log.debug("BuildChart DateStart: "
- + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(dateStart));
-
- // xAxis
- options.xAxis().type("datetime");
- options.xAxis().minRange(minRange);
- options.tooltip().xDateFormat("Selected Data");
-
- for (int i = 0; i < seriesServiceContext.getSeriesServiceDataContextList().size(); i++) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name(seriesServiceContext.getSeriesServiceDataContextList().get(i).getContext());
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- ArrayNumber data = seriesColumnData.dataAsArrayNumber();
-
- for (SeriesServiceData seriesServiceData : seriesServiceContext.getSeriesServiceDataContextList().get(i)
- .getSeries()) {
- switch (measure) {
- case Duration:
- data.push(seriesServiceData.getDuration() / unitMeasure);
- break;
- case MaxInvocationTime:
- data.push(seriesServiceData.getMaxInvocationTime() / unitMeasure);
- break;
- case MinInvocationTime:
- data.push(seriesServiceData.getMinInvocationTime() / unitMeasure);
- break;
- case OperationCount:
- data.push(seriesServiceData.getOperationCount());
- break;
- default:
- data.push(seriesServiceData.getDuration() / unitMeasure);
- break;
-
- }
-
- }
-
- seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
- seriesColumn.add(seriesColumnData);
-
- }
- } else {
- // xAxis
- options.xAxis().type("datetime");
-
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.MONTHLY) == 0) {
- // options.tooltip().xDateFormat("%b, %Y");
- options.tooltip().xDateFormat("Selected Data");
-
- } else {
- if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
- .compareTo(AccountingPeriodMode.YEARLY) == 0) {
- // options.tooltip().xDateFormat("%Y");
- options.tooltip().xDateFormat("Selected Data");
-
- } else {
- options.tooltip().xDateFormat("Selected Data");
- }
-
- }
-
- for (int i = 0; i < seriesServiceContext.getSeriesServiceDataContextList().size(); i++) {
- SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
-
- seriesColumnData.name(seriesServiceContext.getSeriesServiceDataContextList().get(i).getContext());
- seriesColumnData.color(colors.get(i));
- seriesColumnData.type("column");
-
- Array arrayData = seriesColumnData.dataAsArrayObject();
-
- for (SeriesServiceData seriesServiceData : seriesServiceContext.getSeriesServiceDataContextList().get(i)
- .getSeries()) {
- long dateFrom1970 = seriesServiceData.getDate().getTime();
-
- Log.debug("SeriersServiceData: " + seriesServiceData.getDate());
- Log.debug("SeriersServiceData: " + dateFrom1970);
-
- Data data = highchartsFactory.createSeriesColumnData();
-
- switch (measure) {
- case Duration:
- data.x(dateFrom1970);
- data.y(seriesServiceData.getDuration() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case MaxInvocationTime:
- data.x(dateFrom1970);
- data.y(seriesServiceData.getMaxInvocationTime() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case MinInvocationTime:
- data.x(dateFrom1970);
- data.y(seriesServiceData.getMinInvocationTime() / unitMeasure);
- arrayData.addToEnd(data);
- break;
- case OperationCount:
- data.x(dateFrom1970);
- data.y(seriesServiceData.getOperationCount());
- arrayData.addToEnd(data);
- break;
- default:
- data.x(dateFrom1970);
- data.y(seriesServiceData.getDuration() / unitMeasure);
- arrayData.addToEnd(data);
- break;
-
- }
-
- }
-
- seriesColumn.add(seriesColumnData);
-
- }
- }
- }
-
- private String retrieveYAxis(ArrayString colors) {
- switch (measure) {
- case Duration:
- return "[{" + " \"id\": \"" + ServiceChartMeasure.Duration.name() + "\"," + " \"labels\": {"
- + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }," + " \"stackLabels\": {"
- + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
- + ServiceChartMeasure.Duration.getLabel() + "\"," + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
- case MaxInvocationTime:
- return "[{" + " \"id\": \"" + ServiceChartMeasure.MaxInvocationTime.name() + "\"," + " \"labels\": {"
- + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }," + " \"stackLabels\": {"
- + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
- + ServiceChartMeasure.MaxInvocationTime.getLabel() + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }" + "}]";
- case MinInvocationTime:
- return "[{" + " \"id\": \"" + ServiceChartMeasure.MinInvocationTime.name() + "\"," + " \"labels\": {"
- + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }," + " \"stackLabels\": {"
- + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
- + ServiceChartMeasure.MinInvocationTime.getLabel() + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }" + "}]";
- case OperationCount:
- return "[{" + " \"id\": \"" + ServiceChartMeasure.OperationCount.name() + "\"," + " \"labels\": { "
- + " \"format\": \"{value}\"," + " \"style\": { " + " \"color\": \"" + colors.get(1)
- + "\"" + " }" + " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"style\": {"
- + " \"fontWeight\": \"bold\"," + " \"color\": \"gray\"" + " } " + " },"
- + " \"title\": { " + " \"text\": \"" + ServiceChartMeasure.OperationCount.getLabel() + "\","
- + " \"style\": {" + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }" + "}]";
-
- default:
- return "[{" + " \"id\": \"" + ServiceChartMeasure.Duration.name() + "\"," + " \"labels\": {"
- + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
- + " \"color\": \"" + colors.get(1) + "\"" + " }" + " }," + " \"stackLabels\": {"
- + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
- + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
- + ServiceChartMeasure.Duration.getLabel() + "\"," + " \"style\": {" + " \"color\": \""
- + colors.get(1) + "\"" + " }" + " }" + "}]";
-
- }
-
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/service/ServiceChartTopPanel.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/service/ServiceChartTopPanel.java
index 4a3b173..d138c1f 100644
--- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/service/ServiceChartTopPanel.java
+++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/service/ServiceChartTopPanel.java
@@ -6,6 +6,7 @@ import java.util.Date;
import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartDateTimeData;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
+import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ColorsPalette;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ServiceChartMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
@@ -57,8 +58,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
private static final String TIME_UNIT = "Time Unit";
// private static final String MEASURE_TYPE = "Measure";
- private DateTimeFormat dtf = DateTimeFormat
- .getFormat(PredefinedFormat.YEAR_MONTH_DAY);
+ private DateTimeFormat dtf = DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
private EventBus eventBus;
private AccountingClientStateData accountingStateData;
@@ -96,8 +96,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
private VerticalLayoutContainer vert;
- public ServiceChartTopPanel(EventBus eventBus,
- AccountingClientStateData accountingStateData) {
+ public ServiceChartTopPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus = eventBus;
this.accountingStateData = accountingStateData;
forceLayoutOnResize = true;
@@ -109,8 +108,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
ToolBar toolBar = new ToolBar();
toolBar.setSpacing(2);
// Download
- final TextButton downloadButton = new TextButton(
- DownloadConstants.DOWNLOAD,
+ final TextButton downloadButton = new TextButton(DownloadConstants.DOWNLOAD,
AccountingManagerResources.INSTANCE.accountingDownload24());
// downloadButton.setScale(ButtonScale.MEDIUM);
downloadButton.setIconAlign(IconAlign.RIGHT);
@@ -118,16 +116,14 @@ public class ServiceChartTopPanel extends SimpleContainer {
downloadButton.setMenu(createDownloadMenu());
// Measure
- measureButton = new TextButton(
- ServiceChartMeasure.OperationCount.getLabel(),
+ measureButton = new TextButton(ServiceChartMeasure.OperationCount.getLabel(),
AccountingManagerResources.INSTANCE.accountingByte24());
measureButton.setIconAlign(IconAlign.RIGHT);
measureButton.setArrowAlign(ButtonArrowAlign.RIGHT);
measureButton.setMenu(createMeasureMenu());
// Unit
- unitButton = new TextButton(TIME_UNIT,
- AccountingManagerResources.INSTANCE.accountingUnitms24());
+ unitButton = new TextButton(TIME_UNIT, AccountingManagerResources.INSTANCE.accountingUnitms24());
unitButton.setIconAlign(IconAlign.RIGHT);
unitButton.setArrowAlign(ButtonArrowAlign.RIGHT);
unitButton.setMenu(createUnitMenu());
@@ -146,8 +142,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
//
vert = new VerticalLayoutContainer();
vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
- vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1,
- new Margins(0)));
+ vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, new Margins(0)));
add(vert, new MarginData(0));
@@ -266,14 +261,11 @@ public class ServiceChartTopPanel extends SimpleContainer {
// TODO
durationItem = new MenuItem(ServiceChartMeasure.Duration.getLabel());
durationItem.setHeight(30);
- operationCountItem = new MenuItem(
- ServiceChartMeasure.OperationCount.getLabel());
+ operationCountItem = new MenuItem(ServiceChartMeasure.OperationCount.getLabel());
operationCountItem.setHeight(30);
- maxInvocationTimeItem = new MenuItem(
- ServiceChartMeasure.MaxInvocationTime.getLabel());
+ maxInvocationTimeItem = new MenuItem(ServiceChartMeasure.MaxInvocationTime.getLabel());
maxInvocationTimeItem.setHeight(30);
- minInvocationTimeItem = new MenuItem(
- ServiceChartMeasure.MinInvocationTime.getLabel());
+ minInvocationTimeItem = new MenuItem(ServiceChartMeasure.MinInvocationTime.getLabel());
minInvocationTimeItem.setHeight(30);
durationItem.addSelectionHandler(new SelectionHandler
- () {
@@ -291,8 +283,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
@Override
public void onSelection(SelectionEvent
- event) {
- measureButton.setText(ServiceChartMeasure.OperationCount
- .getLabel());
+ measureButton.setText(ServiceChartMeasure.OperationCount.getLabel());
measure = ServiceChartMeasure.OperationCount;
unitButton.setVisible(false);
updateChart();
@@ -303,8 +294,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
@Override
public void onSelection(SelectionEvent
- event) {
- measureButton.setText(ServiceChartMeasure.MaxInvocationTime
- .getLabel());
+ measureButton.setText(ServiceChartMeasure.MaxInvocationTime.getLabel());
measure = ServiceChartMeasure.MaxInvocationTime;
unitButton.setVisible(true);
updateChart();
@@ -315,8 +305,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
@Override
public void onSelection(SelectionEvent
- event) {
- measureButton.setText(ServiceChartMeasure.MinInvocationTime
- .getLabel());
+ measureButton.setText(ServiceChartMeasure.MinInvocationTime.getLabel());
measure = ServiceChartMeasure.MinInvocationTime;
unitButton.setVisible(true);
updateChart();
@@ -334,17 +323,13 @@ public class ServiceChartTopPanel extends SimpleContainer {
private Menu createUnitMenu() {
Menu menuUnit = new Menu();
- msItem = new MenuItem(TimeUnitMeasure.MILLISECONDS,
- AccountingManagerResources.INSTANCE.accountingUnitms24());
+ msItem = new MenuItem(TimeUnitMeasure.MILLISECONDS, AccountingManagerResources.INSTANCE.accountingUnitms24());
msItem.setHeight(30);
- sItem = new MenuItem(TimeUnitMeasure.SECONDS,
- AccountingManagerResources.INSTANCE.accountingUnits24());
+ sItem = new MenuItem(TimeUnitMeasure.SECONDS, AccountingManagerResources.INSTANCE.accountingUnits24());
sItem.setHeight(30);
- mItem = new MenuItem(TimeUnitMeasure.MINUTES,
- AccountingManagerResources.INSTANCE.accountingUnitm24());
+ mItem = new MenuItem(TimeUnitMeasure.MINUTES, AccountingManagerResources.INSTANCE.accountingUnitm24());
mItem.setHeight(30);
- hItem = new MenuItem(TimeUnitMeasure.HOURS,
- AccountingManagerResources.INSTANCE.accountingUnith24());
+ hItem = new MenuItem(TimeUnitMeasure.HOURS, AccountingManagerResources.INSTANCE.accountingUnith24());
hItem.setHeight(30);
msItem.addSelectionHandler(new SelectionHandler
- () {
@@ -353,8 +338,7 @@ public class ServiceChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent