Added support to NoContext in root scope

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@142588 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-02-15 19:20:23 +00:00
parent 297df7e401
commit cf8e664241
17 changed files with 357 additions and 97 deletions

View File

@ -60,6 +60,7 @@ public class AccountingManagerController {
private SimpleEventBus eventBus;
private UserInfo userInfo;
private Boolean rootScope;
private AccountingClientState accountingState;
private AccountingType accountingType;
@SuppressWarnings("unused")
@ -118,6 +119,33 @@ public class AccountingManagerController {
public void onSuccess(UserInfo result) {
userInfo = result;
Log.info("Hello: " + userInfo.getUsername());
isRootScope();
}
});
}
private void isRootScope() {
AccountingManagerServiceAsync.INSTANCE
.isRootScope(new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
Log.info("No valid user found: " + caught.getMessage());
if (caught instanceof SessionExpiredException) {
UtilsGXT3.alert("Error", "Expired Session");
sessionExpiredShowDelayed();
} else {
UtilsGXT3.alert("Error",
"Error checking the scope!");
}
}
@Override
public void onSuccess(Boolean result) {
rootScope = result;
Log.info("RootScope: " + result);
retrieveEnableTabs();
}
@ -316,7 +344,7 @@ public class AccountingManagerController {
this.accountingType = accountingType;
AccountingClientStateData accountingStateData = new AccountingClientStateData(
accountingType, seriesRequest, null, null);
accountingType, seriesRequest, null, null, null, rootScope);
accountingState.setState(accountingType, accountingStateData);
retrieveFilterKey();

View File

@ -124,16 +124,22 @@ public class ActiveFiltersPanel extends SimpleContainer {
private ToolBar toolBar;
// private CheckBox showOthers;
private FieldLabel showOthersLabel;
private FieldLabel noContextLabel;
private IntegerSpinnerField topNumber;
private FieldLabel topNumberLabel;
private FilterKey filterKey;
private boolean cancelValue;
private AccountingMonitor accountingMonitor;
private Radio showOthersYes;
private Radio showOthersNo;
private ToggleGroup showOthersToggle;
private Radio noContextYes;
private Radio noContextNo;
private ToggleGroup noContextToggle;
public interface FilterKeyPropertiesCombo extends PropertyAccess<FilterKey> {
@Path("id")
@ -435,7 +441,8 @@ public class ActiveFiltersPanel extends SimpleContainer {
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<span style='white-space: normal;' title='"
+ SafeHtmlUtils.htmlEscape(value) + "'>"
+ SafeHtmlUtils.htmlEscape(value)
+ "'>"
+ SafeHtmlUtils.htmlEscape(value) + "</span>");
}
@ -526,6 +533,38 @@ public class ActiveFiltersPanel extends SimpleContainer {
showOthersLabel = new FieldLabel(hp, "Show Others");
// TODO NoContext Flag
noContextYes = new Radio();
noContextYes.setBoxLabel("Yes");
noContextNo = new Radio();
noContextNo.setBoxLabel("No");
noContextNo.setValue(true);
noContextToggle = new ToggleGroup();
noContextToggle.add(noContextYes);
noContextToggle.add(noContextNo);
noContextToggle
.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
@Override
public void onValueChange(
ValueChangeEvent<HasValue<Boolean>> event) {
ToggleGroup group = (ToggleGroup) event.getSource();
Radio radio = (Radio) group.getValue();
Log.debug("No Context selected: " + radio.getBoxLabel());
}
});
HBoxLayoutContainer hpNoContext = new HBoxLayoutContainer();
hpNoContext.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
hpNoContext.setPack(BoxLayoutPack.START);
hpNoContext.add(noContextYes, new BoxLayoutData(new Margins(0)));
hpNoContext.add(noContextNo, new BoxLayoutData(new Margins(0)));
noContextLabel = new FieldLabel(hpNoContext, "No Context");
//
topNumber = new IntegerSpinnerField();
topNumber.setMaxValue(TOP_NUMBER_MAX);
@ -543,6 +582,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
vlc.add(comboChartTypeLabel, new VerticalLayoutData(1, -1, new Margins(
0)));
vlc.add(gridContext, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(noContextLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(comboTopFilterKeyLabel, new VerticalLayoutData(1, -1,
new Margins(0)));
vlc.add(showOthersLabel, new VerticalLayoutData(1, -1, new Margins(0)));
@ -558,6 +598,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
add(fieldSet, new MarginData(0));
gridContext.setVisible(false);
noContextLabel.setVisible(false);
comboTopFilterKeyLabel.setVisible(false);
showOthersLabel.setVisible(false);
topNumberLabel.setVisible(false);
@ -674,10 +715,36 @@ public class ActiveFiltersPanel extends SimpleContainer {
storeFilter.commitChanges();
seq = 0;
}
if (accountingStateData.getRootScope()) {
noContextToggle.reset();
if (accountingFilterBasic.isNoContext()) {
noContextYes.setValue(true);
} else {
noContextNo.setValue(true);
}
noContextLabel.setVisible(true);
} else {
noContextToggle.reset();
noContextNo.setValue(true);
noContextLabel.setVisible(false);
}
} else {
storeFilter.clear();
storeFilter.commitChanges();
seq = 0;
if (accountingStateData.getRootScope()) {
noContextToggle.reset();
noContextNo.setValue(true);
noContextLabel.setVisible(true);
} else {
noContextToggle.reset();
noContextNo.setValue(true);
noContextLabel.setVisible(false);
}
}
comboChartType.setValue(ChartType.Basic);
gridContext.setVisible(false);
@ -686,6 +753,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
showOthersToggle.reset();
showOthersNo.setValue(true);
showOthersLabel.setVisible(false);
topNumber.reset();
topNumberLabel.setVisible(false);
forceLayout();
@ -728,6 +796,9 @@ public class ActiveFiltersPanel extends SimpleContainer {
gridContext.setVisible(false);
comboTopFilterKeyLabel.setVisible(true);
showOthersLabel.setVisible(true);
noContextToggle.reset();
noContextNo.setValue(true);
noContextLabel.setVisible(false);
topNumberLabel.setVisible(true);
forceLayout();
}
@ -813,6 +884,9 @@ public class ActiveFiltersPanel extends SimpleContainer {
showOthersToggle.reset();
showOthersNo.setValue(true);
showOthersLabel.setVisible(false);
noContextToggle.reset();
noContextNo.setValue(true);
noContextLabel.setVisible(false);
topNumber.reset();
topNumberLabel.setVisible(false);
forceLayout();
@ -877,9 +951,18 @@ public class ActiveFiltersPanel extends SimpleContainer {
}
}
// TODO
private AccountingFilterDefinition getActiveFiltersForBasic() {
Boolean noContextValue = false;
if (noContextLabel != null && noContextLabel.isVisible()) {
noContextValue = noContextYes.getValue();
} else {
noContextValue = false;
}
Log.debug("noContextValue: "+noContextValue);
if (storeFilter == null || storeFilter.size() <= 0) {
return new AccountingFilterBasic();
return new AccountingFilterBasic(noContextValue);
} else {
List<AccountingFilter> filtersActives = storeFilter.getAll();
ArrayList<AccountingFilter> filtersReady = new ArrayList<AccountingFilter>();
@ -889,23 +972,25 @@ public class ActiveFiltersPanel extends SimpleContainer {
filtersReady.add(filter);
}
}
if (filtersReady.size() > 0) {
return new AccountingFilterBasic(filtersReady);
return new AccountingFilterBasic(filtersReady, noContextValue);
} else {
return new AccountingFilterBasic();
return new AccountingFilterBasic(noContextValue);
}
}
}
private AccountingFilterDefinition getActiveFiltersForTop() {
Boolean showOthersValue = showOthersYes.getValue();
Integer topN = topNumber.getCurrentValue();
FilterKey filterKey = comboTopFilterKey.getCurrentValue();
if (filterKey == null) {
return new AccountingFilterTop();
return new AccountingFilterTop(showOthersValue,topN);
} else {
Boolean showOthersValue = showOthersYes.getValue();
Integer topN = topNumber.getCurrentValue();
if (storeFilter == null || storeFilter.size() <= 0) {
return new AccountingFilterTop(filterKey, null,
showOthersValue, topN);
@ -1148,6 +1233,7 @@ public class ActiveFiltersPanel extends SimpleContainer {
});
}
// TODO
private void updateComboChartType(ChartType chartType) {
if (chartType == null) {
return;
@ -1160,6 +1246,17 @@ public class ActiveFiltersPanel extends SimpleContainer {
showOthersToggle.reset();
showOthersNo.setValue(true);
showOthersLabel.setVisible(false);
if (accountingStateData.getRootScope()) {
noContextToggle.reset();
noContextNo.setValue(true);
noContextLabel.setVisible(true);
} else {
noContextToggle.reset();
noContextNo.setValue(true);
noContextLabel.setVisible(false);
}
topNumber.reset();
topNumberLabel.setVisible(false);
storeFilter.clear();
@ -1180,6 +1277,10 @@ public class ActiveFiltersPanel extends SimpleContainer {
showOthersToggle.reset();
showOthersNo.setValue(true);
showOthersLabel.setVisible(true);
noContextToggle.reset();
noContextYes.setValue(false);
noContextNo.setValue(true);
noContextLabel.setVisible(false);
topNumber.reset();
topNumber.setValue(TOP_NUMBER_DEFAULT);
topNumberLabel.setVisible(true);
@ -1196,6 +1297,10 @@ public class ActiveFiltersPanel extends SimpleContainer {
showOthersToggle.reset();
showOthersNo.setValue(true);
showOthersLabel.setVisible(false);
noContextToggle.reset();
noContextYes.setValue(false);
noContextNo.setValue(true);
noContextLabel.setVisible(false);
topNumber.reset();
topNumberLabel.setVisible(false);
storeFilter.clear();

View File

@ -127,6 +127,13 @@ public interface AccountingManagerService extends RemoteService {
*/
public EnableTabs getEnableTabs() throws ServiceException;
/**
* Check if the user is in root scope
*
* @return
* @throws ServiceException
*/
public Boolean isRootScope() throws ServiceException;
}

View File

@ -116,6 +116,13 @@ public interface AccountingManagerServiceAsync {
* return the list of enabled tabs
*/
void getEnableTabs(AsyncCallback<EnableTabs> callback);
/**
* Check if the user is in root scope
*
* @param callback
*/
void isRootScope(AsyncCallback<Boolean> callback);
}

View File

@ -23,29 +23,38 @@ public class AccountingClientStateData implements Serializable {
private SeriesResponse seriesResponse;
private ArrayList<FilterKey> availableFilterKeys;
private Context availableContext;
private Boolean rootScope;
public AccountingClientStateData() {
super();
}
/**
*
* @param accountingType
* @param seriesRequest
* @param seriesResponse
* @param availableFilterKeys
* @param availableContext
* @param rootScope
*/
public AccountingClientStateData(AccountingType accountingType,
SeriesRequest seriesRequest, SeriesResponse seriesResponse,
ArrayList<FilterKey> availableFilterKeys) {
ArrayList<FilterKey> availableFilterKeys, Context availableContext,
Boolean rootScope) {
super();
this.accountingType = accountingType;
this.seriesRequest = seriesRequest;
this.seriesResponse = seriesResponse;
this.availableFilterKeys = availableFilterKeys;
this.availableContext = availableContext;
this.rootScope = rootScope;
}
public AccountingType getAccountingType() {
return accountingType;
}
public void setAccountingType(AccountingType accountingType) {
this.accountingType = accountingType;
}
public SeriesRequest getSeriesRequest() {
return seriesRequest;
}
@ -78,13 +87,25 @@ public class AccountingClientStateData implements Serializable {
this.availableContext = availableContext;
}
public Boolean getRootScope() {
return rootScope;
}
public void setRootScope(Boolean rootScope) {
this.rootScope = rootScope;
}
public void setAccountingType(AccountingType accountingType) {
this.accountingType = accountingType;
}
@Override
public String toString() {
return "AccountingClientStateData [accountingType=" + accountingType
+ ", seriesRequest=" + seriesRequest + ", seriesResponse="
+ seriesResponse + ", availableFilterKeys="
+ availableFilterKeys + ", availableContext="
+ availableContext + "]";
+ availableContext + ", rootScope=" + rootScope + "]";
}
}

View File

@ -33,6 +33,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceExcept
import org.gcube.portlets.admin.accountingmanager.shared.session.UserInfo;
import org.gcube.portlets.admin.accountingmanager.shared.tabs.EnableTabs;
import org.gcube.portlets.admin.accountingmanager.shared.workspace.ItemDescription;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -54,8 +55,6 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
private static Logger logger = LoggerFactory
.getLogger(AccountingManagerServiceImpl.class);
/**
* {@inheritDoc}
*/
@ -72,7 +71,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
@Override
public void destroy() {
super.destroy();
}
/**
@ -138,12 +137,13 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
String key = new String(serviceCredentials.getScope() + "_"
+ accountingType.name() + "_" + seriesRequest.toString());
logger.info("Search Accounting data in Cache with key: " + key);
ServletContext sc = getServletContext();
AccountingCache accountingCache = (AccountingCache) sc
.getAttribute(SessionConstants.ACCOUNTING_CACHE);
logger.debug("Accounting Cache retrieved in Servlet: "+accountingCache);
logger.debug("Accounting Cache retrieved in Servlet: "
+ accountingCache);
SeriesResponse seriesResponse = accountingCache.get(key);
if (seriesResponse == null) {
@ -154,8 +154,8 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
AccountingStateData accountingStateData = new AccountingStateData(
accountingType, seriesRequest, seriesResponse);
SessionUtil.setAccountingStateData(httpRequest.getSession(), serviceCredentials,
accountingType, accountingStateData);
SessionUtil.setAccountingStateData(httpRequest.getSession(),
serviceCredentials, accountingType, accountingStateData);
return seriesResponse;
} catch (ServiceException e) {
@ -180,17 +180,19 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
//HttpServletResponse httpResponse = this.getThreadLocalResponse();
// HttpServletResponse httpResponse = this.getThreadLocalResponse();
/*AsyncContext asyncContext = httpRequest.startAsync(httpRequest,
httpResponse);*/
/*
* AsyncContext asyncContext = httpRequest.startAsync(httpRequest,
* httpResponse);
*/
String operationId = UUID.randomUUID().toString();
logger.info("Accounting Task Operation Id: " + operationId);
logger.info("Session Id: "+httpRequest.getSession());
logger.info("Session Id: " + httpRequest.getSession());
TaskRequest taskRequest = new TaskRequest(operationId,
httpRequest.getSession(), serviceCredentials, accountingType,
seriesRequest);
httpRequest.getSession(), serviceCredentials,
accountingType, seriesRequest);
ServletContext appScope = httpRequest.getServletContext();
@ -222,20 +224,25 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
.getServiceCredentials(httpRequest);
HashMap<String, TaskWrapper> taskWrapperMap = SessionUtil
.getTaskWrapperMap(httpRequest.getSession(), serviceCredentials);
.getTaskWrapperMap(httpRequest.getSession(),
serviceCredentials);
if (taskWrapperMap == null) {
return null;
} else {
if (taskWrapperMap.containsKey(operationId)) {
TaskWrapper taskWrapper = taskWrapperMap.get(operationId);
if(taskWrapper.getTaskStatus()!=null){
switch(taskWrapper.getTaskStatus()){
if (taskWrapper.getTaskStatus() != null) {
switch (taskWrapper.getTaskStatus()) {
case RUNNING:
case STARTED:
return taskWrapper.getSeriesResponse();
case COMPLETED:
taskWrapperMap.remove(operationId);
return taskWrapper.getSeriesResponse();
case ERROR:
String errorMsg="OperationMonitor, Error in Task: "+taskWrapper.getErrorMessage();
taskWrapperMap.remove(operationId);
String errorMsg = "OperationMonitor, Error in Task: "
+ taskWrapper.getErrorMessage();
logger.error(errorMsg);
throw new ServiceException(errorMsg);
default:
@ -256,7 +263,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
logger.error("Operation Monitor(): " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
@ -349,6 +356,40 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
}
/**
*
* {@inheritDoc}
*/
@Override
public Boolean isRootScope() throws ServiceException {
try {
logger.debug("isRootScope()");
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(this.getThreadLocalRequest());
if (Constants.DEBUG_MODE) {
logger.debug("RootScope: "+true);
return true;
}
LiferayGroupManager groupManagement = new LiferayGroupManager();
Boolean isRoot = groupManagement.isRootVO(groupManagement
.getGroupIdFromInfrastructureScope(serviceCredentials.getScope()));
logger.debug("RootScope: "+isRoot);
return isRoot;
} catch (ServiceException e) {
e.printStackTrace();
throw e;
} catch (Throwable e) {
e.printStackTrace();
logger.error("isRoot(): " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage());
}
}
@Override
public ItemDescription saveCSVOnWorkspace(AccountingType accountingType)
throws ServiceException {
@ -359,8 +400,8 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
logger.debug("SaveDataOnWorkspace(): " + accountingType);
AccountingStateData accountingStateData = SessionUtil
.getAccountingStateData(httpRequest.getSession(), serviceCredentials,
accountingType);
.getAccountingStateData(httpRequest.getSession(),
serviceCredentials, accountingType);
if (accountingStateData == null) {
logger.error("No series present in session for thi accounting type: "
+ accountingType);

View File

@ -192,7 +192,7 @@ public class SessionUtil {
token);
}
logger.info("ServiceCredentials: " + sCredentials);
logger.debug("ServiceCredentials: " + sCredentials);
return sCredentials;
}

View File

@ -31,7 +31,7 @@ public class AccountingCache implements Serializable {
private static Logger logger = LoggerFactory
.getLogger(AccountingCache.class);
private static final String ACCOUNTING_CACHE = "AccountingCache";
private static final String ACCOUNTING_SERIES_CACHE = "AccountingSeriesCache";
private CacheManager cacheManager;
private CacheConfiguration<String, SeriesResponse> cacheConfiguration;
@ -80,7 +80,7 @@ public class AccountingCache implements Serializable {
private Cache<String, SeriesResponse> initCache() throws ServiceException {
try {
String cacheName = ACCOUNTING_CACHE;
String cacheName = ACCOUNTING_SERIES_CACHE;
// create the cache
Cache<String, SeriesResponse> cache = cacheManager.getCache(

View File

@ -24,37 +24,49 @@ import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class AccountingCommandBasic implements AccountingCommand<SeriesResponse> {
private static final Logger logger = LoggerFactory.getLogger(AccountingCommandBasic.class);
public class AccountingCommandBasic implements
AccountingCommand<SeriesResponse> {
private static final Logger logger = LoggerFactory
.getLogger(AccountingCommandBasic.class);
private AccountingQueryBasic accountingQueryBasic;
private AccountingType accountingType;
public AccountingCommandBasic(AccountingQueryBasic accountingQueryBasic, AccountingType accountingType){
this.accountingQueryBasic=accountingQueryBasic;
this.accountingType=accountingType;
public AccountingCommandBasic(AccountingQueryBasic accountingQueryBasic,
AccountingType accountingType) {
this.accountingQueryBasic = accountingQueryBasic;
this.accountingType = accountingType;
}
@Override
public SeriesResponse execute() throws ServiceException {
try {
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance();
SortedMap<Calendar, Info> sm = apq.getTimeSeries(
accountingQueryBasic.getType(),
accountingQueryBasic.getTemporalConstraint(),
accountingQueryBasic.getFilters(), true);
if (sm == null || sm.values()==null) {
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory
.getInstance();
SortedMap<Calendar, Info> sm=null;
if (accountingQueryBasic.isNoContext()) {
logger.debug("Execute NoContextTimeSeries()");
sm = apq.getNoContextTimeSeries(accountingQueryBasic.getType(),
accountingQueryBasic.getTemporalConstraint(),
accountingQueryBasic.getFilters(), true);
} else {
logger.debug("Execute TimeSeries()");
sm = apq.getTimeSeries(
accountingQueryBasic.getType(),
accountingQueryBasic.getTemporalConstraint(),
accountingQueryBasic.getFilters(), true);
}
if (sm == null || sm.values() == null) {
throw new ServiceException(
"Error retrieving info: sorted map is null!");
}
List<Info> infos = new ArrayList<>(sm.values());
logger.debug("Retrieved Infos");
logger.debug("Infos: " + infos);
@ -70,25 +82,24 @@ public class AccountingCommandBasic implements AccountingCommand<SeriesResponse>
.getSeriesResponse();
if (seriesResponse == null) {
throw new ServiceException(
"Error creating series response!");
throw new ServiceException("Error creating series response!");
}
logger.debug("SeriesResponse Created: " + seriesResponse);
return seriesResponse;
} catch (Throwable e) {
logger.error("Error in AccountingCommandBasic(): " + e.getLocalizedMessage());
logger.error("Error in AccountingCommandBasic(): "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException("No data available!");
}
}
private SeriesResponseBuilder getSeriesResponseBuilder(
AccountingType accountingType, List<Info> infos)
throws ServiceException {
if (accountingType == null) {
throw new ServiceException(
"Error accounting type is null");
throw new ServiceException("Error accounting type is null");
}
switch (accountingType) {
@ -103,11 +114,9 @@ public class AccountingCommandBasic implements AccountingCommand<SeriesResponse>
case TASK:
return new SeriesResponse4TaskBasic(infos);
default:
throw new ServiceException(
"Error request type is unknow!");
throw new ServiceException("Error request type is unknow!");
}
}
}

View File

@ -88,7 +88,7 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
}
invocation = new AccountingQueryBasic(
AggregatedJobUsageRecord.class, temporalConstraint,
filters);
filters, accountingFilterBasic.isNoContext());
} else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {

View File

@ -87,7 +87,7 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
}
invocation = new AccountingQueryBasic(
AggregatedPortletUsageRecord.class, temporalConstraint,
filters);
filters,accountingFilterBasic.isNoContext());
} else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {

View File

@ -88,7 +88,7 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
}
invocation = new AccountingQueryBasic(
AggregatedServiceUsageRecord.class, temporalConstraint,
filters);
filters, accountingFilterBasic.isNoContext());
} else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {

View File

@ -88,7 +88,7 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
}
invocation = new AccountingQueryBasic(
AggregatedStorageUsageRecord.class, temporalConstraint,
filters);
filters,accountingFilterBasic.isNoContext());
} else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {

View File

@ -87,7 +87,7 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
}
invocation = new AccountingQueryBasic(
AggregatedTaskUsageRecord.class, temporalConstraint,
filters);
filters, accountingFilterBasic.isNoContext());
} else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {

View File

@ -7,8 +7,6 @@ import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
/**
*
* @author giancarlo email: <a
@ -16,25 +14,28 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
*
*/
public class AccountingQueryBasic extends AccountingQuery {
private Class<? extends AggregatedUsageRecord<?,?>> type;
private Class<? extends AggregatedUsageRecord<?, ?>> type;
private TemporalConstraint temporalConstraint;
private ArrayList<Filter> filters;
private boolean noContext;
public AccountingQueryBasic(Class<? extends AggregatedUsageRecord<?,?>> type,
TemporalConstraint temporalConstraint, ArrayList<Filter> filters) {
public AccountingQueryBasic(
Class<? extends AggregatedUsageRecord<?, ?>> type,
TemporalConstraint temporalConstraint, ArrayList<Filter> filters,
boolean noContext) {
super();
chartType=ChartType.Basic;
chartType = ChartType.Basic;
this.type = type;
this.temporalConstraint = temporalConstraint;
this.filters = filters;
this.noContext = noContext;
}
public Class<? extends AggregatedUsageRecord<?,?>> getType() {
public Class<? extends AggregatedUsageRecord<?, ?>> getType() {
return type;
}
public void setType(Class<? extends AggregatedUsageRecord<?,?>> type) {
public void setType(Class<? extends AggregatedUsageRecord<?, ?>> type) {
this.type = type;
}
@ -54,11 +55,21 @@ public class AccountingQueryBasic extends AccountingQuery {
this.filters = filters;
}
public boolean isNoContext() {
return noContext;
}
public void setNoContext(boolean noContext) {
this.noContext = noContext;
}
@Override
public String toString() {
return "AccountingQueryBasic [type=" + type + ", temporalConstraint="
+ temporalConstraint + ", filters=" + filters + "]";
+ temporalConstraint + ", filters=" + filters + ", noContext="
+ noContext + "]";
}
}

View File

@ -9,22 +9,35 @@ import java.util.ArrayList;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class AccountingFilterBasic extends AccountingFilterDefinition implements Serializable {
public class AccountingFilterBasic extends AccountingFilterDefinition implements
Serializable {
private static final long serialVersionUID = -6805006183397381154L;
ArrayList<AccountingFilter> filters;
private ArrayList<AccountingFilter> filters;
private Boolean noContext;
public AccountingFilterBasic() {
super();
this.chartType=ChartType.Basic;
filters=null;
super();
this.chartType = ChartType.Basic;
noContext = false;
filters = null;
}
public AccountingFilterBasic(boolean noContenxt) {
super();
chartType = ChartType.Basic;
this.filters = null;
this.noContext = noContenxt;
}
public AccountingFilterBasic(ArrayList<AccountingFilter> filters) {
public AccountingFilterBasic(ArrayList<AccountingFilter> filters,
boolean noContenxt) {
super();
chartType = ChartType.Basic;
this.filters = filters;
this.noContext = noContenxt;
}
public ArrayList<AccountingFilter> getFilters() {
@ -35,11 +48,18 @@ public class AccountingFilterBasic extends AccountingFilterDefinition implements
this.filters = filters;
}
@Override
public String toString() {
return "AccountingFilterBasic [filters=" + filters + "]";
public boolean isNoContext() {
return noContext;
}
public void setNoContext(Boolean noContext) {
this.noContext = noContext;
}
@Override
public String toString() {
return "AccountingFilterBasic [filters=" + filters + ", noContext="
+ noContext + "]";
}
}

View File

@ -27,6 +27,17 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements
filters = null;
}
public AccountingFilterTop(Boolean showOthers,Integer topNumber) {
super();
this.chartType = ChartType.Top;
this.showOthers = showOthers;
this.topNumber = topNumber;
filterKey = null;
filters = null;
}
public AccountingFilterTop(FilterKey filterKey,
ArrayList<AccountingFilter> filters, Boolean showOthers,