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
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</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>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -45,5 +45,5 @@
|
|||
</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-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>
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<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"
|
||||
date="2016-07-15">
|
||||
<Change>Added CSV download [Ticket #4041]</Change>
|
||||
|
|
2
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.portlets.admin</groupId>
|
||||
<artifactId>accounting-manager</artifactId>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
<version>1.4.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
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;
|
||||
|
@ -16,12 +19,13 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
|||
*
|
||||
*/
|
||||
public class AccountingChart4Job extends AccountingChartBuilder {
|
||||
|
||||
|
||||
private AccountingClientStateData accountingStateData;
|
||||
private EventBus eventBus;
|
||||
|
||||
public AccountingChart4Job(EventBus eventBus, AccountingClientStateData accountingStateData) {
|
||||
this.eventBus=eventBus;
|
||||
public AccountingChart4Job(EventBus eventBus,
|
||||
AccountingClientStateData accountingStateData) {
|
||||
this.eventBus = eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
}
|
||||
|
||||
|
@ -50,16 +54,14 @@ public class AccountingChart4Job extends AccountingChartBuilder {
|
|||
|
||||
}
|
||||
|
||||
private SimpleContainer createJobChartPanel()
|
||||
throws ChartDrawException {
|
||||
private SimpleContainer createJobChartPanel() throws ChartDrawException {
|
||||
|
||||
if (accountingStateData == null
|
||||
|| accountingStateData.getSeriesRequest() == null
|
||||
|| accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition() == null
|
||||
|| accountingStateData.getSeriesRequest()
|
||||
.getAccountingFilterDefinition()
|
||||
.getChartType() == null) {
|
||||
.getAccountingFilterDefinition().getChartType() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -67,15 +69,10 @@ public class AccountingChart4Job extends AccountingChartBuilder {
|
|||
.getAccountingFilterDefinition().getChartType()) {
|
||||
|
||||
case Top:
|
||||
return null;
|
||||
//return new JobChartTopPanel(accountingStateData);
|
||||
//createJobChart(new JobChart4Top(accountingStateData));
|
||||
return new JobChartTopPanel(eventBus, accountingStateData);
|
||||
case Basic:
|
||||
return new JobChartBasicPanel(eventBus, accountingStateData);
|
||||
//createJobChart(new JobChart4Basic(
|
||||
//accountingStateData));
|
||||
default:
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,11 @@ public class AccountingManagerMenu extends TabPanel {
|
|||
EmptyPanel serviceCategory=new EmptyPanel(AccountingType.SERVICE.name());
|
||||
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);
|
||||
|
@ -65,10 +70,6 @@ public class AccountingManagerMenu extends TabPanel {
|
|||
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));
|
||||
|
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 938 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 938 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.8 KiB |
|
@ -157,7 +157,7 @@ public class ExportServlet extends HttpServlet {
|
|||
logger.error("Error in ExportServlet: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException("Error:"
|
||||
throw new ServletException("Error: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,16 +3,10 @@
|
|||
*/
|
||||
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 org.gcube.application.framework.core.session.ASLSession;
|
||||
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.portlets.admin.accountingmanager.server.state.AccountingState;
|
||||
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.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
|
@ -74,22 +66,7 @@ public class SessionUtil {
|
|||
throws ServiceException {
|
||||
String token = null;
|
||||
if (Constants.DEBUG_MODE) {
|
||||
List<String> userRoles = new ArrayList<>();
|
||||
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());
|
||||
}
|
||||
|
||||
token = Constants.DEFAULT_TOKEN;
|
||||
} else {
|
||||
token = aslSession.getSecurityToken();
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@ 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;
|
||||
|
@ -34,28 +36,25 @@ public class SeriesResponse4JobBasic extends SeriesResponseBuilder {
|
|||
try {
|
||||
if (infos.size() <= 0) {
|
||||
logger.error("Error creating series for job accounting: No data available!");
|
||||
throw new ServiceException(
|
||||
"No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
}
|
||||
|
||||
ArrayList<SeriesJobData> series = new ArrayList<SeriesJobData>();
|
||||
for (Info info : infos) {
|
||||
JSONObject jso = info.getValue();
|
||||
// Long duration =
|
||||
// jso.getLong(AggregatedJobUsageRecord.DURATION);
|
||||
Long duration = jso.getLong(AggregatedJobUsageRecord.DURATION);
|
||||
Long operationCount = jso
|
||||
.getLong(AggregatedJobUsageRecord.OPERATION_COUNT);
|
||||
// Long maxInvocationTime =
|
||||
// jso.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
|
||||
// Long minInvocationTime =
|
||||
// jso.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
|
||||
Long maxInvocationTime = jso
|
||||
.getLong(AggregatedJobUsageRecord.MAX_INVOCATION_TIME);
|
||||
Long minInvocationTime = jso
|
||||
.getLong(AggregatedJobUsageRecord.MIN_INVOCATION_TIME);
|
||||
|
||||
series.add(new SeriesJobData(info.getCalendar().getTime(),
|
||||
operationCount, operationCount, operationCount,
|
||||
operationCount));
|
||||
operationCount, duration, maxInvocationTime,
|
||||
minInvocationTime));
|
||||
|
||||
}
|
||||
|
||||
SeriesJobBasic seriesJobBasic = new SeriesJobBasic(series);
|
||||
|
||||
SeriesJob seriesJob = new SeriesJob(seriesJobBasic);
|
||||
|
|
|
@ -7,11 +7,16 @@ 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;
|
||||
|
@ -43,8 +48,10 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder {
|
|||
try {
|
||||
if (topSM == null || topSM.isEmpty()) {
|
||||
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<>();
|
||||
|
||||
|
@ -54,18 +61,19 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder {
|
|||
SortedMap<Calendar, Info> infos = topSM.get(topValue);
|
||||
for (Info info : infos.values()) {
|
||||
JSONObject jso = info.getValue();
|
||||
// Long duration =
|
||||
// jso.getLong(AggregatedJobUsageRecord.DURATION);
|
||||
Long duration = jso
|
||||
.getLong(AggregatedServiceUsageRecord.DURATION);
|
||||
Long operationCount = jso
|
||||
.getLong(AggregatedJobUsageRecord.OPERATION_COUNT);
|
||||
// Long maxInvocationTime =
|
||||
// jso.getLong(AggregatedJobUsageRecord.MAX_INVOCATION_TIME);
|
||||
// Long minInvocationTime =
|
||||
// jso.getLong(AggregatedJobUsageRecord.MIN_INVOCATION_TIME);
|
||||
.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));
|
||||
|
||||
series.add(new SeriesJobData(info.getCalendar().getTime(),
|
||||
operationCount, operationCount, operationCount,
|
||||
operationCount));
|
||||
}
|
||||
SeriesJobDataTop seriesJobDataTop = new SeriesJobDataTop(
|
||||
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);
|
||||
SeriesJob seriesJob = new SeriesJob(seriesJobTop);
|
||||
SeriesJob seriesService = new SeriesJob(seriesJobTop);
|
||||
|
||||
seriesResponseSpec.setSr(seriesJob);
|
||||
seriesResponseSpec.setSr(seriesService);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error creating series for job accounting top chart: "
|
||||
|
|
|
@ -26,39 +26,48 @@ public class SeriesResponse4ServiceBasic extends SeriesResponseBuilder {
|
|||
private List<Info> infos;
|
||||
|
||||
public SeriesResponse4ServiceBasic(List<Info> infos) {
|
||||
this.infos=infos;
|
||||
this.infos = infos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws ServiceException {
|
||||
try {
|
||||
if(infos.size()<=0){
|
||||
if (infos.size() <= 0) {
|
||||
logger.error("Error creating series for service accounting: 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) {
|
||||
JSONObject jso = info.getValue();
|
||||
Long duration = jso.getLong(AggregatedServiceUsageRecord.DURATION);
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
SeriesServiceBasic seriesServiceBasic=new SeriesServiceBasic(series);
|
||||
|
||||
SeriesServiceBasic seriesServiceBasic = new SeriesServiceBasic(
|
||||
series);
|
||||
|
||||
SeriesService seriesService = new SeriesService(seriesServiceBasic);
|
||||
|
||||
seriesResponseSpec.setSr(seriesService);
|
||||
} 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();
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
|
|||
|
||||
public SeriesResponse4ServiceTop(Boolean showOthers, Integer topNumber,
|
||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
|
||||
this.showOthers=showOthers;
|
||||
this.topNumber=topNumber;
|
||||
this.showOthers = showOthers;
|
||||
this.topNumber = topNumber;
|
||||
this.topSM = topSM;
|
||||
}
|
||||
|
||||
|
@ -43,10 +43,8 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
|
|||
try {
|
||||
if (topSM == null || topSM.isEmpty()) {
|
||||
logger.error("Error creating series for service accounting: No data available!");
|
||||
throw new ServiceException(
|
||||
"No data available!");
|
||||
throw new ServiceException("No data available!");
|
||||
}
|
||||
|
||||
|
||||
ArrayList<SeriesServiceDataTop> seriesServiceDataTopList = new ArrayList<>();
|
||||
|
||||
|
@ -76,8 +74,8 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
|
|||
|
||||
}
|
||||
|
||||
SeriesServiceTop seriesServiceTop = new SeriesServiceTop(showOthers,topNumber,
|
||||
seriesServiceDataTopList);
|
||||
SeriesServiceTop seriesServiceTop = new SeriesServiceTop(
|
||||
showOthers, topNumber, seriesServiceDataTopList);
|
||||
SeriesService seriesService = new SeriesService(seriesServiceTop);
|
||||
|
||||
seriesResponseSpec.setSr(seriesService);
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.apache.commons.csv.CSVFormat;
|
|||
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.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.AccountingModel4Storage;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder;
|
||||
|
@ -62,6 +63,8 @@ public class CSVManager {
|
|||
accountingModelBuilder = new AccountingModel4Storage(accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
accountingModelBuilder = new AccountingModel4Job(accountingStateData);
|
||||
break;
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
|
@ -157,6 +160,8 @@ public class CSVManager {
|
|||
accountindModelBuilder = new AccountingModel4Storage(accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
accountindModelBuilder = new AccountingModel4Job(accountingStateData);
|
||||
break;
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
|
|
|
@ -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.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.AccountingModel4Storage;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder;
|
||||
|
@ -66,6 +67,9 @@ public class JSONManager {
|
|||
accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
accountingModelBuilder = new AccountingModel4Job(
|
||||
accountingStateData);
|
||||
break;
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
|
@ -174,6 +178,9 @@ public class JSONManager {
|
|||
accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
accountingModelBuilder = new AccountingModel4Job(
|
||||
accountingStateData);
|
||||
break;
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.nio.file.Path;
|
|||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
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.AccountingModel4Storage;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.export.model.AccountingModelBuilder;
|
||||
|
@ -63,6 +64,9 @@ public class XMLManager {
|
|||
accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
accountingModelBuilder = new AccountingModel4Job(
|
||||
accountingStateData);
|
||||
break;
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
|
@ -157,6 +161,8 @@ public class XMLManager {
|
|||
accountingStateData);
|
||||
break;
|
||||
case JOB:
|
||||
accountingModelBuilder = new AccountingModel4Job(
|
||||
accountingStateData);
|
||||
case PORTLET:
|
||||
case TASK:
|
||||
default:
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
|
@ -14,13 +14,8 @@ public class Constants {
|
|||
public static final String AM_LANG_COOKIE = "AMLangCookie";
|
||||
public static final String AM_LANG = "AMLang";
|
||||
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/devsec/devVRE";
|
||||
|
||||
//public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
|
||||
|
||||
public static final String DEFAULT_SCOPE = "/gcube";
|
||||
public final static String DEFAULT_SCOPE = "/gcube/devNext";
|
||||
public final static String DEFAULT_TOKEN = "16e65d4f-11e0-4e4a-84b9-351688fccc12-98187548";
|
||||
public static final String DEFAULT_ROLE = "OrganizationMember";
|
||||
|
||||
public static final String EXPORT_SERVLET="ExportServlet";
|
||||
|
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 938 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 938 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.8 KiB |