Updated cache size for FilterValue and change behavior for add filter in grid
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@155184 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2dcc82318b
commit
51cf1628fc
|
@ -33,6 +33,8 @@ import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpire
|
|||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.cell.client.AbstractCell;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.editor.client.Editor;
|
||||
import com.google.gwt.editor.client.EditorError;
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
|
@ -84,6 +86,8 @@ 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.grid.CheckBoxSelectionModel;
|
||||
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
||||
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
|
||||
|
@ -191,8 +195,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
private void create() {
|
||||
// Grid
|
||||
AccountingFilterProperties props = GWT
|
||||
.create(AccountingFilterProperties.class);
|
||||
AccountingFilterProperties props = GWT.create(AccountingFilterProperties.class);
|
||||
|
||||
ColumnConfig<AccountingFilter, FilterKey> keyColumn = new ColumnConfig<AccountingFilter, FilterKey>(
|
||||
props.filterKey(), 130, "Key");
|
||||
|
@ -200,10 +203,8 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
keyColumn.setCell(new AbstractCell<FilterKey>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, FilterKey filterKey,
|
||||
SafeHtmlBuilder sb) {
|
||||
FilterKeyTemplates filterKeyTemplates = GWT
|
||||
.create(FilterKeyTemplates.class);
|
||||
public void render(Context context, FilterKey filterKey, SafeHtmlBuilder sb) {
|
||||
FilterKeyTemplates filterKeyTemplates = GWT.create(FilterKeyTemplates.class);
|
||||
sb.append(filterKeyTemplates.format(filterKey.getKey()));
|
||||
}
|
||||
});
|
||||
|
@ -226,10 +227,8 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
valueColumn.setCell(new AbstractCell<String>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, String filterValue,
|
||||
SafeHtmlBuilder sb) {
|
||||
FilterValueTemplates filterValueTemplates = GWT
|
||||
.create(FilterValueTemplates.class);
|
||||
public void render(Context context, String filterValue, SafeHtmlBuilder sb) {
|
||||
FilterValueTemplates filterValueTemplates = GWT.create(FilterValueTemplates.class);
|
||||
sb.append(filterValueTemplates.format(filterValue));
|
||||
}
|
||||
});
|
||||
|
@ -238,8 +237,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
l.add(keyColumn);
|
||||
l.add(valueColumn);
|
||||
|
||||
ColumnModel<AccountingFilter> columns = new ColumnModel<AccountingFilter>(
|
||||
l);
|
||||
ColumnModel<AccountingFilter> columns = new ColumnModel<AccountingFilter>(l);
|
||||
|
||||
storeFilter = new ListStore<AccountingFilter>(props.id());
|
||||
|
||||
|
@ -256,37 +254,42 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
gridFilter.getView().setAutoExpandColumn(valueColumn);
|
||||
gridFilter.getView().setSortingEnabled(false);
|
||||
|
||||
GridDragSource<AccountingFilter> ds = new GridDragSource<AccountingFilter>(
|
||||
gridFilter);
|
||||
GridDragSource<AccountingFilter> ds = new GridDragSource<AccountingFilter>(gridFilter);
|
||||
ds.addDragStartHandler(new DndDragStartHandler() {
|
||||
|
||||
@Override
|
||||
public void onDragStart(DndDragStartEvent event) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<AccountingFilter> draggingSelection = (ArrayList<AccountingFilter>) event
|
||||
.getData();
|
||||
ArrayList<AccountingFilter> draggingSelection = (ArrayList<AccountingFilter>) event.getData();
|
||||
Log.debug("Start Drag: " + draggingSelection);
|
||||
|
||||
}
|
||||
});
|
||||
GridDropTarget<AccountingFilter> dt = new GridDropTarget<AccountingFilter>(
|
||||
gridFilter);
|
||||
GridDropTarget<AccountingFilter> dt = new GridDropTarget<AccountingFilter>(gridFilter);
|
||||
dt.setFeedback(Feedback.BOTH);
|
||||
dt.setAllowSelfAsSource(true);
|
||||
|
||||
// EDITING //
|
||||
// Key
|
||||
FilterKeyPropertiesCombo filterKeyPropertiesCombo = GWT
|
||||
.create(FilterKeyPropertiesCombo.class);
|
||||
FilterKeyPropertiesCombo filterKeyPropertiesCombo = GWT.create(FilterKeyPropertiesCombo.class);
|
||||
|
||||
storeComboFilterKey = new ListStore<FilterKey>(
|
||||
filterKeyPropertiesCombo.id());
|
||||
storeComboFilterKey = new ListStore<FilterKey>(filterKeyPropertiesCombo.id());
|
||||
|
||||
comboFilterKey = new ComboBox<FilterKey>(storeComboFilterKey,
|
||||
filterKeyPropertiesCombo.key());
|
||||
comboFilterKey = new ComboBox<FilterKey>(storeComboFilterKey, filterKeyPropertiesCombo.key());
|
||||
comboFilterKey.setClearValueOnParseError(false);
|
||||
comboFilterKey.setEditable(false);
|
||||
|
||||
comboFilterKey.addValidator(new EmptyValidator<FilterKey>(){
|
||||
|
||||
@Override
|
||||
public List<EditorError> validate(Editor<FilterKey> editor, FilterKey value) {
|
||||
if (value == null || value.getKey()==null || value.getKey().isEmpty()) {
|
||||
List<EditorError> errors = new ArrayList<EditorError>();
|
||||
errors.add(new DefaultEditorError(editor, getMessages().blankText(), ""));
|
||||
return errors;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
comboFilterKey.setTriggerAction(TriggerAction.ALL);
|
||||
addHandlersForComboFilterKey(filterKeyPropertiesCombo.key());
|
||||
|
||||
|
@ -295,14 +298,13 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
* FilterValuePropertiesCombo filterValuePropertiesCombo = GWT
|
||||
* .create(FilterValuePropertiesCombo.class);
|
||||
*/
|
||||
storeComboFilterValue = new ListStore<String>(
|
||||
new ModelKeyProvider<String>() {
|
||||
storeComboFilterValue = new ListStore<String>(new ModelKeyProvider<String>() {
|
||||
|
||||
@Override
|
||||
public String getKey(String item) {
|
||||
return item;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public String getKey(String item) {
|
||||
return item;
|
||||
}
|
||||
});
|
||||
|
||||
comboFilterValue = new StringComboBox();
|
||||
comboFilterValue.setStore(storeComboFilterValue);
|
||||
|
@ -313,7 +315,8 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
// comboFilterValue.setFinishEditOnEnter(false);
|
||||
// comboFilterValue.setAutoValidate(true);
|
||||
// comboFilterValue.addValidator(new EmptyValidator<String>());
|
||||
comboFilterValue.addValidator(new EmptyValidator<String>());
|
||||
|
||||
comboFilterValue.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
// final TextField valueField = new TextField();
|
||||
|
@ -324,8 +327,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
editing.addEditor(valueColumn, comboFilterValue);
|
||||
|
||||
addButton = new TextButton("Add Filter");
|
||||
addButton.setIcon(AccountingManagerResources.INSTANCE
|
||||
.accountingFilter24());
|
||||
addButton.setIcon(AccountingManagerResources.INSTANCE.accountingFilter24());
|
||||
addButton.setIconAlign(IconAlign.RIGHT);
|
||||
addButton.setToolTip("Add Filter");
|
||||
addButton.addSelectHandler(new SelectHandler() {
|
||||
|
@ -361,8 +363,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
editing.addBeforeStartEditHandler(new BeforeStartEditHandler<AccountingFilter>() {
|
||||
|
||||
@Override
|
||||
public void onBeforeStartEdit(
|
||||
BeforeStartEditEvent<AccountingFilter> event) {
|
||||
public void onBeforeStartEdit(BeforeStartEditEvent<AccountingFilter> event) {
|
||||
editingBeforeStart(event);
|
||||
|
||||
}
|
||||
|
@ -384,21 +385,21 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
@Override
|
||||
public void onCompleteEdit(CompleteEditEvent<AccountingFilter> event) {
|
||||
try {
|
||||
// GridCell cell = event.getEditCell();
|
||||
// int rowIndex = cell.getRow();
|
||||
// AccountingFilter editingFilter = store.get(rowIndex);
|
||||
//GridCell cell = event.getEditCell();
|
||||
//int rowIndex = cell.getRow();
|
||||
//AccountingFilter editingFilter = storeFilter.get(rowIndex);
|
||||
|
||||
if (addStatus) {
|
||||
addStatus = false;
|
||||
}
|
||||
storeFilter.commitChanges();
|
||||
|
||||
GWT.log("Complete Change on store filter");
|
||||
storeFilter.commitChanges();
|
||||
editing.getCancelButton().setVisible(true);
|
||||
addButton.setEnabled(true);
|
||||
|
||||
} catch (Throwable e) {
|
||||
Log.error("Error in RuleOnTableNewDefinitionCard: "
|
||||
+ e.getLocalizedMessage());
|
||||
Log.error("Error in RuleOnTableNewDefinitionCard: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -410,15 +411,14 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
// ChartTypeSelection
|
||||
|
||||
storeComboChartType = new ListStore<ChartType>(
|
||||
new ModelKeyProvider<ChartType>() {
|
||||
storeComboChartType = new ListStore<ChartType>(new ModelKeyProvider<ChartType>() {
|
||||
|
||||
@Override
|
||||
public String getKey(ChartType item) {
|
||||
return item.name();
|
||||
}
|
||||
@Override
|
||||
public String getKey(ChartType item) {
|
||||
return item.name();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
LabelProvider<ChartType> comboChartTypeLabelProvider = new LabelProvider<ChartType>() {
|
||||
|
||||
|
@ -431,23 +431,19 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
};
|
||||
|
||||
// /Grid Context
|
||||
GenresDataProperties propsGenresData = GWT
|
||||
.create(GenresDataProperties.class);
|
||||
GenresDataProperties propsGenresData = GWT.create(GenresDataProperties.class);
|
||||
|
||||
IdentityValueProvider<GenresData> identity = new IdentityValueProvider<GenresData>();
|
||||
smGenres = new CheckBoxSelectionModel<GenresData>(identity);
|
||||
|
||||
labelGenresCol = new ColumnConfig<GenresData, String>(
|
||||
propsGenresData.label(), 356, "Genres");
|
||||
labelGenresCol = new ColumnConfig<GenresData, String>(propsGenresData.label(), 356, "Genres");
|
||||
|
||||
labelGenresCol.setCell(new AbstractCell<String>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
sb.appendHtmlConstant("<span style='white-space: normal;' title='"
|
||||
+ SafeHtmlUtils.htmlEscape(value)
|
||||
+ "'>"
|
||||
+ SafeHtmlUtils.htmlEscape(value) + "</span>");
|
||||
sb.appendHtmlConstant("<span style='white-space: normal;' title='" + SafeHtmlUtils.htmlEscape(value)
|
||||
+ "'>" + SafeHtmlUtils.htmlEscape(value) + "</span>");
|
||||
|
||||
}
|
||||
|
||||
|
@ -456,8 +452,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
List<ColumnConfig<GenresData, ?>> lGenres = new ArrayList<ColumnConfig<GenresData, ?>>();
|
||||
lGenres.add(smGenres.getColumn());
|
||||
lGenres.add(labelGenresCol);
|
||||
ColumnModel<GenresData> cmGenresData = new ColumnModel<GenresData>(
|
||||
lGenres);
|
||||
ColumnModel<GenresData> cmGenresData = new ColumnModel<GenresData>(lGenres);
|
||||
|
||||
storeGenres = new ListStore<GenresData>(propsGenresData.id());
|
||||
|
||||
|
@ -476,8 +471,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
// /
|
||||
|
||||
comboChartType = new ComboBox<>(storeComboChartType,
|
||||
comboChartTypeLabelProvider);
|
||||
comboChartType = new ComboBox<>(storeComboChartType, comboChartTypeLabelProvider);
|
||||
comboChartType.setClearValueOnParseError(false);
|
||||
comboChartType.setEditable(false);
|
||||
comboChartType.setForceSelection(true);
|
||||
|
@ -492,11 +486,9 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
comboChartTypeLabel = new FieldLabel(comboChartType, "Chart");
|
||||
|
||||
// FileterKeyCombo for Top Chart
|
||||
storeComboTopFilterKey = new ListStore<FilterKey>(
|
||||
filterKeyPropertiesCombo.id());
|
||||
storeComboTopFilterKey = new ListStore<FilterKey>(filterKeyPropertiesCombo.id());
|
||||
|
||||
comboTopFilterKey = new ComboBox<FilterKey>(storeComboTopFilterKey,
|
||||
filterKeyPropertiesCombo.key());
|
||||
comboTopFilterKey = new ComboBox<FilterKey>(storeComboTopFilterKey, filterKeyPropertiesCombo.key());
|
||||
comboTopFilterKey.setClearValueOnParseError(false);
|
||||
comboTopFilterKey.setEditable(false);
|
||||
|
||||
|
@ -517,17 +509,15 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
showOthersToggle.add(showOthersYes);
|
||||
showOthersToggle.add(showOthersNo);
|
||||
|
||||
showOthersToggle
|
||||
.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
|
||||
showOthersToggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
|
||||
|
||||
@Override
|
||||
public void onValueChange(
|
||||
ValueChangeEvent<HasValue<Boolean>> event) {
|
||||
ToggleGroup group = (ToggleGroup) event.getSource();
|
||||
Radio radio = (Radio) group.getValue();
|
||||
Log.debug("ShowOthers selected: " + radio.getBoxLabel());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<HasValue<Boolean>> 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);
|
||||
|
@ -549,17 +539,15 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
noContextToggle.add(noContextYes);
|
||||
noContextToggle.add(noContextNo);
|
||||
|
||||
noContextToggle
|
||||
.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
|
||||
noContextToggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
|
||||
|
||||
@Override
|
||||
public void onValueChange(
|
||||
ValueChangeEvent<HasValue<Boolean>> event) {
|
||||
ToggleGroup group = (ToggleGroup) event.getSource();
|
||||
Radio radio = (Radio) group.getValue();
|
||||
Log.debug("No Context selected: " + radio.getBoxLabel());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<HasValue<Boolean>> 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);
|
||||
|
@ -583,12 +571,10 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
// //
|
||||
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
||||
|
||||
vlc.add(comboChartTypeLabel, new VerticalLayoutData(1, -1, new Margins(
|
||||
0)));
|
||||
vlc.add(comboChartTypeLabel, 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(comboTopFilterKeyLabel, new VerticalLayoutData(1, -1,
|
||||
new Margins(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)));
|
||||
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
|
@ -611,27 +597,25 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
// Bind to Events
|
||||
private void bindToEvents() {
|
||||
eventBus.addHandler(StateChangeEvent.TYPE,
|
||||
new StateChangeEvent.StateChangeEventHandler() {
|
||||
eventBus.addHandler(StateChangeEvent.TYPE, new StateChangeEvent.StateChangeEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onStateChange(StateChangeEvent event) {
|
||||
Log.debug("Catch State Change Event");
|
||||
doStateChangeCommand(event);
|
||||
@Override
|
||||
public void onStateChange(StateChangeEvent event) {
|
||||
Log.debug("Catch State Change Event");
|
||||
doStateChangeCommand(event);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(AccountingPeriodEvent.TYPE,
|
||||
new AccountingPeriodEvent.AccountingPeriodEventHandler() {
|
||||
eventBus.addHandler(AccountingPeriodEvent.TYPE, new AccountingPeriodEvent.AccountingPeriodEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onPeriod(AccountingPeriodEvent event) {
|
||||
Log.debug("Catch Accounting Period Event");
|
||||
manageAccountingPeriodEvent(event);
|
||||
@Override
|
||||
public void onPeriod(AccountingPeriodEvent event) {
|
||||
Log.debug("Catch Accounting Period Event");
|
||||
manageAccountingPeriodEvent(event);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doStateChangeCommand(StateChangeEvent event) {
|
||||
|
@ -692,7 +676,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
storeComboChartType.clear();
|
||||
storeComboChartType.commitChanges();
|
||||
comboChartTypeLabel.setVisible(false);
|
||||
|
||||
|
||||
}
|
||||
changeActiveFilters();
|
||||
|
||||
|
@ -706,16 +690,13 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
private void changeActiveFilters() {
|
||||
storeComboFilterKey.clear();
|
||||
storeComboFilterKey
|
||||
.addAll(accountingStateData.getAvailableFilterKeys());
|
||||
storeComboFilterKey.addAll(accountingStateData.getAvailableFilterKeys());
|
||||
storeComboFilterKey.commitChanges();
|
||||
storeComboTopFilterKey.clear();
|
||||
storeComboTopFilterKey.addAll(accountingStateData
|
||||
.getAvailableFilterKeys());
|
||||
storeComboTopFilterKey.addAll(accountingStateData.getAvailableFilterKeys());
|
||||
storeComboTopFilterKey.commitChanges();
|
||||
|
||||
ChartType chartType = accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition().getChartType();
|
||||
ChartType chartType = accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType();
|
||||
|
||||
switch (chartType) {
|
||||
case Basic:
|
||||
|
@ -740,16 +721,13 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
private void changeActiveFiltersForBasic() {
|
||||
if (accountingStateData.getSeriesRequest() != null
|
||||
&& accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition() != null
|
||||
&& accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition() instanceof AccountingFilterBasic) {
|
||||
AccountingFilterBasic accountingFilterBasic = (AccountingFilterBasic) accountingStateData
|
||||
.getSeriesRequest().getAccountingFilterDefinition();
|
||||
&& accountingStateData.getSeriesRequest().getAccountingFilterDefinition() != null && accountingStateData
|
||||
.getSeriesRequest().getAccountingFilterDefinition() instanceof AccountingFilterBasic) {
|
||||
AccountingFilterBasic accountingFilterBasic = (AccountingFilterBasic) accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition();
|
||||
|
||||
if (accountingFilterBasic.getFilters() != null) {
|
||||
List<AccountingFilter> filters = accountingFilterBasic
|
||||
.getFilters();
|
||||
List<AccountingFilter> filters = accountingFilterBasic.getFilters();
|
||||
storeFilter.clear();
|
||||
storeFilter.addAll(filters);
|
||||
seq = 0;
|
||||
|
@ -811,20 +789,17 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
private void changeActiveFiltersForTop() {
|
||||
if (accountingStateData.getSeriesRequest() != null
|
||||
&& accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition() != null
|
||||
&& accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
|
||||
AccountingFilterTop accountingFilterTop = (AccountingFilterTop) accountingStateData
|
||||
.getSeriesRequest().getAccountingFilterDefinition();
|
||||
&& accountingStateData.getSeriesRequest().getAccountingFilterDefinition() != null && accountingStateData
|
||||
.getSeriesRequest().getAccountingFilterDefinition() instanceof AccountingFilterTop) {
|
||||
AccountingFilterTop accountingFilterTop = (AccountingFilterTop) accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition();
|
||||
if (accountingFilterTop.getFilterKey() != null) {
|
||||
comboTopFilterKey.setValue(accountingFilterTop.getFilterKey());
|
||||
topNumber.setValue(accountingFilterTop.getTopNumber());
|
||||
|
||||
// /////////
|
||||
if (accountingFilterTop.getFilters() != null) {
|
||||
List<AccountingFilter> filters = accountingFilterTop
|
||||
.getFilters();
|
||||
List<AccountingFilter> filters = accountingFilterTop.getFilters();
|
||||
storeFilter.clear();
|
||||
storeFilter.addAll(filters);
|
||||
seq = 0;
|
||||
|
@ -875,23 +850,18 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
private void changeActiveFiltersForContext() {
|
||||
if (accountingStateData.getSeriesRequest() != null
|
||||
&& accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition() != null
|
||||
&& accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition() instanceof AccountingFilterContext) {
|
||||
&& 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()) {
|
||||
&& !accountingStateData.getAvailableContext().getContexts().isEmpty()) {
|
||||
|
||||
if (accountingFilterContext.getContext() != null
|
||||
&& accountingFilterContext.getContext().getContexts() != null
|
||||
&& !accountingFilterContext.getContext().getContexts()
|
||||
.isEmpty()) {
|
||||
ArrayList<String> contexts = accountingStateData
|
||||
.getAvailableContext().getContexts();
|
||||
&& !accountingFilterContext.getContext().getContexts().isEmpty()) {
|
||||
ArrayList<String> contexts = accountingStateData.getAvailableContext().getContexts();
|
||||
ArrayList<GenresData> genres = new ArrayList<GenresData>();
|
||||
for (String context : contexts) {
|
||||
GenresData genresData = new GenresData(context);
|
||||
|
@ -904,12 +874,10 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
smGenres.deselectAll();
|
||||
|
||||
if (accountingFilterContext.getContext().getContexts() == null
|
||||
|| accountingFilterContext.getContext()
|
||||
.getContexts().isEmpty()) {
|
||||
|| accountingFilterContext.getContext().getContexts().isEmpty()) {
|
||||
} else {
|
||||
ArrayList<GenresData> selected = new ArrayList<>();
|
||||
for (String c : accountingFilterContext.getContext()
|
||||
.getContexts()) {
|
||||
for (String c : accountingFilterContext.getContext().getContexts()) {
|
||||
for (GenresData genresData : storeGenres.getAll()) {
|
||||
if (c.compareTo(genresData.getGenre()) == 0) {
|
||||
selected.add(genresData);
|
||||
|
@ -937,8 +905,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
if (accountingFilterContext.getFilters() != null) {
|
||||
List<AccountingFilter> filters = accountingFilterContext
|
||||
.getFilters();
|
||||
List<AccountingFilter> filters = accountingFilterContext.getFilters();
|
||||
storeFilter.clear();
|
||||
storeFilter.addAll(filters);
|
||||
seq = 0;
|
||||
|
@ -982,8 +949,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
private void reconfigureContext() {
|
||||
if (accountingStateData.getAvailableContext() != null
|
||||
&& accountingStateData.getAvailableContext().getContexts() != null
|
||||
&& !accountingStateData.getAvailableContext().getContexts()
|
||||
.isEmpty()) {
|
||||
&& !accountingStateData.getAvailableContext().getContexts().isEmpty()) {
|
||||
repopulatesContexts();
|
||||
} else {
|
||||
resetContexts();
|
||||
|
@ -998,8 +964,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
private void repopulatesContexts() {
|
||||
ArrayList<String> contexts = accountingStateData.getAvailableContext()
|
||||
.getContexts();
|
||||
ArrayList<String> contexts = accountingStateData.getAvailableContext().getContexts();
|
||||
ArrayList<GenresData> genres = new ArrayList<GenresData>();
|
||||
for (String context : contexts) {
|
||||
GenresData genresData = new GenresData(context);
|
||||
|
@ -1014,23 +979,18 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
private void changeActiveFiltersForSpaces() {
|
||||
if (accountingStateData.getSeriesRequest() != null
|
||||
&& accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition() != null
|
||||
&& accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition() instanceof AccountingFilterSpaces) {
|
||||
&& 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()) {
|
||||
&& !accountingStateData.getAvailableSpaces().getSpacesList().isEmpty()) {
|
||||
|
||||
if (accountingFilterSapces.getSpaces() != null
|
||||
&& accountingFilterSapces.getSpaces().getSpacesList() != null
|
||||
&& !accountingFilterSapces.getSpaces().getSpacesList()
|
||||
.isEmpty()) {
|
||||
ArrayList<String> spacesList = accountingStateData
|
||||
.getAvailableSpaces().getSpacesList();
|
||||
&& !accountingFilterSapces.getSpaces().getSpacesList().isEmpty()) {
|
||||
ArrayList<String> spacesList = accountingStateData.getAvailableSpaces().getSpacesList();
|
||||
ArrayList<GenresData> genres = new ArrayList<GenresData>();
|
||||
for (String space : spacesList) {
|
||||
GenresData genresData = new GenresData(space);
|
||||
|
@ -1043,12 +1003,10 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
smGenres.deselectAll();
|
||||
|
||||
if (accountingFilterSapces.getSpaces().getSpacesList() == null
|
||||
|| accountingFilterSapces.getSpaces()
|
||||
.getSpacesList().isEmpty()) {
|
||||
|| accountingFilterSapces.getSpaces().getSpacesList().isEmpty()) {
|
||||
} else {
|
||||
ArrayList<GenresData> selected = new ArrayList<>();
|
||||
for (String s : accountingFilterSapces.getSpaces()
|
||||
.getSpacesList()) {
|
||||
for (String s : accountingFilterSapces.getSpaces().getSpacesList()) {
|
||||
for (GenresData genresData : storeGenres.getAll()) {
|
||||
if (s.compareTo(genresData.getGenre()) == 0) {
|
||||
selected.add(genresData);
|
||||
|
@ -1076,8 +1034,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
if (accountingFilterSapces.getFilters() != null) {
|
||||
List<AccountingFilter> filters = accountingFilterSapces
|
||||
.getFilters();
|
||||
List<AccountingFilter> filters = accountingFilterSapces.getFilters();
|
||||
storeFilter.clear();
|
||||
storeFilter.addAll(filters);
|
||||
seq = 0;
|
||||
|
@ -1121,8 +1078,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
private void reconfigureSpaces() {
|
||||
if (accountingStateData.getAvailableSpaces() != null
|
||||
&& accountingStateData.getAvailableSpaces().getSpacesList() != null
|
||||
&& !accountingStateData.getAvailableSpaces().getSpacesList()
|
||||
.isEmpty()) {
|
||||
&& !accountingStateData.getAvailableSpaces().getSpacesList().isEmpty()) {
|
||||
repopulatesSpaces();
|
||||
} else {
|
||||
resetSpaces();
|
||||
|
@ -1137,8 +1093,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
private void repopulatesSpaces() {
|
||||
ArrayList<String> spaces = accountingStateData.getAvailableSpaces()
|
||||
.getSpacesList();
|
||||
ArrayList<String> spaces = accountingStateData.getAvailableSpaces().getSpacesList();
|
||||
ArrayList<GenresData> genres = new ArrayList<GenresData>();
|
||||
for (String space : spaces) {
|
||||
GenresData genresData = new GenresData(space);
|
||||
|
@ -1193,8 +1148,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
List<AccountingFilter> filtersActives = storeFilter.getAll();
|
||||
ArrayList<AccountingFilter> filtersReady = new ArrayList<AccountingFilter>();
|
||||
for (AccountingFilter filter : filtersActives) {
|
||||
if (filter.getFilterValue() != null
|
||||
&& !filter.getFilterValue().isEmpty()) {
|
||||
if (filter.getFilterValue() != null && !filter.getFilterValue().isEmpty()) {
|
||||
filtersReady.add(filter);
|
||||
}
|
||||
}
|
||||
|
@ -1216,23 +1170,19 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
return new AccountingFilterTop(showOthersValue, topN);
|
||||
} else {
|
||||
if (storeFilter == null || storeFilter.size() <= 0) {
|
||||
return new AccountingFilterTop(filterKey, null,
|
||||
showOthersValue, topN);
|
||||
return new AccountingFilterTop(filterKey, null, showOthersValue, topN);
|
||||
} else {
|
||||
List<AccountingFilter> filtersActives = storeFilter.getAll();
|
||||
ArrayList<AccountingFilter> filtersReady = new ArrayList<AccountingFilter>();
|
||||
for (AccountingFilter filter : filtersActives) {
|
||||
if (filter.getFilterValue() != null
|
||||
&& !filter.getFilterValue().isEmpty()) {
|
||||
if (filter.getFilterValue() != null && !filter.getFilterValue().isEmpty()) {
|
||||
filtersReady.add(filter);
|
||||
}
|
||||
}
|
||||
if (filtersReady.size() > 0) {
|
||||
return new AccountingFilterTop(filterKey, filtersReady,
|
||||
showOthersValue, topN);
|
||||
return new AccountingFilterTop(filterKey, filtersReady, showOthersValue, topN);
|
||||
} else {
|
||||
return new AccountingFilterTop(filterKey, null,
|
||||
showOthersValue, topN);
|
||||
return new AccountingFilterTop(filterKey, null, showOthersValue, topN);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1254,8 +1204,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
List<AccountingFilter> filtersActives = storeFilter.getAll();
|
||||
ArrayList<AccountingFilter> filtersReady = new ArrayList<AccountingFilter>();
|
||||
for (AccountingFilter filter : filtersActives) {
|
||||
if (filter.getFilterValue() != null
|
||||
&& !filter.getFilterValue().isEmpty()) {
|
||||
if (filter.getFilterValue() != null && !filter.getFilterValue().isEmpty()) {
|
||||
filtersReady.add(filter);
|
||||
}
|
||||
}
|
||||
|
@ -1280,8 +1229,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
List<AccountingFilter> filtersActives = storeFilter.getAll();
|
||||
ArrayList<AccountingFilter> filtersReady = new ArrayList<AccountingFilter>();
|
||||
for (AccountingFilter filter : filtersActives) {
|
||||
if (filter.getFilterValue() != null
|
||||
&& !filter.getFilterValue().isEmpty()) {
|
||||
if (filter.getFilterValue() != null && !filter.getFilterValue().isEmpty()) {
|
||||
filtersReady.add(filter);
|
||||
}
|
||||
}
|
||||
|
@ -1297,8 +1245,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
List<AccountingFilter> filtersSet = storeFilter.getAll();
|
||||
FilterKey fk = null;
|
||||
|
||||
if (accountingStateData == null
|
||||
|| accountingStateData.getAvailableFilterKeys() == null
|
||||
if (accountingStateData == null || accountingStateData.getAvailableFilterKeys() == null
|
||||
|| accountingStateData.getAvailableFilterKeys().size() < 0) {
|
||||
UtilsGXT3.info("No key available", "No key available");
|
||||
|
||||
|
@ -1312,11 +1259,9 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
if (comboChartType.getCurrentValue() != null
|
||||
&& comboChartType.getCurrentValue()
|
||||
.compareTo(ChartType.Top) == 0) {
|
||||
&& comboChartType.getCurrentValue().compareTo(ChartType.Top) == 0) {
|
||||
if (comboTopFilterKey.getCurrentValue() != null) {
|
||||
removableFilterKeys
|
||||
.add(comboTopFilterKey.getCurrentValue());
|
||||
removableFilterKeys.add(comboTopFilterKey.getCurrentValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1330,14 +1275,15 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
* UtilsGXT3.info("Attention",
|
||||
* "You can add at most 2 filters for top chart!"); return; } }
|
||||
*/
|
||||
fk = remainingFilterKeys.get(0);
|
||||
// fk = remainingFilterKeys.get(0);
|
||||
fk = new FilterKey("");
|
||||
seq++;
|
||||
AccountingFilter newAccountingFilter = new AccountingFilter(
|
||||
seq, fk, "");
|
||||
AccountingFilter newAccountingFilter = new AccountingFilter(seq, fk, "");
|
||||
Log.debug("newAccountingFilter: " + newAccountingFilter);
|
||||
editing.cancelEditing();
|
||||
addStatus = true;
|
||||
editing.getCancelButton().setVisible(false);
|
||||
|
||||
storeFilter.add(newAccountingFilter);
|
||||
int row = storeFilter.indexOf(newAccountingFilter);
|
||||
|
||||
|
@ -1346,6 +1292,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
storeComboFilterKey.commitChanges();
|
||||
|
||||
editing.startEditing(new GridCell(row, 0));
|
||||
|
||||
} else {
|
||||
UtilsGXT3.info("No key available", "No key available");
|
||||
|
||||
|
@ -1353,8 +1300,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
}
|
||||
}
|
||||
|
||||
private void retrieveFilterValuesByKey(FilterKey filterKey,
|
||||
final boolean cancelValue) {
|
||||
private void retrieveFilterValuesByKey(FilterKey filterKey, final boolean cancelValue) {
|
||||
this.filterKey = filterKey;
|
||||
this.cancelValue = cancelValue;
|
||||
AccountingPeriodRequestEvent event = new AccountingPeriodRequestEvent();
|
||||
|
@ -1367,25 +1313,30 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
Log.debug("AccountingPeriod not valid");
|
||||
return;
|
||||
}
|
||||
accountingMonitor = new AccountingMonitor();
|
||||
FilterValuesRequest requestFilterValue = new FilterValuesRequest(
|
||||
filterKey, accountingStateData.getAccountingType(),
|
||||
event.getAccountingPeriod());
|
||||
|
||||
AccountingManagerServiceAsync.INSTANCE.getFilterValues(
|
||||
requestFilterValue, new AsyncCallback<FilterValuesResponse>() {
|
||||
if (filterKey == null || filterKey.getKey() == null || filterKey.getKey().isEmpty()) {
|
||||
Log.debug("FilterKey: " + filterKey);
|
||||
comboFilterValue.clear();
|
||||
storeComboFilterValue.clear();
|
||||
storeComboFilterValue.commitChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
accountingMonitor = new AccountingMonitor();
|
||||
FilterValuesRequest requestFilterValue = new FilterValuesRequest(filterKey,
|
||||
accountingStateData.getAccountingType(), event.getAccountingPeriod());
|
||||
|
||||
AccountingManagerServiceAsync.INSTANCE.getFilterValues(requestFilterValue,
|
||||
new AsyncCallback<FilterValuesResponse>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
accountingMonitor.hide();
|
||||
if (caught instanceof SessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error retrieving filter values:"
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error retrieving filter values",
|
||||
caught.getLocalizedMessage());
|
||||
Log.error("Error retrieving filter values:" + caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error retrieving filter values", caught.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1416,12 +1367,10 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
List<AccountingFilter> filtersSet = storeFilter.getAll();
|
||||
|
||||
List<FilterKey> remainingFilterKeys = null;
|
||||
if (accountingStateData == null
|
||||
|| accountingStateData.getAvailableFilterKeys() == null) {
|
||||
if (accountingStateData == null || accountingStateData.getAvailableFilterKeys() == null) {
|
||||
remainingFilterKeys = new ArrayList<FilterKey>();
|
||||
} else {
|
||||
remainingFilterKeys = new ArrayList<FilterKey>(
|
||||
accountingStateData.getAvailableFilterKeys());
|
||||
remainingFilterKeys = new ArrayList<FilterKey>(accountingStateData.getAvailableFilterKeys());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1435,8 +1384,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
for (AccountingFilter filterSet : filtersSet) {
|
||||
if (filterSet.getFilterKey().getKey()
|
||||
.compareTo(editingFilter.getFilterKey().getKey()) != 0) {
|
||||
if (filterSet.getFilterKey().getKey().compareTo(editingFilter.getFilterKey().getKey()) != 0) {
|
||||
setFilterKeys.add(filterSet.getFilterKey());
|
||||
}
|
||||
}
|
||||
|
@ -1455,8 +1403,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
}
|
||||
|
||||
private void addHandlersForComboFilterKey(
|
||||
final LabelProvider<FilterKey> labelProvider) {
|
||||
private void addHandlersForComboFilterKey(final LabelProvider<FilterKey> labelProvider) {
|
||||
comboFilterKey.addSelectionHandler(new SelectionHandler<FilterKey>() {
|
||||
public void onSelection(SelectionEvent<FilterKey> event) {
|
||||
Log.debug("FilterKey selected: " + event.getSelectedItem());
|
||||
|
@ -1470,8 +1417,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
retrieveFilterValuesByKey(selectedFilterKey, true);
|
||||
}
|
||||
|
||||
private void addHandlersForComboChartType(
|
||||
final LabelProvider<ChartType> labelProvider) {
|
||||
private void addHandlersForComboChartType(final LabelProvider<ChartType> labelProvider) {
|
||||
comboChartType.addSelectionHandler(new SelectionHandler<ChartType>() {
|
||||
public void onSelection(SelectionEvent<ChartType> event) {
|
||||
Log.debug("FilterKey selected: " + event.getSelectedItem());
|
||||
|
@ -1515,11 +1461,9 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
case Top:
|
||||
gridGenres.setVisible(false);
|
||||
comboTopFilterKey.reset();
|
||||
if (accountingStateData != null
|
||||
&& accountingStateData.getAvailableFilterKeys() != null
|
||||
if (accountingStateData != null && accountingStateData.getAvailableFilterKeys() != null
|
||||
&& accountingStateData.getAvailableFilterKeys().size() > 0) {
|
||||
comboTopFilterKey.setValue(accountingStateData
|
||||
.getAvailableFilterKeys().get(0));
|
||||
comboTopFilterKey.setValue(accountingStateData.getAvailableFilterKeys().get(0));
|
||||
}
|
||||
comboTopFilterKeyLabel.setVisible(true);
|
||||
showOthersToggle.reset();
|
||||
|
@ -1586,17 +1530,14 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
}
|
||||
|
||||
private void addHandlersForComboTopFilterKey(
|
||||
final LabelProvider<FilterKey> labelProvider) {
|
||||
comboTopFilterKey
|
||||
.addSelectionHandler(new SelectionHandler<FilterKey>() {
|
||||
public void onSelection(SelectionEvent<FilterKey> event) {
|
||||
Log.debug("FilterKey selected: "
|
||||
+ event.getSelectedItem());
|
||||
updateTopFilterKey(event.getSelectedItem());
|
||||
}
|
||||
private void addHandlersForComboTopFilterKey(final LabelProvider<FilterKey> labelProvider) {
|
||||
comboTopFilterKey.addSelectionHandler(new SelectionHandler<FilterKey>() {
|
||||
public void onSelection(SelectionEvent<FilterKey> event) {
|
||||
Log.debug("FilterKey selected: " + event.getSelectedItem());
|
||||
updateTopFilterKey(event.getSelectedItem());
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void updateTopFilterKey(FilterKey selectedFilterKey) {
|
||||
|
|
|
@ -27,9 +27,19 @@ import org.slf4j.LoggerFactory;
|
|||
*
|
||||
*/
|
||||
public class AccountingCache implements Serializable {
|
||||
private static final long serialVersionUID = -4352823042594405108L;
|
||||
|
||||
private static final long serialVersionUID = -4352823042594405108L;
|
||||
private static Logger logger = LoggerFactory.getLogger(AccountingCache.class);
|
||||
|
||||
private static final long SERIES_HEAP_DIMENSION_MB = 60L;
|
||||
private static final long SERIES_OFFHEAP_DIMENSION_MB = 240L;
|
||||
private static final long SERIES_MAXOBJECT_SIZE_MB = 50L;
|
||||
private static final long SIERES_TIMETOLIVE_EXPIRATION_MINUTES = 30L;
|
||||
|
||||
private static final long FILTERVALUE_HEAP_DIMENSION_MB = 20L;
|
||||
private static final long FILTERVALUE_OFFHEAP_DIMENSION_MB = 60L;
|
||||
private static final long FILTERVALUE_MAXOBJECT_SIZE_MB = 6L;
|
||||
private static final long FILTERVALUE_TIMETOLIVE_EXPIRATION_MINUTES = 30L;
|
||||
|
||||
private static final String ACCOUNTING_SERIES_CACHE = "AccountingSeriesCache";
|
||||
private static final String ACCOUNTING_FILTER_VALUES_CACHE = "AccountingFilterValuesCache";
|
||||
|
@ -37,7 +47,6 @@ public class AccountingCache implements Serializable {
|
|||
private CacheConfiguration<String, SeriesResponse> cacheSeriesConfiguration;
|
||||
private CacheConfiguration<String, FilterValuesResponse> cacheFilterValuesConfiguration;
|
||||
|
||||
// private MBeanServer mBeanServer;
|
||||
|
||||
public AccountingCache() throws ServiceException {
|
||||
super();
|
||||
|
@ -48,16 +57,16 @@ public class AccountingCache implements Serializable {
|
|||
cacheManager = cachingProvider.getCacheManager();
|
||||
logger.info("AccountingCache URI: " + cacheManager.getURI());
|
||||
|
||||
ResourcePoolsBuilder builderSeries = ResourcePoolsBuilder.newResourcePoolsBuilder().heap(60L, MemoryUnit.MB)
|
||||
.offheap(240L, MemoryUnit.MB);
|
||||
ResourcePoolsBuilder builderSeries = ResourcePoolsBuilder.newResourcePoolsBuilder().heap(SERIES_HEAP_DIMENSION_MB, MemoryUnit.MB)
|
||||
.offheap(SERIES_OFFHEAP_DIMENSION_MB, MemoryUnit.MB);
|
||||
|
||||
// .disk(500L, MemoryUnit.KB)
|
||||
|
||||
// .withSizeOfMaxObjectSize(1L, MemoryUnit.KB)
|
||||
cacheSeriesConfiguration = CacheConfigurationBuilder
|
||||
.newCacheConfigurationBuilder(String.class, SeriesResponse.class, builderSeries)
|
||||
.withExpiry(Expirations.timeToLiveExpiration(org.ehcache.expiry.Duration.of(30L, TimeUnit.MINUTES)))
|
||||
.withSizeOfMaxObjectSize(50L, MemoryUnit.MB).build();
|
||||
.withExpiry(Expirations.timeToLiveExpiration(org.ehcache.expiry.Duration.of(SIERES_TIMETOLIVE_EXPIRATION_MINUTES, TimeUnit.MINUTES)))
|
||||
.withSizeOfMaxObjectSize(SERIES_MAXOBJECT_SIZE_MB, MemoryUnit.MB).build();
|
||||
|
||||
// mBeanServer = ManagementFactory.getPlatformMBeanServer();
|
||||
|
||||
|
@ -69,15 +78,15 @@ public class AccountingCache implements Serializable {
|
|||
*/
|
||||
|
||||
ResourcePoolsBuilder builderFilterValues = ResourcePoolsBuilder.newResourcePoolsBuilder()
|
||||
.heap(10L, MemoryUnit.MB).offheap(30L, MemoryUnit.MB);
|
||||
.heap(FILTERVALUE_HEAP_DIMENSION_MB, MemoryUnit.MB).offheap(FILTERVALUE_OFFHEAP_DIMENSION_MB, MemoryUnit.MB);
|
||||
|
||||
// .disk(500L, MemoryUnit.KB)
|
||||
|
||||
// .withSizeOfMaxObjectSize(1L, MemoryUnit.KB)
|
||||
cacheFilterValuesConfiguration = CacheConfigurationBuilder
|
||||
.newCacheConfigurationBuilder(String.class, FilterValuesResponse.class, builderFilterValues)
|
||||
.withExpiry(Expirations.timeToLiveExpiration(org.ehcache.expiry.Duration.of(30L, TimeUnit.MINUTES)))
|
||||
.withSizeOfMaxObjectSize(4L, MemoryUnit.MB).build();
|
||||
.withExpiry(Expirations.timeToLiveExpiration(org.ehcache.expiry.Duration.of(FILTERVALUE_TIMETOLIVE_EXPIRATION_MINUTES, TimeUnit.MINUTES)))
|
||||
.withSizeOfMaxObjectSize(FILTERVALUE_MAXOBJECT_SIZE_MB, MemoryUnit.MB).build();
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
|
|
Loading…
Reference in New Issue