Fixed ScopeDescriptior initialization in
AccountingDashboardHarvesterPlugin
This commit is contained in:
parent
b659c45890
commit
0069f4f363
|
@ -38,6 +38,7 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
|
||||||
import org.gcube.common.resources.gcore.utils.Group;
|
import org.gcube.common.resources.gcore.utils.Group;
|
||||||
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
import org.gcube.dataharvest.datamodel.AnalyticsReportCredentials;
|
import org.gcube.dataharvest.datamodel.AnalyticsReportCredentials;
|
||||||
import org.gcube.dataharvest.datamodel.CatalogueAccessesReportRow;
|
import org.gcube.dataharvest.datamodel.CatalogueAccessesReportRow;
|
||||||
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
||||||
|
@ -125,7 +126,10 @@ public class CatalogueAccessesHarvester extends BasicHarvester {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ScopeDescriptor scopeDescriptor = new ScopeDescriptor();
|
ScopeDescriptor scopeDescriptor = new ScopeDescriptor();
|
||||||
scopeDescriptor.setName(dashboardContext);
|
ScopeBean scopeBean = new ScopeBean(dashboardContext);
|
||||||
|
scopeDescriptor.setId(dashboardContext);
|
||||||
|
scopeDescriptor.setName(scopeBean.name());
|
||||||
|
|
||||||
AccountingRecord ar1 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.CATALOGUE_ACCESSES), (long) catalogueTotalAccesses);
|
AccountingRecord ar1 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.CATALOGUE_ACCESSES), (long) catalogueTotalAccesses);
|
||||||
AccountingRecord ar2 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.CATALOGUE_DATASET_LIST_ACCESSES), (long) catalogueDatasetListAccesses);
|
AccountingRecord ar2 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.CATALOGUE_DATASET_LIST_ACCESSES), (long) catalogueDatasetListAccesses);
|
||||||
AccountingRecord ar3 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.CATALOGUE_DATASET_ACCESSES), (long) catalogueDatasetAccesses);
|
AccountingRecord ar3 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.CATALOGUE_DATASET_ACCESSES), (long) catalogueDatasetAccesses);
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||||
import org.gcube.vremanagement.executor.client.SmartExecutorClient;
|
import org.gcube.vremanagement.executor.client.SmartExecutorClient;
|
||||||
import org.gcube.vremanagement.executor.client.SmartExecutorClientFactory;
|
import org.gcube.vremanagement.executor.client.SmartExecutorClientFactory;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
|
||||||
import org.quartz.CronExpression;
|
import org.quartz.CronExpression;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -731,40 +730,34 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void testCatalogueHarvester() {
|
public void testCatalogueHarvester() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
//Utils.setContext(RESOURCE_CATALOGUE);
|
String context = "/gcube";
|
||||||
ContextTest.setContextByName(ROOT);
|
ContextTest.setContextByName(context);
|
||||||
System.out.println("vaaa");
|
|
||||||
|
AccountingDao dao = getAccountingDao();
|
||||||
|
|
||||||
Date start = DateUtils.getStartCalendar(2020, Calendar.JANUARY, 1).getTime();
|
Date start = DateUtils.getStartCalendar(2020, Calendar.JANUARY, 1).getTime();
|
||||||
Date end = DateUtils.getStartCalendar(2020, Calendar.FEBRUARY, 1).getTime();
|
Date end = DateUtils.getStartCalendar(2020, Calendar.FEBRUARY, 1).getTime();
|
||||||
|
|
||||||
// Date start = DateUtils.getPreviousPeriod(measureType, false).getTime();
|
/*
|
||||||
// Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false);
|
* Date start = DateUtils.getPreviousPeriod(measureType, false).getTime();
|
||||||
|
* Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false);
|
||||||
|
*/
|
||||||
|
|
||||||
|
ScopeBean scopeBean = new ScopeBean(context);
|
||||||
|
logger.debug("FullName {} - Name {}", scopeBean.toString(), scopeBean.name());
|
||||||
|
|
||||||
// AccountingDashboardHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDashboardHarvesterPlugin(null);
|
CatalogueAccessesHarvester catalogueHarvester = new CatalogueAccessesHarvester(start, end);
|
||||||
// accountingDataHarvesterPlugin.getConfigParameters();
|
List<AccountingRecord> accountingRecords = catalogueHarvester.getAccountingRecords();
|
||||||
|
for (AccountingRecord accountingRecord : accountingRecords) {
|
||||||
|
logger.debug("{}", accountingRecord);
|
||||||
|
}
|
||||||
|
logger.debug("{}", accountingRecords);
|
||||||
|
|
||||||
// ContextAuthorization contextAuthorization = new ContextAuthorization();
|
dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
||||||
// SortedSet<String> contexts = contextAuthorization.getContexts();
|
|
||||||
//
|
|
||||||
// for(String context : contexts) {
|
|
||||||
ScopeBean scopeBean = new ScopeBean(ROOT);
|
|
||||||
logger.debug("FullName {} - Name {}", scopeBean.toString(), scopeBean.name());
|
|
||||||
|
|
||||||
|
|
||||||
ContextTest.setContextByName(ROOT);
|
|
||||||
CatalogueAccessesHarvester catalogueHarvester = new CatalogueAccessesHarvester(start, end);
|
|
||||||
List<AccountingRecord> data = catalogueHarvester.getAccountingRecords();
|
|
||||||
for (AccountingRecord accountingRecord : data) {
|
|
||||||
logger.debug("{}", accountingRecord);
|
|
||||||
}
|
|
||||||
logger.debug("{}", data);
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.error("", e);
|
logger.error("", e);
|
||||||
|
|
Loading…
Reference in New Issue