Added harvesting of CatalogueHarvesterPlugin

This commit is contained in:
Luca Frosini 2020-02-12 17:30:04 +01:00
parent a9ab818768
commit c8a87abd73
3 changed files with 16 additions and 13 deletions

View File

@ -19,6 +19,7 @@ import org.gcube.accounting.accounting.summary.access.model.update.AccountingRec
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.MethodInvocationHarvester;
import org.gcube.dataharvest.harvester.SocialInteractionsHarvester;
import org.gcube.dataharvest.harvester.VREAccessesHarvester;
@ -213,7 +214,11 @@ public class AccountingDashboardHarvesterPlugin extends Plugin<AccountingDashboa
ContextAuthorization contextAuthorization = new ContextAuthorization();
// DatabaseManager dbaseManager = new DatabaseManager();
SortedSet<String> contexts = contextAuthorization.getContexts();
String root = contexts.first();
Utils.setContext(contextAuthorization.getTokenForContext(root));
AccountingDao dao = AccountingDao.get();
Set<ScopeDescriptor> scopeDescriptorSet = dao.getContexts();
@ -232,10 +237,6 @@ public class AccountingDashboardHarvesterPlugin extends Plugin<AccountingDashboa
dimensions.set(dimensionMap);
SortedSet<String> contexts = contextAuthorization.getContexts();
// ArrayList<HarvestedData> data = new ArrayList<HarvestedData>();
ArrayList<AccountingRecord> accountingRecords = new ArrayList<AccountingRecord>();
String initialToken = SecurityTokenProvider.instance.get();
@ -255,6 +256,16 @@ public class AccountingDashboardHarvesterPlugin extends Plugin<AccountingDashboa
scopeDescriptor.set(actualScopeDescriptor);
if(scopeBean.is(Type.INFRASTRUCTURE)) {
try {
CatalogueAccessesHarvester catalogueHarvester = new CatalogueAccessesHarvester(start, end);
List<AccountingRecord> harvested = catalogueHarvester.getAccountingRecords();
accountingRecords.addAll(harvested);
}catch (Exception e) {
logger.error("Error harvesting {} for {}", CatalogueAccessesHarvester.class.getSimpleName(), context, e);
}
}
if(vreAccessesHarvester == null) {
@ -369,11 +380,6 @@ public class AccountingDashboardHarvesterPlugin extends Plugin<AccountingDashboa
List<AccountingRecord> harvested = dataMethodDownloadHarvester.getAccountingRecords();
accountingRecords.addAll(harvested);
/*
List<HarvestedData> harvested = dataMethodDownloadHarvester.getData();
data.addAll(harvested);
*/
} catch(Exception e) {
logger.error("Error harvesting Data Method Download for {}", context, e);
}

View File

@ -38,7 +38,6 @@ 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.dataharvest.AccountingDashboardHarvesterPlugin;
import org.gcube.dataharvest.datamodel.AnalyticsReportCredentials;
import org.gcube.dataharvest.datamodel.CatalogueAccessesReportRow;
import org.gcube.dataharvest.datamodel.HarvestedDataKey;

View File

@ -15,8 +15,6 @@ import org.gcube.common.authorization.library.provider.ClientInfo;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.authorization.library.utils.Caller;
import org.gcube.common.scope.api.ScopeProvider;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;