Accounting Manager

Enable Job

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@131459 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-09-16 14:43:29 +00:00
parent c5372732df
commit 096b18cdb8
32 changed files with 256 additions and 99 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/accounting-manager-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/accounting-manager-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/accounting-manager-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/accounting-manager-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -45,5 +45,5 @@
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/> <classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/> <classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="output" path="target/accounting-manager-1.3.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/accounting-manager-1.4.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,4 +1,9 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-4-0"
date="2016-10-01">
<Change>Updated to AUTH2.0</Change>
<Change>Added Job</Change>
</Changeset>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-3-0" <Changeset component="org.gcube.portlets.admin.accounting-manager.1-3-0"
date="2016-07-15"> date="2016-07-15">
<Change>Added CSV download [Ticket #4041]</Change> <Change>Added CSV download [Ticket #4041]</Change>

View File

@ -13,7 +13,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.admin</groupId> <groupId>org.gcube.portlets.admin</groupId>
<artifactId>accounting-manager</artifactId> <artifactId>accounting-manager</artifactId>
<version>1.3.0-SNAPSHOT</version> <version>1.4.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>

View File

@ -1,6 +1,9 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; 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.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.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ChartDrawException;
@ -16,12 +19,13 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
* *
*/ */
public class AccountingChart4Job extends AccountingChartBuilder { public class AccountingChart4Job extends AccountingChartBuilder {
private AccountingClientStateData accountingStateData; private AccountingClientStateData accountingStateData;
private EventBus eventBus; private EventBus eventBus;
public AccountingChart4Job(EventBus eventBus, AccountingClientStateData accountingStateData) { public AccountingChart4Job(EventBus eventBus,
this.eventBus=eventBus; AccountingClientStateData accountingStateData) {
this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
} }
@ -50,16 +54,14 @@ public class AccountingChart4Job extends AccountingChartBuilder {
} }
private SimpleContainer createJobChartPanel() private SimpleContainer createJobChartPanel() throws ChartDrawException {
throws ChartDrawException {
if (accountingStateData == null if (accountingStateData == null
|| accountingStateData.getSeriesRequest() == null || accountingStateData.getSeriesRequest() == null
|| accountingStateData.getSeriesRequest() || accountingStateData.getSeriesRequest()
.getAccountingFilterDefinition() == null .getAccountingFilterDefinition() == null
|| accountingStateData.getSeriesRequest() || accountingStateData.getSeriesRequest()
.getAccountingFilterDefinition() .getAccountingFilterDefinition().getChartType() == null) {
.getChartType() == null) {
return null; return null;
} }
@ -67,15 +69,10 @@ public class AccountingChart4Job extends AccountingChartBuilder {
.getAccountingFilterDefinition().getChartType()) { .getAccountingFilterDefinition().getChartType()) {
case Top: case Top:
return null; return new JobChartTopPanel(eventBus, accountingStateData);
//return new JobChartTopPanel(accountingStateData);
//createJobChart(new JobChart4Top(accountingStateData));
case Basic: case Basic:
return new JobChartBasicPanel(eventBus, accountingStateData); return new JobChartBasicPanel(eventBus, accountingStateData);
//createJobChart(new JobChart4Basic(
//accountingStateData));
default: default:
return null; return null;
} }

View File

@ -52,6 +52,11 @@ public class AccountingManagerMenu extends TabPanel {
EmptyPanel serviceCategory=new EmptyPanel(AccountingType.SERVICE.name()); EmptyPanel serviceCategory=new EmptyPanel(AccountingType.SERVICE.name());
add(serviceCategory, serviceItemConf); add(serviceCategory, serviceItemConf);
TabItemConfig jobItemConf = new TabItemConfig("Job", false);
jobItemConf.setIcon(AccountingManagerResources.INSTANCE.accountingJob48());
EmptyPanel jobCategory=new EmptyPanel(AccountingType.JOB.name());
add(jobCategory, jobItemConf);
/* /*
TabItemConfig portletItemConf = new TabItemConfig("Portlet", false); TabItemConfig portletItemConf = new TabItemConfig("Portlet", false);
@ -65,10 +70,6 @@ public class AccountingManagerMenu extends TabPanel {
add(taskCategory, taskItemConf); add(taskCategory, taskItemConf);
*/ */
/*TabItemConfig jobItemConf = new TabItemConfig("Job", false);
jobItemConf.setIcon(AccountingManagerResources.INSTANCE.accountingJob48());
EmptyPanel jobCategory=new EmptyPanel(AccountingType.JOB.name());
add(jobCategory, jobItemConf);*/
setActiveWidget(getWidget(0)); setActiveWidget(getWidget(0));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 938 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 938 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -157,7 +157,7 @@ public class ExportServlet extends HttpServlet {
logger.error("Error in ExportServlet: " logger.error("Error in ExportServlet: "
+ e.getLocalizedMessage()); + e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new ServletException("Error:" throw new ServletException("Error: "
+ e.getLocalizedMessage(), e); + e.getLocalizedMessage(), e);
} }

View File

@ -3,16 +3,10 @@
*/ */
package org.gcube.portlets.admin.accountingmanager.server; package org.gcube.portlets.admin.accountingmanager.server;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager; import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.authorization.library.provider.UserInfo;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.admin.accountingmanager.server.state.AccountingState; import org.gcube.portlets.admin.accountingmanager.server.state.AccountingState;
import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData; import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData;
@ -23,8 +17,6 @@ import org.gcube.portlets.admin.accountingmanager.shared.exception.SessionExpire
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author "Giancarlo Panichi" <a
@ -74,22 +66,7 @@ public class SessionUtil {
throws ServiceException { throws ServiceException {
String token = null; String token = null;
if (Constants.DEBUG_MODE) { if (Constants.DEBUG_MODE) {
List<String> userRoles = new ArrayList<>(); token = Constants.DEFAULT_TOKEN;
userRoles.add(Constants.DEFAULT_ROLE);
/*
* if (aslSession.getUsername().compareTo("lucio.lelii") == 0)
* userRoles.add("VRE-Manager");
*/
try {
token = authorizationService().generateUserToken(
new UserInfo(aslSession.getUsername(), userRoles),
aslSession.getScope());
} catch (Exception e) {
logger.error("Error generating the token for test: "+e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException("Error generating the token for test: "+e.getLocalizedMessage());
}
} else { } else {
token = aslSession.getSecurityToken(); token = aslSession.getSecurityToken();
} }

View File

@ -5,9 +5,11 @@ import java.util.List;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; 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.SeriesJob;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic; 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.job.SeriesJobData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -34,28 +36,25 @@ public class SeriesResponse4JobBasic extends SeriesResponseBuilder {
try { try {
if (infos.size() <= 0) { if (infos.size() <= 0) {
logger.error("Error creating series for job accounting: No data available!"); logger.error("Error creating series for job accounting: No data available!");
throw new ServiceException( throw new ServiceException("No data available!");
"No data available!");
} }
ArrayList<SeriesJobData> series = new ArrayList<SeriesJobData>(); ArrayList<SeriesJobData> series = new ArrayList<SeriesJobData>();
for (Info info : infos) { for (Info info : infos) {
JSONObject jso = info.getValue(); JSONObject jso = info.getValue();
// Long duration = Long duration = jso.getLong(AggregatedJobUsageRecord.DURATION);
// jso.getLong(AggregatedJobUsageRecord.DURATION);
Long operationCount = jso Long operationCount = jso
.getLong(AggregatedJobUsageRecord.OPERATION_COUNT); .getLong(AggregatedJobUsageRecord.OPERATION_COUNT);
// Long maxInvocationTime = Long maxInvocationTime = jso
// jso.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); .getLong(AggregatedJobUsageRecord.MAX_INVOCATION_TIME);
// Long minInvocationTime = Long minInvocationTime = jso
// jso.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); .getLong(AggregatedJobUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesJobData(info.getCalendar().getTime(), series.add(new SeriesJobData(info.getCalendar().getTime(),
operationCount, operationCount, operationCount, operationCount, duration, maxInvocationTime,
operationCount)); minInvocationTime));
} }
SeriesJobBasic seriesJobBasic = new SeriesJobBasic(series); SeriesJobBasic seriesJobBasic = new SeriesJobBasic(series);
SeriesJob seriesJob = new SeriesJob(seriesJobBasic); SeriesJob seriesJob = new SeriesJob(seriesJobBasic);

View File

@ -7,11 +7,16 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; 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.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; 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.SeriesJobData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop; 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.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.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -43,8 +48,10 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder {
try { try {
if (topSM == null || topSM.isEmpty()) { if (topSM == null || topSM.isEmpty()) {
logger.error("Error creating series for job accounting: No data available!"); logger.error("Error creating series for job accounting: No data available!");
throw new ServiceException("No data available!"); throw new ServiceException(
"No data available!");
} }
ArrayList<SeriesJobDataTop> seriesJobDataTopList = new ArrayList<>(); ArrayList<SeriesJobDataTop> seriesJobDataTopList = new ArrayList<>();
@ -54,18 +61,19 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder {
SortedMap<Calendar, Info> infos = topSM.get(topValue); SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) { for (Info info : infos.values()) {
JSONObject jso = info.getValue(); JSONObject jso = info.getValue();
// Long duration = Long duration = jso
// jso.getLong(AggregatedJobUsageRecord.DURATION); .getLong(AggregatedServiceUsageRecord.DURATION);
Long operationCount = jso Long operationCount = jso
.getLong(AggregatedJobUsageRecord.OPERATION_COUNT); .getLong(AggregatedServiceUsageRecord.OPERATION_COUNT);
// Long maxInvocationTime = Long maxInvocationTime = jso
// jso.getLong(AggregatedJobUsageRecord.MAX_INVOCATION_TIME); .getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
// Long minInvocationTime = Long minInvocationTime = jso
// jso.getLong(AggregatedJobUsageRecord.MIN_INVOCATION_TIME); .getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesJobData(info.getCalendar()
.getTime(), operationCount, duration,
maxInvocationTime, minInvocationTime));
series.add(new SeriesJobData(info.getCalendar().getTime(),
operationCount, operationCount, operationCount,
operationCount));
} }
SeriesJobDataTop seriesJobDataTop = new SeriesJobDataTop( SeriesJobDataTop seriesJobDataTop = new SeriesJobDataTop(
new FilterValue(topValue.getValue()), series); new FilterValue(topValue.getValue()), series);
@ -73,11 +81,11 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder {
} }
SeriesJobTop seriesJobTop = new SeriesJobTop(showOthers, topNumber, SeriesJobTop seriesJobTop = new SeriesJobTop(showOthers,topNumber,
seriesJobDataTopList); seriesJobDataTopList);
SeriesJob seriesJob = new SeriesJob(seriesJobTop); SeriesJob seriesService = new SeriesJob(seriesJobTop);
seriesResponseSpec.setSr(seriesJob); seriesResponseSpec.setSr(seriesService);
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error creating series for job accounting top chart: " logger.error("Error creating series for job accounting top chart: "

View File

@ -26,39 +26,48 @@ public class SeriesResponse4ServiceBasic extends SeriesResponseBuilder {
private List<Info> infos; private List<Info> infos;
public SeriesResponse4ServiceBasic(List<Info> infos) { public SeriesResponse4ServiceBasic(List<Info> infos) {
this.infos=infos; this.infos = infos;
} }
@Override @Override
public void buildSeriesResponse() throws ServiceException { public void buildSeriesResponse() throws ServiceException {
try { try {
if(infos.size()<=0){ if (infos.size() <= 0) {
logger.error("Error creating series for service accounting: No data available!"); logger.error("Error creating series for service accounting: No data available!");
throw new ServiceException("No data available!"); throw new ServiceException("No data available!");
} }
ArrayList<SeriesServiceData> series=new ArrayList<SeriesServiceData>(); ArrayList<SeriesServiceData> series = new ArrayList<SeriesServiceData>();
for (Info info : infos) { for (Info info : infos) {
JSONObject jso = info.getValue(); JSONObject jso = info.getValue();
Long duration = jso.getLong(AggregatedServiceUsageRecord.DURATION); Long duration = jso
.getLong(AggregatedServiceUsageRecord.DURATION);
Long operationCount = jso Long operationCount = jso
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT); .getLong(AggregatedServiceUsageRecord.OPERATION_COUNT);
Long maxInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); Long maxInvocationTime = jso
Long minInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); .getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
Long minInvocationTime = jso
series.add(new SeriesServiceData(info.getCalendar().getTime(), operationCount, duration, maxInvocationTime, minInvocationTime)); .getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesServiceData(info.getCalendar().getTime(),
operationCount, duration, maxInvocationTime,
minInvocationTime));
} }
SeriesServiceBasic seriesServiceBasic=new SeriesServiceBasic(series); SeriesServiceBasic seriesServiceBasic = new SeriesServiceBasic(
series);
SeriesService seriesService = new SeriesService(seriesServiceBasic); SeriesService seriesService = new SeriesService(seriesServiceBasic);
seriesResponseSpec.setSr(seriesService); seriesResponseSpec.setSr(seriesService);
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error creating series for service accounting chart basic: "+e.getLocalizedMessage()); logger.error("Error creating series for service accounting chart basic: "
+ e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new ServiceException("Error creating series for service accounting chart basic: "+e.getLocalizedMessage()); throw new ServiceException(
"Error creating series for service accounting chart basic: "
+ e.getLocalizedMessage());
} }
} }

View File

@ -33,8 +33,8 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
public SeriesResponse4ServiceTop(Boolean showOthers, Integer topNumber, public SeriesResponse4ServiceTop(Boolean showOthers, Integer topNumber,
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) { SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.showOthers=showOthers; this.showOthers = showOthers;
this.topNumber=topNumber; this.topNumber = topNumber;
this.topSM = topSM; this.topSM = topSM;
} }
@ -43,10 +43,8 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
try { try {
if (topSM == null || topSM.isEmpty()) { if (topSM == null || topSM.isEmpty()) {
logger.error("Error creating series for service accounting: No data available!"); logger.error("Error creating series for service accounting: No data available!");
throw new ServiceException( throw new ServiceException("No data available!");
"No data available!");
} }
ArrayList<SeriesServiceDataTop> seriesServiceDataTopList = new ArrayList<>(); ArrayList<SeriesServiceDataTop> seriesServiceDataTopList = new ArrayList<>();
@ -76,8 +74,8 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
} }
SeriesServiceTop seriesServiceTop = new SeriesServiceTop(showOthers,topNumber, SeriesServiceTop seriesServiceTop = new SeriesServiceTop(
seriesServiceDataTopList); showOthers, topNumber, seriesServiceDataTopList);
SeriesService seriesService = new SeriesService(seriesServiceTop); SeriesService seriesService = new SeriesService(seriesServiceTop);
seriesResponseSpec.setSr(seriesService); seriesResponseSpec.setSr(seriesService);

View File

@ -11,6 +11,7 @@ import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter; import org.apache.commons.csv.CSVPrinter;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataRow; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataRow;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataModel; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataModel;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Job;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Service; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Service;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Storage; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Storage;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder;
@ -62,6 +63,8 @@ public class CSVManager {
accountingModelBuilder = new AccountingModel4Storage(accountingStateData); accountingModelBuilder = new AccountingModel4Storage(accountingStateData);
break; break;
case JOB: case JOB:
accountingModelBuilder = new AccountingModel4Job(accountingStateData);
break;
case PORTLET: case PORTLET:
case TASK: case TASK:
default: default:
@ -157,6 +160,8 @@ public class CSVManager {
accountindModelBuilder = new AccountingModel4Storage(accountingStateData); accountindModelBuilder = new AccountingModel4Storage(accountingStateData);
break; break;
case JOB: case JOB:
accountindModelBuilder = new AccountingModel4Job(accountingStateData);
break;
case PORTLET: case PORTLET:
case TASK: case TASK:
default: default:

View File

@ -10,6 +10,7 @@ import java.nio.file.StandardOpenOption;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataModel; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataModel;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataRow; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataRow;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Job;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Service; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Service;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Storage; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Storage;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder;
@ -66,6 +67,9 @@ public class JSONManager {
accountingStateData); accountingStateData);
break; break;
case JOB: case JOB:
accountingModelBuilder = new AccountingModel4Job(
accountingStateData);
break;
case PORTLET: case PORTLET:
case TASK: case TASK:
default: default:
@ -174,6 +178,9 @@ public class JSONManager {
accountingStateData); accountingStateData);
break; break;
case JOB: case JOB:
accountingModelBuilder = new AccountingModel4Job(
accountingStateData);
break;
case PORTLET: case PORTLET:
case TASK: case TASK:
default: default:

View File

@ -9,6 +9,7 @@ import java.nio.file.Path;
import java.nio.file.StandardOpenOption; import java.nio.file.StandardOpenOption;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataModel; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingDataModel;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Job;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Service; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Service;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Storage; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModel4Storage;
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder; import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder;
@ -63,6 +64,9 @@ public class XMLManager {
accountingStateData); accountingStateData);
break; break;
case JOB: case JOB:
accountingModelBuilder = new AccountingModel4Job(
accountingStateData);
break;
case PORTLET: case PORTLET:
case TASK: case TASK:
default: default:
@ -157,6 +161,8 @@ public class XMLManager {
accountingStateData); accountingStateData);
break; break;
case JOB: case JOB:
accountingModelBuilder = new AccountingModel4Job(
accountingStateData);
case PORTLET: case PORTLET:
case TASK: case TASK:
default: default:

View File

@ -0,0 +1,150 @@
package org.gcube.portlets.admin.accountingmanager.server.export.model;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import org.gcube.portlets.admin.accountingmanager.server.state.AccountingStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
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.job.SeriesJobDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDefinition;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Accounting Model 4 Job
*
* @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class AccountingModel4Job extends AccountingModelBuilder {
protected static Logger logger = LoggerFactory
.getLogger(AccountingModel4Job.class);
private AccountingStateData accountingStateData;
public AccountingModel4Job(AccountingStateData accountingStateData) {
this.accountingStateData = accountingStateData;
}
@Override
public void buildOpEx() throws ServiceException {
SeriesRequest seriesRequest = accountingStateData.getSeriesRequest();
if (seriesRequest == null) {
logger.error("Error series request is null");
throw new ServiceException(
"Error series request is null");
}
String startDate="";
try {
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getStartDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String endDate="";
try {
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getEndDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String periodType = seriesRequest.getAccountingPeriod().getPeriod()
.getLabel();
SeriesResponse seriesResponse = accountingStateData.getSeriesResponse();
if (seriesResponse == null) {
logger.error("Error series response is null");
throw new ServiceException(
"Error series response is null");
}
String fileName = "Untitled";
ArrayList<String> header;
ArrayList<AccountingDataRow> rows = new ArrayList<>();
if (seriesResponse instanceof SeriesJob) {
SeriesJob seriesService = (SeriesJob) seriesResponse;
SeriesJobDefinition definition = seriesService
.getSeriesJobDefinition();
if (definition instanceof SeriesJobBasic) {
SeriesJobBasic seriesJobBasic = (SeriesJobBasic) definition;
fileName = "Job_" + periodType + "_" + startDate + "_"
+ endDate;
header = new ArrayList<>(Arrays.asList(new String[] { "Date",
"Operation Count", "Duration", "Max Invocation",
"Min Invocation" }));
ArrayList<SeriesJobData> listData = seriesJobBasic
.getSeries();
for (SeriesJobData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData.getOperationCount()));
data.add(String.valueOf(seriesData.getDuration()));
data.add(String.valueOf(seriesData.getMaxInvocationTime()));
data.add(String.valueOf(seriesData.getMinInvocationTime()));
AccountingDataRow csvDataRow = new AccountingDataRow(data);
rows.add(csvDataRow);
}
} else {
if (definition instanceof SeriesJobTop) {
SeriesJobTop seriesJobTop = (SeriesJobTop) definition;
fileName = "JobTop_" + periodType + "_" + startDate
+ "_" + endDate;
header = new ArrayList<>(Arrays.asList(new String[] {
"Value", "Date", "Operation Count", "Duration",
"Max Invocation", "Min Invocation" }));
ArrayList<SeriesJobDataTop> listDataTop = seriesJobTop
.getSeriesJobDataTopList();
for (SeriesJobDataTop seriesDataTop : listDataTop) {
FilterValue filterValue = seriesDataTop
.getFilterValue();
ArrayList<SeriesJobData> listData = seriesDataTop
.getSeries();
for (SeriesJobData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(filterValue.getValue());
data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData
.getOperationCount()));
data.add(String.valueOf(seriesData.getDuration()));
data.add(String.valueOf(seriesData
.getMaxInvocationTime()));
data.add(String.valueOf(seriesData
.getMinInvocationTime()));
AccountingDataRow csvDataRow = new AccountingDataRow(data);
rows.add(csvDataRow);
}
}
} else {
logger.error("Unsupported Serie Definition for Job: "
+ definition);
throw new ServiceException(
"Unsupported Serie Definition for Job: "
+ definition);
}
}
} else {
logger.error("Job not support this serie response: "
+ seriesResponse);
throw new ServiceException(
"Job not support this serie response: "
+ seriesResponse);
}
AccountingDataModel invocation = new AccountingDataModel(fileName, header, rows);
accountingModelSpec.setOp(invocation);
}
}

View File

@ -14,13 +14,8 @@ public class Constants {
public static final String AM_LANG_COOKIE = "AMLangCookie"; public static final String AM_LANG_COOKIE = "AMLangCookie";
public static final String AM_LANG = "AMLang"; public static final String AM_LANG = "AMLang";
public static final String DEFAULT_USER = "giancarlo.panichi"; public static final String DEFAULT_USER = "giancarlo.panichi";
//public final static String DEFAULT_USER = "test.user"; public final static String DEFAULT_SCOPE = "/gcube/devNext";
//public final static String DEFAULT_SCOPE = "/gcube/devNext"; public final static String DEFAULT_TOKEN = "16e65d4f-11e0-4e4a-84b9-351688fccc12-98187548";
//public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
//public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
public static final String DEFAULT_SCOPE = "/gcube";
public static final String DEFAULT_ROLE = "OrganizationMember"; public static final String DEFAULT_ROLE = "OrganizationMember";
public static final String EXPORT_SERVLET="ExportServlet"; public static final String EXPORT_SERVLET="ExportServlet";

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 938 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 938 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB