Refs #21354: Improve accounting manager portlet by new persistence

Updated portlet behavior
This commit is contained in:
Giancarlo Panichi 2021-11-23 19:21:22 +01:00
parent 3ffb9f8523
commit ac4c236019
8 changed files with 216 additions and 91 deletions

View File

@ -46,7 +46,8 @@
<!-- <set-configuration-property name="CssResource.style" value="pretty"/> -->
<!-- <set-property name="log_DivLogger" value="ENABLED" /> <set-property
<!--
<set-property name="log_DivLogger" value="ENABLED" /> <set-property
name="log_ConsoleLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> -->
@ -56,8 +57,7 @@
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" />
<!-- Specify the paths for translatable code -->
<source path='client' />

View File

@ -430,7 +430,7 @@ public class AccountingManagerController {
AccountingClientStateData accountingStateData = accountingState.getState(accountingType);
SeriesRequest seriesRequest = null;
Context defaultContext=new Context();
Context defaultContext=availableContext;
switch (accountingType) {
case JOB:

View File

@ -93,6 +93,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;
/**
@ -113,6 +115,8 @@ public class ActiveFiltersPanel extends SimpleContainer {
private ListStore<ContextData> storeScopes;
private CheckBoxSelectionModel<ContextData> smScopes;
private ColumnConfig<ContextData, String> labelScopesCol;
private StringFilter<ContextData> scopeFilter;
private boolean addStatus;
private AccountingClientStateData accountingStateData;
private ListStore<FilterKey> storeComboFilterKey;
@ -428,6 +432,21 @@ public class ActiveFiltersPanel extends SimpleContainer {
gridScopes.getView().setAutoExpandColumn(labelScopesCol);
gridScopes.getView().setSortingEnabled(true);
//gridScopes.setStateful(true);
//gridScopes.setStateId("gridScopesDefault");
scopeFilter = new StringFilter<ContextData>(propsScopeData.label());
GridFilters<ContextData> gridScopesFilters = new GridFilters<ContextData>();
gridScopesFilters.initPlugin(gridScopes);
gridScopesFilters.setLocal(true);
gridScopesFilters.addFilter(scopeFilter);
//GridFilterStateHandler<ContextData> handler = new GridFilterStateHandler<ContextData>(gridScopes,
// gridScopesFilters);
//handler.loadState();
// ChartTypeSelection
storeComboChartType = new ListStore<ChartType>(new ModelKeyProvider<ChartType>() {
@ -541,7 +560,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
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(comboChartTypeLabel, new VerticalLayoutData(1, -1, new Margins(10, 0, 0, 0)));
vlc.add(comboTopFilterKeyLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(showOthersLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(topNumberLabel, new VerticalLayoutData(1, -1, new Margins(0)));
@ -549,15 +568,15 @@ public class ActiveFiltersPanel extends SimpleContainer {
vlc.add(gridFilter, new VerticalLayoutData(1, 1, new Margins(0)));
FieldSet fieldSet = new FieldSet();
//fieldSet.setHeight("360px");
// fieldSet.setHeight("360px");
fieldSet.setHeight("480px");
fieldSet.setHeadingHtml("<b>Active Filters</b>");
fieldSet.setCollapsible(false);
fieldSet.add(vlc);
add(fieldSet, new MarginData(0));
comboChartTypeLabel.setVisible(false);
gridScopes.setVisible(false);
//gridScopes.setVisible(true);
//comboChartTypeLabel.setVisible(true);
comboTopFilterKeyLabel.setVisible(false);
showOthersLabel.setVisible(false);
topNumberLabel.setVisible(false);
@ -685,6 +704,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
private void changeActiveFiltersForBasic() {
Log.debug("ChangeActiveFiltersForBasic");
if (accountingStateData.getSeriesRequest() != null
&& accountingStateData.getSeriesRequest().getAccountingFilterDefinition() != null && accountingStateData
.getSeriesRequest().getAccountingFilterDefinition() instanceof AccountingFilterBasic) {
@ -704,14 +724,27 @@ public class ActiveFiltersPanel extends SimpleContainer {
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()) {
} else {
if (accountingFilterBasic.getContext().getContexts() != null
&&!accountingFilterBasic.getContext().getContexts().isEmpty()) {
ArrayList<ContextData> selected = new ArrayList<>();
for (String c : accountingFilterBasic.getContext().getContexts()) {
for (ContextData contextData : storeScopes.getAll()) {
@ -723,15 +756,18 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
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 {
repopulatesContexts();
}
@ -768,6 +804,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
gridScopes.setVisible(true);
labelScopesCol.setHeader("Scope");
gridScopes.getView().refresh(true);
comboChartType.setValue(ChartType.Basic);
comboTopFilterKey.reset();
comboTopFilterKeyLabel.setVisible(false);
@ -781,6 +818,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
private void changeActiveFiltersForTop() {
Log.debug("ChangeActiveFiltersForTop");
if (accountingStateData.getSeriesRequest() != null
&& accountingStateData.getSeriesRequest().getAccountingFilterDefinition() != null && accountingStateData
.getSeriesRequest().getAccountingFilterDefinition() instanceof AccountingFilterTop) {
@ -799,15 +837,30 @@ public class ActiveFiltersPanel extends SimpleContainer {
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()) {
} else {
if (accountingFilterTop.getContext().getContexts() != null &&
!accountingFilterTop.getContext().getContexts().isEmpty()) {
ArrayList<ContextData> selected = new ArrayList<>();
for (String c : accountingFilterTop.getContext().getContexts()) {
for (ContextData contextData : storeScopes.getAll()) {
@ -819,15 +872,18 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
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 {
repopulatesContexts();
}
@ -878,18 +934,22 @@ public class ActiveFiltersPanel extends SimpleContainer {
for (String context : contexts) {
scopes.add(new ContextData(context));
}
storeScopes.clear();
storeScopes.setEnableFilters(false);
storeScopes.addAll(scopes);
storeScopes.commitChanges();
smScopes.deselectAll();
} else {
storeScopes.clear();
storeScopes.setEnableFilters(false);
storeScopes.commitChanges();
smScopes.deselectAll();
}
scopeFilter.setValue(null);
scopeFilter.setActive(false, false);
smScopes.deselectAll();
comboTopFilterKey.reset();
showOthersToggle.reset();
showOthersNo.setValue(true);
@ -904,6 +964,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
gridScopes.setVisible(true);
labelScopesCol.setHeader("Scope");
gridScopes.getView().refresh(true);
comboChartType.setValue(ChartType.Top);
comboTopFilterKeyLabel.setVisible(true);
showOthersLabel.setVisible(true);
@ -924,6 +985,8 @@ public class ActiveFiltersPanel extends SimpleContainer {
private void resetContexts() {
storeScopes.clear();
storeScopes.commitChanges();
scopeFilter.setValue(null);
scopeFilter.setActive(false, false);
smScopes.deselectAll();
smScopes.refresh();
}
@ -938,8 +1001,11 @@ public class ActiveFiltersPanel extends SimpleContainer {
storeScopes.clear();
storeScopes.addAll(contextList);
storeScopes.commitChanges();
scopeFilter.setValue(null);
scopeFilter.setActive(false, false);
smScopes.selectAll();
smScopes.refresh();
}
/*
@ -1030,8 +1096,8 @@ public class ActiveFiltersPanel extends SimpleContainer {
return getActiveFiltersForBasic();
case Top:
return getActiveFiltersForTop();
//case Spaces:
// return getActiveFiltersForSpaces();
// case Spaces:
// return getActiveFiltersForSpaces();
default:
return null;
@ -1058,8 +1124,16 @@ public class ActiveFiltersPanel extends SimpleContainer {
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(context);
return new AccountingFilterBasic(context, scopeFilterActive);
} else {
List<AccountingFilter> filtersActives = storeFilter.getAll();
ArrayList<AccountingFilter> filtersReady = new ArrayList<AccountingFilter>();
@ -1070,9 +1144,9 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
if (filtersReady.size() > 0) {
return new AccountingFilterBasic(context, filtersReady);
return new AccountingFilterBasic(context, scopeFilterActive, filtersReady);
} else {
return new AccountingFilterBasic(context);
return new AccountingFilterBasic(context, scopeFilterActive);
}
}
@ -1090,15 +1164,21 @@ public class ActiveFiltersPanel extends SimpleContainer {
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();
FilterKey filterKey = comboTopFilterKey.getCurrentValue();
if (filterKey == null) {
return new AccountingFilterTop(context, showOthersValue, topN);
return new AccountingFilterTop(context, scopeFilterActive, showOthersValue, topN);
} else {
if (storeFilter == null || storeFilter.size() <= 0) {
return new AccountingFilterTop(context, filterKey, null, showOthersValue, topN);
return new AccountingFilterTop(context, scopeFilterActive, filterKey, null, showOthersValue, topN);
} else {
List<AccountingFilter> filtersActives = storeFilter.getAll();
ArrayList<AccountingFilter> filtersReady = new ArrayList<AccountingFilter>();
@ -1108,9 +1188,10 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
}
if (filtersReady.size() > 0) {
return new AccountingFilterTop(context, filterKey, filtersReady, showOthersValue, topN);
return new AccountingFilterTop(context, scopeFilterActive, filterKey, filtersReady, showOthersValue,
topN);
} else {
return new AccountingFilterTop(context, filterKey, null, showOthersValue, topN);
return new AccountingFilterTop(context, scopeFilterActive, filterKey, null, showOthersValue, topN);
}
}
@ -1119,32 +1200,26 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
/*
private AccountingFilterDefinition getActiveFiltersForSpaces() {
ArrayList<String> spacesSelected = new ArrayList<String>();
if (storeSpaces != null && storeSpaces.size() > 0 && smSpaces != null) {
List<SpacesData> selected = smSpaces.getSelectedItems();
for (SpacesData cd : selected) {
spacesSelected.add(cd.getSpace());
}
}
Spaces spaces = new Spaces(spacesSelected);
Log.debug("Spaces selected: " + spaces);
List<AccountingFilter> filtersActives = storeFilter.getAll();
ArrayList<AccountingFilter> filtersReady = new ArrayList<AccountingFilter>();
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<String> spacesSelected = new ArrayList<String>(); if
* (storeSpaces != null && storeSpaces.size() > 0 && smSpaces != null) {
* List<SpacesData> selected = smSpaces.getSelectedItems(); for (SpacesData
* cd : selected) { spacesSelected.add(cd.getSpace()); } } Spaces spaces =
* new Spaces(spacesSelected);
*
* Log.debug("Spaces selected: " + spaces);
*
* List<AccountingFilter> filtersActives = storeFilter.getAll();
* ArrayList<AccountingFilter> filtersReady = new
* ArrayList<AccountingFilter>(); 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<AccountingFilter> filtersSet = storeFilter.getAll();
@ -1370,24 +1445,15 @@ public class ActiveFiltersPanel extends SimpleContainer {
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;*/
* 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;

View File

@ -68,7 +68,7 @@ public class AccountingClientStateData implements Serializable {
*/
public AccountingClientStateData(AccountingType accountingType, SeriesRequest seriesRequest,
SeriesResponse seriesResponse, ArrayList<FilterKey> availableFilterKeys, Context availableContext,
Spaces availableSpaces, Boolean rootScope) {
String scopeFilterActive, Spaces availableSpaces, Boolean rootScope) {
super();
this.accountingType = accountingType;
this.seriesRequest = seriesRequest;

View File

@ -14,12 +14,14 @@ public class AccountingFilterBasic extends AccountingFilterDefinition implements
private static final long serialVersionUID = -6805006183397381154L;
private ArrayList<AccountingFilter> filters;
private Context context;
private String scopeFilterActive;
public AccountingFilterBasic() {
super();
this.chartType = ChartType.Basic;
filters = null;
context = null;
scopeFilterActive = null;
}
public AccountingFilterBasic(Context context) {
@ -27,14 +29,40 @@ public class AccountingFilterBasic extends AccountingFilterDefinition implements
chartType = ChartType.Basic;
this.filters = null;
this.context = context;
this.scopeFilterActive = null;
}
public AccountingFilterBasic(Context context,String scopeFilterActive) {
super();
chartType = ChartType.Basic;
this.filters = null;
this.context = context;
this.scopeFilterActive = scopeFilterActive;
}
public AccountingFilterBasic(Context context, ArrayList<AccountingFilter> filters) {
super();
chartType = ChartType.Basic;
this.filters = filters;
this.context = context;
this.scopeFilterActive = null;
}
public AccountingFilterBasic(Context context, String scopeFilterActive, ArrayList<AccountingFilter> filters) {
super();
chartType = ChartType.Basic;
this.filters = filters;
this.context = context;
this.scopeFilterActive = scopeFilterActive;
}
public String getScopeFilterActive() {
return scopeFilterActive;
}
public void setScopeFilterActive(String scopeFilterActive) {
this.scopeFilterActive = scopeFilterActive;
}
public ArrayList<AccountingFilter> getFilters() {
@ -55,7 +83,8 @@ public class AccountingFilterBasic extends AccountingFilterDefinition implements
@Override
public String toString() {
return "AccountingFilterBasic [filters=" + filters + ", context=" + context + ", chartType=" + chartType + "]";
return "AccountingFilterBasic [filters=" + filters + ", context=" + context + ", scopeFilterActive="
+ scopeFilterActive + ", chartType=" + chartType + "]";
}

View File

@ -13,6 +13,7 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements S
private static final long serialVersionUID = -6805006183397381154L;
private Context context;
private String scopeFilterActive;
private FilterKey filterKey;
private Boolean showOthers;
private Integer topNumber;
@ -22,6 +23,7 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements S
super();
this.chartType = ChartType.Top;
context = null;
scopeFilterActive = null;
showOthers = false;
topNumber = 5;
filterKey = null;
@ -33,6 +35,19 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements S
super();
this.chartType = ChartType.Top;
this.context = context;
this.scopeFilterActive = null;
this.showOthers = showOthers;
this.topNumber = topNumber;
filterKey = null;
filters = null;
}
public AccountingFilterTop(Context context, String scopeFilterActive, Boolean showOthers, Integer topNumber) {
super();
this.chartType = ChartType.Top;
this.context = context;
this.scopeFilterActive = scopeFilterActive;
this.showOthers = showOthers;
this.topNumber = topNumber;
filterKey = null;
@ -45,11 +60,23 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements S
super();
chartType = ChartType.Top;
this.context = context;
this.scopeFilterActive = null;
this.filterKey = filterKey;
this.filters = filters;
this.showOthers = showOthers;
this.topNumber = topNumber;
}
public AccountingFilterTop(Context context, String scopeFilterActive, FilterKey filterKey,
ArrayList<AccountingFilter> filters, Boolean showOthers, Integer topNumber) {
super();
chartType = ChartType.Top;
this.context = context;
this.scopeFilterActive = scopeFilterActive;
this.filterKey = filterKey;
this.filters = filters;
this.showOthers = showOthers;
this.topNumber = topNumber;
}
public Context getContext() {
@ -92,12 +119,20 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements S
this.filters = filters;
}
public String getScopeFilterActive() {
return scopeFilterActive;
}
public void setScopeFilterActive(String scopeFilterActive) {
this.scopeFilterActive = scopeFilterActive;
}
@Override
public String toString() {
return "AccountingFilterTop [context=" + context + ", filterKey=" + filterKey + ", showOthers=" + showOthers
+ ", topNumber=" + topNumber + ", filters=" + filters + ", chartType=" + chartType + "]";
return "AccountingFilterTop [context=" + context + ", scopeFilterActive=" + scopeFilterActive + ", filterKey="
+ filterKey + ", showOthers=" + showOthers + ", topNumber=" + topNumber + ", filters=" + filters
+ ", chartType=" + chartType + "]";
}
}

View File

@ -21,8 +21,7 @@ public class SeriesRequest implements Serializable {
super();
}
public SeriesRequest(AccountingPeriod accountingPeriod,
AccountingFilterDefinition accountingFilterDefinition) {
public SeriesRequest(AccountingPeriod accountingPeriod, AccountingFilterDefinition accountingFilterDefinition) {
super();
this.accountingPeriod = accountingPeriod;
this.accountingFilterDefinition = accountingFilterDefinition;
@ -40,18 +39,14 @@ public class SeriesRequest implements Serializable {
return accountingFilterDefinition;
}
public void setAccountingFilterDefinition(
AccountingFilterDefinition accountingFilterDefinition) {
public void setAccountingFilterDefinition(AccountingFilterDefinition accountingFilterDefinition) {
this.accountingFilterDefinition = accountingFilterDefinition;
}
@Override
public String toString() {
return "SeriesRequest [accountingPeriod=" + accountingPeriod
+ ", accountingFilterDefinition=" + accountingFilterDefinition
+ "]";
return "SeriesRequest [accountingPeriod=" + accountingPeriod + ", accountingFilterDefinition="
+ accountingFilterDefinition + "]";
}
}

View File

@ -55,11 +55,11 @@
<set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> -->
/> -->
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
/> -->
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />