514: Accounting Manager - List of Possible Values for a Filter by Key
Task-Url: https://support.d4science.org/issues/514 Updated filter values request git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@117771 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
72510d6a43
commit
918cbcfbcb
|
@ -14,6 +14,7 @@ import org.gcube.portlets.admin.accountingmanager.client.utils.UtilsGXT3;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
|
||||
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.exception.AccountingManagerSessionExpiredException;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -85,8 +86,6 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
private GridRowEditing<AccountingFilter> editing;
|
||||
private TextButton addButton;
|
||||
private int seq;
|
||||
|
||||
|
||||
|
||||
public interface FilterKeyPropertiesCombo extends PropertyAccess<FilterKey> {
|
||||
|
||||
|
@ -96,8 +95,9 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
LabelProvider<FilterKey> key();
|
||||
|
||||
}
|
||||
|
||||
public interface FilterValuePropertiesCombo extends PropertyAccess<FilterValue> {
|
||||
|
||||
public interface FilterValuePropertiesCombo extends
|
||||
PropertyAccess<FilterValue> {
|
||||
|
||||
@Path("id")
|
||||
ModelKeyProvider<FilterValue> id();
|
||||
|
@ -105,7 +105,6 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
LabelProvider<FilterValue> value();
|
||||
|
||||
}
|
||||
|
||||
|
||||
interface FilterKeyTemplates extends XTemplates {
|
||||
@XTemplate("<span title=\"{value}\">{value}</span>")
|
||||
|
@ -117,8 +116,6 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
SafeHtml format(String value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ActiveFiltersPanel(EventBus eventBus) {
|
||||
super();
|
||||
Log.debug("ActiveFiltersPanel");
|
||||
|
@ -166,7 +163,6 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
ArrayList<ColumnConfig<AccountingFilter, ?>> l = new ArrayList<ColumnConfig<AccountingFilter, ?>>();
|
||||
l.add(keyColumn);
|
||||
l.add(valueColumn);
|
||||
|
@ -188,7 +184,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
grid.setColumnReordering(false);
|
||||
grid.getView().setAutoExpandColumn(valueColumn);
|
||||
grid.getView().setSortingEnabled(false);
|
||||
|
||||
|
||||
GridDragSource<AccountingFilter> ds = new GridDragSource<AccountingFilter>(
|
||||
grid);
|
||||
ds.addDragStartHandler(new DndDragStartHandler() {
|
||||
|
@ -208,44 +204,43 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
dt.setAllowSelfAsSource(true);
|
||||
|
||||
// EDITING //
|
||||
//Key
|
||||
// Key
|
||||
FilterKeyPropertiesCombo filterKeyPropertiesCombo = GWT
|
||||
.create(FilterKeyPropertiesCombo.class);
|
||||
|
||||
storeComboFilterKey = new ListStore<FilterKey>(
|
||||
filterKeyPropertiesCombo.id());
|
||||
|
||||
comboFilterKey = new ComboBox<FilterKey>(
|
||||
storeComboFilterKey, filterKeyPropertiesCombo.key());
|
||||
|
||||
comboFilterKey = new ComboBox<FilterKey>(storeComboFilterKey,
|
||||
filterKeyPropertiesCombo.key());
|
||||
comboFilterKey.setClearValueOnParseError(false);
|
||||
|
||||
comboFilterKey.setTriggerAction(TriggerAction.ALL);
|
||||
addHandlersForComboFilterKey(filterKeyPropertiesCombo.key());
|
||||
|
||||
//Value
|
||||
|
||||
// Value
|
||||
FilterValuePropertiesCombo filterValuePropertiesCombo = GWT
|
||||
.create(FilterValuePropertiesCombo.class);
|
||||
|
||||
storeComboFilterValue = new ListStore<FilterValue>(
|
||||
filterValuePropertiesCombo.id());
|
||||
|
||||
|
||||
ComboBox<FilterValue> comboFilterValue = new ComboBox<FilterValue>(
|
||||
storeComboFilterValue, filterValuePropertiesCombo.value());
|
||||
comboFilterValue.setClearValueOnParseError(false);
|
||||
comboFilterValue.addValidator(new EmptyValidator<FilterValue>());
|
||||
comboFilterValue.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
|
||||
//final TextField valueField = new TextField();
|
||||
//valueField.addValidator(new EmptyValidator<String>());
|
||||
// final TextField valueField = new TextField();
|
||||
// valueField.addValidator(new EmptyValidator<String>());
|
||||
|
||||
editing = new GridRowEditing<AccountingFilter>(grid);
|
||||
editing.addEditor(keyColumn, comboFilterKey);
|
||||
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() {
|
||||
|
@ -308,7 +303,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
addStatus = false;
|
||||
}
|
||||
store.commitChanges();
|
||||
|
||||
|
||||
editing.getCancelButton().setVisible(true);
|
||||
addButton.setEnabled(true);
|
||||
|
||||
|
@ -375,9 +370,9 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
|
||||
} else {
|
||||
accountingStateData = null;
|
||||
seq=0;
|
||||
seq = 0;
|
||||
}
|
||||
Log.debug("Set seq to: "+seq);
|
||||
Log.debug("Set seq to: " + seq);
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
|
@ -393,20 +388,20 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
.getSeriesRequest().getFilters();
|
||||
store.clear();
|
||||
store.addAll(filters);
|
||||
seq=0;
|
||||
for(AccountingFilter filter:filters){
|
||||
if(filter.getId()>seq){
|
||||
seq=filter.getId();
|
||||
};
|
||||
seq = 0;
|
||||
for (AccountingFilter filter : filters) {
|
||||
if (filter.getId() > seq) {
|
||||
seq = filter.getId();
|
||||
}
|
||||
;
|
||||
}
|
||||
store.commitChanges();
|
||||
} else {
|
||||
store.clear();
|
||||
store.commitChanges();
|
||||
seq=0;
|
||||
seq = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<AccountingFilter> getActiveFilters() {
|
||||
|
@ -443,26 +438,25 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
for (AccountingFilter filterSet : filtersSet) {
|
||||
removableFilterKeys.add(filterSet.getFilterKey());
|
||||
}
|
||||
|
||||
|
||||
remainingFilterKeys.removeAll(removableFilterKeys);
|
||||
|
||||
|
||||
if (remainingFilterKeys.size() > 0) {
|
||||
|
||||
if (remainingFilterKeys.size() > 0) {
|
||||
fk = remainingFilterKeys.get(0);
|
||||
seq++;
|
||||
AccountingFilter newAccountingFilter = new AccountingFilter(seq,fk,
|
||||
new FilterValue());
|
||||
Log.debug("newAccountingFilter: "+newAccountingFilter);
|
||||
AccountingFilter newAccountingFilter = new AccountingFilter(
|
||||
seq, fk, new FilterValue());
|
||||
Log.debug("newAccountingFilter: " + newAccountingFilter);
|
||||
editing.cancelEditing();
|
||||
addStatus = true;
|
||||
editing.getCancelButton().setVisible(false);
|
||||
store.add(newAccountingFilter);
|
||||
int row = store.indexOf(newAccountingFilter);
|
||||
|
||||
|
||||
storeComboFilterKey.clear();
|
||||
storeComboFilterKey.addAll(remainingFilterKeys);
|
||||
storeComboFilterKey.commitChanges();
|
||||
|
||||
|
||||
editing.startEditing(new GridCell(row, 0));
|
||||
} else {
|
||||
UtilsGXT3.info("No key available", "No key available");
|
||||
|
@ -470,11 +464,12 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void retrieveFilterValuesByKey(FilterKey filterKey){
|
||||
AccountingManagerServiceAsync.INSTANCE.getFilterValues(filterKey,
|
||||
|
||||
private void retrieveFilterValuesByKey(FilterKey filterKey) {
|
||||
FilterValuesRequest requestFilterValue = new FilterValuesRequest(
|
||||
filterKey, accountingStateData.getAccountingType());
|
||||
|
||||
AccountingManagerServiceAsync.INSTANCE.getFilterValues(requestFilterValue,
|
||||
new AsyncCallback<ArrayList<FilterValue>>() {
|
||||
|
||||
@Override
|
||||
|
@ -497,11 +492,10 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
storeComboFilterValue.clear();
|
||||
storeComboFilterValue.addAll(result);
|
||||
storeComboFilterValue.commitChanges();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void editingBeforeStart(BeforeStartEditEvent<AccountingFilter> event) {
|
||||
GridCell cell = event.getEditCell();
|
||||
|
@ -534,16 +528,15 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
storeComboFilterKey.clear();
|
||||
storeComboFilterKey.addAll(remainingFilterKeys);
|
||||
storeComboFilterKey.commitChanges();
|
||||
|
||||
|
||||
if(editingFilter.getFilterKey()!=null){
|
||||
|
||||
if (editingFilter.getFilterKey() != null) {
|
||||
retrieveFilterValuesByKey(editingFilter.getFilterKey());
|
||||
}
|
||||
|
||||
addButton.setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void addHandlersForComboFilterKey(
|
||||
final LabelProvider<FilterKey> labelProvider) {
|
||||
comboFilterKey.addSelectionHandler(new SelectionHandler<FilterKey>() {
|
||||
|
@ -552,13 +545,11 @@ public class ActiveFiltersPanel extends SimpleContainer {
|
|||
updateFilterKey(event.getSelectedItem());
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void updateFilterKey(FilterKey selectedFilterKey) {
|
||||
retrieveFilterValuesByKey(selectedFilterKey);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
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.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
|
@ -55,11 +56,12 @@ public interface AccountingManagerService extends RemoteService {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param filterKey filter on values
|
||||
*
|
||||
* @param filterValuesRequest request values available
|
||||
* @return
|
||||
* @throws AccountingManagerServiceException
|
||||
*/
|
||||
public ArrayList<FilterValue> getFilterValues(FilterKey filterKey)
|
||||
public ArrayList<FilterValue> getFilterValues(FilterValuesRequest filterValuesRequest)
|
||||
throws AccountingManagerServiceException;
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
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.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.session.UserInfo;
|
||||
|
@ -55,10 +56,10 @@ public interface AccountingManagerServiceAsync {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param filterKey filter on values
|
||||
* @param filterValuesRequest request values available
|
||||
* @param callback
|
||||
*/
|
||||
void getFilterValues(FilterKey filterKey,
|
||||
void getFilterValues(FilterValuesRequest filterValuesRequest,
|
||||
AsyncCallback<ArrayList<FilterValue>> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCal
|
|||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
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.query.SeriesRequest;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
|
@ -153,17 +154,17 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<FilterValue> getFilterValues(FilterKey filterKey)
|
||||
public ArrayList<FilterValue> getFilterValues(FilterValuesRequest filterValuesRequest)
|
||||
throws AccountingManagerServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
|
||||
if (filterKey == null) {
|
||||
if (filterValuesRequest.getFilterKey() == null) {
|
||||
return new ArrayList<FilterValue>();
|
||||
}
|
||||
|
||||
switch(filterKey.getKey()){
|
||||
switch(filterValuesRequest.getFilterKey().getKey()){
|
||||
case "consumerId":
|
||||
return new ArrayList<FilterValue>(Arrays.asList(new FilterValue("giancarlo.panichi"),
|
||||
new FilterValue("gianpaolo.coro"), new FilterValue("luca.frosini")));
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.shared.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class FilterValuesRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3544245558153491901L;
|
||||
private FilterKey filterKey;
|
||||
private AccountingType accountingType;
|
||||
|
||||
public FilterValuesRequest(){
|
||||
super();
|
||||
}
|
||||
|
||||
public FilterValuesRequest(FilterKey filterKey,
|
||||
AccountingType accountingType) {
|
||||
super();
|
||||
this.filterKey = filterKey;
|
||||
this.accountingType = accountingType;
|
||||
}
|
||||
|
||||
public FilterKey getFilterKey() {
|
||||
return filterKey;
|
||||
}
|
||||
|
||||
public void setFilterKey(FilterKey filterKey) {
|
||||
this.filterKey = filterKey;
|
||||
}
|
||||
|
||||
public AccountingType getAccountingType() {
|
||||
return accountingType;
|
||||
}
|
||||
|
||||
public void setAccountingType(AccountingType accountingType) {
|
||||
this.accountingType = accountingType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FilterValuesRequest [filterKey=" + filterKey
|
||||
+ ", accountingType=" + accountingType + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue