69: Create new Accounting Portlet

Task-Url: https://support.d4science.org/issues/69

Updated Filters

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@117629 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-07-31 16:27:02 +00:00
parent a54249c9c8
commit 42bf14730e
28 changed files with 400 additions and 277 deletions

View File

@ -4,6 +4,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="accounting-manager-theme-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/accounting-manager-theme/accounting-manager-theme">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/accounting-manager/target/accounting-manager-0.0.1-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/accounting-manager/target/accounting-manager-0.0.1-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="accounting-manager"/> <property name="context-root" value="accounting-manager"/>
</wb-module> </wb-module>

14
pom.xml
View File

@ -208,9 +208,19 @@
<version>[0.2.0-SNAPSHOT,1.0.0-SNAPSHOT)</version> <version>[0.2.0-SNAPSHOT,1.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<!-- Common Encryption -->
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId>
<scope>provided</scope>
</dependency>
<!-- Accounting Lib -->
<dependency>
<groupId>org.gcube.accounting</groupId>
<artifactId>accounting-lib</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<!-- Accounting Analytics --> <!-- Accounting Analytics -->
<dependency> <dependency>

View File

@ -95,15 +95,15 @@ public class AccountingManager implements EntryPoint {
//Filters //Filters
FiltersPanel filtersPanel=new FiltersPanel(eventBus); FiltersPanel filtersPanel=new FiltersPanel(eventBus);
BorderLayoutData westData = new BorderLayoutData(310); BorderLayoutData westData = new BorderLayoutData(410);
westData.setCollapsible(false); westData.setCollapsible(false);
westData.setSplit(false); westData.setSplit(false);
westData.setFloatable(false); westData.setFloatable(false);
westData.setCollapseMini(false); westData.setCollapseMini(false);
westData.setMargins(new Margins(2, 7, 2, 7)); westData.setMargins(new Margins(2, 7, 2, 7));
westData.setCollapseHidden(true); westData.setCollapseHidden(true);
westData.setMaxSize(310); westData.setMaxSize(410);
westData.setMinSize(310); westData.setMinSize(410);
mainPanelLayout.setWestWidget(filtersPanel, westData); mainPanelLayout.setWestWidget(filtersPanel, westData);
filtersPanel.expand(); filtersPanel.expand();
filtersPanel.enable(); filtersPanel.enable();

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.admin.accountingmanager.client; package org.gcube.portlets.admin.accountingmanager.client;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import org.gcube.portlets.admin.accountingmanager.client.event.AccountingMenuEvent; import org.gcube.portlets.admin.accountingmanager.client.event.AccountingMenuEvent;
@ -19,6 +20,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriod; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriod;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriodMode; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriodMode;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; 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.query.SeriesRequest; 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.data.response.SeriesResponse;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerSessionExpiredException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerSessionExpiredException;
@ -56,7 +58,7 @@ public class AccountingManagerController {
accountingType = AccountingType.STORAGE; accountingType = AccountingType.STORAGE;
accountingState = new AccountingState(); accountingState = new AccountingState();
AccountingStateData accountingStateData = new AccountingStateData( AccountingStateData accountingStateData = new AccountingStateData(
accountingType, null, null); accountingType, null, null,null);
accountingState.setState(accountingType, accountingStateData); accountingState.setState(accountingType, accountingStateData);
init(); init();
} }
@ -242,25 +244,60 @@ public class AccountingManagerController {
this.accountingType = accountingType; this.accountingType = accountingType;
AccountingStateData accountingStateData = new AccountingStateData( AccountingStateData accountingStateData = new AccountingStateData(
accountingType, seriesRequest, null); accountingType, seriesRequest, null,null);
accountingState.setState(accountingType, accountingState.setState(accountingType,
accountingStateData); accountingStateData);
callDefaultSeriesRequest(accountingStateData); retrieveFilterKey();
} }
private void callDefaultSeriesRequest(final AccountingStateData accountingStateData) { private void retrieveFilterKey() {
AccountingManagerServiceAsync.INSTANCE.getFilterKeys(accountingType,
new AsyncCallback<ArrayList<FilterKey>>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof AccountingManagerSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error retrieving filter keys for "+accountingType+":"
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving filter keys",
caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(ArrayList<FilterKey> result) {
Log.debug("FilterKeys: " + result);
AccountingStateData accountingStateData=accountingState.getState(accountingType);
accountingStateData.setAvailableFilterKeys(result);
accountingState.setState(accountingType,
accountingStateData);
callDefaultSeriesRequest();
}
});
}
private void callDefaultSeriesRequest() {
AccountingManagerServiceAsync.INSTANCE.getSeries( AccountingManagerServiceAsync.INSTANCE.getSeries(
accountingStateData.getAccountingType(), accountingType,
accountingStateData.getSeriesRequest(), accountingState.getState(accountingType).getSeriesRequest(),
new AsyncCallback<SeriesResponse>() { new AsyncCallback<SeriesResponse>() {
@Override @Override
public void onSuccess(SeriesResponse seriesResponse) { public void onSuccess(SeriesResponse seriesResponse) {
Log.debug("SeriesResponse: " + seriesResponse); Log.debug("SeriesResponse: " + seriesResponse);
AccountingStateData accountingStateData=accountingState.getState(accountingType);
accountingStateData.setSeriesResponse(seriesResponse); accountingStateData.setSeriesResponse(seriesResponse);
accountingState.setState(accountingType, accountingState.setState(accountingType,
accountingStateData); accountingStateData);
@ -278,10 +315,11 @@ public class AccountingManagerController {
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("Error:" + caught.getLocalizedMessage()); Log.error("Error:" + caught.getLocalizedMessage());
caught.printStackTrace();
UtilsGXT3.alert("Error", UtilsGXT3.alert("Error",
caught.getLocalizedMessage()); caught.getLocalizedMessage());
StateChangeEvent stateChangeEvent = new StateChangeEvent( StateChangeEvent stateChangeEvent = new StateChangeEvent(
StateChangeType.Restore, accountingStateData); StateChangeType.Restore, accountingState.getState(accountingType));
eventBus.fireEvent(stateChangeEvent); eventBus.fireEvent(stateChangeEvent);
} }
@ -307,7 +345,7 @@ public class AccountingManagerController {
accountingMonitor = new AccountingMonitor(); accountingMonitor = new AccountingMonitor();
accountingStateData.setSeriesRequest(seriesRequest); accountingStateData.setSeriesRequest(seriesRequest);
accountingState.setState(accountingType, accountingStateData); accountingState.setState(accountingType, accountingStateData);
callSeriesRequest(accountingStateData); callSeriesRequest();
} }
@ -318,16 +356,16 @@ public class AccountingManagerController {
} }
private void callSeriesRequest(final AccountingStateData accountingStateData) { private void callSeriesRequest() {
AccountingManagerServiceAsync.INSTANCE.getSeries( AccountingManagerServiceAsync.INSTANCE.getSeries(
accountingStateData.getAccountingType(), accountingType,
accountingStateData.getSeriesRequest(), accountingState.getState(accountingType).getSeriesRequest(),
new AsyncCallback<SeriesResponse>() { new AsyncCallback<SeriesResponse>() {
@Override @Override
public void onSuccess(SeriesResponse seriesResponse) { public void onSuccess(SeriesResponse seriesResponse) {
Log.debug("SeriesResponse: " + seriesResponse); Log.debug("SeriesResponse: " + seriesResponse);
AccountingStateData accountingStateData=accountingState.getState(accountingType);
accountingStateData.setSeriesResponse(seriesResponse); accountingStateData.setSeriesResponse(seriesResponse);
accountingState.setState(accountingType, accountingState.setState(accountingType,
accountingStateData); accountingStateData);
@ -347,7 +385,7 @@ public class AccountingManagerController {
Log.error("Error:" + caught.getLocalizedMessage()); Log.error("Error:" + caught.getLocalizedMessage());
UtilsGXT3.alert("Error", UtilsGXT3.alert("Error",
caught.getLocalizedMessage()); caught.getLocalizedMessage());
caught.printStackTrace();
} }
} }

View File

@ -32,7 +32,6 @@ 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.FieldSet;
import com.sencha.gxt.widget.core.client.form.validator.EmptyValidator; import com.sencha.gxt.widget.core.client.form.validator.EmptyValidator;
import com.sencha.gxt.widget.core.client.form.validator.MaxDateValidator; import com.sencha.gxt.widget.core.client.form.validator.MaxDateValidator;
import com.sencha.gxt.widget.core.client.info.Info;
/** /**
* *
@ -63,50 +62,6 @@ public class AccountingPeriodPanel extends SimpleContainer {
} }
private void create() { private void create() {
startDate = new DateField();
startDate.addValidator(new MaxDateValidator(new Date()));
startDate.addValidator(new EmptyValidator<Date>());
startDate.addParseErrorHandler(new ParseErrorEvent.ParseErrorHandler() {
@Override
public void onParseError(ParseErrorEvent event) {
Info.display("Parse Error", event.getErrorValue()
+ " could not be parsed as a date");
}
});
startDate.addValueChangeHandler(new ValueChangeHandler<Date>() {
@Override
public void onValueChange(ValueChangeEvent<Date> event) {
String v = event.getValue() == null ? "Nothing"
: DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)
.format(event.getValue());
Info.display("Start Date Selected", v);
}
});
FieldLabel startDateLabel = new FieldLabel(startDate, "Start Date");
endDate = new DateField();
endDate.addValidator(new EmptyValidator<Date>());
endDate.addParseErrorHandler(new ParseErrorEvent.ParseErrorHandler() {
@Override
public void onParseError(ParseErrorEvent event) {
Info.display("Parse Error", event.getErrorValue()
+ " could not be parsed as a date");
}
});
endDate.addValueChangeHandler(new ValueChangeHandler<Date>() {
@Override
public void onValueChange(ValueChangeEvent<Date> event) {
String v = event.getValue() == null ? "Nothing"
: DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)
.format(event.getValue());
Info.display("End Date Selected", v);
}
});
FieldLabel endDateLabel = new FieldLabel(endDate, "End Date");
// Aggreagation Mode // Aggreagation Mode
AccountingPeriodModePropertiesCombo props = GWT AccountingPeriodModePropertiesCombo props = GWT
@ -129,10 +84,57 @@ public class AccountingPeriodPanel extends SimpleContainer {
FieldLabel periodModeLabel = new FieldLabel(comboPeriodMode, FieldLabel periodModeLabel = new FieldLabel(comboPeriodMode,
"Aggregation"); "Aggregation");
//
startDate = new DateField();
startDate.addValidator(new MaxDateValidator(new Date()));
startDate.addValidator(new EmptyValidator<Date>());
startDate.addParseErrorHandler(new ParseErrorEvent.ParseErrorHandler() {
@Override
public void onParseError(ParseErrorEvent event) {
Log.debug("Parse Error", event.getErrorValue()
+ " could not be parsed as a date");
}
});
startDate.addValueChangeHandler(new ValueChangeHandler<Date>() {
@Override
public void onValueChange(ValueChangeEvent<Date> event) {
String v = event.getValue() == null ? "Nothing"
: DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)
.format(event.getValue());
Log.debug("Start Date Selected "+ v);
}
});
FieldLabel startDateLabel = new FieldLabel(startDate, "Start Date");
endDate = new DateField();
endDate.addValidator(new EmptyValidator<Date>());
endDate.addParseErrorHandler(new ParseErrorEvent.ParseErrorHandler() {
@Override
public void onParseError(ParseErrorEvent event) {
Log.debug("Parse Error", event.getErrorValue()
+ " could not be parsed as a date");
}
});
endDate.addValueChangeHandler(new ValueChangeHandler<Date>() {
@Override
public void onValueChange(ValueChangeEvent<Date> event) {
String v = event.getValue() == null ? "Nothing"
: DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)
.format(event.getValue());
Log.debug("End Date Selected "+ v);
}
});
FieldLabel endDateLabel = new FieldLabel(endDate, "End Date");
VerticalLayoutContainer vlc = new VerticalLayoutContainer(); VerticalLayoutContainer vlc = new VerticalLayoutContainer();
vlc.add(periodModeLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(startDateLabel, new VerticalLayoutData(1, -1, new Margins(0))); vlc.add(startDateLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(endDateLabel, new VerticalLayoutData(1, -1, new Margins(0))); vlc.add(endDateLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(periodModeLabel, new VerticalLayoutData(1, -1, new Margins(0)));
FieldSet fieldSet = new FieldSet(); FieldSet fieldSet = new FieldSet();
fieldSet.setHeadingHtml("<b>Temporal Constraint</b>"); fieldSet.setHeadingHtml("<b>Temporal Constraint</b>");
@ -163,13 +165,6 @@ public class AccountingPeriodPanel extends SimpleContainer {
.addSelectionHandler(new SelectionHandler<AccountingPeriodMode>() { .addSelectionHandler(new SelectionHandler<AccountingPeriodMode>() {
public void onSelection( public void onSelection(
SelectionEvent<AccountingPeriodMode> event) { SelectionEvent<AccountingPeriodMode> event) {
Info.display(
"Aggregation",
"You selected "
+ (event.getSelectedItem() == null ? "nothing"
: labelProvider.getLabel(event
.getSelectedItem())
+ "!"));
Log.debug("ComboPeriodMode selected: " Log.debug("ComboPeriodMode selected: "
+ event.getSelectedItem()); + event.getSelectedItem());

View File

@ -3,17 +3,13 @@ package org.gcube.portlets.admin.accountingmanager.client.filters;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.gcube.portlets.admin.accountingmanager.client.event.SessionExpiredEvent;
import org.gcube.portlets.admin.accountingmanager.client.event.StateChangeEvent; import org.gcube.portlets.admin.accountingmanager.client.event.StateChangeEvent;
import org.gcube.portlets.admin.accountingmanager.client.properties.AccountingFilterProperties; import org.gcube.portlets.admin.accountingmanager.client.properties.AccountingFilterProperties;
import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerServiceAsync; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.client.type.SessionExpiredType;
import org.gcube.portlets.admin.accountingmanager.client.utils.UtilsGXT3; 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.AccountingFilter;
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.FilterKey;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerSessionExpiredException;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.cell.client.AbstractCell; import com.google.gwt.cell.client.AbstractCell;
@ -22,7 +18,6 @@ import com.google.gwt.editor.client.Editor.Path;
import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.EventBus;
import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction; import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.Style.SelectionMode; import com.sencha.gxt.core.client.Style.SelectionMode;
@ -39,6 +34,7 @@ import com.sencha.gxt.dnd.core.client.GridDragSource;
import com.sencha.gxt.dnd.core.client.GridDropTarget; 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.ButtonBar;
import com.sencha.gxt.widget.core.client.button.TextButton; 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.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer; 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;
@ -75,9 +71,11 @@ public class ActiveFiltersPanel extends SimpleContainer {
private Grid<AccountingFilter> grid; private Grid<AccountingFilter> grid;
private ListStore<AccountingFilter> store; private ListStore<AccountingFilter> store;
private boolean addStatus; private boolean addStatus;
private List<FilterKey> filterKeys;
private AccountingStateData accountingStateData; private AccountingStateData accountingStateData;
private ListStore<FilterKey> storeComboFilterKey; private ListStore<FilterKey> storeComboFilterKey;
private GridRowEditing<AccountingFilter> editing;
private TextButton addButton;
private int seq;
public interface FilterKeyPropertiesCombo extends PropertyAccess<FilterKey> { public interface FilterKeyPropertiesCombo extends PropertyAccess<FilterKey> {
@ -88,13 +86,11 @@ public class ActiveFiltersPanel extends SimpleContainer {
} }
interface FilterKeyTemplates extends XTemplates { interface FilterKeyTemplates extends XTemplates {
@XTemplate("<span title=\"{value}\">{value}</span>") @XTemplate("<span title=\"{value}\">{value}</span>")
SafeHtml format(String value); SafeHtml format(String value);
} }
public ActiveFiltersPanel(EventBus eventBus) { public ActiveFiltersPanel(EventBus eventBus) {
super(); super();
Log.debug("ActiveFiltersPanel"); Log.debug("ActiveFiltersPanel");
@ -115,22 +111,22 @@ public class ActiveFiltersPanel extends SimpleContainer {
.create(AccountingFilterProperties.class); .create(AccountingFilterProperties.class);
ColumnConfig<AccountingFilter, FilterKey> keyColumn = new ColumnConfig<AccountingFilter, FilterKey>( ColumnConfig<AccountingFilter, FilterKey> keyColumn = new ColumnConfig<AccountingFilter, FilterKey>(
props.key(), 130, "Key"); props.filterKey(), 130, "Key");
keyColumn.setMenuDisabled(true);
keyColumn.setCell(new AbstractCell<FilterKey>() { keyColumn.setCell(new AbstractCell<FilterKey>() {
@Override @Override
public void render(Context context, FilterKey value, SafeHtmlBuilder sb) { public void render(Context context, FilterKey value,
SafeHtmlBuilder sb) {
FilterKeyTemplates filterKeyTemplates = GWT FilterKeyTemplates filterKeyTemplates = GWT
.create(FilterKeyTemplates.class); .create(FilterKeyTemplates.class);
sb.append(filterKeyTemplates.format(value.getKey())); sb.append(filterKeyTemplates.format(value.getKey()));
} }
}); });
ColumnConfig<AccountingFilter, String> valueColumn = new ColumnConfig<AccountingFilter, String>( ColumnConfig<AccountingFilter, String> valueColumn = new ColumnConfig<AccountingFilter, String>(
props.value(), 130, "Value"); props.value(), 130, "Value");
valueColumn.setMenuDisabled(true);
ArrayList<ColumnConfig<AccountingFilter, ?>> l = new ArrayList<ColumnConfig<AccountingFilter, ?>>(); ArrayList<ColumnConfig<AccountingFilter, ?>> l = new ArrayList<ColumnConfig<AccountingFilter, ?>>();
l.add(keyColumn); l.add(keyColumn);
l.add(valueColumn); l.add(valueColumn);
@ -187,53 +183,22 @@ public class ActiveFiltersPanel extends SimpleContainer {
final TextField valueField = new TextField(); final TextField valueField = new TextField();
valueField.addValidator(new EmptyValidator<String>()); valueField.addValidator(new EmptyValidator<String>());
final GridRowEditing<AccountingFilter> editing = new GridRowEditing<AccountingFilter>( editing = new GridRowEditing<AccountingFilter>(grid);
grid);
editing.addEditor(keyColumn, comboFilterKey); editing.addEditor(keyColumn, comboFilterKey);
editing.addEditor(valueColumn, valueField); editing.addEditor(valueColumn, valueField);
final TextButton addButton = new TextButton("Add Filter");
// addButton.setIcon(ResourceBundle.INSTANCE.columnAdd24()); addButton = new TextButton("Add Filter");
addButton.setIcon(AccountingManagerResources.INSTANCE.accountingFilter24());
addButton.setIconAlign(IconAlign.RIGHT); addButton.setIconAlign(IconAlign.RIGHT);
addButton.setToolTip("Add Filter"); addButton.setToolTip("Add Filter");
addButton.addSelectHandler(new SelectHandler() { addButton.addSelectHandler(new SelectHandler() {
@Override @Override
public void onSelect(SelectEvent event) { public void onSelect(SelectEvent event) {
List<AccountingFilter> filtersSet=store.getAll(); addNewFilter(event);
FilterKey fk=null;
if(filterKeys==null|| filterKeys.size()<0){
} else {
for(FilterKey availableFilterKey:filterKeys){
boolean isSet=false;
for(AccountingFilter filterSet:filtersSet){
if(availableFilterKey.getKey().compareTo(filterSet.getFilterKey().getKey())==0){
isSet=true;
break;
}
}
if(!isSet){
fk=availableFilterKey;
break;
}
} }
}
AccountingFilter newAccountingFilter = new AccountingFilter(
fk, "");
editing.cancelEditing();
addStatus = true;
editing.getCancelButton().setVisible(false);
store.add(newAccountingFilter);
int row = store.indexOf(newAccountingFilter);
editing.startEditing(new GridCell(row, 0));
}
}); });
TextButton deleteBtn = new TextButton("Delete"); TextButton deleteBtn = new TextButton("Delete");
@ -262,8 +227,8 @@ public class ActiveFiltersPanel extends SimpleContainer {
@Override @Override
public void onBeforeStartEdit( public void onBeforeStartEdit(
BeforeStartEditEvent<AccountingFilter> event) { BeforeStartEditEvent<AccountingFilter> event) {
addButton.setEnabled(false); editingBeforeStart(event);
// setEnableNextButton(false);
} }
}); });
@ -273,7 +238,6 @@ public class ActiveFiltersPanel extends SimpleContainer {
public void onCancelEdit(CancelEditEvent<AccountingFilter> event) { public void onCancelEdit(CancelEditEvent<AccountingFilter> event) {
store.rejectChanges(); store.rejectChanges();
addButton.setEnabled(true); addButton.setEnabled(true);
// setEnableNextButton(true);
} }
@ -284,44 +248,15 @@ public class ActiveFiltersPanel extends SimpleContainer {
@Override @Override
public void onCompleteEdit(CompleteEditEvent<AccountingFilter> event) { public void onCompleteEdit(CompleteEditEvent<AccountingFilter> event) {
try { try {
String value = valueField.getCurrentValue();
Log.debug("Current Value: " + value);
boolean exist = false;
GridCell cell = event.getEditCell();
int rowIndex = cell.getRow();
AccountingFilter newFilter = store.get(rowIndex);
Log.debug("Store: " + store.getAll().toString());
for (AccountingFilter filter : store.getAll()) {
if (newFilter.getId().compareTo(filter.getId()) != 0) {
exist = true;
break;
}
}
Log.debug("Exist: " + exist);
if (exist) {
Log.debug("AddStatus: " + addStatus);
if (addStatus) { if (addStatus) {
addStatus = false; addStatus = false;
store.remove(rowIndex);
store.commitChanges();
} else {
store.rejectChanges();
} }
UtilsGXT3
.alert("Attention",
"This label is already present, please choose another(case insensitive)!");
} else {
store.commitChanges(); store.commitChanges();
}
editing.getCancelButton().setVisible(true); editing.getCancelButton().setVisible(true);
addButton.setEnabled(true); addButton.setEnabled(true);
// setEnableNextButton(true);
} catch (Throwable e) { } catch (Throwable e) {
Log.error("Error in RuleOnTableNewDefinitionCard: " Log.error("Error in RuleOnTableNewDefinitionCard: "
@ -333,7 +268,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
// //
ToolBar toolBar = new ToolBar(); ToolBar toolBar = new ToolBar();
toolBar.add(addButton); toolBar.add(addButton, new BoxLayoutData(new Margins(0)));
VerticalLayoutContainer vlc = new VerticalLayoutContainer(); VerticalLayoutContainer vlc = new VerticalLayoutContainer();
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
@ -382,39 +317,51 @@ public class ActiveFiltersPanel extends SimpleContainer {
private void onRestoreStateChange(StateChangeEvent event) { private void onRestoreStateChange(StateChangeEvent event) {
if (event.getAccountingStateData() != null) { if (event.getAccountingStateData() != null) {
accountingStateData = event.getAccountingStateData(); accountingStateData = event.getAccountingStateData();
retrieveFilterKey(event.getAccountingStateData().getAccountingType()); changeActiveFilters();
} else { } else {
accountingStateData = null; accountingStateData = null;
seq=0;
} }
Log.debug("Set seq to: "+seq);
forceLayout(); forceLayout();
} }
private void changeActiveFilters() { private void changeActiveFilters() {
storeComboFilterKey.clear(); storeComboFilterKey.clear();
storeComboFilterKey.addAll(filterKeys); storeComboFilterKey
.addAll(accountingStateData.getAvailableFilterKeys());
storeComboFilterKey.commitChanges(); storeComboFilterKey.commitChanges();
if (accountingStateData.getSeriesRequest() != null) { if (accountingStateData.getSeriesRequest() != null
List<AccountingFilter> filters = accountingStateData.getSeriesRequest().getFilters(); && accountingStateData.getSeriesRequest().getFilters() != null) {
List<AccountingFilter> filters = accountingStateData
.getSeriesRequest().getFilters();
store.clear(); store.clear();
store.addAll(filters); store.addAll(filters);
seq=0;
for(AccountingFilter filter:filters){
if(filter.getId()>seq){
seq=filter.getId();
};
}
store.commitChanges(); store.commitChanges();
} else { } else {
store.clear(); store.clear();
store.commitChanges(); store.commitChanges();
seq=0;
} }
forceLayout();
} }
public List<AccountingFilter> getActiveFilters() { public ArrayList<AccountingFilter> getActiveFilters() {
try { try {
if (store == null || store.size() <= 0) { if (store == null || store.size() <= 0) {
return null; return null;
} else { } else {
return store.getAll(); return new ArrayList<AccountingFilter>(store.getAll());
} }
} catch (Throwable e) { } catch (Throwable e) {
@ -425,32 +372,83 @@ public class ActiveFiltersPanel extends SimpleContainer {
} }
} }
private void retrieveFilterKey(AccountingType accountingType) { private void addNewFilter(SelectEvent event) {
List<AccountingFilter> filtersSet = store.getAll();
FilterKey fk = null;
AccountingManagerServiceAsync.INSTANCE.getFilterKeys(accountingType, if (accountingStateData == null
new AsyncCallback<ArrayList<FilterKey>>() { || accountingStateData.getAvailableFilterKeys() == null
|| accountingStateData.getAvailableFilterKeys().size() < 0) {
UtilsGXT3.info("No key available", "No key available");
@Override
public void onFailure(Throwable caught) {
if (caught instanceof AccountingManagerSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("Error retrieving filter keys:" List<FilterKey> remainingFilterKeys = new ArrayList<FilterKey>(
+ caught.getLocalizedMessage()); accountingStateData.getAvailableFilterKeys());
UtilsGXT3.alert("Error retrieving filter keys", List<FilterKey> removableFilterKeys = new ArrayList<FilterKey>();
caught.getLocalizedMessage());
for (AccountingFilter filterSet : filtersSet) {
removableFilterKeys.add(filterSet.getFilterKey());
} }
remainingFilterKeys.removeAll(removableFilterKeys);
if (remainingFilterKeys.size() > 0) {
fk = remainingFilterKeys.get(0);
seq++;
AccountingFilter newAccountingFilter = new AccountingFilter(seq,fk,
"");
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");
}
}
}
private void editingBeforeStart(BeforeStartEditEvent<AccountingFilter> event) {
GridCell cell = event.getEditCell();
int rowIndex = cell.getRow();
AccountingFilter editingFilter = store.get(rowIndex);
List<AccountingFilter> filtersSet = store.getAll();
List<FilterKey> remainingFilterKeys = null;
if (accountingStateData == null
|| accountingStateData.getAvailableFilterKeys() == null) {
remainingFilterKeys = new ArrayList<FilterKey>();
} else {
remainingFilterKeys = new ArrayList<FilterKey>(
accountingStateData.getAvailableFilterKeys());
} }
@Override List<FilterKey> setFilterKeys = new ArrayList<FilterKey>();
public void onSuccess(ArrayList<FilterKey> result) {
Log.debug("FilterKeys: " + result); for (AccountingFilter filterSet : filtersSet) {
filterKeys = result; if (filterSet.getFilterKey().getKey()
changeActiveFilters(); .compareTo(editingFilter.getFilterKey().getKey()) != 0) {
setFilterKeys.add(filterSet.getFilterKey());
} }
}); }
remainingFilterKeys.removeAll(setFilterKeys);
storeComboFilterKey.clear();
storeComboFilterKey.addAll(remainingFilterKeys);
storeComboFilterKey.commitChanges();
addButton.setEnabled(false);
} }

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.admin.accountingmanager.client.filters; package org.gcube.portlets.admin.accountingmanager.client.filters;
import java.util.List; import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.client.event.FiltersChangeEvent; import org.gcube.portlets.admin.accountingmanager.client.event.FiltersChangeEvent;
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
@ -91,7 +91,7 @@ public class FiltersPanel extends FramedPanel {
protected void updateChart() { protected void updateChart() {
AccountingPeriod accountingPeriod = accountPeriodPanel AccountingPeriod accountingPeriod = accountPeriodPanel
.getAccountingPeriod(); .getAccountingPeriod();
List<AccountingFilter> activeFilters=activeFiltersPanel.getActiveFilters(); ArrayList<AccountingFilter> activeFilters=activeFiltersPanel.getActiveFilters();
if (accountingPeriod != null) { if (accountingPeriod != null) {
SeriesRequest seriesRequest = new SeriesRequest(accountingPeriod,activeFilters); SeriesRequest seriesRequest = new SeriesRequest(accountingPeriod,activeFilters);

View File

@ -18,7 +18,7 @@ public interface AccountingFilterProperties extends
ModelKeyProvider<AccountingFilter> id(); ModelKeyProvider<AccountingFilter> id();
ValueProvider<AccountingFilter, FilterKey> key(); ValueProvider<AccountingFilter, FilterKey> filterKey();
ValueProvider<AccountingFilter, String> value(); ValueProvider<AccountingFilter, String> value();

View File

@ -107,13 +107,16 @@ public interface AccountingManagerResources extends ClientBundle {
@Source("accounting-reload_48.png") @Source("accounting-reload_48.png")
ImageResource accountingReload48(); ImageResource accountingReload48();
@Source("accounting-chart-variable-axis_16.png")
ImageResource accountingChartVariableAxis16();
@Source("accounting-chart-variable-axis_24.png") @Source("accounting-chart-variable-axis_24.png")
ImageResource accountingChartVariableAxis24(); ImageResource accountingChartVariableAxis24();
@Source("accounting-chart-variable-axis_32.png") @Source("accounting-chart-variable-axis_32.png")
ImageResource accountingChartVariableAxis32(); ImageResource accountingChartVariableAxis32();
@Source("accounting-filter_24.png")
ImageResource accountingFilter24();
@Source("accounting-filter_32.png")
ImageResource accountingFilter32();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,8 +1,10 @@
package org.gcube.portlets.admin.accountingmanager.client.state; package org.gcube.portlets.admin.accountingmanager.client.state;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; 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.query.SeriesRequest; 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.data.response.SeriesResponse;
@ -14,21 +16,24 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesRes
*/ */
public class AccountingStateData implements Serializable { public class AccountingStateData implements Serializable {
private static final long serialVersionUID = 4853602427569285252L; private static final long serialVersionUID = -2080165745912743812L;
private AccountingType accountingType; private AccountingType accountingType;
private SeriesRequest seriesRequest; private SeriesRequest seriesRequest;
private SeriesResponse seriesResponse; private SeriesResponse seriesResponse;
private ArrayList<FilterKey> availableFilterKeys;
public AccountingStateData() { public AccountingStateData() {
super(); super();
} }
public AccountingStateData(AccountingType accountingType, public AccountingStateData(AccountingType accountingType,
SeriesRequest seriesRequest, SeriesResponse seriesResponse) { SeriesRequest seriesRequest, SeriesResponse seriesResponse,
ArrayList<FilterKey> availableFilterKeys) {
super(); super();
this.accountingType = accountingType; this.accountingType = accountingType;
this.seriesRequest = seriesRequest; this.seriesRequest = seriesRequest;
this.seriesResponse = seriesResponse; this.seriesResponse = seriesResponse;
this.availableFilterKeys = availableFilterKeys;
} }
public AccountingType getAccountingType() { public AccountingType getAccountingType() {
@ -55,11 +60,23 @@ public class AccountingStateData implements Serializable {
this.seriesResponse = seriesResponse; this.seriesResponse = seriesResponse;
} }
public ArrayList<FilterKey> getAvailableFilterKeys() {
return availableFilterKeys;
}
public void setAvailableFilterKeys(ArrayList<FilterKey> availableFilterKeys) {
this.availableFilterKeys = availableFilterKeys;
}
@Override @Override
public String toString() { public String toString() {
return "AccountingStateData [accountingType=" + accountingType return "AccountingStateData [accountingType=" + accountingType
+ ", seriesRequest=" + seriesRequest + ", seriesResponse=" + ", seriesRequest=" + seriesRequest + ", seriesResponse="
+ seriesResponse + "]"; + seriesResponse + ", availableFilterKeys="
+ availableFilterKeys + "]";
} }
} }

View File

@ -115,7 +115,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
return new ArrayList<FilterKey>(); return new ArrayList<FilterKey>();
case SERVICE: case SERVICE:
return new ArrayList<FilterKey>(Arrays.asList(new FilterKey("consumerId"), return new ArrayList<FilterKey>(Arrays.asList(new FilterKey("consumerId"),
new FilterKey("host"), new FilterKey("scope"), new FilterKey("serviceName"))); new FilterKey("host"), new FilterKey("scope"), new FilterKey("serviceName"),new FilterKey("serviceClass")));
case STORAGE: case STORAGE:
return new ArrayList<FilterKey>(Arrays.asList(new FilterKey("consumerId"), return new ArrayList<FilterKey>(Arrays.asList(new FilterKey("consumerId"),

View File

@ -63,7 +63,7 @@ public class AccountingCaller {
List<Info> infos = rrq.getInfo(query.getType(), List<Info> infos = rrq.getInfo(query.getType(),
query.getTemporalConstraint(), null, true); query.getTemporalConstraint(), query.getFilters(), true);
if (infos == null) { if (infos == null) {
throw new AccountingManagerServiceException( throw new AccountingManagerServiceException(
"Error retrieving list of info: list is null!"); "Error retrieving list of info: list is null!");

View File

@ -1,59 +1,62 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.query; package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
import java.util.ArrayList;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.datamodel.SingleUsageRecord; import org.gcube.accounting.datamodel.AggregatedUsageRecord;
/** /**
* *
* @author giancarlo * @author giancarlo email: <a
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
@SuppressWarnings("rawtypes")
public class AccountingQuery { public class AccountingQuery {
private Class<? extends AggregatedUsageRecord> type;
private Class<? extends SingleUsageRecord> type;
private TemporalConstraint temporalConstraint; private TemporalConstraint temporalConstraint;
private ArrayList<Filter> filters;
public AccountingQuery(Class<? extends SingleUsageRecord> type, TemporalConstraint temporalConstraint) { public AccountingQuery(Class<? extends AggregatedUsageRecord> type,
TemporalConstraint temporalConstraint, ArrayList<Filter> filters) {
super(); super();
this.type = type; this.type = type;
this.temporalConstraint = temporalConstraint; this.temporalConstraint = temporalConstraint;
this.filters = filters;
} }
public Class<? extends AggregatedUsageRecord> getType() {
public Class<? extends SingleUsageRecord> getType() {
return type; return type;
} }
public void setType(Class<? extends AggregatedUsageRecord> type) {
public void setType(Class<? extends SingleUsageRecord> type) {
this.type = type; this.type = type;
} }
public TemporalConstraint getTemporalConstraint() { public TemporalConstraint getTemporalConstraint() {
return temporalConstraint; return temporalConstraint;
} }
public void setTemporalConstraint(TemporalConstraint temporalConstraint) { public void setTemporalConstraint(TemporalConstraint temporalConstraint) {
this.temporalConstraint = temporalConstraint; this.temporalConstraint = temporalConstraint;
} }
public ArrayList<Filter> getFilters() {
return filters;
}
public void setFilters(ArrayList<Filter> filters) {
this.filters = filters;
}
@Override @Override
public String toString() { public String toString() {
return "AccountingQuery [type=" + type + ", temporalConstraint=" return "AccountingQuery [type=" + type + ", temporalConstraint="
+ temporalConstraint + "]"; + temporalConstraint + ", filters=" + filters + "]";
} }
} }

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.query; package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
import org.gcube.accounting.aggregation.AggregatedJobUsageRecord;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
@ -34,7 +34,7 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
.getPeriod())); .getPeriod()));
AccountingQuery invocation = new AccountingQuery( AccountingQuery invocation = new AccountingQuery(
JobUsageRecord.class, temporalConstraint); AggregatedJobUsageRecord.class, temporalConstraint,null);
accountingQuerySpec.setOp(invocation); accountingQuerySpec.setOp(invocation);

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.query; package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
import org.gcube.accounting.aggregation.AggregatedPortletUsageRecord;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord;
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
@ -34,7 +34,7 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
.getPeriod())); .getPeriod()));
AccountingQuery invocation = new AccountingQuery( AccountingQuery invocation = new AccountingQuery(
PortletUsageRecord.class, temporalConstraint); AggregatedPortletUsageRecord.class, temporalConstraint,null);
accountingQuerySpec.setOp(invocation); accountingQuerySpec.setOp(invocation);

View File

@ -1,8 +1,12 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.query; package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
import java.util.ArrayList;
import org.gcube.accounting.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -33,8 +37,21 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
PeriodModeMap.getMode(seriesRequest.getAccountingPeriod() PeriodModeMap.getMode(seriesRequest.getAccountingPeriod()
.getPeriod())); .getPeriod()));
ArrayList<AccountingFilter> accountingFilters = seriesRequest
.getFilters();
ArrayList<Filter> filters=null;
if (accountingFilters != null) {
filters = new ArrayList<Filter>();
for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters.getFilterKey()
.getKey(), accountigFilters.getValue());
filters.add(filter);
}
}
AccountingQuery invocation = new AccountingQuery( AccountingQuery invocation = new AccountingQuery(
ServiceUsageRecord.class, temporalConstraint); AggregatedServiceUsageRecord.class, temporalConstraint, filters);
accountingQuerySpec.setOp(invocation); accountingQuerySpec.setOp(invocation);

View File

@ -1,8 +1,12 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.query; package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
import java.util.ArrayList;
import org.gcube.accounting.aggregation.AggregatedStorageUsageRecord;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -33,8 +37,21 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
PeriodModeMap.getMode(seriesRequest.getAccountingPeriod() PeriodModeMap.getMode(seriesRequest.getAccountingPeriod()
.getPeriod())); .getPeriod()));
ArrayList<AccountingFilter> accountingFilters = seriesRequest
.getFilters();
ArrayList<Filter> filters=null;
if (accountingFilters != null) {
filters = new ArrayList<Filter>();
for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters.getFilterKey()
.getKey(), accountigFilters.getValue());
filters.add(filter);
}
}
AccountingQuery invocation = new AccountingQuery( AccountingQuery invocation = new AccountingQuery(
StorageUsageRecord.class, temporalConstraint); AggregatedStorageUsageRecord.class, temporalConstraint, filters);
accountingQuerySpec.setOp(invocation); accountingQuerySpec.setOp(invocation);

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.query; package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
import org.gcube.accounting.aggregation.AggregatedStorageUsageRecord;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
@ -34,7 +34,7 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
.getPeriod())); .getPeriod()));
AccountingQuery invocation = new AccountingQuery( AccountingQuery invocation = new AccountingQuery(
StorageUsageRecord.class, temporalConstraint); AggregatedStorageUsageRecord.class, temporalConstraint,null);
accountingQuerySpec.setOp(invocation); accountingQuerySpec.setOp(invocation);

View File

@ -11,6 +11,7 @@ import java.io.Serializable;
public class AccountingFilter implements Serializable { public class AccountingFilter implements Serializable {
private static final long serialVersionUID = 7200526591393559078L; private static final long serialVersionUID = 7200526591393559078L;
private int id;
private FilterKey filterKey; private FilterKey filterKey;
private String value; private String value;
@ -18,18 +19,19 @@ public class AccountingFilter implements Serializable {
super(); super();
} }
public AccountingFilter(FilterKey filterKey, String value) { public AccountingFilter(int id, FilterKey filterKey, String value) {
super(); super();
this.id=id;
this.filterKey = filterKey; this.filterKey = filterKey;
this.value = value; this.value = value;
} }
public String getId() { public int getId() {
if (filterKey != null) { return id;
return filterKey.getId();
} else {
return null;
} }
public void setId(int id) {
this.id = id;
} }
public FilterKey getFilterKey() { public FilterKey getFilterKey() {
@ -50,8 +52,8 @@ public class AccountingFilter implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "AccountingFilter [filterKey=" + filterKey + ", value=" + value return "AccountingFilter [id=" + id + ", filterKey=" + filterKey
+ "]"; + ", value=" + value + "]";
} }
} }

View File

@ -8,7 +8,7 @@ import java.io.Serializable;
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class FilterKey implements Serializable { public class FilterKey implements Serializable, Comparable<FilterKey> {
private static final long serialVersionUID = 7200526591393559078L; private static final long serialVersionUID = 7200526591393559078L;
private String key; private String key;
@ -35,9 +35,25 @@ public class FilterKey implements Serializable {
this.key = key; this.key = key;
} }
@Override
public int compareTo(FilterKey filterKey) {
if(filterKey==null && key==null){
return 0;
} else {
if(filterKey==null && key!=null){
return 1;
} else {
return key.compareTo(filterKey.getKey());
}
}
}
@Override @Override
public String toString() { public String toString() {
return "FilterKey [key=" + key + "]"; return "FilterKey [key=" + key + "]";
} }

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.query; package org.gcube.portlets.admin.accountingmanager.shared.data.query;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriod; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriod;
@ -16,14 +16,14 @@ public class SeriesRequest implements Serializable {
private static final long serialVersionUID = -109538024097615414L; private static final long serialVersionUID = -109538024097615414L;
private AccountingPeriod accountingPeriod; private AccountingPeriod accountingPeriod;
private List<AccountingFilter> filters; private ArrayList<AccountingFilter> filters;
public SeriesRequest() { public SeriesRequest() {
super(); super();
} }
public SeriesRequest(AccountingPeriod accountingPeriod, public SeriesRequest(AccountingPeriod accountingPeriod,
List<AccountingFilter> filters) { ArrayList<AccountingFilter> filters) {
super(); super();
this.accountingPeriod = accountingPeriod; this.accountingPeriod = accountingPeriod;
this.filters = filters; this.filters = filters;
@ -37,11 +37,11 @@ public class SeriesRequest implements Serializable {
this.accountingPeriod = accountingPeriod; this.accountingPeriod = accountingPeriod;
} }
public List<AccountingFilter> getFilters() { public ArrayList<AccountingFilter> getFilters() {
return filters; return filters;
} }
public void setFilters(List<AccountingFilter> filters) { public void setFilters(ArrayList<AccountingFilter> filters) {
this.filters = filters; this.filters = filters;
} }
@ -53,4 +53,6 @@ public class SeriesRequest implements Serializable {
} }

View File

@ -24,8 +24,8 @@
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<!-- Debug CSS style --> <!-- Debug CSS style -->
<!-- <set-configuration-property name="CssResource.style" <!-- <set-configuration-property name="CssResource.style" value="pretty"
value="pretty" /> --> /> -->
<!--<inherits name="org.moxieapps.gwt.highcharts.Highcharts"/> --> <!--<inherits name="org.moxieapps.gwt.highcharts.Highcharts"/> -->
<inherits name='com.github.highcharts4gwt.highcharts' /> <inherits name='com.github.highcharts4gwt.highcharts' />
@ -48,10 +48,12 @@
name="locale" values="es" /> <set-property name="locale" value="en, it, es" name="locale" values="es" /> <set-property name="locale" value="en, it, es"
/> <set-property-fallback name="locale" value="en" /> --> /> <set-property-fallback name="locale" value="en" /> -->
<!-- <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" <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" <!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
/> --> /> -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB