69: Create new Accounting Portlet

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

Updated to support filter keys from service

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@118936 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-09-09 13:42:00 +00:00
parent 303f43218c
commit 0ff30d417f
3 changed files with 57 additions and 32 deletions

View File

@ -44,7 +44,8 @@ public class CarouselPanel extends FramedPanel {
private Vector2D startPosition;
private Vector2D currentPosition;
private Vector2D endPosition;
private Vector2D displacement;
@SuppressWarnings("unused")
private Vector2D displacement;
public CarouselPanel() {
init();

View File

@ -116,37 +116,11 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
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("calledMethod"),
new FilterKey("callerHost"), new FilterKey("host"),
new FilterKey("operationResult"),
new FilterKey("scope"), new FilterKey("serviceClass"),
new FilterKey("serviceName")));
case STORAGE:
return new ArrayList<FilterKey>(Arrays.asList(new FilterKey(
"consumerId"), new FilterKey("dataType"),
new FilterKey("operationResult"), new FilterKey(
"operationType"), new FilterKey("providerURI"),
new FilterKey("resourceOwner"), new FilterKey(
"resourceScope"), new FilterKey("resourceURI"),
new FilterKey("scope")));
case TASK:
return new ArrayList<FilterKey>();
default:
return new ArrayList<FilterKey>();
}
AccountingCaller accountingCaller = new AccountingCaller();
ArrayList<FilterKey> filterKeys = accountingCaller.getFilterKeys(accountingType);
return filterKeys;
} catch (AccountingManagerServiceException e) {
e.printStackTrace();
throw e;

View File

@ -1,10 +1,13 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import org.gcube.accounting.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.aggregation.AggregatedStorageUsageRecord;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.ResourceRecordQuery;
import org.gcube.accounting.analytics.TemporalConstraint;
@ -24,6 +27,7 @@ import org.gcube.portlets.admin.accountingmanager.server.amservice.response.Seri
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponseBuilder;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponseDirector;
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.response.SeriesResponse;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
@ -43,7 +47,53 @@ public class AccountingCaller {
public AccountingCaller() {
}
public ArrayList<FilterKey> getFilterKeys(AccountingType accountingType)
throws AccountingManagerServiceException {
try {
logger.debug("getFilterKeys(): [AccountingType=" + accountingType+"]");
if(accountingType==null){
return new ArrayList<FilterKey>();
}
ArrayList<FilterKey> filterKeys=new ArrayList<FilterKey>();
List<String> keys;
ResourceRecordQuery rrq = new ResourceRecordQuery();
switch(accountingType){
case JOB:
//keys=rrq.getKeys(AggregatedJobUsageRecord.class);
return filterKeys;
case PORTLET:
//keys=rrq.getKeys(AggregatedPortletUsageRecord.class);
return filterKeys;
case SERVICE:
keys=rrq.getKeys(AggregatedServiceUsageRecord.class);
break;
case STORAGE:
keys=rrq.getKeys(AggregatedStorageUsageRecord.class);
break;
case TASK:
//keys=rrq.getKeys(AggregatedTaskUsageRecord.class);
return filterKeys;
default:
return filterKeys;
}
for(String key:keys){
if(key!=null&& !key.isEmpty()){
filterKeys.add(new FilterKey(key));
}
}
return filterKeys;
} catch (Throwable e) {
logger.error("Error in getFilterKeys(): " + e.getLocalizedMessage());
e.printStackTrace();
throw new AccountingManagerServiceException("No keys available!");
}
}
public SeriesResponse getSeries(AccountingType accountingType,
SeriesRequest seriesRequest)
throws AccountingManagerServiceException {