diff --git a/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java b/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java index 2a852cc..df6ed70 100644 --- a/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java +++ b/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java @@ -7,9 +7,7 @@ import java.util.Date; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.Set; import java.util.SortedSet; -import java.util.TreeSet; import org.gcube.dataharvest.dao.DatabaseManager; import org.gcube.dataharvest.datamodel.HarvestedData; @@ -17,8 +15,8 @@ import org.gcube.dataharvest.harvester.MethodInvocationHarvester; import org.gcube.dataharvest.harvester.SocialInteractionsHarvester; import org.gcube.dataharvest.harvester.VREUsersHarvester; import org.gcube.dataharvest.harvester.sobigdata.DataMethodDownloadHarvester; -import org.gcube.dataharvest.harvester.sobigdata.TagMeMethodInvocationHarvester; import org.gcube.dataharvest.harvester.sobigdata.ResourceCatalogueHarvester; +import org.gcube.dataharvest.harvester.sobigdata.TagMeMethodInvocationHarvester; import org.gcube.dataharvest.utils.ContextAuthorization; import org.gcube.dataharvest.utils.DateUtils; import org.gcube.dataharvest.utils.MeasureType; @@ -42,7 +40,6 @@ public class AccountingDataHarvesterPlugin extends Plugin soBigDataContexts = getSoBigDataContexts(contexts, SO_BIG_DATA_CONTEXT + "/"); - try { // Collecting info on Resource Catalogue (Dataset, Application, Deliverables, Methods) ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end); @@ -214,17 +208,6 @@ public class AccountingDataHarvesterPlugin extends Plugin getSoBigDataContexts(Set contexts, String base){ - SortedSet filteredContext = new TreeSet<>(); - for(String context : contexts) { - if(context.startsWith(SO_BIG_DATA_CONTEXT)){ - filteredContext.add(context); - } - } - return filteredContext; - } - /** {@inheritDoc} */ @Override protected void onStop() throws Exception { diff --git a/src/main/java/org/gcube/dataharvest/harvester/sobigdata/SoBigDataHarvester.java b/src/main/java/org/gcube/dataharvest/harvester/sobigdata/SoBigDataHarvester.java index 3efa420..4908331 100644 --- a/src/main/java/org/gcube/dataharvest/harvester/sobigdata/SoBigDataHarvester.java +++ b/src/main/java/org/gcube/dataharvest/harvester/sobigdata/SoBigDataHarvester.java @@ -2,12 +2,20 @@ package org.gcube.dataharvest.harvester.sobigdata; import java.text.ParseException; import java.util.Date; +import java.util.List; +import java.util.Set; import java.util.SortedSet; +import java.util.TreeSet; +import org.gcube.common.resources.gcore.GenericResource; import org.gcube.dataharvest.harvester.BasicHarvester; +import org.gcube.resources.discovery.client.queries.api.SimpleQuery; +import org.gcube.resources.discovery.icclient.ICFactory; public abstract class SoBigDataHarvester extends BasicHarvester { + public static final String SO_BIG_DATA_CONTEXT = "/d4science.research-infrastructures.eu/SoBigData"; + protected SortedSet contexts; public SoBigDataHarvester(Date start, Date end) throws ParseException { @@ -19,7 +27,43 @@ public abstract class SoBigDataHarvester extends BasicHarvester { } public void setContexts(SortedSet contexts) { - this.contexts = contexts; + // Adding trailing slash to SO_BIG_DATA_CONTEXT to avoid to get VO + this.contexts = getSoBigDataContexts(contexts, SO_BIG_DATA_CONTEXT + "/"); + } + + public static String SECONDARY_TYPE_FORMAT = "$resource/Profile/SecondaryType/text() eq '%1s'"; + public static String NAME_FORMAT = "$resource/Profile/Name/text() eq '%1s'"; + + public static String SECONDARY_TYPE = "ExcludingVREs"; + public static String NAME = "AccountingHarvesters"; + + protected SimpleQuery getFilteringGenericResource() { + return ICFactory.queryFor(GenericResource.class) + .addCondition(String.format(SECONDARY_TYPE_FORMAT, SECONDARY_TYPE)) + .addCondition(String.format(NAME_FORMAT, NAME)); + } + + protected void getExcludedContexts(){ + SimpleQuery simpleQuery = getFilteringGenericResource(); + List res = ICFactory.client().submit(simpleQuery); + + } + + protected boolean filterContext(String context) { + return false; + } + + + protected SortedSet getSoBigDataContexts(Set contexts, String base){ + SortedSet filteredContext = new TreeSet<>(); + for(String context : contexts) { + if(context.startsWith(SO_BIG_DATA_CONTEXT)){ + if(!filterContext(context)) { + filteredContext.add(context); + } + } + } + return filteredContext; } }