feature completed

This commit is contained in:
Massimiliano Assante 2020-05-14 15:33:46 +02:00
parent baab4ba432
commit b041f78e1f
2 changed files with 14 additions and 12 deletions

View File

@ -106,7 +106,7 @@ public class CoreServicesAccessesHarvester extends BasicHarvester {
int messagesAccesses = 0; int messagesAccesses = 0;
int notificationsAccesses = 0; int notificationsAccesses = 0;
int profileAccesses = 0; int profileAccesses = 0;
logger.debug("CoreServices accesses for {} ", dashboardContext); logger.debug("{};", dashboardContext);
for(CoreServiceAccessesReportRow row : coreServicesAccesses.get(dashboardContext)) { for(CoreServiceAccessesReportRow row : coreServicesAccesses.get(dashboardContext)) {
// String pagePath = row.getPagePath(); // String pagePath = row.getPagePath();
switch (row.getKey()) { switch (row.getKey()) {
@ -135,13 +135,13 @@ public class CoreServicesAccessesHarvester extends BasicHarvester {
AccountingRecord ar2 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.MESSAGES_ACCESSES), (long) messagesAccesses); AccountingRecord ar2 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.MESSAGES_ACCESSES), (long) messagesAccesses);
AccountingRecord ar3 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.NOTIFICATIONS_ACCESSES), (long) notificationsAccesses); AccountingRecord ar3 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.NOTIFICATIONS_ACCESSES), (long) notificationsAccesses);
AccountingRecord ar4 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.PROFILE_ACCESSES), (long) profileAccesses); AccountingRecord ar4 = new AccountingRecord(scopeDescriptor, instant, getDimension(HarvestedDataKey.PROFILE_ACCESSES), (long) profileAccesses);
logger.debug("{} : {}", ar1.getDimension().getId(), ar1.getMeasure()); logger.debug("{};{}", ar1.getDimension().getId(), ar1.getMeasure());
accountingRecords.add(ar1); accountingRecords.add(ar1);
logger.debug("{} : {}", ar2.getDimension().getId(), ar2.getMeasure()); logger.debug("{};{}", ar2.getDimension().getId(), ar2.getMeasure());
accountingRecords.add(ar2); accountingRecords.add(ar2);
logger.debug("{} : {}", ar3.getDimension().getId(), ar3.getMeasure()); logger.debug("{};{}", ar3.getDimension().getId(), ar3.getMeasure());
accountingRecords.add(ar3); accountingRecords.add(ar3);
logger.debug("{} : {}", ar4.getDimension().getId(), ar4.getMeasure()); logger.debug("{};{}", ar4.getDimension().getId(), ar4.getMeasure());
accountingRecords.add(ar4); accountingRecords.add(ar4);
} }
@ -171,16 +171,18 @@ public class CoreServicesAccessesHarvester extends BasicHarvester {
HashMap<String,List<GetReportsResponse>> responses = getReportResponses(service, credentialsFromD4S.getViewIds(), dateRange); HashMap<String,List<GetReportsResponse>> responses = getReportResponses(service, credentialsFromD4S.getViewIds(), dateRange);
HashMap<String, List<CoreServiceAccessesReportRow>> toReturn = new HashMap<>(); HashMap<String, List<CoreServiceAccessesReportRow>> toReturn = new HashMap<>();
int i = 1;
for(String view : responses.keySet()) { for(String view : responses.keySet()) {
String dashboardContext = getAccountingDashboardContextGivenGAViewID(view); String dashboardContext = getAccountingDashboardContextGivenGAViewID(view);
if (dashboardContext != null ) { if (dashboardContext != null ) {
logger.trace("Parsing responses for this Gateway view, which corresponds to Dashboard Context: " + dashboardContext); logger.trace("\n ({}) *** Parsing responses for this Gateway view, which corresponds to Dashboard Context: {} \n", i, dashboardContext );
List<CoreServiceAccessesReportRow> viewReport = parseResponse(view, responses.get(view), dashboardContext); List<CoreServiceAccessesReportRow> viewReport = parseResponse(view, responses.get(view), dashboardContext);
logger.trace("Got {} entries from view id={}", viewReport.size(), view); logger.trace("Got {} entries from view id={}", viewReport.size(), view);
toReturn.put(dashboardContext, viewReport); toReturn.put(dashboardContext, viewReport);
} else { } else {
logger.warn("Got entries from view id={} but cannot find Dashboard Context correspondance, I think you need to update the Generic Resource of the Mappings", view); logger.warn("Got entries from view id={} but cannot find Dashboard Context correspondance, I think you need to update the Generic Resource of the Mappings", view);
} }
i++;
} }
return toReturn; return toReturn;
} }
@ -274,22 +276,22 @@ public class CoreServicesAccessesHarvester extends BasicHarvester {
if (!pagePath.contains("_redirect=/group")) { if (!pagePath.contains("_redirect=/group")) {
if ( pagePath.contains(PAGE_WORKSPACE_ACCESSES)) { if ( pagePath.contains(PAGE_WORKSPACE_ACCESSES)) {
var.setKey(HarvestedDataKey.WORKSPACE_ACCESSES); var.setKey(HarvestedDataKey.WORKSPACE_ACCESSES);
System.out.println("\n **matched "+pagePath); logger.trace("**matched "+pagePath);
validEntry = true; validEntry = true;
} }
else if ( pagePath.contains(PAGE_MESSAGES_ACCESSES)) { else if ( pagePath.contains(PAGE_MESSAGES_ACCESSES)) {
var.setKey(HarvestedDataKey.MESSAGES_ACCESSES); var.setKey(HarvestedDataKey.MESSAGES_ACCESSES);
System.out.println("\n **matched "+pagePath); logger.trace("**matched "+pagePath);
validEntry = true; validEntry = true;
} }
else if ( pagePath.contains(PAGE_PROFILE_ACCESSES)) { else if ( pagePath.contains(PAGE_PROFILE_ACCESSES)) {
var.setKey(HarvestedDataKey.PROFILE_ACCESSES); var.setKey(HarvestedDataKey.PROFILE_ACCESSES);
System.out.println("\n **matched "+pagePath); logger.trace("**matched "+pagePath);
validEntry = true; validEntry = true;
} }
else if ( pagePath.contains(PAGE_NOTIFICATION_ACCESSES)) { else if ( pagePath.contains(PAGE_NOTIFICATION_ACCESSES)) {
var.setKey(HarvestedDataKey.NOTIFICATIONS_ACCESSES); var.setKey(HarvestedDataKey.NOTIFICATIONS_ACCESSES);
System.out.println("\n **matched "+pagePath); logger.trace("**matched "+pagePath);
validEntry = true; validEntry = true;
} }
} }

View File

@ -741,8 +741,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
//AccountingDao dao = getAccountingDao(); //AccountingDao dao = getAccountingDao();
Date start = DateUtils.getStartCalendar(2020, Calendar.JANUARY, 1).getTime(); Date start = DateUtils.getStartCalendar(2020, Calendar.APRIL, 1).getTime();
Date end = DateUtils.getStartCalendar(2020, Calendar.FEBRUARY, 1).getTime(); Date end = DateUtils.getStartCalendar(2020, Calendar.MAY, 1).getTime();
/* /*
* Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); * Date start = DateUtils.getPreviousPeriod(measureType, false).getTime();