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.XPathHelper;
|
||||
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.CatalogueAccessesReportRow;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
||||
|
@ -125,7 +126,10 @@ public class CatalogueAccessesHarvester extends BasicHarvester {
|
|||
}
|
||||
}
|
||||
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 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);
|
||||
|
|
|
@ -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.SmartExecutorClientFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.quartz.CronExpression;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -731,40 +730,34 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
public void testCatalogueHarvester() {
|
||||
try {
|
||||
|
||||
//Utils.setContext(RESOURCE_CATALOGUE);
|
||||
ContextTest.setContextByName(ROOT);
|
||||
System.out.println("vaaa");
|
||||
|
||||
String context = "/gcube";
|
||||
ContextTest.setContextByName(context);
|
||||
|
||||
AccountingDao dao = getAccountingDao();
|
||||
|
||||
Date start = DateUtils.getStartCalendar(2020, Calendar.JANUARY, 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);
|
||||
// accountingDataHarvesterPlugin.getConfigParameters();
|
||||
CatalogueAccessesHarvester catalogueHarvester = new CatalogueAccessesHarvester(start, end);
|
||||
List<AccountingRecord> accountingRecords = catalogueHarvester.getAccountingRecords();
|
||||
for (AccountingRecord accountingRecord : accountingRecords) {
|
||||
logger.debug("{}", accountingRecord);
|
||||
}
|
||||
logger.debug("{}", accountingRecords);
|
||||
|
||||
// ContextAuthorization contextAuthorization = new ContextAuthorization();
|
||||
// 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);
|
||||
|
||||
// }
|
||||
dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
||||
|
||||
} catch(Exception e) {
|
||||
logger.error("", e);
|
||||
|
|
Loading…
Reference in New Issue