69: Create new Accounting Portlet
Task-Url: https://support.d4science.org/issues/69 Updated Filters Management git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@117577 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e9e2386440
commit
a54249c9c8
|
@ -238,7 +238,7 @@ public class AccountingManagerController {
|
||||||
CalendarUtil.addMonthsToDate(d, -1);
|
CalendarUtil.addMonthsToDate(d, -1);
|
||||||
|
|
||||||
SeriesRequest seriesRequest=new SeriesRequest(
|
SeriesRequest seriesRequest=new SeriesRequest(
|
||||||
new AccountingPeriod(d,new Date(),AccountingPeriodMode.DAILY));
|
new AccountingPeriod(d,new Date(),AccountingPeriodMode.DAILY), null);
|
||||||
this.accountingType = accountingType;
|
this.accountingType = accountingType;
|
||||||
|
|
||||||
AccountingStateData accountingStateData = new AccountingStateData(
|
AccountingStateData accountingStateData = new AccountingStateData(
|
||||||
|
|
|
@ -0,0 +1,457 @@
|
||||||
|
package org.gcube.portlets.admin.accountingmanager.client.filters;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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.properties.AccountingFilterProperties;
|
||||||
|
import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerServiceAsync;
|
||||||
|
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.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.exception.AccountingManagerSessionExpiredException;
|
||||||
|
|
||||||
|
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.Path;
|
||||||
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||||
|
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||||
|
import com.sencha.gxt.core.client.Style.SelectionMode;
|
||||||
|
import com.sencha.gxt.core.client.XTemplates;
|
||||||
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
|
import com.sencha.gxt.data.shared.LabelProvider;
|
||||||
|
import com.sencha.gxt.data.shared.ListStore;
|
||||||
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||||
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||||
|
import com.sencha.gxt.dnd.core.client.DND.Feedback;
|
||||||
|
import com.sencha.gxt.dnd.core.client.DndDragStartEvent;
|
||||||
|
import com.sencha.gxt.dnd.core.client.DndDragStartEvent.DndDragStartHandler;
|
||||||
|
import com.sencha.gxt.dnd.core.client.GridDragSource;
|
||||||
|
import com.sencha.gxt.dnd.core.client.GridDropTarget;
|
||||||
|
import com.sencha.gxt.widget.core.client.button.ButtonBar;
|
||||||
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.BeforeStartEditEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.BeforeStartEditEvent.BeforeStartEditHandler;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.CancelEditEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.CancelEditEvent.CancelEditHandler;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.CompleteEditEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.CompleteEditEvent.CompleteEditHandler;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.FieldSet;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.validator.EmptyValidator;
|
||||||
|
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
||||||
|
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
|
||||||
|
import com.sencha.gxt.widget.core.client.grid.Grid;
|
||||||
|
import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
|
||||||
|
import com.sencha.gxt.widget.core.client.grid.GridSelectionModel;
|
||||||
|
import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
|
||||||
|
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ActiveFiltersPanel extends SimpleContainer {
|
||||||
|
|
||||||
|
private EventBus eventBus;
|
||||||
|
private Grid<AccountingFilter> grid;
|
||||||
|
private ListStore<AccountingFilter> store;
|
||||||
|
private boolean addStatus;
|
||||||
|
private List<FilterKey> filterKeys;
|
||||||
|
private AccountingStateData accountingStateData;
|
||||||
|
private ListStore<FilterKey> storeComboFilterKey;
|
||||||
|
|
||||||
|
public interface FilterKeyPropertiesCombo extends PropertyAccess<FilterKey> {
|
||||||
|
|
||||||
|
@Path("id")
|
||||||
|
ModelKeyProvider<FilterKey> id();
|
||||||
|
|
||||||
|
LabelProvider<FilterKey> key();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface FilterKeyTemplates extends XTemplates {
|
||||||
|
@XTemplate("<span title=\"{value}\">{value}</span>")
|
||||||
|
SafeHtml format(String value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ActiveFiltersPanel(EventBus eventBus) {
|
||||||
|
super();
|
||||||
|
Log.debug("ActiveFiltersPanel");
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
init();
|
||||||
|
create();
|
||||||
|
bindToEvents();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create() {
|
||||||
|
// Grid
|
||||||
|
AccountingFilterProperties props = GWT
|
||||||
|
.create(AccountingFilterProperties.class);
|
||||||
|
|
||||||
|
ColumnConfig<AccountingFilter, FilterKey> keyColumn = new ColumnConfig<AccountingFilter, FilterKey>(
|
||||||
|
props.key(), 130, "Key");
|
||||||
|
|
||||||
|
keyColumn.setCell(new AbstractCell<FilterKey>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Context context, FilterKey value, SafeHtmlBuilder sb) {
|
||||||
|
FilterKeyTemplates filterKeyTemplates = GWT
|
||||||
|
.create(FilterKeyTemplates.class);
|
||||||
|
sb.append(filterKeyTemplates.format(value.getKey()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
ColumnConfig<AccountingFilter, String> valueColumn = new ColumnConfig<AccountingFilter, String>(
|
||||||
|
props.value(), 130, "Value");
|
||||||
|
|
||||||
|
ArrayList<ColumnConfig<AccountingFilter, ?>> l = new ArrayList<ColumnConfig<AccountingFilter, ?>>();
|
||||||
|
l.add(keyColumn);
|
||||||
|
l.add(valueColumn);
|
||||||
|
|
||||||
|
ColumnModel<AccountingFilter> columns = new ColumnModel<AccountingFilter>(
|
||||||
|
l);
|
||||||
|
|
||||||
|
store = new ListStore<AccountingFilter>(props.id());
|
||||||
|
|
||||||
|
final GridSelectionModel<AccountingFilter> sm = new GridSelectionModel<AccountingFilter>();
|
||||||
|
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||||
|
|
||||||
|
grid = new Grid<AccountingFilter>(store, columns);
|
||||||
|
grid.setSelectionModel(sm);
|
||||||
|
grid.getView().setStripeRows(true);
|
||||||
|
grid.getView().setColumnLines(true);
|
||||||
|
grid.getView().setAutoFill(true);
|
||||||
|
grid.setBorders(false);
|
||||||
|
grid.setColumnReordering(false);
|
||||||
|
grid.getView().setAutoExpandColumn(valueColumn);
|
||||||
|
grid.getView().setSortingEnabled(false);
|
||||||
|
|
||||||
|
GridDragSource<AccountingFilter> ds = new GridDragSource<AccountingFilter>(
|
||||||
|
grid);
|
||||||
|
ds.addDragStartHandler(new DndDragStartHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDragStart(DndDragStartEvent event) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
ArrayList<AccountingFilter> draggingSelection = (ArrayList<AccountingFilter>) event
|
||||||
|
.getData();
|
||||||
|
Log.debug("Start Drag: " + draggingSelection);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridDropTarget<AccountingFilter> dt = new GridDropTarget<AccountingFilter>(
|
||||||
|
grid);
|
||||||
|
dt.setFeedback(Feedback.BOTH);
|
||||||
|
dt.setAllowSelfAsSource(true);
|
||||||
|
|
||||||
|
// EDITING //
|
||||||
|
FilterKeyPropertiesCombo filterKeyPropertiesCombo = GWT
|
||||||
|
.create(FilterKeyPropertiesCombo.class);
|
||||||
|
|
||||||
|
storeComboFilterKey = new ListStore<FilterKey>(
|
||||||
|
filterKeyPropertiesCombo.id());
|
||||||
|
//
|
||||||
|
ComboBox<FilterKey> comboFilterKey = new ComboBox<FilterKey>(
|
||||||
|
storeComboFilterKey, filterKeyPropertiesCombo.key());
|
||||||
|
comboFilterKey.setClearValueOnParseError(false);
|
||||||
|
|
||||||
|
comboFilterKey.setTriggerAction(TriggerAction.ALL);
|
||||||
|
|
||||||
|
final TextField valueField = new TextField();
|
||||||
|
valueField.addValidator(new EmptyValidator<String>());
|
||||||
|
|
||||||
|
final GridRowEditing<AccountingFilter> editing = new GridRowEditing<AccountingFilter>(
|
||||||
|
grid);
|
||||||
|
editing.addEditor(keyColumn, comboFilterKey);
|
||||||
|
editing.addEditor(valueColumn, valueField);
|
||||||
|
|
||||||
|
final TextButton addButton = new TextButton("Add Filter");
|
||||||
|
// addButton.setIcon(ResourceBundle.INSTANCE.columnAdd24());
|
||||||
|
addButton.setIconAlign(IconAlign.RIGHT);
|
||||||
|
addButton.setToolTip("Add Filter");
|
||||||
|
addButton.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
List<AccountingFilter> filtersSet=store.getAll();
|
||||||
|
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");
|
||||||
|
deleteBtn.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
GridCell cell = editing.getActiveCell();
|
||||||
|
int rowIndex = cell.getRow();
|
||||||
|
|
||||||
|
editing.cancelEditing();
|
||||||
|
|
||||||
|
store.remove(rowIndex);
|
||||||
|
store.commitChanges();
|
||||||
|
|
||||||
|
editing.getCancelButton().setVisible(true);
|
||||||
|
addButton.setEnabled(true);
|
||||||
|
if (addStatus) {
|
||||||
|
addStatus = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ButtonBar buttonBar = editing.getButtonBar();
|
||||||
|
buttonBar.add(deleteBtn);
|
||||||
|
|
||||||
|
editing.addBeforeStartEditHandler(new BeforeStartEditHandler<AccountingFilter>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBeforeStartEdit(
|
||||||
|
BeforeStartEditEvent<AccountingFilter> event) {
|
||||||
|
addButton.setEnabled(false);
|
||||||
|
// setEnableNextButton(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
editing.addCancelEditHandler(new CancelEditHandler<AccountingFilter>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCancelEdit(CancelEditEvent<AccountingFilter> event) {
|
||||||
|
store.rejectChanges();
|
||||||
|
addButton.setEnabled(true);
|
||||||
|
// setEnableNextButton(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
editing.addCompleteEditHandler(new CompleteEditHandler<AccountingFilter>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCompleteEdit(CompleteEditEvent<AccountingFilter> event) {
|
||||||
|
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) {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
editing.getCancelButton().setVisible(true);
|
||||||
|
addButton.setEnabled(true);
|
||||||
|
// setEnableNextButton(true);
|
||||||
|
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.error("Error in RuleOnTableNewDefinitionCard: "
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
ToolBar toolBar = new ToolBar();
|
||||||
|
toolBar.add(addButton);
|
||||||
|
|
||||||
|
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
||||||
|
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||||
|
vlc.add(grid, new VerticalLayoutData(1, 1, new Margins(0)));
|
||||||
|
|
||||||
|
FieldSet fieldSet = new FieldSet();
|
||||||
|
fieldSet.setHeadingHtml("<b>Active Filters</b>");
|
||||||
|
fieldSet.setCollapsible(false);
|
||||||
|
fieldSet.add(vlc);
|
||||||
|
|
||||||
|
add(fieldSet, new MarginData(0));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind to Events
|
||||||
|
private void bindToEvents() {
|
||||||
|
eventBus.addHandler(StateChangeEvent.TYPE,
|
||||||
|
new StateChangeEvent.StateChangeEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStateChange(StateChangeEvent event) {
|
||||||
|
Log.debug("Catch Event State Change");
|
||||||
|
doStateChangeCommand(event);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doStateChangeCommand(StateChangeEvent event) {
|
||||||
|
if (event.getStateChangeType() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (event.getStateChangeType()) {
|
||||||
|
case Restore:
|
||||||
|
onRestoreStateChange(event);
|
||||||
|
break;
|
||||||
|
case Update:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onRestoreStateChange(StateChangeEvent event) {
|
||||||
|
if (event.getAccountingStateData() != null) {
|
||||||
|
accountingStateData=event.getAccountingStateData();
|
||||||
|
retrieveFilterKey(event.getAccountingStateData().getAccountingType());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
accountingStateData=null;
|
||||||
|
}
|
||||||
|
forceLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeActiveFilters() {
|
||||||
|
storeComboFilterKey.clear();
|
||||||
|
storeComboFilterKey.addAll(filterKeys);
|
||||||
|
storeComboFilterKey.commitChanges();
|
||||||
|
|
||||||
|
if (accountingStateData.getSeriesRequest() != null) {
|
||||||
|
List<AccountingFilter> filters = accountingStateData.getSeriesRequest().getFilters();
|
||||||
|
store.clear();
|
||||||
|
store.addAll(filters);
|
||||||
|
store.commitChanges();
|
||||||
|
} else {
|
||||||
|
store.clear();
|
||||||
|
store.commitChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
forceLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AccountingFilter> getActiveFilters() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (store == null || store.size() <= 0) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return store.getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.error(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void retrieveFilterKey(AccountingType accountingType) {
|
||||||
|
|
||||||
|
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:"
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
UtilsGXT3.alert("Error retrieving filter keys",
|
||||||
|
caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ArrayList<FilterKey> result) {
|
||||||
|
Log.debug("FilterKeys: " + result);
|
||||||
|
filterKeys = result;
|
||||||
|
changeActiveFilters();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,11 @@
|
||||||
package org.gcube.portlets.admin.accountingmanager.client.filters;
|
package org.gcube.portlets.admin.accountingmanager.client.filters;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
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;
|
||||||
import org.gcube.portlets.admin.accountingmanager.client.type.FiltersChangeType;
|
import org.gcube.portlets.admin.accountingmanager.client.type.FiltersChangeType;
|
||||||
|
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;
|
||||||
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
|
||||||
|
|
||||||
|
@ -31,6 +34,7 @@ public class FiltersPanel extends FramedPanel {
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
private AccountingPeriodPanel accountPeriodPanel;
|
private AccountingPeriodPanel accountPeriodPanel;
|
||||||
private TextButton updateCharts;
|
private TextButton updateCharts;
|
||||||
|
private ActiveFiltersPanel activeFiltersPanel;
|
||||||
|
|
||||||
public FiltersPanel(EventBus eventBus) {
|
public FiltersPanel(EventBus eventBus) {
|
||||||
super();
|
super();
|
||||||
|
@ -52,6 +56,7 @@ public class FiltersPanel extends FramedPanel {
|
||||||
|
|
||||||
protected void create() {
|
protected void create() {
|
||||||
accountPeriodPanel = new AccountingPeriodPanel(eventBus);
|
accountPeriodPanel = new AccountingPeriodPanel(eventBus);
|
||||||
|
activeFiltersPanel = new ActiveFiltersPanel(eventBus);
|
||||||
|
|
||||||
updateCharts = new TextButton("Update Chart");
|
updateCharts = new TextButton("Update Chart");
|
||||||
updateCharts.setIcon(AccountingManagerResources.INSTANCE
|
updateCharts.setIcon(AccountingManagerResources.INSTANCE
|
||||||
|
@ -75,6 +80,9 @@ public class FiltersPanel extends FramedPanel {
|
||||||
vlc.setScrollMode(ScrollMode.AUTO);
|
vlc.setScrollMode(ScrollMode.AUTO);
|
||||||
vlc.add(accountPeriodPanel, new VerticalLayoutData(1, -1, new Margins(
|
vlc.add(accountPeriodPanel, new VerticalLayoutData(1, -1, new Margins(
|
||||||
4, 0, 2, 4)));
|
4, 0, 2, 4)));
|
||||||
|
vlc.add(activeFiltersPanel, new VerticalLayoutData(1, 1, new Margins(
|
||||||
|
4, 0, 2, 4)));
|
||||||
|
|
||||||
vlc.add(hBox, new VerticalLayoutData(1, -1, new Margins(0)));
|
vlc.add(hBox, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||||
|
|
||||||
add(vlc);
|
add(vlc);
|
||||||
|
@ -83,8 +91,10 @@ public class FiltersPanel extends FramedPanel {
|
||||||
protected void updateChart() {
|
protected void updateChart() {
|
||||||
AccountingPeriod accountingPeriod = accountPeriodPanel
|
AccountingPeriod accountingPeriod = accountPeriodPanel
|
||||||
.getAccountingPeriod();
|
.getAccountingPeriod();
|
||||||
|
List<AccountingFilter> activeFilters=activeFiltersPanel.getActiveFilters();
|
||||||
|
|
||||||
if (accountingPeriod != null) {
|
if (accountingPeriod != null) {
|
||||||
SeriesRequest seriesRequest = new SeriesRequest(accountingPeriod);
|
SeriesRequest seriesRequest = new SeriesRequest(accountingPeriod,activeFilters);
|
||||||
FiltersChangeEvent filtersChangeEvent = new FiltersChangeEvent(
|
FiltersChangeEvent filtersChangeEvent = new FiltersChangeEvent(
|
||||||
FiltersChangeType.Update, seriesRequest);
|
FiltersChangeType.Update, seriesRequest);
|
||||||
eventBus.fireEvent(filtersChangeEvent);
|
eventBus.fireEvent(filtersChangeEvent);
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package org.gcube.portlets.admin.accountingmanager.client.properties;
|
||||||
|
|
||||||
|
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
|
||||||
|
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
|
||||||
|
|
||||||
|
import com.sencha.gxt.core.client.ValueProvider;
|
||||||
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||||
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface AccountingFilterProperties extends
|
||||||
|
PropertyAccess<AccountingFilter> {
|
||||||
|
|
||||||
|
ModelKeyProvider<AccountingFilter> id();
|
||||||
|
|
||||||
|
ValueProvider<AccountingFilter, FilterKey> key();
|
||||||
|
|
||||||
|
ValueProvider<AccountingFilter, String> value();
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
package org.gcube.portlets.admin.accountingmanager.client.rpc;
|
package org.gcube.portlets.admin.accountingmanager.client.rpc;
|
||||||
|
|
||||||
|
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;
|
||||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||||
|
@ -12,8 +14,8 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi"
|
* @author "Giancarlo Panichi" <a
|
||||||
* <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>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RemoteServiceRelativePath("ams")
|
@RemoteServiceRelativePath("ams")
|
||||||
|
@ -29,11 +31,25 @@ public interface AccountingManagerService extends RemoteService {
|
||||||
/**
|
/**
|
||||||
* Retrieve Accounting Series
|
* Retrieve Accounting Series
|
||||||
*
|
*
|
||||||
* @param accountingType the resource on which to accounting
|
* @param accountingType
|
||||||
* @param seriesRequest filters and constraints descriptions
|
* the resource on which to accounting
|
||||||
|
* @param seriesRequest
|
||||||
|
* filters and constraints descriptions
|
||||||
* @return
|
* @return
|
||||||
* @throws AccountingManagerServiceException
|
* @throws AccountingManagerServiceException
|
||||||
*/
|
*/
|
||||||
public SeriesResponse getSeries(AccountingType accountingType, SeriesRequest seriesRequest) throws AccountingManagerServiceException;
|
public SeriesResponse getSeries(AccountingType accountingType,
|
||||||
|
SeriesRequest seriesRequest)
|
||||||
|
throws AccountingManagerServiceException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param accountingType
|
||||||
|
* type of accounting
|
||||||
|
* @return list of filter keys
|
||||||
|
* @throws AccountingManagerServiceException
|
||||||
|
*/
|
||||||
|
public ArrayList<FilterKey> getFilterKeys(AccountingType accountingType)
|
||||||
|
throws AccountingManagerServiceException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.admin.accountingmanager.client.rpc;
|
package org.gcube.portlets.admin.accountingmanager.client.rpc;
|
||||||
|
|
||||||
|
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;
|
||||||
import org.gcube.portlets.admin.accountingmanager.shared.session.UserInfo;
|
import org.gcube.portlets.admin.accountingmanager.shared.session.UserInfo;
|
||||||
|
@ -14,8 +16,8 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi"
|
* @author "Giancarlo Panichi" <a
|
||||||
* <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>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface AccountingManagerServiceAsync {
|
public interface AccountingManagerServiceAsync {
|
||||||
|
@ -29,15 +31,25 @@ public interface AccountingManagerServiceAsync {
|
||||||
*/
|
*/
|
||||||
void hello(AsyncCallback<UserInfo> callback);
|
void hello(AsyncCallback<UserInfo> callback);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Accounting Series
|
* Retrieve Accounting Series
|
||||||
*
|
*
|
||||||
* @param accountingType the resource on which to accounting
|
* @param accountingType
|
||||||
* @param seriesRequest filters and constraints descriptions
|
* the resource on which to accounting
|
||||||
|
* @param seriesRequest
|
||||||
|
* filters and constraints descriptions
|
||||||
* @param callback
|
* @param callback
|
||||||
*/
|
*/
|
||||||
void getSeries(AccountingType accountingType, SeriesRequest seriesRequest,AsyncCallback<SeriesResponse> callback);
|
void getSeries(AccountingType accountingType, SeriesRequest seriesRequest,
|
||||||
|
AsyncCallback<SeriesResponse> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param accountingType
|
||||||
|
* accounting type
|
||||||
|
* @param callback
|
||||||
|
*/
|
||||||
|
void getFilterKeys(AccountingType accountingType,
|
||||||
|
AsyncCallback<ArrayList<FilterKey>> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package org.gcube.portlets.admin.accountingmanager.server;
|
package org.gcube.portlets.admin.accountingmanager.server;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
@ -7,6 +10,7 @@ import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerService;
|
import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerService;
|
||||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCaller;
|
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCaller;
|
||||||
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.AccountingManagerServiceException;
|
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||||
|
@ -16,14 +20,16 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The server side implementation of the RPC service.
|
* The server side implementation of the RPC service.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class AccountingManagerServiceImpl extends RemoteServiceServlet implements AccountingManagerService {
|
public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
||||||
|
implements AccountingManagerService {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory
|
||||||
|
.getLogger(AccountingManagerServiceImpl.class);
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(AccountingManagerServiceImpl.class);
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -37,14 +43,12 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet implement
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public UserInfo hello() throws AccountingManagerServiceException {
|
public UserInfo hello() throws AccountingManagerServiceException {
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
@ -70,12 +74,15 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet implement
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SeriesResponse getSeries(AccountingType accountingType, SeriesRequest seriesRequest) throws AccountingManagerServiceException {
|
public SeriesResponse getSeries(AccountingType accountingType,
|
||||||
|
SeriesRequest seriesRequest)
|
||||||
|
throws AccountingManagerServiceException {
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
SessionUtil.getAslSession(session);
|
SessionUtil.getAslSession(session);
|
||||||
AccountingCaller accountingCaller=new AccountingCaller();
|
AccountingCaller accountingCaller = new AccountingCaller();
|
||||||
SeriesResponse seriesResponse=accountingCaller.getSeries(accountingType,seriesRequest);
|
SeriesResponse seriesResponse = accountingCaller.getSeries(
|
||||||
|
accountingType, seriesRequest);
|
||||||
|
|
||||||
return seriesResponse;
|
return seriesResponse;
|
||||||
|
|
||||||
|
@ -84,12 +91,50 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet implement
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error("Hello(): " + e.getLocalizedMessage(), e);
|
logger.error("getSeries(): " + e.getLocalizedMessage(), e);
|
||||||
throw new AccountingManagerServiceException(e.getLocalizedMessage());
|
throw new AccountingManagerServiceException(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<FilterKey> getFilterKeys(AccountingType accountingType)
|
||||||
|
throws AccountingManagerServiceException {
|
||||||
|
try {
|
||||||
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
|
if (accountingType == null) {
|
||||||
|
return new ArrayList<FilterKey>();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (accountingType) {
|
||||||
|
case JOB:
|
||||||
|
return new ArrayList<FilterKey>();
|
||||||
|
case PORTLET:
|
||||||
|
return new ArrayList<FilterKey>();
|
||||||
|
case SERVICE:
|
||||||
|
return new ArrayList<FilterKey>(Arrays.asList(new FilterKey("consumerId"),
|
||||||
|
new FilterKey("host"), new FilterKey("scope"), new FilterKey("serviceName")));
|
||||||
|
|
||||||
|
case STORAGE:
|
||||||
|
return new ArrayList<FilterKey>(Arrays.asList(new FilterKey("consumerId"),
|
||||||
|
new FilterKey("dataType"), new FilterKey("scope"), new FilterKey("providerURI"), new FilterKey("resourceOwner")));
|
||||||
|
case TASK:
|
||||||
|
return new ArrayList<FilterKey>();
|
||||||
|
default:
|
||||||
|
return new ArrayList<FilterKey>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (AccountingManagerServiceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("getFilterKeys(): " + e.getLocalizedMessage(), e);
|
||||||
|
throw new AccountingManagerServiceException(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ public class AccountingCaller {
|
||||||
"Error in invocation: Operation not supported");
|
"Error in invocation: Operation not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<Info> infos = rrq.getInfo(query.getType(),
|
List<Info> infos = rrq.getInfo(query.getType(),
|
||||||
query.getTemporalConstraint(), null, true);
|
query.getTemporalConstraint(), null, true);
|
||||||
if (infos == null) {
|
if (infos == null) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.accounting.aggregation.ServiceUsageRecord;
|
import org.gcube.accounting.aggregation.AggregatedServiceUsageRecord;
|
||||||
import org.gcube.accounting.analytics.Info;
|
import org.gcube.accounting.analytics.Info;
|
||||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
|
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
|
||||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesServiceData;
|
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesServiceData;
|
||||||
|
@ -42,11 +42,11 @@ public class SeriesResponse4Service extends SeriesResponseBuilder {
|
||||||
for (Info info : infos) {
|
for (Info info : infos) {
|
||||||
Date date = info.getDate();
|
Date date = info.getDate();
|
||||||
JSONObject jso = info.getValue();
|
JSONObject jso = info.getValue();
|
||||||
Long duration = jso.getLong(ServiceUsageRecord.DURATION);
|
Long duration = jso.getLong(AggregatedServiceUsageRecord.DURATION);
|
||||||
Long operationCount = jso
|
Long operationCount = jso
|
||||||
.getLong(ServiceUsageRecord.OPERATION_COUNT);
|
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT);
|
||||||
Long maxInvocationTime = jso.getLong(ServiceUsageRecord.MAX_INVOCATION_TIME);
|
Long maxInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
|
||||||
Long minInvocationTime = jso.getLong(ServiceUsageRecord.MIN_INVOCATION_TIME);
|
Long minInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
|
||||||
|
|
||||||
series.add(new SeriesServiceData(date, operationCount, duration, maxInvocationTime, minInvocationTime));
|
series.add(new SeriesServiceData(date, operationCount, duration, maxInvocationTime, minInvocationTime));
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.accounting.aggregation.StorageUsageRecord;
|
import org.gcube.accounting.aggregation.AggregatedStorageUsageRecord;
|
||||||
import org.gcube.accounting.analytics.Info;
|
import org.gcube.accounting.analytics.Info;
|
||||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
|
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
|
||||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorageData;
|
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorageData;
|
||||||
|
@ -42,9 +42,9 @@ public class SeriesResponse4Storage extends SeriesResponseBuilder {
|
||||||
for (Info info : infos) {
|
for (Info info : infos) {
|
||||||
Date date = info.getDate();
|
Date date = info.getDate();
|
||||||
JSONObject jso = info.getValue();
|
JSONObject jso = info.getValue();
|
||||||
Long dataVolume = jso.getLong(StorageUsageRecord.DATA_VOLUME);
|
Long dataVolume = jso.getLong(AggregatedStorageUsageRecord.DATA_VOLUME);
|
||||||
Long operationCount = jso
|
Long operationCount = jso
|
||||||
.getLong(StorageUsageRecord.OPERATION_COUNT);
|
.getLong(AggregatedStorageUsageRecord.OPERATION_COUNT);
|
||||||
series.add(new SeriesStorageData(date, dataVolume, operationCount));
|
series.add(new SeriesStorageData(date, dataVolume, operationCount));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
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 AccountingFilter implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7200526591393559078L;
|
||||||
|
private FilterKey filterKey;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public AccountingFilter() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountingFilter(FilterKey filterKey, String value) {
|
||||||
|
super();
|
||||||
|
this.filterKey = filterKey;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
if (filterKey != null) {
|
||||||
|
return filterKey.getId();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterKey getFilterKey() {
|
||||||
|
return filterKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilterKey(FilterKey filterKey) {
|
||||||
|
this.filterKey = filterKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "AccountingFilter [filterKey=" + filterKey + ", value=" + value
|
||||||
|
+ "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
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 FilterKey implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7200526591393559078L;
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
|
||||||
|
public FilterKey(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterKey(String key) {
|
||||||
|
super();
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId(){
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "FilterKey [key=" + key + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
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 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,14 +16,17 @@ 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;
|
||||||
|
|
||||||
public SeriesRequest() {
|
public SeriesRequest() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SeriesRequest(AccountingPeriod accountingPeriod) {
|
public SeriesRequest(AccountingPeriod accountingPeriod,
|
||||||
|
List<AccountingFilter> filters) {
|
||||||
super();
|
super();
|
||||||
this.accountingPeriod = accountingPeriod;
|
this.accountingPeriod = accountingPeriod;
|
||||||
|
this.filters = filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountingPeriod getAccountingPeriod() {
|
public AccountingPeriod getAccountingPeriod() {
|
||||||
|
@ -32,13 +37,20 @@ public class SeriesRequest implements Serializable {
|
||||||
this.accountingPeriod = accountingPeriod;
|
this.accountingPeriod = accountingPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<AccountingFilter> getFilters() {
|
||||||
|
return filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilters(List<AccountingFilter> filters) {
|
||||||
|
this.filters = filters;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SeriesRequest [accountingPeriod=" + accountingPeriod + "]";
|
return "SeriesRequest [accountingPeriod=" + accountingPeriod
|
||||||
|
+ ", filters=" + filters + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue