|
|
|
@ -22,6 +22,11 @@ import eu.dnetlib.dhp.schema.oaf.Datasource;
|
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.Organization;
|
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.Relation;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
public class PrepareResultInstRepoAssociation {
|
|
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(PrepareResultInstRepoAssociation.class);
|
|
|
|
@ -51,6 +56,10 @@ public class PrepareResultInstRepoAssociation {
|
|
|
|
|
final String alreadyLinkedPath = parser.get("alreadyLinkedPath");
|
|
|
|
|
log.info("alreadyLinkedPath {}: ", alreadyLinkedPath);
|
|
|
|
|
|
|
|
|
|
List<String> blacklist = Optional.ofNullable(parser.get("blacklist"))
|
|
|
|
|
.map(v -> Arrays.asList(v.split(";")))
|
|
|
|
|
.orElse(new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
SparkConf conf = new SparkConf();
|
|
|
|
|
conf.set("hive.metastore.uris", parser.get("hive_metastore_uris"));
|
|
|
|
|
|
|
|
|
@ -61,7 +70,7 @@ public class PrepareResultInstRepoAssociation {
|
|
|
|
|
readNeededResources(spark, inputPath);
|
|
|
|
|
|
|
|
|
|
removeOutputDir(spark, datasourceOrganizationPath);
|
|
|
|
|
prepareDatasourceOrganization(spark, datasourceOrganizationPath);
|
|
|
|
|
prepareDatasourceOrganization(spark, datasourceOrganizationPath, blacklist);
|
|
|
|
|
|
|
|
|
|
removeOutputDir(spark, alreadyLinkedPath);
|
|
|
|
|
prepareAlreadyLinkedAssociation(spark, alreadyLinkedPath);
|
|
|
|
@ -80,7 +89,15 @@ public class PrepareResultInstRepoAssociation {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void prepareDatasourceOrganization(
|
|
|
|
|
SparkSession spark, String datasourceOrganizationPath) {
|
|
|
|
|
SparkSession spark, String datasourceOrganizationPath, List<String> blacklist) {
|
|
|
|
|
String blacklisted = "";
|
|
|
|
|
if(blacklist.size() > 0 ){
|
|
|
|
|
blacklisted = " AND d.id != '" + blacklist.get(0) + "'";
|
|
|
|
|
for (int i = 1; i < blacklist.size(); i++) {
|
|
|
|
|
blacklisted += " AND d.id != '" + blacklist.get(i) + "'";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String query = "SELECT source datasourceId, target organizationId "
|
|
|
|
|
+ "FROM ( SELECT id "
|
|
|
|
@ -88,7 +105,7 @@ public class PrepareResultInstRepoAssociation {
|
|
|
|
|
+ "WHERE datasourcetype.classid = '"
|
|
|
|
|
+ INSTITUTIONAL_REPO_TYPE
|
|
|
|
|
+ "' "
|
|
|
|
|
+ "AND datainfo.deletedbyinference = false ) d "
|
|
|
|
|
+ "AND datainfo.deletedbyinference = false " + blacklisted + " ) d "
|
|
|
|
|
+ "JOIN ( SELECT source, target "
|
|
|
|
|
+ "FROM relation "
|
|
|
|
|
+ "WHERE lower(relclass) = '"
|
|
|
|
|