From 15118e2f18a20410fb2f048601ea31df1740e076 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 7 Jul 2023 11:53:25 +0200 Subject: [PATCH] nwo projects import --- .../importer/CommunityImporterController.java | 2 +- .../community/importer/CommunityImporterService.java | 2 ++ .../src/main/resources/application.properties | 1 + .../src/main/resources/sql/export_nwo_projects.sql | 11 +++++++++++ .../src/main/resources/sql/import_nwo_projects.sql | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 apps/dnet-exporter-api/src/main/resources/sql/export_nwo_projects.sql create mode 100644 apps/dnet-exporter-api/src/main/resources/sql/import_nwo_projects.sql diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterController.java index a8461754..6c55849e 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterController.java @@ -27,7 +27,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; @CrossOrigin(origins = { "*" }) -@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") +@ConditionalOnProperty(value = "openaire.exporter.enable.community.import", havingValue = "true") @Tag(name = "OpenAIRE Communities: Migration API", description = "OpenAIRE Communities: Migration API") public class CommunityImporterController { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterService.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterService.java index de766915..5f013587 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterService.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterService.java @@ -16,6 +16,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dom4j.DocumentHelper; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; @@ -45,6 +46,7 @@ import eu.dnetlib.openaire.exporter.model.context.Context; import eu.dnetlib.openaire.exporter.model.context.Param; @Service +@ConditionalOnProperty(value = "openaire.exporter.enable.community.import", havingValue = "true") public class CommunityImporterService { // common diff --git a/apps/dnet-exporter-api/src/main/resources/application.properties b/apps/dnet-exporter-api/src/main/resources/application.properties index 9d1b9961..3aeb5b58 100644 --- a/apps/dnet-exporter-api/src/main/resources/application.properties +++ b/apps/dnet-exporter-api/src/main/resources/application.properties @@ -25,6 +25,7 @@ management.endpoints.web.path-mapping.health = health # ENABLE / DISABLE CONTROLLERS openaire.exporter.enable.dsm = true openaire.exporter.enable.community = true +openaire.exporter.enable.community.import = false openaire.exporter.enable.context = true openaire.exporter.enable.funders = false openaire.exporter.enable.project = true diff --git a/apps/dnet-exporter-api/src/main/resources/sql/export_nwo_projects.sql b/apps/dnet-exporter-api/src/main/resources/sql/export_nwo_projects.sql new file mode 100644 index 00000000..13d01503 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/resources/sql/export_nwo_projects.sql @@ -0,0 +1,11 @@ +\copy ( + SELECT + 'netherlands' AS community, + 'nwo_________::'||md5(substr(id, 15)) AS project_id, + code AS project_code, + title AS project_name, + acronym AS project_acronym, + 'NWO' AS project_funder + FROM projects + WHERE id LIKE 'nwo\_\_\_\_\_\_\_\_\_::%' +) TO '/tmp/nwo_community_projects.csv' CSV HEADER; diff --git a/apps/dnet-exporter-api/src/main/resources/sql/import_nwo_projects.sql b/apps/dnet-exporter-api/src/main/resources/sql/import_nwo_projects.sql new file mode 100644 index 00000000..91f41172 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/resources/sql/import_nwo_projects.sql @@ -0,0 +1 @@ +\copy community_projects FROM '/tmp/nwo_community_projects.csv' CSV HEADER;