From 88c8e22ecb2a720da8f81b42913289b9d9e2c180 Mon Sep 17 00:00:00 2001 From: "giancarlo.panichi" Date: Tue, 8 Nov 2016 14:29:04 +0000 Subject: [PATCH] Added support for Context git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@133956 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../maindata/charts/AccountingChart4Job.java | 2 - .../storage/StorageChartBasicPanel.java | 8 ++ .../client/rpc/AccountingManagerService.java | 9 ++ .../rpc/AccountingManagerServiceAsync.java | 24 ++-- .../server/AccountingManagerServiceImpl.java | 30 +++++ .../accountingmanager/server/SessionUtil.java | 64 +++++++++ .../server/amservice/AccountingCaller.java | 8 ++ .../command/AccountingCommandContext.java | 126 ++++++++++++++++++ .../command/AccountingCommandTop.java | 2 +- .../amservice/query/AccountingQuery4Job.java | 26 +++- .../query/AccountingQuery4Portlet.java | 26 +++- .../query/AccountingQuery4Service.java | 27 +++- .../query/AccountingQuery4Storage.java | 26 +++- .../amservice/query/AccountingQuery4Task.java | 27 +++- .../query/AccountingQueryContext.java | 73 ++++++++++ .../response/SeriesResponse4JobBasic.java | 2 - .../response/SeriesResponse4JobContext.java | 91 +++++++++++++ .../response/SeriesResponse4JobTop.java | 5 - .../SeriesResponse4PortletContext.java | 89 +++++++++++++ .../SeriesResponse4ServiceContext.java | 92 +++++++++++++ .../SeriesResponse4StorageContext.java | 85 ++++++++++++ .../response/SeriesResponse4TaskContext.java | 88 ++++++++++++ .../shared/data/AccountingFilterContext.java | 58 ++++++++ .../shared/data/ChartType.java | 2 +- .../shared/data/Context.java | 39 ++++++ .../data/response/job/SeriesJobContext.java | 57 ++++++++ .../response/job/SeriesJobDataContext.java | 50 +++++++ .../portlet/SeriesPortletContext.java | 57 ++++++++ .../portlet/SeriesPortletDataContext.java | 51 +++++++ .../service/SeriesServiceContext.java | 58 ++++++++ .../service/SeriesServiceDataContext.java | 51 +++++++ .../storage/SeriesStorageContext.java | 59 ++++++++ .../storage/SeriesStorageDataContext.java | 51 +++++++ .../data/response/task/SeriesTaskContext.java | 58 ++++++++ .../response/task/SeriesTaskDataContext.java | 51 +++++++ 35 files changed, 1538 insertions(+), 34 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4PortletContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4TaskContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/Context.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/job/SeriesJobContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/job/SeriesJobDataContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/portlet/SeriesPortletContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/portlet/SeriesPortletDataContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/service/SeriesServiceContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/service/SeriesServiceDataContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/storage/SeriesStorageContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/storage/SeriesStorageDataContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/task/SeriesTaskContext.java create mode 100644 src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/task/SeriesTaskDataContext.java diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Job.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Job.java index 1266f21..53a77eb 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Job.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/AccountingChart4Job.java @@ -2,8 +2,6 @@ package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartBasicPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartTopPanel; -import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartBasicPanel; -import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartTopPanel; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException; diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/storage/StorageChartBasicPanel.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/storage/StorageChartBasicPanel.java index 8d39f04..c94c735 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/storage/StorageChartBasicPanel.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/maindata/charts/storage/StorageChartBasicPanel.java @@ -495,6 +495,14 @@ public class StorageChartBasicPanel extends SimpleContainer { seriesOperationCount.pointInterval(interval).pointStart( dateStart.getTime()); + /*seriesOperationCount.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent clickEvent) { + clickEvent.series().xAxis(). + clickEvent.series().name() + } + });*/ ArrayNumber dataDataVolume = seriesDataVolume.dataAsArrayNumber(); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/rpc/AccountingManagerService.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/rpc/AccountingManagerService.java index b12ae6b..38cec55 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/rpc/AccountingManagerService.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/rpc/AccountingManagerService.java @@ -3,6 +3,7 @@ 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.Context; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest; @@ -66,6 +67,14 @@ public interface AccountingManagerService extends RemoteService { public ArrayList getFilterValues( FilterValuesRequest filterValuesRequest) throws ServiceException; + /** + * + * + * @return + * @throws ServiceException + */ + public Context getContext() throws ServiceException; + /** * * @param itemDescription diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/rpc/AccountingManagerServiceAsync.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/rpc/AccountingManagerServiceAsync.java index ee6f74a..3c5a476 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/rpc/AccountingManagerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/rpc/AccountingManagerServiceAsync.java @@ -6,6 +6,7 @@ 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.Context; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest; @@ -58,20 +59,28 @@ public interface AccountingManagerServiceAsync { /** * - * @param filterValuesRequest request values available + * @param filterValuesRequest + * request values available * @param callback */ void getFilterValues(FilterValuesRequest filterValuesRequest, AsyncCallback> callback); - + /** * - * @param itemDescription item description + * @param callback + */ + void getContext(AsyncCallback callback); + + /** + * + * @param itemDescription + * item description * @param callback */ void getPublicLink(ItemDescription itemDescription, AsyncCallback callback); - + /** * * @param accountingStateData @@ -79,13 +88,12 @@ public interface AccountingManagerServiceAsync { */ void saveCSVOnWorkspace(AccountingType accountingType, AsyncCallback callback); - - + /** * - * @param callback return the list of enabled tabs + * @param callback + * return the list of enabled tabs */ void getEnableTabs(AsyncCallback callback); - } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/AccountingManagerServiceImpl.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/AccountingManagerServiceImpl.java index ba3278d..ec87612 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/AccountingManagerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/AccountingManagerServiceImpl.java @@ -16,6 +16,7 @@ import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateDa import org.gcube.portlets.admin.accountingmanager.server.storage.StorageUtil; import org.gcube.portlets.admin.accountingmanager.shared.Constants; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest; @@ -216,6 +217,35 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet } } + + /** + * + * {@inheritDoc} + */ + @Override + public Context getContext() throws ServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + ASLSession aslSession = SessionUtil.getASLSession(session); + String token = SessionUtil.getToken(aslSession); + logger.debug("UserToken: " + token); + + Context context=SessionUtil.getContext(aslSession); + logger.debug("getContext(): "+context); + + return context; + + } catch (ServiceException e) { + e.printStackTrace(); + throw e; + } catch (Throwable e) { + e.printStackTrace(); + logger.error("getContext(): " + e.getLocalizedMessage(), e); + throw new ServiceException(e.getLocalizedMessage()); + } + + } + @Override public ItemDescription saveCSVOnWorkspace(AccountingType accountingType) diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/SessionUtil.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/SessionUtil.java index e137ee2..05b303f 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/SessionUtil.java @@ -3,6 +3,9 @@ */ package org.gcube.portlets.admin.accountingmanager.server; +import java.util.ArrayList; +import java.util.List; + import javax.servlet.http.HttpSession; import org.gcube.application.framework.core.session.ASLSession; @@ -12,8 +15,12 @@ import org.gcube.portlets.admin.accountingmanager.server.state.AccountingState; import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.shared.Constants; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpiredException; +import org.gcube.vomanagement.usermanagement.GroupManager; +import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; +import org.gcube.vomanagement.usermanagement.model.GCubeGroup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -104,4 +111,61 @@ public class SessionUtil { } } + public static Context getContext(ASLSession aslSession) throws ServiceException { + + try { + logger.info("Current context is " + aslSession.getScope()); + ArrayList contexts = new ArrayList<>(); + contexts.add(aslSession.getScope()); + + GroupManager gm = new LiferayGroupManager(); + long currentGroupId = gm + .getGroupIdFromInfrastructureScope(aslSession.getScope()); + GCubeGroup currentGroup = gm.getGroup(currentGroupId); + + // three cases + if (gm.isVRE(currentGroupId)) { + + // do nothing + + } else if (gm.isVO(currentGroupId)) { + + // iterate over its vres + List children = currentGroup.getChildren(); + for (GCubeGroup gCubeGroup : children) { + contexts.add(gm.getInfrastructureScope(gCubeGroup + .getGroupId())); + } + + } else { + + // is root + List children = currentGroup.getChildren(); + for (GCubeGroup gCubeGroup : children) { + contexts.add(gm.getInfrastructureScope(gCubeGroup + .getGroupId())); + + // get the vo children + List childrenVO = gCubeGroup.getChildren(); + for (GCubeGroup voChildren : childrenVO) { + contexts.add(gm.getInfrastructureScope(voChildren + .getGroupId())); + } + } + + } + + // add the current scope too + Context context=new Context(contexts); + + + return context; + + } catch (Exception e) { + logger.error("Error retrieving context!", e); + throw new ServiceException("Error retrieving context!", e); + } + + } + } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java index dd118c6..9f0b0e1 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java @@ -3,6 +3,7 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice; import java.util.ArrayList; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandBasic; +import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandContext; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetFilterKeys; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetFilterValues; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandTop; @@ -14,6 +15,7 @@ import org.gcube.portlets.admin.accountingmanager.server.amservice.query.Account import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Task; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryBasic; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryBuilder; +import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryContext; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryDirector; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryTop; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; @@ -52,6 +54,8 @@ public class AccountingCaller implements AccountingCallerInterface { return accountingCommand.execute(); } + + public SeriesResponse getSeries(AccountingType accountingType, SeriesRequest seriesRequest) @@ -84,6 +88,10 @@ public class AccountingCaller implements AccountingCallerInterface { AccountingQueryTop accountingQueryTop = (AccountingQueryTop) query; AccountingCommandTop accountingCommandTop=new AccountingCommandTop(accountingQueryTop,accountingType); return accountingCommandTop.execute(); + case Context: + AccountingQueryContext accountingQueryContext = (AccountingQueryContext) query; + AccountingCommandContext accountingCommandContext=new AccountingCommandContext(accountingQueryContext,accountingType); + return accountingCommandContext.execute(); default: throw new ServiceException( "Error in invocation: Operation not supported"); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandContext.java new file mode 100644 index 0000000..e0d0da2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandContext.java @@ -0,0 +1,126 @@ +package org.gcube.portlets.admin.accountingmanager.server.amservice.command; + +import java.util.Calendar; +import java.util.SortedMap; + +import org.gcube.accounting.analytics.Filter; +import org.gcube.accounting.analytics.Info; +import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery; +import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory; +import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryContext; +import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4JobContext; +import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4PortletContext; +import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4ServiceContext; +import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4StorageContext; +import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4TaskContext; +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.Context; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; +import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class AccountingCommandContext implements AccountingCommand { + private static final Logger logger = LoggerFactory + .getLogger(AccountingCommandContext.class); + + private AccountingQueryContext accountingQueryContext; + private AccountingType accountingType; + + public AccountingCommandContext(AccountingQueryContext accountingQueryContext, + AccountingType accountingType) { + this.accountingQueryContext = accountingQueryContext; + this.accountingType = accountingType; + } + + @Override + public SeriesResponse execute() throws ServiceException { + try { + AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory + .getInstance(); + + logger.debug("Query Context: " + + accountingQueryContext.getContext()); + + SortedMap> contextSM; + + Context context=accountingQueryContext.getContext(); + + if(context==null){ + throw new ServiceException( + "Error retrieving context param: null!"); + } + + contextSM= apq.getContextTimeSeries(accountingQueryContext.getType(), + accountingQueryContext.getTemporalConstraint(), + accountingQueryContext.getFilters(), + context.getContexts(), + true); + + + if (contextSM == null) { + throw new ServiceException( + "Error retrieving info for context: sorted map is null!"); + } + + logger.debug("ContextSM: " + contextSM); + + SeriesResponseBuilder seriesResponseBuilder = getSeriesResponseBuilder( + accountingType, context, contextSM); + + SeriesResponseDirector seriesResponseDirector = new SeriesResponseDirector(); + seriesResponseDirector + .setSeriesResponseBuilder(seriesResponseBuilder); + seriesResponseDirector.constructSeriesResponse(); + SeriesResponse seriesResponse = seriesResponseDirector + .getSeriesResponse(); + + if (seriesResponse == null) { + throw new ServiceException("Error creating series response!"); + } + logger.debug("SeriesResponse Created: " + seriesResponse); + return seriesResponse; + + } catch (Throwable e) { + logger.error("Error in AccountingCommandTop(): " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw new ServiceException("No data available!"); + + } + } + + private SeriesResponseBuilder getSeriesResponseBuilder( + AccountingType accountingType, Context context, + SortedMap> contextSM) + throws ServiceException { + if (accountingType == null) { + throw new ServiceException("Error accounting type is null"); + } + + switch (accountingType) { + case JOB: + return new SeriesResponse4JobContext(context,contextSM); + case PORTLET: + return new SeriesResponse4PortletContext(context, contextSM); + case SERVICE: + return new SeriesResponse4ServiceContext(context, contextSM); + case STORAGE: + return new SeriesResponse4StorageContext(context, contextSM); + case TASK: + return new SeriesResponse4TaskContext(context, contextSM); + default: + throw new ServiceException("Error request type is unknow!"); + + } + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandTop.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandTop.java index 621e265..3494b22 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandTop.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandTop.java @@ -46,7 +46,7 @@ public class AccountingCommandTop implements AccountingCommand { AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory .getInstance(); - logger.debug("Qyery TopValues: " + logger.debug("Query TopValues: " + accountingQueryTop.getFilterKey().getKey()); SortedMap> topSM; diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Job.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Job.java index ea8b56b..0b8483a 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Job.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Job.java @@ -11,6 +11,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; 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.AccountingFilterBasic; +import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -110,9 +111,28 @@ public class AccountingQuery4Job extends AccountingQueryBuilder { accountingFilterTop.getTopNumber(), temporalConstraint, filters); } else { - logger.error("Invalid Request: " + seriesRequest); - throw new ServiceException( - "Invalid Request!"); + if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { + AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest + .getAccountingFilterDefinition(); + accountingFilters = accountingFilterContext.getFilters(); + filters = new ArrayList(); + if (accountingFilters != null) { + for (AccountingFilter accountigFilters : accountingFilters) { + Filter filter = new Filter(accountigFilters + .getFilterKey().getKey(), + accountigFilters.getFilterValue()); + filters.add(filter); + } + } + invocation = new AccountingQueryContext( + AggregatedJobUsageRecord.class, + accountingFilterContext.getContexts(), + temporalConstraint, filters); + } else { + logger.error("Invalid Request: " + seriesRequest); + throw new ServiceException( + "Invalid Request!"); + } } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Portlet.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Portlet.java index ff8a887..01264a4 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Portlet.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Portlet.java @@ -11,6 +11,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedPortletUsageRecord; 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.AccountingFilterBasic; +import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -109,9 +110,28 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder { accountingFilterTop.getTopNumber(), temporalConstraint, filters); } else { - logger.error("Invalid Request: " + seriesRequest); - throw new ServiceException( - "Invalid Request!"); + if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { + AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest + .getAccountingFilterDefinition(); + accountingFilters = accountingFilterContext.getFilters(); + filters = new ArrayList(); + if (accountingFilters != null) { + for (AccountingFilter accountigFilters : accountingFilters) { + Filter filter = new Filter(accountigFilters + .getFilterKey().getKey(), + accountigFilters.getFilterValue()); + filters.add(filter); + } + } + invocation = new AccountingQueryContext( + AggregatedPortletUsageRecord.class, + accountingFilterContext.getContexts(), + temporalConstraint, filters); + } else { + logger.error("Invalid Request: " + seriesRequest); + throw new ServiceException( + "Invalid Request!"); + } } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Service.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Service.java index 67c158f..c6762c6 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Service.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Service.java @@ -11,6 +11,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; 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.AccountingFilterBasic; +import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -110,9 +111,29 @@ public class AccountingQuery4Service extends AccountingQueryBuilder { accountingFilterTop.getTopNumber(), temporalConstraint, filters); } else { - logger.error("Invalid Request: " + seriesRequest); - throw new ServiceException( - "Invalid Request!"); + if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { + AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest + .getAccountingFilterDefinition(); + accountingFilters = accountingFilterContext.getFilters(); + filters = new ArrayList(); + if (accountingFilters != null) { + for (AccountingFilter accountigFilters : accountingFilters) { + Filter filter = new Filter(accountigFilters + .getFilterKey().getKey(), + accountigFilters.getFilterValue()); + filters.add(filter); + } + } + invocation = new AccountingQueryContext( + AggregatedServiceUsageRecord.class, + accountingFilterContext.getContexts(), + temporalConstraint, filters); + } else { + logger.error("Invalid Request: " + seriesRequest); + throw new ServiceException( + "Invalid Request!"); + } + } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Storage.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Storage.java index d4d0947..4756c7b 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Storage.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Storage.java @@ -11,6 +11,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; 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.AccountingFilterBasic; +import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -110,9 +111,28 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder { accountingFilterTop.getTopNumber(), temporalConstraint, filters); } else { - logger.error("Invalid Request: " + seriesRequest); - throw new ServiceException( - "Invalid Request!"); + if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { + AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest + .getAccountingFilterDefinition(); + accountingFilters = accountingFilterContext.getFilters(); + filters = new ArrayList(); + if (accountingFilters != null) { + for (AccountingFilter accountigFilters : accountingFilters) { + Filter filter = new Filter(accountigFilters + .getFilterKey().getKey(), + accountigFilters.getFilterValue()); + filters.add(filter); + } + } + invocation = new AccountingQueryContext( + AggregatedStorageUsageRecord.class, + accountingFilterContext.getContexts(), + temporalConstraint, filters); + } else { + logger.error("Invalid Request: " + seriesRequest); + throw new ServiceException( + "Invalid Request!"); + } } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Task.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Task.java index e41d7d5..04ffbf6 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Task.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQuery4Task.java @@ -11,6 +11,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedTaskUsageRecord; 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.AccountingFilterBasic; +import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; @@ -109,9 +110,29 @@ public class AccountingQuery4Task extends AccountingQueryBuilder { accountingFilterTop.getTopNumber(), temporalConstraint, filters); } else { - logger.error("Invalid Request: " + seriesRequest); - throw new ServiceException( - "Invalid Request!"); + if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { + AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest + .getAccountingFilterDefinition(); + accountingFilters = accountingFilterContext.getFilters(); + filters = new ArrayList(); + if (accountingFilters != null) { + for (AccountingFilter accountigFilters : accountingFilters) { + Filter filter = new Filter(accountigFilters + .getFilterKey().getKey(), + accountigFilters.getFilterValue()); + filters.add(filter); + } + } + invocation = new AccountingQueryContext( + AggregatedTaskUsageRecord.class, + accountingFilterContext.getContexts(), + temporalConstraint, + filters); + } else { + logger.error("Invalid Request: " + seriesRequest); + throw new ServiceException( + "Invalid Request!"); + } } } diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryContext.java new file mode 100644 index 0000000..91fae1e --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/query/AccountingQueryContext.java @@ -0,0 +1,73 @@ +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.datamodel.AggregatedUsageRecord; +import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; + +/** + * + * @author giancarlo email: g.panichi@isti.cnr.it + * + */ +public class AccountingQueryContext extends AccountingQuery { + private Class> type; + private Context context; + private TemporalConstraint temporalConstraint; + private ArrayList filters; + + public AccountingQueryContext( + Class> type, Context context, + TemporalConstraint temporalConstraint, ArrayList filters) { + super(); + chartType = ChartType.Context; + this.type = type; + this.temporalConstraint = temporalConstraint; + this.filters = filters; + this.context = context; + } + + public Class> getType() { + return type; + } + + public void setType(Class> type) { + this.type = type; + } + + public TemporalConstraint getTemporalConstraint() { + return temporalConstraint; + } + + public void setTemporalConstraint(TemporalConstraint temporalConstraint) { + this.temporalConstraint = temporalConstraint; + } + + public ArrayList getFilters() { + return filters; + } + + public void setFilters(ArrayList filters) { + this.filters = filters; + } + + public Context getContext() { + return context; + } + + public void setContext(Context context) { + this.context = context; + } + + @Override + public String toString() { + return "AccountingQueryContext [type=" + type + ", context=" + context + + ", temporalConstraint=" + temporalConstraint + ", filters=" + + filters + "]"; + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobBasic.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobBasic.java index 3058031..7164bf3 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobBasic.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobBasic.java @@ -5,11 +5,9 @@ import java.util.List; import org.gcube.accounting.analytics.Info; import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; -import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.json.JSONObject; import org.slf4j.Logger; diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobContext.java new file mode 100644 index 0000000..9560ff8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobContext.java @@ -0,0 +1,91 @@ +package org.gcube.portlets.admin.accountingmanager.server.amservice.response; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.SortedMap; + +import org.gcube.accounting.analytics.Filter; +import org.gcube.accounting.analytics.Info; +import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobContext; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataContext; +import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Context Series Response 4 Job + * + * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it + * + */ +public class SeriesResponse4JobContext extends SeriesResponseBuilder { + protected static Logger logger = LoggerFactory + .getLogger(SeriesResponse4JobContext.class); + private Context context; + private SortedMap> contextSM; + + public SeriesResponse4JobContext(Context context, + SortedMap> contextSM) { + this.context=context; + this.contextSM = contextSM; + } + + @Override + public void buildSeriesResponse() throws ServiceException { + try { + if (contextSM == null || contextSM.isEmpty()) { + logger.error("Error creating series for job accounting: No data available!"); + throw new ServiceException("No data available!"); + } + + ArrayList seriesJobDataContextList = new ArrayList<>(); + + for (Filter contextValue : contextSM.keySet()) { + + ArrayList series = new ArrayList<>(); + SortedMap infos = contextSM.get(contextValue); + for (Info info : infos.values()) { + JSONObject jso = info.getValue(); + Long duration = jso + .getLong(AggregatedServiceUsageRecord.DURATION); + Long operationCount = jso + .getLong(AggregatedServiceUsageRecord.OPERATION_COUNT); + Long maxInvocationTime = jso + .getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); + Long minInvocationTime = jso + .getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); + + series.add(new SeriesJobData(info.getCalendar().getTime(), + operationCount, duration, maxInvocationTime, + minInvocationTime)); + + } + SeriesJobDataContext seriesJobDataContext = new SeriesJobDataContext( + contextValue.getValue(), series); + seriesJobDataContextList.add(seriesJobDataContext); + + } + + SeriesJobContext seriesJobContext = new SeriesJobContext(context, + seriesJobDataContextList); + SeriesJob seriesService = new SeriesJob(seriesJobContext); + + seriesResponseSpec.setSr(seriesService); + + } catch (Throwable e) { + logger.error("Error creating series for job accounting context chart: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw new ServiceException( + "Error creating series for job accounting context chart: " + + e.getLocalizedMessage()); + } + + } +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobTop.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobTop.java index 872e7f1..1c65e83 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobTop.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4JobTop.java @@ -6,17 +6,12 @@ import java.util.SortedMap; import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.NumberedFilter; -import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop; -import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.json.JSONObject; import org.slf4j.Logger; diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4PortletContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4PortletContext.java new file mode 100644 index 0000000..dc110f0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4PortletContext.java @@ -0,0 +1,89 @@ +package org.gcube.portlets.admin.accountingmanager.server.amservice.response; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.SortedMap; + +import org.gcube.accounting.analytics.Filter; +import org.gcube.accounting.analytics.Info; +import org.gcube.accounting.datamodel.aggregation.AggregatedPortletUsageRecord; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesPortlet; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletContext; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletData; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletDataContext; +import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Context Series Response 4 Portlet + * + * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it + * + */ +public class SeriesResponse4PortletContext extends SeriesResponseBuilder { + protected static Logger logger = LoggerFactory + .getLogger(SeriesResponse4PortletContext.class); + private Context context; + private SortedMap> contextSM; + + public SeriesResponse4PortletContext(Context context, + SortedMap> contextSM) { + this.context = context; + this.contextSM = contextSM; + } + + @Override + public void buildSeriesResponse() throws ServiceException { + try { + if (contextSM == null || contextSM.isEmpty()) { + logger.error("Error creating series for portlet accounting: No data available!"); + throw new ServiceException("No data available!"); + } + + ArrayList seriesPortletDataContextList = new ArrayList<>(); + + for (Filter contextValue : contextSM.keySet()) { + + ArrayList series = new ArrayList<>(); + SortedMap infos = contextSM.get(contextValue); + for (Info info : infos.values()) { + JSONObject jso = info.getValue(); + // Long duration = + // jso.getLong(AggregatedPortletUsageRecord.DURATION); + Long operationCount = jso + .getLong(AggregatedPortletUsageRecord.OPERATION_COUNT); + // Long maxInvocationTime = + // jso.getLong(AggregatedPortletUsageRecord.MAX_INVOCATION_TIME); + // Long minInvocationTime = + // jso.getLong(AggregatedPortletUsageRecord.MIN_INVOCATION_TIME); + + series.add(new SeriesPortletData(info.getCalendar() + .getTime(), operationCount)); + } + SeriesPortletDataContext seriesPortletDataContext = new SeriesPortletDataContext( + contextValue.getValue(), series); + seriesPortletDataContextList.add(seriesPortletDataContext); + + } + + SeriesPortletContext seriesPortletContext = new SeriesPortletContext( + context, seriesPortletDataContextList); + SeriesPortlet seriesPortlet = new SeriesPortlet( + seriesPortletContext); + + seriesResponseSpec.setSr(seriesPortlet); + + } catch (Throwable e) { + logger.error("Error creating series for portlet accounting context chart: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw new ServiceException( + "Error creating series for portlet accounting context chart: " + + e.getLocalizedMessage()); + } + } +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceContext.java new file mode 100644 index 0000000..e738425 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4ServiceContext.java @@ -0,0 +1,92 @@ +package org.gcube.portlets.admin.accountingmanager.server.amservice.response; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.SortedMap; + +import org.gcube.accounting.analytics.Filter; +import org.gcube.accounting.analytics.Info; +import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceContext; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataContext; +import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Context Series Response 4 Service + * + * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it + * + */ +public class SeriesResponse4ServiceContext extends SeriesResponseBuilder { + protected static Logger logger = LoggerFactory + .getLogger(SeriesResponse4ServiceContext.class); + private Context context; + private SortedMap> contextSM; + + public SeriesResponse4ServiceContext(Context context, + SortedMap> contextSM) { + this.context = context; + this.contextSM = contextSM; + } + + @Override + public void buildSeriesResponse() throws ServiceException { + try { + if (contextSM == null || contextSM.isEmpty()) { + logger.error("Error creating series for service accounting: No data available!"); + throw new ServiceException("No data available!"); + } + + ArrayList seriesServiceDataContextList = new ArrayList<>(); + + for (Filter contextValue : contextSM.keySet()) { + + ArrayList series = new ArrayList<>(); + SortedMap infos = contextSM.get(contextValue); + for (Info info : infos.values()) { + JSONObject jso = info.getValue(); + Long duration = jso + .getLong(AggregatedServiceUsageRecord.DURATION); + Long operationCount = jso + .getLong(AggregatedServiceUsageRecord.OPERATION_COUNT); + Long maxInvocationTime = jso + .getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); + Long minInvocationTime = jso + .getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); + + series.add(new SeriesServiceData(info.getCalendar() + .getTime(), operationCount, duration, + maxInvocationTime, minInvocationTime)); + + } + SeriesServiceDataContext seriesServiceDataContext = new SeriesServiceDataContext( + contextValue.getValue(), series); + seriesServiceDataContextList.add(seriesServiceDataContext); + + } + + SeriesServiceContext seriesServiceContext = new SeriesServiceContext(context, + seriesServiceDataContextList); + SeriesService seriesService = new SeriesService( + seriesServiceContext); + + seriesResponseSpec.setSr(seriesService); + + } catch (Throwable e) { + logger.error("Error creating series for service accounting context chart: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw new ServiceException( + "Error creating series for service accounting context chart: " + + e.getLocalizedMessage()); + } + + } +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageContext.java new file mode 100644 index 0000000..6d0237d --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4StorageContext.java @@ -0,0 +1,85 @@ +package org.gcube.portlets.admin.accountingmanager.server.amservice.response; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.SortedMap; + +import org.gcube.accounting.analytics.Filter; +import org.gcube.accounting.analytics.Info; +import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageContext; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataContext; +import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Context Series Response 4 Storage + * + * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it + * + */ +public class SeriesResponse4StorageContext extends SeriesResponseBuilder { + protected static Logger logger = LoggerFactory + .getLogger(SeriesResponse4StorageContext.class); + private Context context; + private SortedMap> contextSM; + + public SeriesResponse4StorageContext(Context context, + SortedMap> contextSM) { + this.context = context; + this.contextSM = contextSM; + + } + + @Override + public void buildSeriesResponse() throws ServiceException { + try { + if (contextSM == null || contextSM.isEmpty()) { + logger.error("Error creating series for storage accounting: No data available!"); + throw new ServiceException("No data available!"); + } + + ArrayList seriesStorageDataContextList = new ArrayList<>(); + + for (Filter contextValue : contextSM.keySet()) { + + ArrayList series = new ArrayList<>(); + SortedMap infos = contextSM.get(contextValue); + for (Info info : infos.values()) { + JSONObject jso = info.getValue(); + Long dataVolume = jso + .getLong(AggregatedStorageUsageRecord.DATA_VOLUME); + Long operationCount = jso + .getLong(AggregatedStorageUsageRecord.OPERATION_COUNT); + series.add(new SeriesStorageData(info.getCalendar() + .getTime(), dataVolume, operationCount)); + + } + SeriesStorageDataContext seriesStorageDataContext = new SeriesStorageDataContext( + contextValue.getValue(), series); + seriesStorageDataContextList.add(seriesStorageDataContext); + + } + + SeriesStorageContext seriesStorageContext = new SeriesStorageContext( + context, seriesStorageDataContextList); + SeriesStorage seriesStorage = new SeriesStorage( + seriesStorageContext); + + seriesResponseSpec.setSr(seriesStorage); + } catch (Throwable e) { + logger.error("Error creating series for storage accounting context chart: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw new ServiceException( + "Error creating series for storage accounting context chart: " + + e.getLocalizedMessage()); + } + } +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4TaskContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4TaskContext.java new file mode 100644 index 0000000..2a902d1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/response/SeriesResponse4TaskContext.java @@ -0,0 +1,88 @@ +package org.gcube.portlets.admin.accountingmanager.server.amservice.response; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.SortedMap; + +import org.gcube.accounting.analytics.Filter; +import org.gcube.accounting.analytics.Info; +import org.gcube.accounting.datamodel.aggregation.AggregatedTaskUsageRecord; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesTask; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskContext; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskData; +import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskDataContext; +import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Context Series Response 4 Task + * + * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it + * + */ +public class SeriesResponse4TaskContext extends SeriesResponseBuilder { + protected static Logger logger = LoggerFactory + .getLogger(SeriesResponse4TaskContext.class); + private Context context; + private SortedMap> contextSM; + + public SeriesResponse4TaskContext(Context context, + SortedMap> contextSM) { + this.context = context; + this.contextSM = contextSM; + } + + @Override + public void buildSeriesResponse() throws ServiceException { + try { + if (contextSM == null || contextSM.isEmpty()) { + logger.error("Error creating series for task accounting: No data available!"); + throw new ServiceException("No data available!"); + } + + ArrayList seriesTaskDataContextList = new ArrayList<>(); + + for (Filter contextValue : contextSM.keySet()) { + + ArrayList series = new ArrayList<>(); + SortedMap infos = contextSM.get(contextValue); + for (Info info : infos.values()) { + JSONObject jso = info.getValue(); + // Long duration = + // jso.getLong(AggregatedTaskUsageRecord.DURATION); + Long operationCount = jso + .getLong(AggregatedTaskUsageRecord.OPERATION_COUNT); + // Long maxInvocationTime = + // jso.getLong(AggregatedTaskUsageRecord.MAX_INVOCATION_TIME); + // Long minInvocationTime = + // jso.getLong(AggregatedTaskUsageRecord.MIN_INVOCATION_TIME); + + series.add(new SeriesTaskData(info.getCalendar().getTime(), + operationCount)); + } + SeriesTaskDataContext seriesTaskDataContext = new SeriesTaskDataContext( + contextValue.getValue(), series); + seriesTaskDataContextList.add(seriesTaskDataContext); + + } + + SeriesTaskContext seriesTaskContext = new SeriesTaskContext( + context, seriesTaskDataContextList); + SeriesTask seriesTask = new SeriesTask(seriesTaskContext); + + seriesResponseSpec.setSr(seriesTask); + + } catch (Throwable e) { + logger.error("Error creating series for portlet accounting context chart: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw new ServiceException( + "Error creating series for portlet accounting context chart: " + + e.getLocalizedMessage()); + } + } +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterContext.java new file mode 100644 index 0000000..ca457ba --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/AccountingFilterContext.java @@ -0,0 +1,58 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class AccountingFilterContext extends AccountingFilterDefinition + implements Serializable { + + private static final long serialVersionUID = -6805006183397381154L; + private Context context; + private ArrayList filters; + + public AccountingFilterContext() { + super(); + this.chartType = ChartType.Context; + context = null; + filters = null; + + } + + public AccountingFilterContext(Context context, + ArrayList filters) { + super(); + chartType = ChartType.Context; + this.context = context; + this.filters = filters; + + } + + public Context getContext() { + return context; + } + + public void setContext(Context context) { + this.context = context; + } + + public ArrayList getFilters() { + return filters; + } + + public void setFilters(ArrayList filters) { + this.filters = filters; + } + + @Override + public String toString() { + return "AccountingFilterContext [context=" + context + ", filters=" + + filters + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ChartType.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ChartType.java index f34e30d..b339d0e 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ChartType.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/ChartType.java @@ -14,7 +14,7 @@ import java.util.List; public enum ChartType { - Basic("Basic"),Top("Top"); + Basic("Basic"),Top("Top"), Context("Context"); /** * diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/Context.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/Context.java new file mode 100644 index 0000000..306de05 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/Context.java @@ -0,0 +1,39 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class Context implements Serializable { + + private static final long serialVersionUID = -2453517525713556421L; + private ArrayList contexts; + + public Context() { + super(); + } + + public Context(ArrayList contexts) { + super(); + this.contexts = contexts; + } + + public ArrayList getContexts() { + return contexts; + } + + public void setContexts(ArrayList contexts) { + this.contexts = contexts; + } + + @Override + public String toString() { + return "Context [contexts=" + contexts + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/job/SeriesJobContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/job/SeriesJobContext.java new file mode 100644 index 0000000..52e764c --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/job/SeriesJobContext.java @@ -0,0 +1,57 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data.response.job; + +import java.util.ArrayList; + +import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class SeriesJobContext extends SeriesJobDefinition { + + private static final long serialVersionUID = -2350334263342186590L; + private Context context; + private ArrayList seriesJobDataContextList; + + public SeriesJobContext() { + super(); + this.chartType = ChartType.Context; + } + + public SeriesJobContext(Context context, + ArrayList seriesJobDataContextList) { + super(); + this.chartType = ChartType.Context; + this.context = context; + this.seriesJobDataContextList = seriesJobDataContextList; + } + + public Context getContext() { + return context; + } + + public void setContext(Context context) { + this.context = context; + } + + public ArrayList getSeriesJobDataContextList() { + return seriesJobDataContextList; + } + + public void setSeriesJobDataContextList( + ArrayList seriesJobDataContextList) { + this.seriesJobDataContextList = seriesJobDataContextList; + } + + @Override + public String toString() { + return "SeriesJobContext [context=" + context + + ", seriesJobDataContextList=" + seriesJobDataContextList + + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/job/SeriesJobDataContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/job/SeriesJobDataContext.java new file mode 100644 index 0000000..12cca47 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/job/SeriesJobDataContext.java @@ -0,0 +1,50 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data.response.job; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class SeriesJobDataContext implements Serializable { + + private static final long serialVersionUID = 6043106605633429465L; + private String context; + private ArrayList series; + + public SeriesJobDataContext() { + super(); + } + + public SeriesJobDataContext(String context, ArrayList series) { + super(); + this.context = context; + this.series = series; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public ArrayList getSeries() { + return series; + } + + public void setSeries(ArrayList series) { + this.series = series; + } + + @Override + public String toString() { + return "SeriesJobDataContext [context=" + context + ", series=" + + series + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/portlet/SeriesPortletContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/portlet/SeriesPortletContext.java new file mode 100644 index 0000000..fbb4ee6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/portlet/SeriesPortletContext.java @@ -0,0 +1,57 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet; + +import java.util.ArrayList; + +import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class SeriesPortletContext extends SeriesPortletDefinition { + + private static final long serialVersionUID = -2350334263342186590L; + private Context context; + private ArrayList seriesPortletDataContextList; + + public SeriesPortletContext() { + super(); + this.chartType = ChartType.Context; + } + + public SeriesPortletContext(Context context, + ArrayList seriesPortletDataContextList) { + super(); + this.chartType = ChartType.Context; + this.context = context; + this.seriesPortletDataContextList = seriesPortletDataContextList; + } + + public Context getContext() { + return context; + } + + public void setContext(Context context) { + this.context = context; + } + + public ArrayList getSeriesPortletDataContextList() { + return seriesPortletDataContextList; + } + + public void setSeriesPortletDataContextList( + ArrayList seriesPortletDataContextList) { + this.seriesPortletDataContextList = seriesPortletDataContextList; + } + + @Override + public String toString() { + return "SeriesPortletContext [context=" + context + + ", seriesPortletDataContextList=" + + seriesPortletDataContextList + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/portlet/SeriesPortletDataContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/portlet/SeriesPortletDataContext.java new file mode 100644 index 0000000..62ff394 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/portlet/SeriesPortletDataContext.java @@ -0,0 +1,51 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class SeriesPortletDataContext implements Serializable { + + private static final long serialVersionUID = 6043106605633429465L; + private String context; + private ArrayList series; + + public SeriesPortletDataContext() { + super(); + } + + public SeriesPortletDataContext(String context, + ArrayList series) { + super(); + this.context = context; + this.series = series; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public ArrayList getSeries() { + return series; + } + + public void setSeries(ArrayList series) { + this.series = series; + } + + @Override + public String toString() { + return "SeriesPortletDataContext [context=" + context + ", series=" + + series + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/service/SeriesServiceContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/service/SeriesServiceContext.java new file mode 100644 index 0000000..ae5d3f0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/service/SeriesServiceContext.java @@ -0,0 +1,58 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data.response.service; + +import java.util.ArrayList; + +import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class SeriesServiceContext extends SeriesServiceDefinition { + + private static final long serialVersionUID = -2350334263342186590L; + private Context context; + private ArrayList seriesServiceDataContextList; + + public SeriesServiceContext() { + super(); + this.chartType = ChartType.Context; + + } + + public SeriesServiceContext(Context context, + ArrayList seriesServiceDataContextList) { + super(); + this.chartType = ChartType.Context; + this.context = context; + this.seriesServiceDataContextList = seriesServiceDataContextList; + } + + public Context getContext() { + return context; + } + + public void setContext(Context context) { + this.context = context; + } + + public ArrayList getSeriesServiceDataContextList() { + return seriesServiceDataContextList; + } + + public void setSeriesServiceDataContextList( + ArrayList seriesServiceDataContextList) { + this.seriesServiceDataContextList = seriesServiceDataContextList; + } + + @Override + public String toString() { + return "SeriesServiceContext [context=" + context + + ", seriesServiceDataContextList=" + + seriesServiceDataContextList + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/service/SeriesServiceDataContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/service/SeriesServiceDataContext.java new file mode 100644 index 0000000..4f85ef7 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/service/SeriesServiceDataContext.java @@ -0,0 +1,51 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data.response.service; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class SeriesServiceDataContext implements Serializable { + + private static final long serialVersionUID = 6043106605633429465L; + private String context; + private ArrayList series; + + public SeriesServiceDataContext() { + super(); + } + + public SeriesServiceDataContext(String context, + ArrayList series) { + super(); + this.context = context; + this.series = series; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public ArrayList getSeries() { + return series; + } + + public void setSeries(ArrayList series) { + this.series = series; + } + + @Override + public String toString() { + return "SeriesServiceDataContext [context=" + context + ", series=" + + series + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/storage/SeriesStorageContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/storage/SeriesStorageContext.java new file mode 100644 index 0000000..1dc595e --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/storage/SeriesStorageContext.java @@ -0,0 +1,59 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data.response.storage; + +import java.util.ArrayList; + +import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class SeriesStorageContext extends SeriesStorageDefinition { + + private static final long serialVersionUID = -5477545972037227361L; + private Context context; + private ArrayList seriesStorageDataContextList; + + public SeriesStorageContext() { + super(); + this.chartType = ChartType.Context; + + } + + public SeriesStorageContext(Context context, + ArrayList seriesStorageDataContextList) { + super(); + this.chartType = ChartType.Context; + this.context=context; + this.seriesStorageDataContextList = seriesStorageDataContextList; + } + + public Context getContext() { + return context; + } + + public void setContext(Context context) { + this.context = context; + } + + public ArrayList getSeriesStorageDataContextList() { + return seriesStorageDataContextList; + } + + public void setSeriesStorageDataContextList( + ArrayList seriesStorageDataContextList) { + this.seriesStorageDataContextList = seriesStorageDataContextList; + } + + @Override + public String toString() { + return "SeriesStorageContext [context=" + context + + ", seriesStorageDataContextList=" + + seriesStorageDataContextList + "]"; + } + + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/storage/SeriesStorageDataContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/storage/SeriesStorageDataContext.java new file mode 100644 index 0000000..02a13e7 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/storage/SeriesStorageDataContext.java @@ -0,0 +1,51 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data.response.storage; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class SeriesStorageDataContext implements Serializable { + + private static final long serialVersionUID = -627227653308818605L; + private String context; + private ArrayList series; + + public SeriesStorageDataContext() { + super(); + } + + public SeriesStorageDataContext(String context, + ArrayList series) { + super(); + this.context = context; + this.series = series; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public ArrayList getSeries() { + return series; + } + + public void setSeries(ArrayList series) { + this.series = series; + } + + @Override + public String toString() { + return "SeriesStorageDataContext [context=" + context + ", series=" + + series + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/task/SeriesTaskContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/task/SeriesTaskContext.java new file mode 100644 index 0000000..399e37a --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/task/SeriesTaskContext.java @@ -0,0 +1,58 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data.response.task; + +import java.util.ArrayList; + +import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; +import org.gcube.portlets.admin.accountingmanager.shared.data.Context; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class SeriesTaskContext extends SeriesTaskDefinition { + + private static final long serialVersionUID = 6805210072384752359L; + private Context context; + private ArrayList seriesTaskDataContextList; + + public SeriesTaskContext() { + super(); + this.chartType = ChartType.Context; + + } + + public SeriesTaskContext(Context context, + ArrayList seriesTaskDataTopList) { + super(); + this.chartType = ChartType.Context; + this.context = context; + this.seriesTaskDataContextList = seriesTaskDataTopList; + } + + public Context getContext() { + return context; + } + + public void setContext(Context context) { + this.context = context; + } + + public ArrayList getSeriesTaskDataContextList() { + return seriesTaskDataContextList; + } + + public void setSeriesTaskDataContextList( + ArrayList seriesTaskDataContextList) { + this.seriesTaskDataContextList = seriesTaskDataContextList; + } + + @Override + public String toString() { + return "SeriesTaskContext [context=" + context + + ", seriesTaskDataContextList=" + seriesTaskDataContextList + + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/task/SeriesTaskDataContext.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/task/SeriesTaskDataContext.java new file mode 100644 index 0000000..3b80fd9 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/data/response/task/SeriesTaskDataContext.java @@ -0,0 +1,51 @@ +package org.gcube.portlets.admin.accountingmanager.shared.data.response.task; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class SeriesTaskDataContext implements Serializable { + + private static final long serialVersionUID = 6799983693606904130L; + private String context; + private ArrayList series; + + public SeriesTaskDataContext() { + super(); + } + + public SeriesTaskDataContext(String context, + ArrayList series) { + super(); + this.context = context; + this.series = series; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public ArrayList getSeries() { + return series; + } + + public void setSeries(ArrayList series) { + this.series = series; + } + + @Override + public String toString() { + return "SeriesTaskDataContext [context=" + context + ", series=" + + series + "]"; + } + +}