Updated by Francesco:
- new Resource Catalogue Harvester created. git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-dashboard-harvester-se-plugin@167720 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
deb7890ea1
commit
09a8f2d2dc
|
@ -40,7 +40,9 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
|
|||
public static final String RERUN_INPUT_PARAMETER = "reRun";
|
||||
public static final String DRY_RUN_INPUT_PARAMETER = "dryRun";
|
||||
|
||||
public static final String RESOURCE_CATALOGUE_CONTEXT = "/d4science.research-infrastructures.eu/SoBigData/ResourceCatalogue";
|
||||
public static final String RESOURCE_CATALOGUE_CONTEXT = "RESOURCE_CATALOGUE_CONTEXT";
|
||||
|
||||
//public static final String RESOURCE_CATALOGUE_CONTEXT = "/d4science.research-infrastructures.eu/SoBigData/ResourceCatalogue";
|
||||
public static final String TAGME_CONTEXT = "/d4science.research-infrastructures.eu/SoBigData/TagMe";
|
||||
|
||||
protected Date start;
|
||||
|
@ -63,7 +65,7 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
|
|||
return properties;
|
||||
}
|
||||
|
||||
private void getConfigParameters() throws IOException {
|
||||
public void getConfigParameters() throws IOException {
|
||||
try {
|
||||
Properties properties = new Properties();
|
||||
InputStream input = AccountingDataHarvesterPlugin.class.getClassLoader()
|
||||
|
@ -156,11 +158,17 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
|
|||
logger.error("Error harvesting Context Users for {}", context, e);
|
||||
}
|
||||
|
||||
if(context.startsWith(RESOURCE_CATALOGUE_CONTEXT)) {
|
||||
//Added by Francesco
|
||||
Properties properties = AccountingDataHarvesterPlugin.getProperties().get();
|
||||
String catalogueContext = (String) properties.get(RESOURCE_CATALOGUE_CONTEXT);
|
||||
logger.debug("Read from properties "+RESOURCE_CATALOGUE_CONTEXT+" value: "+catalogueContext);
|
||||
//end
|
||||
|
||||
if(context.startsWith(catalogueContext)) {
|
||||
|
||||
try {
|
||||
// Collecting info on Resource Catalogue (Dataset, Application, Deliverables, Methods)
|
||||
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end,contexts);
|
||||
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end, catalogueContext, contexts);
|
||||
List<HarvestedData> harvested = resourceCatalogueHarvester.getData();
|
||||
data.addAll(harvested);
|
||||
} catch(Exception e) {
|
||||
|
@ -169,7 +177,7 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
|
|||
|
||||
try {
|
||||
// Collecting info on Data/Method download
|
||||
DataMethodDownloadHarvester dataMethodDownloadHarvester = new DataMethodDownloadHarvester(start, end,contexts);;
|
||||
DataMethodDownloadHarvester dataMethodDownloadHarvester = new DataMethodDownloadHarvester(start, end,contexts);
|
||||
List<HarvestedData> harvested = dataMethodDownloadHarvester.getData();
|
||||
data.addAll(harvested);
|
||||
} catch(Exception e) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.dataharvest;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.dataharvest.AccountingDataHarvesterPlugin;
|
||||
import org.gcube.vremanagement.executor.plugin.Plugin;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
/*
|
||||
*
|
||||
*/
|
||||
package org.gcube.dataharvest.datamodel;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The Class HarvestedData.
|
||||
*
|
||||
* @author Eric Perrone (ISTI - CNR)
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
* @author Luca Frosini
|
||||
* @author Francesco Mangiacrapa (ISTI - CNR)
|
||||
*/
|
||||
public class HarvestedData implements Serializable {
|
||||
|
||||
|
@ -14,77 +20,161 @@ public class HarvestedData implements Serializable {
|
|||
*/
|
||||
private static final long serialVersionUID = 3699669951917080213L;
|
||||
|
||||
public static int ACCESSESS = 1;
|
||||
public static int USERS = 2;
|
||||
public static int DATA_METHOD_DOWNLOAD = 3;
|
||||
public static int NEW_CATALOGUE_METHODS = 4;
|
||||
public static int NEW_CATALOGUE_DATASETS = 5;
|
||||
public static int NEW_CATALOGUE_DELIVERABLES = 6;
|
||||
public static int NEW_CATALOGUE_APPLICATIONS = 7;
|
||||
public static int SOCIAL_POSTS = 8;
|
||||
public static int SOCIAL_REPLIES = 9;
|
||||
public static int SOCIAL_LIKES = 10;
|
||||
public static int METHOD_INVOCATIONS = 11;
|
||||
public static int VISUAL_TOOLS = 12;
|
||||
// public static int ACCESSESS = 1;
|
||||
// public static int USERS = 2;
|
||||
// public static int DATA_METHOD_DOWNLOAD = 3;
|
||||
// public static int NEW_CATALOGUE_METHODS = 4;
|
||||
// public static int NEW_CATALOGUE_DATASETS = 5;
|
||||
// public static int NEW_CATALOGUE_DELIVERABLES = 6;
|
||||
// public static int NEW_CATALOGUE_APPLICATIONS = 7;
|
||||
// public static int SOCIAL_POSTS = 8;
|
||||
// public static int SOCIAL_REPLIES = 9;
|
||||
// public static int SOCIAL_LIKES = 10;
|
||||
// public static int METHOD_INVOCATIONS = 11;
|
||||
// public static int VISUAL_TOOLS = 12;
|
||||
|
||||
private int dataType;
|
||||
private String context;
|
||||
private long measure;
|
||||
private Date day;
|
||||
private HarvestedDataKey harvestedDataKey;
|
||||
|
||||
/**
|
||||
* Instantiates a new harvested data.
|
||||
*/
|
||||
public HarvestedData() {
|
||||
|
||||
}
|
||||
|
||||
public HarvestedData(int dataType, String context, long measure, Date day) {
|
||||
super();
|
||||
this.dataType = dataType;
|
||||
/**
|
||||
* Instantiates a new harvested data.
|
||||
*
|
||||
* @param key the key
|
||||
*/
|
||||
private HarvestedData(HarvestedDataKey key){
|
||||
this.harvestedDataKey = key;
|
||||
setDataType(harvestedDataKey.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new harvested data.
|
||||
*
|
||||
* @param key the key
|
||||
* @param context the context
|
||||
* @param measure the measure
|
||||
* @param day the day
|
||||
*/
|
||||
public HarvestedData(HarvestedDataKey key, String context, long measure, Date day) {
|
||||
this(key);
|
||||
this.context = context;
|
||||
this.measure = measure;
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
public HarvestedData(int dataType, String context, long measure) {
|
||||
this.dataType = dataType;
|
||||
/**
|
||||
* Instantiates a new harvested data.
|
||||
*
|
||||
* @param key the key
|
||||
* @param context the context
|
||||
* @param measure the measure
|
||||
*/
|
||||
public HarvestedData(HarvestedDataKey key, String context, long measure) {
|
||||
this(key);
|
||||
this.context = context;
|
||||
this.measure = measure;
|
||||
}
|
||||
|
||||
public void setDataType(int dataType) {
|
||||
/**
|
||||
* Sets the data type.
|
||||
*
|
||||
* @param dataType the new data type
|
||||
*/
|
||||
private void setDataType(int dataType) {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context.
|
||||
*
|
||||
* @param context the new context
|
||||
*/
|
||||
public void setContext(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the measure.
|
||||
*
|
||||
* @param measure the new measure
|
||||
*/
|
||||
public void setMeasure(long measure) {
|
||||
this.measure = measure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the day.
|
||||
*
|
||||
* @param day the new day
|
||||
*/
|
||||
public void setDay(Date day) {
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data type.
|
||||
*
|
||||
* @return the data type
|
||||
*/
|
||||
public int getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the context.
|
||||
*
|
||||
* @return the context
|
||||
*/
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the measure.
|
||||
*
|
||||
* @return the measure
|
||||
*/
|
||||
public long getMeasure() {
|
||||
return measure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the day.
|
||||
*
|
||||
* @return the day
|
||||
*/
|
||||
public Date getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Harvest [context=" + context + ", dataType=" + dataType + ", measure=" + measure + "]";
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("HarvestedData [dataType=");
|
||||
builder.append(dataType);
|
||||
builder.append(", context=");
|
||||
builder.append(context);
|
||||
builder.append(", measure=");
|
||||
builder.append(measure);
|
||||
builder.append(", day=");
|
||||
builder.append(day);
|
||||
builder.append(", harvestedDataKey=");
|
||||
builder.append(harvestedDataKey);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.dataharvest.datamodel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* May 22, 2018
|
||||
*/
|
||||
public enum HarvestedDataKey {
|
||||
|
||||
ACCESSESS(1),
|
||||
USERS(2),
|
||||
DATA_METHOD_DOWNLOAD(3),
|
||||
NEW_CATALOGUE_METHODS(4),
|
||||
NEW_CATALOGUE_DATASETS(5),
|
||||
NEW_CATALOGUE_DELIVERABLES(6),
|
||||
NEW_CATALOGUE_APPLICATIONS(7),
|
||||
SOCIAL_POSTS(8),
|
||||
SOCIAL_REPLIES(9),
|
||||
SOCIAL_LIKES(10),
|
||||
METHOD_INVOCATIONS(11),
|
||||
VISUAL_TOOLS(12);
|
||||
|
||||
private int value;
|
||||
|
||||
HarvestedDataKey(int value){
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public int getValue() {
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
|
@ -16,6 +16,7 @@ import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFact
|
|||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedData;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
||||
import org.gcube.dataharvest.utils.DateUtils;
|
||||
import org.gcube.dataharvest.utils.Utils;
|
||||
import org.json.JSONObject;
|
||||
|
@ -72,7 +73,7 @@ public class MethodInvocationHarvester extends BasicHarvester {
|
|||
JSONObject jsonObject = info.getValue();
|
||||
long numberOfInvocation = jsonObject.getLong(AggregatedUsageRecord.OPERATION_COUNT);
|
||||
|
||||
HarvestedData harvestedData = new HarvestedData(HarvestedData.METHOD_INVOCATIONS, context,
|
||||
HarvestedData harvestedData = new HarvestedData(HarvestedDataKey.METHOD_INVOCATIONS, context,
|
||||
numberOfInvocation);
|
||||
data.add(harvestedData);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.dataharvest.datamodel.HarvestedData;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
||||
import org.gcube.dataharvest.utils.Utils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -42,15 +43,15 @@ public class SocialInteractionsHarvester extends SocialNetworkingHarvester {
|
|||
|
||||
getJson();
|
||||
|
||||
HarvestedData likesH = new HarvestedData(HarvestedData.SOCIAL_LIKES, context, likes);
|
||||
HarvestedData likesH = new HarvestedData(HarvestedDataKey.SOCIAL_LIKES, context, likes);
|
||||
logger.debug("{}", likesH);
|
||||
data.add(likesH);
|
||||
|
||||
HarvestedData postsH = new HarvestedData(HarvestedData.SOCIAL_POSTS, context, posts);
|
||||
HarvestedData postsH = new HarvestedData(HarvestedDataKey.SOCIAL_POSTS, context, posts);
|
||||
logger.debug("{}", postsH);
|
||||
data.add(postsH);
|
||||
|
||||
HarvestedData socialReplies = new HarvestedData(HarvestedData.SOCIAL_REPLIES, context, replies);
|
||||
HarvestedData socialReplies = new HarvestedData(HarvestedDataKey.SOCIAL_REPLIES, context, replies);
|
||||
logger.debug("{}", socialReplies);
|
||||
data.add(socialReplies);
|
||||
|
||||
|
@ -82,7 +83,7 @@ public class SocialInteractionsHarvester extends SocialNetworkingHarvester {
|
|||
JSONObject item = res.getJSONObject(i);
|
||||
long time = item.getLong("time");
|
||||
|
||||
if((startDate.getTime() <= time) && (time <= endDate.getTime())) {
|
||||
if(startDate.getTime() <= time && time <= endDate.getTime()) {
|
||||
posts++;
|
||||
replies += item.getInt("comments_no");
|
||||
likes += item.getInt("likes_no");
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.dataharvest.datamodel.HarvestedData;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
||||
import org.gcube.dataharvest.utils.Utils;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -32,7 +33,7 @@ public class VREUsersHarvester extends SocialNetworkingHarvester {
|
|||
try {
|
||||
String context = Utils.getCurrentContext();
|
||||
int measure = get();
|
||||
HarvestedData harvest = new HarvestedData(HarvestedData.USERS, context, measure);
|
||||
HarvestedData harvest = new HarvestedData(HarvestedDataKey.USERS, context, measure);
|
||||
logger.debug(harvest.toString());
|
||||
ArrayList<HarvestedData> data = new ArrayList<HarvestedData>();
|
||||
data.add(harvest);
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.gcube.common.homelibrary.jcr.repository.JCRRepository;
|
|||
import org.gcube.common.homelibrary.jcr.workspace.JCRWorkspace;
|
||||
import org.gcube.common.homelibrary.jcr.workspace.JCRWorkspaceItem;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedData;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
||||
import org.gcube.dataharvest.utils.DateUtils;
|
||||
import org.gcube.dataharvest.utils.Utils;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -63,7 +64,7 @@ public class DataMethodDownloadHarvester extends SoBigDataHarvester {
|
|||
logger.error("Before getStats()");
|
||||
getStats(item, startDate, endDate);
|
||||
logger.error("After getStats()");
|
||||
HarvestedData harvest = new HarvestedData(HarvestedData.DATA_METHOD_DOWNLOAD, context, count);
|
||||
HarvestedData harvest = new HarvestedData(HarvestedDataKey.DATA_METHOD_DOWNLOAD, context, count);
|
||||
data.add(harvest);
|
||||
logger.debug(harvest.toString());
|
||||
return data;
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
package org.gcube.dataharvest.harvester.sobigdata;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueImpl;
|
||||
import org.gcube.dataharvest.AccountingDataHarvesterPlugin;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedData;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
||||
import org.gcube.dataharvest.utils.DateUtils;
|
||||
import org.gcube.dataharvest.utils.Utils;
|
||||
import org.gcube.portlets.user.urlshortener.UrlEncoderUtil;
|
||||
|
@ -17,80 +25,147 @@ import org.json.JSONObject;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.trentorise.opendata.jackan.model.CkanGroup;
|
||||
|
||||
/**
|
||||
* The Class ResourceCatalogueHarvester.
|
||||
*
|
||||
* @author Eric Perrone (ISTI - CNR)
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
* @author Francesco Mangiacrapa(ISTI - CNR)
|
||||
*/
|
||||
public class ResourceCatalogueHarvester extends SoBigDataHarvester {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ResourceCatalogueHarvester.class);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final String GROUP_LABEL = "group";
|
||||
|
||||
private int cityOfCitizensCounter = 0;
|
||||
private int migrationStudiesCounter = 0;
|
||||
private int societalDebatesCounter = 0;
|
||||
private int wellBeingAndEconomyCounter = 0;
|
||||
private static final String AND = " AND ";
|
||||
|
||||
public static int ROWS = 500;
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ResourceCatalogueHarvester.class);
|
||||
|
||||
protected String solrBaseUrl;
|
||||
|
||||
public ResourceCatalogueHarvester(Date start, Date end, SortedSet<String> contexts) throws ParseException {
|
||||
private DataCatalogueFactory factory;
|
||||
|
||||
private HashMap<String, String> mapTypeToDBEntry;
|
||||
|
||||
private HashMap<String, String> mapCatalogueGroupToVRE;
|
||||
|
||||
private String catalogueContext;
|
||||
|
||||
/**
|
||||
* Instantiates a new resource catalogue harvester.
|
||||
*
|
||||
* @param start the start
|
||||
* @param end the end
|
||||
* @param catalogueContext the catalogue context
|
||||
* @param contexts the contexts
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public ResourceCatalogueHarvester(Date start, Date end, String catalogueContext, SortedSet<String> contexts) throws Exception {
|
||||
super(start, end, contexts);
|
||||
factory = DataCatalogueFactory.getFactory();
|
||||
this.catalogueContext = catalogueContext;
|
||||
|
||||
if(catalogueContext==null || catalogueContext.isEmpty())
|
||||
throw new Exception("The catalogue context is null or empty. Pass a valid scope");
|
||||
|
||||
logger.debug("Catalogue context is: "+catalogueContext);
|
||||
|
||||
Properties properties = AccountingDataHarvesterPlugin.getProperties().get();
|
||||
Set<String> keys = properties.stringPropertyNames();
|
||||
|
||||
mapTypeToDBEntry = new HashMap<String, String>();
|
||||
for (String key : keys) {
|
||||
//System.out.println(key + " : " + properties.getProperty(key));
|
||||
try{
|
||||
HarvestedDataKey valueEnum = HarvestedDataKey.valueOf(key);
|
||||
mapTypeToDBEntry.put(properties.getProperty(key), valueEnum.name());
|
||||
}catch(Exception e){
|
||||
//silent
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Built from properties the mapping 'SystemType' to 'DB entry' : "+mapTypeToDBEntry);
|
||||
|
||||
//GET CATALOGUE'S GROUPS
|
||||
List<String> groups = getGroups(catalogueContext);
|
||||
//NORMALIZING THE GROUP NAME TO MATCH WITH VRE NAME
|
||||
Map<String,String> mapNormalizedGroups = normalizeGroups(groups);
|
||||
logger.debug("Map of Normalized Groups is: "+mapNormalizedGroups);
|
||||
|
||||
//CREATING MAPPING BETWEEN (CATALOGUE GROUP NAME TO VRE NAME)
|
||||
mapCatalogueGroupToVRE = new HashMap<String, String>();
|
||||
Set<String> normalizedGroups = mapNormalizedGroups.keySet();
|
||||
for (String context : contexts) {
|
||||
//logger.trace("Context is: " + context);
|
||||
String loweredVREName =context.substring(context.lastIndexOf("/") + 1, context.length()).toLowerCase();
|
||||
//logger.trace("vreName lowered is: " + loweredVREName);
|
||||
try {
|
||||
if (normalizedGroups.contains(loweredVREName)) {
|
||||
logger.debug("Normalized Groups matching the lowered VRE name: "+loweredVREName);
|
||||
// Creating the map with couple (catalogue group name,
|
||||
// scope)
|
||||
mapCatalogueGroupToVRE.put(mapNormalizedGroups.get(loweredVREName), context);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
// silent
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Map of Catalogue Groups To VRE is: "+mapCatalogueGroupToVRE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the solr base url.
|
||||
*
|
||||
* @return the solr base url
|
||||
*/
|
||||
protected String getSolrBaseUrl() {
|
||||
return "https://ckan-solr-d4s.d4science.org/solr/sobigdata";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.dataharvest.harvester.BasicHarvester#getData()
|
||||
*/
|
||||
@Override
|
||||
public List<HarvestedData> getData() throws Exception {
|
||||
|
||||
ArrayList<HarvestedData> data = new ArrayList<HarvestedData>();
|
||||
List<HarvestedData> dataDeliverable = getDataDeliverable();
|
||||
for(HarvestedData harvest : dataDeliverable) {
|
||||
data.add(harvest);
|
||||
}
|
||||
|
||||
List<HarvestedData> dataMethod = getDataMethod();
|
||||
for(HarvestedData harvest : dataMethod) {
|
||||
data.add(harvest);
|
||||
}
|
||||
List<HarvestedData> data = new ArrayList<HarvestedData>();
|
||||
|
||||
List<HarvestedData> dataDataset = getDataDataset();
|
||||
for(HarvestedData harvest : dataDataset) {
|
||||
data.add(harvest);
|
||||
}
|
||||
//FOR EACH SYSTEM_TYPE
|
||||
for (String systemType : mapTypeToDBEntry.keySet()) {
|
||||
|
||||
List<HarvestedData> dataApplication = getDataApplication();
|
||||
for(HarvestedData harvest : dataApplication) {
|
||||
data.add(harvest);
|
||||
List<String> solrParameters = new ArrayList<String>(1);
|
||||
solrParameters.add("extras_systemtype:\""+systemType+"\"");
|
||||
//EXECUTING THE QUERY IN THE PERIOD
|
||||
String queryResult = executeQueryFor(solrParameters, startDate, endDate, "groups");
|
||||
HarvestedDataKey insertDBKey = HarvestedDataKey.valueOf(mapTypeToDBEntry.get(systemType));
|
||||
logger.info("Creating statistics for type: "+systemType+ " using db key "+insertDBKey);
|
||||
data.addAll(buildListOfHarvestedData(queryResult, insertDBKey));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<HarvestedData> getDataDeliverable() throws Exception {
|
||||
String json = executeQuery("Deliverable");
|
||||
return buildList(json, HarvestedData.NEW_CATALOGUE_DELIVERABLES);
|
||||
}
|
||||
|
||||
public List<HarvestedData> getDataMethod() throws Exception {
|
||||
String json = executeQuery("Method");
|
||||
return buildList(json, HarvestedData.NEW_CATALOGUE_METHODS);
|
||||
}
|
||||
/**
|
||||
* Builds the list of harvested data.
|
||||
*
|
||||
* @param json the json
|
||||
* @param harvestKey the harvest key
|
||||
* @return the list
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
private List<HarvestedData> buildListOfHarvestedData(String json, HarvestedDataKey harvestKey) throws Exception {
|
||||
|
||||
public List<HarvestedData> getDataDataset() throws Exception {
|
||||
String json = executeQuery("Dataset");
|
||||
return buildList(json, HarvestedData.NEW_CATALOGUE_DATASETS);
|
||||
}
|
||||
|
||||
public List<HarvestedData> getDataApplication() throws Exception {
|
||||
String json = executeQuery("Application");
|
||||
return buildList(json, HarvestedData.NEW_CATALOGUE_APPLICATIONS);
|
||||
}
|
||||
|
||||
private List<HarvestedData> buildList(String json, int dataType) throws Exception {
|
||||
ArrayList<HarvestedData> data = new ArrayList<HarvestedData>();
|
||||
JSONObject jsonObject = new JSONObject(json);
|
||||
|
||||
JSONObject responseHeader = jsonObject.getJSONObject("responseHeader");
|
||||
int status = responseHeader.getInt("status");
|
||||
if(status != 0) {
|
||||
|
@ -102,10 +177,15 @@ public class ResourceCatalogueHarvester extends SoBigDataHarvester {
|
|||
JSONObject response = jsonObject.getJSONObject("response");
|
||||
|
||||
int numFound = response.getInt("numFound");
|
||||
HarvestedData h = new HarvestedData(dataType,
|
||||
"/d4science.research-infrastructures.eu/SoBigData/ResourceCatalogue", numFound);
|
||||
logger.debug(h.toString());
|
||||
data.add(h);
|
||||
|
||||
Map<String, Integer> counter = new HashMap<String, Integer>(mapCatalogueGroupToVRE.size()+1);
|
||||
|
||||
for (String groupName : mapCatalogueGroupToVRE.keySet()) {
|
||||
counter.put(groupName, 0);
|
||||
}
|
||||
//Counter for default context of accounting
|
||||
int catalogueContextCount = 0;
|
||||
logger.debug("For "+harvestKey+" has found "+numFound+" doc/s");
|
||||
if(numFound > 0) {
|
||||
|
||||
JSONArray docs = response.getJSONArray("docs");
|
||||
|
@ -115,70 +195,211 @@ public class ResourceCatalogueHarvester extends SoBigDataHarvester {
|
|||
JSONArray groups = doc.getJSONArray("groups");
|
||||
Iterator<Object> git = groups.iterator();
|
||||
while(git.hasNext()) {
|
||||
String groupItem = (String) git.next();
|
||||
counterByGroup(groupItem);
|
||||
String catalogueGroupName = (String) git.next();
|
||||
logger.debug("GroupName found: "+catalogueGroupName);
|
||||
//counterByGroup(groupItem);
|
||||
Integer currentCount = counter.get(catalogueGroupName);
|
||||
if(currentCount!=null)
|
||||
counter.put(catalogueGroupName, currentCount+1);
|
||||
else{
|
||||
logger.warn("No mapping found for Catalogue-Group Name: "+catalogueGroupName+" from VREs. Accounting it in the catalogue context: "+catalogueContext);
|
||||
//counter.put(catalogueContext, counter.get(catalogueContext)+1);
|
||||
catalogueContextCount++;
|
||||
}
|
||||
|
||||
break; //Accounting the item only in the first group found
|
||||
}
|
||||
} catch(JSONException x) {
|
||||
logger.debug("Document without groups");
|
||||
logger.debug("Document without groups, accounting it in the catalogue context");
|
||||
catalogueContextCount++;
|
||||
} catch (Exception e) {
|
||||
logger.error("Skipping parsing error", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
h = new HarvestedData(dataType, "/d4science.research-infrastructures.eu/SoBigData/CityOfCitizens",
|
||||
cityOfCitizensCounter);
|
||||
logger.debug(h.toString());
|
||||
data.add(h);
|
||||
h = new HarvestedData(dataType, "/Migration Studies", migrationStudiesCounter);
|
||||
logger.debug(h.toString());
|
||||
data.add(h);
|
||||
h = new HarvestedData(dataType, "/d4science.research-infrastructures.eu/SoBigData/SocietalDebates",
|
||||
societalDebatesCounter);
|
||||
logger.debug(h.toString());
|
||||
data.add(h);
|
||||
h = new HarvestedData(dataType, "/d4science.research-infrastructures.eu/SoBigData/WellBeingAndEconomy",
|
||||
wellBeingAndEconomyCounter);
|
||||
logger.debug(h.toString());
|
||||
data.add(h);
|
||||
List<HarvestedData> data = new ArrayList<HarvestedData>();
|
||||
logger.trace("The context: "+catalogueContext + " has count: "+catalogueContextCount);
|
||||
data.add(new HarvestedData(harvestKey,catalogueContext, catalogueContextCount));
|
||||
for (String key : counter.keySet()) {
|
||||
logger.trace("The group: "+key + " has count: "+counter.get(key));
|
||||
data.add(new HarvestedData(harvestKey, mapCatalogueGroupToVRE.get(key), counter.get(key)));
|
||||
}
|
||||
|
||||
logger.info("For "+harvestKey+ " in the period [from "+startDate+" to "+endDate+ "] returning accouting data:");
|
||||
for (HarvestedData harvestedData : data) {
|
||||
logger.info(harvestedData.toString());
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
private String executeQuery(String fqSubString) throws Exception {
|
||||
|
||||
String query = getSolrBaseUrl() + "select?";
|
||||
|
||||
String q = UrlEncoderUtil.encodeQuery("metadata_created:[" + DateUtils.dateToStringWithTZ(startDate) + " TO "
|
||||
+ DateUtils.dateToStringWithTZ(endDate) + "]");
|
||||
query += "q=" + q;
|
||||
String fq = UrlEncoderUtil.encodeQuery("extras_systemtype:\"SoBigData.eu: " + fqSubString + "\"");
|
||||
query += "&fq=" + fq + "&wt=json&indent=true";
|
||||
logger.debug(query);
|
||||
|
||||
String json = Utils.getJson(query);
|
||||
// logger.debug(json);
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
private void counterByGroup(String groupName) {
|
||||
cityOfCitizensCounter = migrationStudiesCounter = societalDebatesCounter = wellBeingAndEconomyCounter = 0;
|
||||
switch(groupName) {
|
||||
case "city-of-citizens-group":
|
||||
cityOfCitizensCounter++;
|
||||
break;
|
||||
case "migration-studies":
|
||||
migrationStudiesCounter++;
|
||||
break;
|
||||
case "societal-debates-group":
|
||||
societalDebatesCounter++;
|
||||
break;
|
||||
case "well-being-and-economy-group":
|
||||
wellBeingAndEconomyCounter++;
|
||||
break;
|
||||
/**
|
||||
* Gets the groups.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @return the groups
|
||||
*/
|
||||
private List<String> getGroups(String scope){
|
||||
List<String> groups = new ArrayList<String>();
|
||||
String ckanURL = "";
|
||||
try {
|
||||
DataCatalogueImpl utils = factory.getUtilsPerScope(scope);
|
||||
ckanURL = utils.getCatalogueUrl();
|
||||
List<CkanGroup> theGroups = utils.getGroups();
|
||||
Validate.notNull(theGroups, "The list of Groups is null");
|
||||
for (CkanGroup ckanGroup : theGroups) {
|
||||
groups.add(ckanGroup.getName());
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Error occurred on getting CKAN groups for scope: "+scope+" and CKAN URL: "+ckanURL,e);
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * Execute query.
|
||||
// *
|
||||
// * @param fqSubString the fq sub string
|
||||
// * @return the string
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// //TODO THIS METHOD MUST BE OPTIMIZED USING HttpSolrClient
|
||||
// //We are not considering the rows (the number of documents returned from Solr by default)
|
||||
// private String executeQuery(String fqSubString) throws Exception {
|
||||
//
|
||||
// String query = getSolrBaseUrl().endsWith("/")? getSolrBaseUrl():getSolrBaseUrl()+"/";
|
||||
// query+="select?";
|
||||
//
|
||||
// String q = UrlEncoderUtil.encodeQuery("metadata_created:[" + DateUtils.dateToStringWithTZ(startDate) + " TO "
|
||||
// + DateUtils.dateToStringWithTZ(endDate) + "]");
|
||||
// query += "q=" + q;
|
||||
// String fq = UrlEncoderUtil.encodeQuery("extras_systemtype:\"SoBigData.eu: " + fqSubString + "\"");
|
||||
// query += "&fq=" + fq + "&wt=json&indent=true&rows="+ROWS;
|
||||
// logger.debug("Performing query: "+query);
|
||||
//
|
||||
// String json = Utils.getJson(query);
|
||||
// logger.trace("Response is: "+json);
|
||||
//
|
||||
// return json;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Execute query.
|
||||
*
|
||||
* @param solrParameters the solr parameters
|
||||
* @param startDate the start date
|
||||
* @param endDate the end date
|
||||
* @param flValue the fl value
|
||||
* @return the string
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
//TODO THIS METHOD MUST BE OPTIMIZED USING HttpSolrClient
|
||||
//We are not considering the rows (the number of documents returned from Solr by default)
|
||||
public String executeQueryFor(List<String> solrParameters, Date startDate, Date endDate, String flValue) throws Exception {
|
||||
|
||||
String query = getSolrBaseUrl().endsWith("/")? getSolrBaseUrl():getSolrBaseUrl()+"/";
|
||||
query+="select?";
|
||||
|
||||
String q="";
|
||||
//ADDING START AND END DATE IF ARE VALIDS
|
||||
if(startDate!=null && endDate!=null){
|
||||
q+= "metadata_created:[" + DateUtils.dateToStringWithTZ(startDate) + " TO " + DateUtils.dateToStringWithTZ(endDate) + "]";
|
||||
}
|
||||
|
||||
//ADDING PARAMETERS
|
||||
if(solrParameters!=null && solrParameters.size()>0){
|
||||
q+= q.isEmpty()?"":AND;
|
||||
|
||||
for (int i = 0; i < solrParameters.size()-1; i++) {
|
||||
q+= solrParameters.get(i)+AND;
|
||||
}
|
||||
|
||||
q+= solrParameters.get(solrParameters.size()-1);
|
||||
}
|
||||
|
||||
query += "q=" + UrlEncoderUtil.encodeQuery(q) + "&wt=json&indent=true&rows="+ROWS;
|
||||
query += flValue!=null && !flValue.isEmpty()?"&fl="+UrlEncoderUtil.encodeQuery(flValue):"";
|
||||
logger.debug("\nPerforming query: "+query);
|
||||
String jsonResult = Utils.getJson(query);
|
||||
logger.trace("Response is: "+jsonResult);
|
||||
|
||||
return jsonResult;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the catalogue context.
|
||||
*
|
||||
* @return the catalogueContext
|
||||
*/
|
||||
public String getCatalogueContext() {
|
||||
|
||||
return catalogueContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the catalogue context.
|
||||
*
|
||||
* @param catalogueContext the catalogueContext to set
|
||||
*/
|
||||
public void setCatalogueContext(String catalogueContext) {
|
||||
|
||||
this.catalogueContext = catalogueContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Normalize groups.
|
||||
*
|
||||
* @param groups the groups
|
||||
* @return the map with couple (normalized group name, group name)
|
||||
*/
|
||||
private Map<String,String> normalizeGroups(List<String> groups) {
|
||||
Map<String,String> listNGroups = new HashMap<String,String>(groups.size());
|
||||
for (String group : groups) {
|
||||
String normalizedGroup = group;
|
||||
if(normalizedGroup.endsWith(GROUP_LABEL)){
|
||||
normalizedGroup = normalizedGroup.substring(0, normalizedGroup.length()-GROUP_LABEL.length());
|
||||
}
|
||||
normalizedGroup = normalizedGroup.replaceAll("-","");
|
||||
listNGroups.put(normalizedGroup.toLowerCase(), group);
|
||||
}
|
||||
return listNGroups;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * Gets the data francesco.
|
||||
// *
|
||||
// * @return the data francesco
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// public List<HarvestedData> getDataFrancesco() throws Exception {
|
||||
//
|
||||
// List<HarvestedData> data = new ArrayList<HarvestedData>();
|
||||
//
|
||||
// //FOR EACH SYSTEM_TYPE
|
||||
// for (String systemType : mapTypeToDBEntry.keySet()) {
|
||||
//
|
||||
// List<String> solrParameters = new ArrayList<String>(1);
|
||||
// solrParameters.add("extras_systemtype:\""+systemType+"\"");
|
||||
// //EXECUTING THE QUERY IN THE PERIOD
|
||||
// String queryResult = executeQueryFor(solrParameters, startDate, endDate, "groups");
|
||||
// HarvestedDataKey insertDBKey = HarvestedDataKey.valueOf(mapTypeToDBEntry.get(systemType));
|
||||
// logger.info("Creating statistics for type: "+systemType+ " using db key "+insertDBKey);
|
||||
// data.addAll(buildListOfHarvestedData(queryResult, insertDBKey));
|
||||
// }
|
||||
//
|
||||
// return data;
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
|||
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedData;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
||||
import org.gcube.dataharvest.harvester.BasicHarvester;
|
||||
import org.gcube.dataharvest.utils.DateUtils;
|
||||
import org.gcube.dataharvest.utils.Utils;
|
||||
|
@ -71,7 +72,7 @@ public class TagMeMethodInvocationHarvester extends BasicHarvester {
|
|||
JSONObject jsonObject = info.getValue();
|
||||
long numberOfInvocation = jsonObject.getLong(AggregatedUsageRecord.OPERATION_COUNT);
|
||||
|
||||
HarvestedData harvestedData = new HarvestedData(HarvestedData.METHOD_INVOCATIONS, context,
|
||||
HarvestedData harvestedData = new HarvestedData(HarvestedDataKey.METHOD_INVOCATIONS, context,
|
||||
numberOfInvocation);
|
||||
data.add(harvestedData);
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.dataharvest.utils;
|
|||
|
||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
@ -63,8 +62,9 @@ public class ContextAuthorization {
|
|||
try {
|
||||
String context = map.get(scope).toString();
|
||||
logger.info("Going to generate Token for Context {}", context);
|
||||
UserInfo userInfo = new UserInfo(properties.getProperty(USERNAME, DEFAULT_USERNAME),
|
||||
new ArrayList<>());
|
||||
// UserInfo userInfo = new UserInfo(properties.getProperty(USERNAME, DEFAULT_USERNAME),
|
||||
// new ArrayList<>());
|
||||
UserInfo userInfo = null;
|
||||
String userToken = authorizationService().generateUserToken(userInfo, context);
|
||||
SecurityTokenProvider.instance.set(userToken);
|
||||
String generatedToken = authorizationService()
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
@ -25,7 +26,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(AccountingDataHarvesterPluginTest.class);
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void test() {
|
||||
try {
|
||||
|
||||
|
@ -59,7 +60,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void testMethodInvocation() {
|
||||
try {
|
||||
|
||||
|
@ -80,7 +81,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void testTagMeMethodInvocation() {
|
||||
try {
|
||||
|
||||
|
@ -101,31 +102,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResourceCatalogueHarvester() {
|
||||
try {
|
||||
|
||||
org.gcube.dataharvest.utils.Utils.setContext(RESOURCE_CATALOGUE);
|
||||
|
||||
MeasureType measureType = MeasureType.MONTHLY;
|
||||
|
||||
Date start = DateUtils.getPreviousPeriod(measureType).getTime();
|
||||
Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1);
|
||||
|
||||
LinkedHashMap<String,ScopeBean> map = ContextManager.readContexts();
|
||||
SortedSet<String> contexts = new TreeSet<>(map.keySet());
|
||||
|
||||
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end, contexts);
|
||||
List<HarvestedData> harvestedData = resourceCatalogueHarvester.getData();
|
||||
|
||||
logger.debug("{}", harvestedData);
|
||||
|
||||
} catch(Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void testFilteringGenericResource() {
|
||||
try {
|
||||
org.gcube.dataharvest.utils.Utils.setContext(RESOURCE_CATALOGUE);
|
||||
|
@ -139,7 +117,16 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
|||
LinkedHashMap<String,ScopeBean> map = ContextManager.readContexts();
|
||||
SortedSet<String> contexts = new TreeSet<>(map.keySet());
|
||||
|
||||
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end, contexts);
|
||||
AccountingDataHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDataHarvesterPlugin(null);
|
||||
accountingDataHarvesterPlugin.getConfigParameters();
|
||||
|
||||
//Added by Francesco
|
||||
Properties properties = AccountingDataHarvesterPlugin.getProperties().get();
|
||||
String catalogueContext = (String) properties.get(AccountingDataHarvesterPlugin.RESOURCE_CATALOGUE_CONTEXT);
|
||||
logger.debug("Read from properties "+AccountingDataHarvesterPlugin.RESOURCE_CATALOGUE_CONTEXT+" value: "+catalogueContext);
|
||||
//end
|
||||
|
||||
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end, catalogueContext, contexts);
|
||||
SortedSet<String> excludedContexts = resourceCatalogueHarvester.getExcludedContexts();
|
||||
logger.info("Excluded contexts {}", excludedContexts);
|
||||
SortedSet<String> validContexts = resourceCatalogueHarvester.getFilteredContexts();
|
||||
|
@ -151,4 +138,75 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResourceCatalogueHarvester() {
|
||||
try {
|
||||
|
||||
// Properties properties = AccountingDataHarvesterPlugin.getProperties().get();
|
||||
// //Enumeration<String> enums = (Enumeration<String>) properties.propertyNames();
|
||||
// //System.out.println("enums: " +enums.hasMoreElements());
|
||||
// Set<String> keys = properties.stringPropertyNames();
|
||||
//
|
||||
// Map<String, String> typeToDB = new HashMap<String, String>();
|
||||
// for (String key : keys) {
|
||||
// System.out.println(key + " : " + properties.getProperty(key));
|
||||
//
|
||||
// try{
|
||||
// HarvestedDataKey valueEnum = HarvestedDataKey.valueOf(key);
|
||||
// typeToDB.put(properties.getProperty(key), valueEnum.name());
|
||||
// }catch(Exception e){
|
||||
// //silent
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// System.out.println(typeToDB);
|
||||
|
||||
org.gcube.dataharvest.utils.Utils.setContext(RESOURCE_CATALOGUE);
|
||||
|
||||
MeasureType measureType = MeasureType.MONTHLY;
|
||||
|
||||
// Date start = DateUtils.getPreviousPeriod(measureType).getTime();
|
||||
// Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1);
|
||||
|
||||
//Date start = DateUtils.getPreviousPeriod(measureType).getTime();
|
||||
Date start = DateUtils.getStartCalendar(2016, 12, 01).getTime();
|
||||
Date end = DateUtils.getEndDateFromStartDate(measureType, start, 18);
|
||||
|
||||
LinkedHashMap<String,ScopeBean> map = ContextManager.readContexts();
|
||||
SortedSet<String> contexts = new TreeSet<>(map.keySet());
|
||||
|
||||
for (String context : contexts) {
|
||||
System.out.println("context: "+context);
|
||||
}
|
||||
|
||||
|
||||
AccountingDataHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDataHarvesterPlugin(null);
|
||||
accountingDataHarvesterPlugin.getConfigParameters();
|
||||
|
||||
//Added by Francesco
|
||||
Properties properties = AccountingDataHarvesterPlugin.getProperties().get();
|
||||
String catalogueContext = (String) properties.get(AccountingDataHarvesterPlugin.RESOURCE_CATALOGUE_CONTEXT);
|
||||
logger.debug("Read from properties "+AccountingDataHarvesterPlugin.RESOURCE_CATALOGUE_CONTEXT+" value: "+catalogueContext);
|
||||
//end
|
||||
|
||||
contexts = new TreeSet<String>();
|
||||
contexts.add("/d4science.research-infrastructures.eu/SoBigData/ResourceCatalogue");
|
||||
contexts.add("/d4science.research-infrastructures.eu/SoBigData/TagMe");
|
||||
contexts.add("/d4science.research-infrastructures.eu/SoBigData/WellBeingAndEconomy");
|
||||
contexts.add("/d4science.research-infrastructures.eu/SoBigData/CityOfCitizens");
|
||||
contexts.add("/d4science.research-infrastructures.eu/SoBigData/SocietalDebates");
|
||||
contexts.add("/d4science.research-infrastructures.eu/SoBigData/SportsDataScience");
|
||||
contexts.add("/d4science.research-infrastructures.eu/SoBigData/SMAPH");
|
||||
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end, catalogueContext, contexts);
|
||||
List<HarvestedData> data = resourceCatalogueHarvester.getData();
|
||||
|
||||
for (HarvestedData harvestedData : data) {
|
||||
System.out.println(harvestedData.toString());
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue