Fixed integration of CoreServicesAccessesHarvester
This commit is contained in:
parent
a6cf5c09a4
commit
9d2b2e5010
|
@ -20,6 +20,7 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||
import org.gcube.dataharvest.harvester.CatalogueAccessesHarvester;
|
||||
import org.gcube.dataharvest.harvester.CoreServicesAccessesHarvester;
|
||||
import org.gcube.dataharvest.harvester.MethodInvocationHarvester;
|
||||
import org.gcube.dataharvest.harvester.SocialInteractionsHarvester;
|
||||
import org.gcube.dataharvest.harvester.VREAccessesHarvester;
|
||||
|
@ -258,9 +259,15 @@ public class AccountingDashboardHarvesterPlugin extends Plugin<AccountingDashboa
|
|||
|
||||
if(scopeBean.is(Type.INFRASTRUCTURE)) {
|
||||
try {
|
||||
|
||||
CatalogueAccessesHarvester catalogueHarvester = new CatalogueAccessesHarvester(start, end);
|
||||
List<AccountingRecord> harvested = catalogueHarvester.getAccountingRecords();
|
||||
accountingRecords.addAll(harvested);
|
||||
|
||||
CoreServicesAccessesHarvester coreServicesHarvester = new CoreServicesAccessesHarvester(start, end);
|
||||
List<AccountingRecord> records = coreServicesHarvester.getAccountingRecords();
|
||||
accountingRecords.addAll(records);
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("Error harvesting {} for {}", CatalogueAccessesHarvester.class.getSimpleName(), context, e);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void launch() {
|
||||
try {
|
||||
|
||||
|
@ -109,13 +109,13 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
|||
inputs.put(AccountingDashboardHarvesterPlugin.GET_VRE_USERS_INPUT_PARAMETER, true);
|
||||
inputs.put(AccountingDashboardHarvesterPlugin.RERUN_INPUT_PARAMETER, true);
|
||||
inputs.put(AccountingDashboardHarvesterPlugin.DRY_RUN_INPUT_PARAMETER, false);
|
||||
inputs.put(AccountingDashboardHarvesterPlugin.PARTIAL_HARVESTING, true);
|
||||
inputs.put(AccountingDashboardHarvesterPlugin.PARTIAL_HARVESTING, false);
|
||||
|
||||
/*
|
||||
Calendar from = DateUtils.getStartCalendar(2016, Calendar.SEPTEMBER, 1);
|
||||
Calendar from = DateUtils.getStartCalendar(2020, Calendar.MAY, 1);
|
||||
String fromDate = DateUtils.LAUNCH_DATE_FORMAT.format(from.getTime());
|
||||
logger.trace("{} is {}", AccountingDataHarvesterPlugin.START_DATE_INPUT_PARAMETER, fromDate);
|
||||
inputs.put(AccountingDataHarvesterPlugin.START_DATE_INPUT_PARAMETER, fromDate);
|
||||
logger.trace("{} is {}", AccountingDashboardHarvesterPlugin.START_DATE_INPUT_PARAMETER, fromDate);
|
||||
inputs.put(AccountingDashboardHarvesterPlugin.START_DATE_INPUT_PARAMETER, fromDate);
|
||||
*/
|
||||
|
||||
accountingDataHarvesterPlugin.launch(inputs);
|
||||
|
@ -738,27 +738,29 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
|||
String context = ROOT; //"/gcube";
|
||||
ContextTest.setContextByName(context);
|
||||
|
||||
//AccountingDao dao = getAccountingDao();
|
||||
AccountingDao dao = getAccountingDao();
|
||||
|
||||
Date start = DateUtils.getStartCalendar(2020, Calendar.JANUARY, 1).getTime();
|
||||
Date end = DateUtils.getStartCalendar(2020, Calendar.FEBRUARY, 1).getTime();
|
||||
Date start = DateUtils.getStartCalendar(2017, Calendar.MAY, 1).getTime();
|
||||
Date finalEnd = DateUtils.getStartCalendar(2020, Calendar.MAY, 1).getTime();
|
||||
|
||||
/*
|
||||
* Date start = DateUtils.getPreviousPeriod(measureType, false).getTime();
|
||||
* Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false);
|
||||
*/
|
||||
Date end = DateUtils.getEndDateFromStartDate(AggregationType.MONTHLY, start, 1, false);
|
||||
|
||||
ScopeBean scopeBean = new ScopeBean(context);
|
||||
logger.debug("FullName {} - Name {}", scopeBean.toString(), scopeBean.name());
|
||||
|
||||
CoreServicesAccessesHarvester coreServicesHarvester = new CoreServicesAccessesHarvester(start, end);
|
||||
List<AccountingRecord> accountingRecords = coreServicesHarvester.getAccountingRecords();
|
||||
for (AccountingRecord accountingRecord : accountingRecords) {
|
||||
logger.debug("{}", accountingRecord);
|
||||
|
||||
while(end.before(finalEnd)) {
|
||||
CoreServicesAccessesHarvester coreServicesHarvester = new CoreServicesAccessesHarvester(start, end);
|
||||
List<AccountingRecord> accountingRecords = coreServicesHarvester.getAccountingRecords();
|
||||
dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
||||
|
||||
logger.debug("{} -> {} Data Inserted", DateUtils.format(start), DateUtils.format(end));
|
||||
logger.debug("---------------------------------------------------------------------------------------");
|
||||
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(90));
|
||||
start = end;
|
||||
end = DateUtils.getEndDateFromStartDate(AggregationType.MONTHLY, start, 1, false);
|
||||
}
|
||||
logger.debug("{}", accountingRecords);
|
||||
|
||||
//dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1]));
|
||||
|
||||
|
||||
} catch(Exception e) {
|
||||
logger.error("", e);
|
||||
|
|
Loading…
Reference in New Issue