From 40160d171f736e38834dcfcd568c45a0c97056c7 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 9 Nov 2020 12:58:36 +0100 Subject: [PATCH] organizations pids --- .../raw/MigrateDbEntitiesApplication.java | 21 ++++++------ .../dhp/oa/graph/sql/queryOrganizations.sql | 32 +++++++++++++++---- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/MigrateDbEntitiesApplication.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/MigrateDbEntitiesApplication.java index adf7b92be2..6365a1db9b 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/MigrateDbEntitiesApplication.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/MigrateDbEntitiesApplication.java @@ -38,7 +38,11 @@ import java.io.IOException; import java.sql.Array; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Objects; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; @@ -174,7 +178,8 @@ public class MigrateDbEntitiesApplication extends AbstractMigrationApplication i execute(sqlFile, producer, oaf -> true); } - public void execute(final String sqlFile, final Function> producer, + public void execute(final String sqlFile, + final Function> producer, final Predicate predicate) throws Exception { final String sql = IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/dhp/oa/graph/sql/" + sqlFile)); @@ -198,8 +203,7 @@ public class MigrateDbEntitiesApplication extends AbstractMigrationApplication i ds .setOriginalId( Arrays - .asList( - (String[]) rs.getArray("identities").getArray()) + .asList((String[]) rs.getArray("identities").getArray()) .stream() .filter(StringUtils::isNotBlank) .collect(Collectors.toList())); @@ -250,11 +254,8 @@ public class MigrateDbEntitiesApplication extends AbstractMigrationApplication i ds .setJournal( journal( - rs.getString("officialname"), - rs.getString("issnPrinted"), - rs.getString("issnOnline"), - rs.getString("issnLinking"), - info)); // Journal + rs.getString("officialname"), rs.getString("issnPrinted"), rs.getString("issnOnline"), + rs.getString("issnLinking"), info)); // Journal ds.setDataInfo(info); ds.setLastupdatetimestamp(lastUpdateTimestamp); @@ -332,7 +333,7 @@ public class MigrateDbEntitiesApplication extends AbstractMigrationApplication i listKeyValues( createOpenaireId(10, rs.getString("collectedfromid"), true), rs.getString("collectedfromname"))); - o.setPid(new ArrayList<>()); + o.setPid(prepareListOfStructProps(rs.getArray("pid"), info)); o.setDateofcollection(asString(rs.getDate("dateofcollection"))); o.setDateoftransformation(asString(rs.getDate("dateoftransformation"))); o.setExtraInfo(new ArrayList<>()); // Values not present in the DB diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/sql/queryOrganizations.sql b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/sql/queryOrganizations.sql index 3e5de80711..938744b110 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/sql/queryOrganizations.sql +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/sql/queryOrganizations.sql @@ -24,12 +24,30 @@ SELECT d.officialname AS collectedfromname, o.country || '@@@dnet:countries' AS country, 'sysimport:crosswalk:entityregistry@@@dnet:provenance_actions' AS provenanceaction, - ARRAY[]::text[] AS pid - + array_remove(array_agg(DISTINCT i.pid || '###' || i.issuertype), NULL) AS pid FROM dsm_organizations o LEFT OUTER JOIN dsm_datasources d ON (d.id = o.collectedfrom) - - - - - + LEFT OUTER JOIN dsm_organizationpids p ON (p.organization = o.id) + LEFT OUTER JOIN dsm_identities i ON (i.pid = p.pid) +GROUP BY + o.id, + o.legalshortname, + o.legalname, + o.websiteurl, + o.logourl, + o.ec_legalbody, + o.ec_legalperson, + o.ec_nonprofit, + o.ec_researchorganization, + o.ec_highereducation, + o.ec_internationalorganizationeurinterests, + o.ec_internationalorganization, + o.ec_enterprise, + o.ec_smevalidated, + o.ec_nutscode, + o.dateofcollection, + o.lastupdate, + o.trust, + d.id, + d.officialname, + o.country