From f8b36434088192915bf14a6358d62e1cd3606d47 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 9 Jun 2023 15:31:30 +0200 Subject: [PATCH 01/78] schema for community api --- .../src/main/resources/community-schema.sql | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 libs/dnet-exporter-model/src/main/resources/community-schema.sql diff --git a/libs/dnet-exporter-model/src/main/resources/community-schema.sql b/libs/dnet-exporter-model/src/main/resources/community-schema.sql new file mode 100644 index 00000000..a4860108 --- /dev/null +++ b/libs/dnet-exporter-model/src/main/resources/community-schema.sql @@ -0,0 +1,48 @@ +CREATE TABLE communities ( + id text PRIMARY KEY, + label text NOT NULL, + description text NOT NULL DEFFAULT '', + status text NOT NULL DEFAULT 'hidden', -- all, manager, hidden + type text NOT NULL, -- community, ri + subjects text[], + fos text[], + sdg text[], + adv_constraints json, + remove_constraints json, + main_zenodo_community text, + other_zenodo_communities text[], + creation_date timestamp NOT NULL DEFAULT now(), + logo_url text +); + +CREATE TABLE community_projects ( + community text NOT NULL REFERENCES communities(id), + project_id text NOT NULL, + project_code text NOT NULL, + project_name text NOT NULL, + project_acronym text, + project_funder text NOT NULL, + PRIMARY KEY (community, project_id) +); + +CREATE TABLE community_datasources ( + community text NOT NULL REFERENCES communities(id), + ds_id text NOT NULL, + ds_name text NOT NULL, + constraints json, + PRIMARY KEY (community, ds_id) +); + +CREATE TABLE community_support_orgs ( + community text REFERENCES communities(id), + org_name text NOT NULL, + org_url text NOT NULL, + org_logourl text NOT NULL, + PRIMARY KEY (community, org_name) +); + +CREATE TABLE community_orgs ( + community text REFERENCES communities(id), + org_id text NOT NULL, + PRIMARY KEY (community, org_id) +); From 827dec7a29f2c98fb6392ebe5ad44b3b9180f80b Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 12 Jun 2023 10:59:20 +0200 Subject: [PATCH 02/78] sql folder --- .../src/main/resources/{ => sql}/community-schema.sql | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) rename libs/dnet-exporter-model/src/main/resources/{ => sql}/community-schema.sql (84%) diff --git a/libs/dnet-exporter-model/src/main/resources/community-schema.sql b/libs/dnet-exporter-model/src/main/resources/sql/community-schema.sql similarity index 84% rename from libs/dnet-exporter-model/src/main/resources/community-schema.sql rename to libs/dnet-exporter-model/src/main/resources/sql/community-schema.sql index a4860108..0dac52bb 100644 --- a/libs/dnet-exporter-model/src/main/resources/community-schema.sql +++ b/libs/dnet-exporter-model/src/main/resources/sql/community-schema.sql @@ -1,7 +1,14 @@ +DROP TABLE IF EXISTS community_projects; +DROP TABLE IF EXISTS community_datasources; +DROP TABLE IF EXISTS community_support_orgs; +DROP TABLE IF EXISTS community_orgs; +DROP TABLE IF EXISTS communities; + + CREATE TABLE communities ( id text PRIMARY KEY, label text NOT NULL, - description text NOT NULL DEFFAULT '', + description text NOT NULL DEFAULT '', status text NOT NULL DEFAULT 'hidden', -- all, manager, hidden type text NOT NULL, -- community, ri subjects text[], From cdc8084cb6bda61a1bffd1ab8a75f515c18ea5cd Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 12 Jun 2023 14:30:42 +0200 Subject: [PATCH 03/78] community db classes --- apps/dnet-exporter-api/pom.xml | 6 + .../community/db/CommunityService.java | 25 +++ .../community/db/CommunityStatus.java | 7 + .../openaire/community/db/CommunityType.java | 6 + .../community/db/model/Community.java | 201 ++++++++++++++++++ .../db/model/CommunityDatasource.java | 61 ++++++ .../db/model/CommunityDatasourcePK.java | 48 +++++ .../community/db/model/CommunityOrg.java | 49 +++++ .../community/db/model/CommunityOrgPK.java | 47 ++++ .../community/db/model/CommunityProject.java | 97 +++++++++ .../db/model/CommunityProjectPK.java | 47 ++++ .../db/model/CommunitySupportOrg.java | 64 ++++++ .../db/model/CommunitySupportOrgPK.java | 48 +++++ .../CommunityDatasourceRepository.java | 9 + .../db/repository/CommunityOrgRepository.java | 10 + .../CommunityProjectRepository.java | 10 + .../db/repository/CommunityRepository.java | 9 + .../CommunitySupportOrgRepository.java | 10 + .../src/main/resources/global.properties | 4 +- .../main/resources/sql/community-schema.sql | 4 +- 20 files changed, 758 insertions(+), 4 deletions(-) create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityType.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasource.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasourcePK.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrg.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrgPK.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProject.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProjectPK.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrg.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrgPK.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java rename {libs/dnet-exporter-model => apps/dnet-exporter-api}/src/main/resources/sql/community-schema.sql (96%) diff --git a/apps/dnet-exporter-api/pom.xml b/apps/dnet-exporter-api/pom.xml index 06fde34d..36a5e924 100644 --- a/apps/dnet-exporter-api/pom.xml +++ b/apps/dnet-exporter-api/pom.xml @@ -141,6 +141,12 @@ spring-web 5.3.8 + + + com.vladmihalcea + hibernate-types-52 + + diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java new file mode 100644 index 00000000..84a01a97 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java @@ -0,0 +1,25 @@ +package eu.dnetlib.openaire.community.db; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import eu.dnetlib.openaire.community.db.repository.CommunityDatasourceRepository; +import eu.dnetlib.openaire.community.db.repository.CommunityOrgRepository; +import eu.dnetlib.openaire.community.db.repository.CommunityProjectRepository; +import eu.dnetlib.openaire.community.db.repository.CommunityRepository; +import eu.dnetlib.openaire.community.db.repository.CommunitySupportOrgRepository; + +@Service +public class CommunityService { + + @Autowired + private CommunityRepository communityRepository; + @Autowired + private CommunityProjectRepository communityProjectRepository; + @Autowired + private CommunityDatasourceRepository communityDatasourceRepository; + @Autowired + private CommunityOrgRepository communityOrgRepository; + @Autowired + private CommunitySupportOrgRepository communitySupportOrgRepository; +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java new file mode 100644 index 00000000..521da00e --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java @@ -0,0 +1,7 @@ +package eu.dnetlib.openaire.community.db; + +public enum CommunityStatus { + all, + manager, + hidden +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityType.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityType.java new file mode 100644 index 00000000..65f2b175 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityType.java @@ -0,0 +1,6 @@ +package eu.dnetlib.openaire.community.db; + +public enum CommunityType { + community, + ri +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java new file mode 100644 index 00000000..c107d608 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java @@ -0,0 +1,201 @@ +package eu.dnetlib.openaire.community.db.model; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.hibernate.annotations.Type; +import org.hibernate.annotations.TypeDef; +import org.hibernate.annotations.TypeDefs; + +import com.vladmihalcea.hibernate.type.array.StringArrayType; +import com.vladmihalcea.hibernate.type.json.JsonBinaryType; +import com.vladmihalcea.hibernate.type.json.JsonStringType; + +import eu.dnetlib.openaire.community.db.CommunityStatus; +import eu.dnetlib.openaire.community.db.CommunityType; + +@Entity +@Table(name = "communities") +@TypeDefs({ + @TypeDef(name = "string-array", typeClass = StringArrayType.class), + @TypeDef(name = "json", typeClass = JsonStringType.class), + @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) +}) +public class Community implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "id") + private String id; + + @Column(name = "label") + private String label; + + @Column(name = "description") + private String description; + + @Column(name = "status") + @Enumerated(EnumType.STRING) + private CommunityStatus status = CommunityStatus.hidden; + + @Column(name = "type") + @Enumerated(EnumType.STRING) + private CommunityType type; + + @Type(type = "string-array") + @Column(name = "subjects", columnDefinition = "text[]") + private String[] subjects; + + @Type(type = "string-array") + @Column(name = "fos", columnDefinition = "text[]") + private String[] fos; + + @Type(type = "string-array") + @Column(name = "sdg", columnDefinition = "text[]") + private String[] sdg; + + @Type(type = "jsonb") + @Column(name = "adv_constraints") + private String advancedConstraints; + + @Type(type = "jsonb") + @Column(name = "remove_constraints") + private String removeConstraints; + + @Column(name = "main_zenodo_community") + private String mainZenodoCommunity; + + @Type(type = "string-array") + @Column(name = "other_zenodo_communities", columnDefinition = "text[]") + private String[] otherZenodoCommunities; + + @Column(name = "creation_date") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private LocalDateTime creationDate; + + @Column(name = "logo_url") + private String logoUrl; + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(final String label) { + this.label = label; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + + public CommunityStatus getStatus() { + return status; + } + + public void setStatus(final CommunityStatus status) { + this.status = status; + } + + public CommunityType getType() { + return type; + } + + public void setType(final CommunityType type) { + this.type = type; + } + + public String[] getSubjects() { + return subjects; + } + + public void setSubjects(final String[] subjects) { + this.subjects = subjects; + } + + public String[] getFos() { + return fos; + } + + public void setFos(final String[] fos) { + this.fos = fos; + } + + public String[] getSdg() { + return sdg; + } + + public void setSdg(final String[] sdg) { + this.sdg = sdg; + } + + public String getAdvancedConstraints() { + return advancedConstraints; + } + + public void setAdvancedConstraints(final String advancedConstraints) { + this.advancedConstraints = advancedConstraints; + } + + public String getRemoveConstraints() { + return removeConstraints; + } + + public void setRemoveConstraints(final String removeConstraints) { + this.removeConstraints = removeConstraints; + } + + public String getMainZenodoCommunity() { + return mainZenodoCommunity; + } + + public void setMainZenodoCommunity(final String mainZenodoCommunity) { + this.mainZenodoCommunity = mainZenodoCommunity; + } + + public String[] getOtherZenodoCommunities() { + return otherZenodoCommunities; + } + + public void setOtherZenodoCommunities(final String[] otherZenodoCommunities) { + this.otherZenodoCommunities = otherZenodoCommunities; + } + + public LocalDateTime getCreationDate() { + return creationDate; + } + + public void setCreationDate(final LocalDateTime creationDate) { + this.creationDate = creationDate; + } + + public String getLogoUrl() { + return logoUrl; + } + + public void setLogoUrl(final String logoUrl) { + this.logoUrl = logoUrl; + } + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasource.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasource.java new file mode 100644 index 00000000..8623cde8 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasource.java @@ -0,0 +1,61 @@ +package eu.dnetlib.openaire.community.db.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; + +@Entity +@Table(name = "community_datasources") +@IdClass(CommunityDatasourcePK.class) +public class CommunityDatasource implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "community") + private String community; + + @Id + @Column(name = "ds_id") + private String dsId; + + @Column(name = "ds_name") + private String dsName; + + public CommunityDatasource() {} + + public CommunityDatasource(final String community, final String dsId, final String dsName) { + this.community = community; + this.dsId = dsId; + this.dsName = dsName; + } + + public String getCommunity() { + return community; + } + + public void setCommunity(final String community) { + this.community = community; + } + + public String getDsId() { + return dsId; + } + + public void setDsId(final String dsId) { + this.dsId = dsId; + } + + public String getDsName() { + return dsName; + } + + public void setDsName(final String dsName) { + this.dsName = dsName; + } + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasourcePK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasourcePK.java new file mode 100644 index 00000000..848017db --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasourcePK.java @@ -0,0 +1,48 @@ +package eu.dnetlib.openaire.community.db.model; + +import java.io.Serializable; +import java.util.Objects; + +public class CommunityDatasourcePK implements Serializable { + + private static final long serialVersionUID = 1L; + + private String community; + + private String dsId; + + public String getCommunity() { + return community; + } + + public void setCommunity(final String community) { + this.community = community; + } + + public String getDsId() { + return dsId; + } + + public void setDsId(final String dsId) { + this.dsId = dsId; + } + + @Override + public int hashCode() { + return Objects.hash(community, dsId); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { return true; } + if (!(obj instanceof CommunityDatasourcePK)) { return false; } + final CommunityDatasourcePK other = (CommunityDatasourcePK) obj; + return Objects.equals(community, other.community) && Objects.equals(dsId, other.dsId); + } + + @Override + public String toString() { + return String.format("CommunityDatasourcePK [community=%s, dsId=%s]", community, dsId); + } + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrg.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrg.java new file mode 100644 index 00000000..43569acf --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrg.java @@ -0,0 +1,49 @@ +package eu.dnetlib.openaire.community.db.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; + +@Entity +@Table(name = "community_orgs") +@IdClass(CommunityOrgPK.class) +public class CommunityOrg implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "community") + private String community; + + @Id + @Column(name = "org_id") + private String orgId; + + public CommunityOrg() {} + + public CommunityOrg(final String community, final String orgId) { + this.community = community; + this.orgId = orgId; + } + + public String getCommunity() { + return community; + } + + public void setCommunity(final String community) { + this.community = community; + } + + public String getOrgId() { + return orgId; + } + + public void setOrgId(final String orgId) { + this.orgId = orgId; + } + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrgPK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrgPK.java new file mode 100644 index 00000000..aee8f753 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrgPK.java @@ -0,0 +1,47 @@ +package eu.dnetlib.openaire.community.db.model; + +import java.io.Serializable; +import java.util.Objects; + +public class CommunityOrgPK implements Serializable { + + private static final long serialVersionUID = 1L; + + private String community; + + private String orgId; + + public String getCommunity() { + return community; + } + + public void setCommunity(final String community) { + this.community = community; + } + + public String getOrgId() { + return orgId; + } + + public void setOrgId(final String orgId) { + this.orgId = orgId; + } + + @Override + public int hashCode() { + return Objects.hash(community, orgId); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { return true; } + if (!(obj instanceof CommunityDatasourcePK)) { return false; } + final CommunityOrgPK other = (CommunityOrgPK) obj; + return Objects.equals(community, other.community) && Objects.equals(orgId, other.orgId); + } + + @Override + public String toString() { + return String.format("CommunityOrgPK [community=%s, orgId=%s]", community, orgId); + } +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProject.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProject.java new file mode 100644 index 00000000..39322124 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProject.java @@ -0,0 +1,97 @@ +package eu.dnetlib.openaire.community.db.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; + +@Entity +@Table(name = "community_projects") +@IdClass(CommunityProjectPK.class) +public class CommunityProject implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "community") + private String community; + + @Id + @Column(name = "project_id") + private String projectId; + + @Column(name = "project_code") + private String projectCode; + + @Column(name = "project_name") + private String projectName; + + @Column(name = "project_acronym") + private String projectAcronym; + + @Column(name = "project_funder") + private String projectFunder; + + public CommunityProject() {} + + public CommunityProject(final String community, final String projectId, final String projectCode, final String projectName, final String projectAcronym, + final String projectFunder) { + this.community = community; + this.projectId = projectId; + this.projectCode = projectCode; + this.projectName = projectName; + this.projectAcronym = projectAcronym; + this.projectFunder = projectFunder; + } + + public String getCommunity() { + return community; + } + + public void setCommunity(final String community) { + this.community = community; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(final String projectId) { + this.projectId = projectId; + } + + public String getProjectCode() { + return projectCode; + } + + public void setProjectCode(final String projectCode) { + this.projectCode = projectCode; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(final String projectName) { + this.projectName = projectName; + } + + public String getProjectAcronym() { + return projectAcronym; + } + + public void setProjectAcronym(final String projectAcronym) { + this.projectAcronym = projectAcronym; + } + + public String getProjectFunder() { + return projectFunder; + } + + public void setProjectFunder(final String projectFunder) { + this.projectFunder = projectFunder; + } +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProjectPK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProjectPK.java new file mode 100644 index 00000000..d12bb489 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProjectPK.java @@ -0,0 +1,47 @@ +package eu.dnetlib.openaire.community.db.model; + +import java.io.Serializable; +import java.util.Objects; + +public class CommunityProjectPK implements Serializable { + + private static final long serialVersionUID = 1L; + + private String community; + + private String projectId; + + public String getCommunity() { + return community; + } + + public void setCommunity(final String community) { + this.community = community; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(final String projectId) { + this.projectId = projectId; + } + + @Override + public int hashCode() { + return Objects.hash(community, projectId); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { return true; } + if (!(obj instanceof CommunityProjectPK)) { return false; } + final CommunityProjectPK other = (CommunityProjectPK) obj; + return Objects.equals(community, other.community) && Objects.equals(projectId, other.projectId); + } + + @Override + public String toString() { + return String.format("CommunityProjectPK [community=%s, projectId=%s]", community, projectId); + } +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrg.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrg.java new file mode 100644 index 00000000..06d508e2 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrg.java @@ -0,0 +1,64 @@ +package eu.dnetlib.openaire.community.db.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; + +@Entity +@Table(name = "community_support_orgs") +@IdClass(CommunitySupportOrgPK.class) +public class CommunitySupportOrg implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "community") + private String community; + + @Id + @Column(name = "org_name") + private String orgName; + + @Column(name = "org_url") + private String orgUrl; + + @Column(name = "org_logourl") + private String orgLogoUrl; + + public String getCommunity() { + return community; + } + + public void setCommunity(final String community) { + this.community = community; + } + + public String getOrgName() { + return orgName; + } + + public void setOrgName(final String orgName) { + this.orgName = orgName; + } + + public String getOrgUrl() { + return orgUrl; + } + + public void setOrgUrl(final String orgUrl) { + this.orgUrl = orgUrl; + } + + public String getOrgLogoUrl() { + return orgLogoUrl; + } + + public void setOrgLogoUrl(final String orgLogoUrl) { + this.orgLogoUrl = orgLogoUrl; + } + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrgPK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrgPK.java new file mode 100644 index 00000000..78557fbf --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrgPK.java @@ -0,0 +1,48 @@ +package eu.dnetlib.openaire.community.db.model; + +import java.io.Serializable; +import java.util.Objects; + +public class CommunitySupportOrgPK implements Serializable { + + private static final long serialVersionUID = 1L; + + private String community; + + private String orgName; + + public String getCommunity() { + return community; + } + + public void setCommunity(final String community) { + this.community = community; + } + + public String getOrgName() { + return orgName; + } + + public void setOrgName(final String orgName) { + this.orgName = orgName; + } + + @Override + public int hashCode() { + return Objects.hash(community, orgName); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { return true; } + if (!(obj instanceof CommunitySupportOrgPK)) { return false; } + final CommunitySupportOrgPK other = (CommunitySupportOrgPK) obj; + return Objects.equals(community, other.community) && Objects.equals(orgName, other.orgName); + } + + @Override + public String toString() { + return String.format("CommunitySupportOrgPK [community=%s, orgName=%s]", community, orgName); + } + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java new file mode 100644 index 00000000..ef351a78 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java @@ -0,0 +1,9 @@ +package eu.dnetlib.openaire.community.db.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import eu.dnetlib.openaire.community.db.model.Community; + +public interface CommunityDatasourceRepository extends JpaRepository { + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java new file mode 100644 index 00000000..1a128c4e --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java @@ -0,0 +1,10 @@ +package eu.dnetlib.openaire.community.db.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import eu.dnetlib.openaire.community.db.model.CommunityOrg; +import eu.dnetlib.openaire.community.db.model.CommunityOrgPK; + +public interface CommunityOrgRepository extends JpaRepository { + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java new file mode 100644 index 00000000..e911826f --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java @@ -0,0 +1,10 @@ +package eu.dnetlib.openaire.community.db.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import eu.dnetlib.openaire.community.db.model.CommunityProject; +import eu.dnetlib.openaire.community.db.model.CommunityProjectPK; + +public interface CommunityProjectRepository extends JpaRepository { + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java new file mode 100644 index 00000000..1e4d5aee --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java @@ -0,0 +1,9 @@ +package eu.dnetlib.openaire.community.db.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import eu.dnetlib.openaire.community.db.model.Community; + +public interface CommunityRepository extends JpaRepository { + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java new file mode 100644 index 00000000..e50b2c16 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java @@ -0,0 +1,10 @@ +package eu.dnetlib.openaire.community.db.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import eu.dnetlib.openaire.community.db.model.CommunitySupportOrg; +import eu.dnetlib.openaire.community.db.model.CommunitySupportOrgPK; + +public interface CommunitySupportOrgRepository extends JpaRepository { + +} diff --git a/apps/dnet-exporter-api/src/main/resources/global.properties b/apps/dnet-exporter-api/src/main/resources/global.properties index c92fca73..2a7ae380 100644 --- a/apps/dnet-exporter-api/src/main/resources/global.properties +++ b/apps/dnet-exporter-api/src/main/resources/global.properties @@ -15,8 +15,8 @@ openaire.exporter.cxfClientConnectTimeout = 60000 openaire.exporter.cxfClientReceiveTimeout = 120000 # JDBC -#openaire.exporter.jdbc.url = jdbc:postgresql://localhost:5432/dnet_openaireplus -openaire.exporter.jdbc.url = jdbc:postgresql://localhost:5432/dev_openaire_8280 +openaire.exporter.jdbc.url = jdbc:postgresql://localhost:5432/dnet_openaireplus +#openaire.exporter.jdbc.url = jdbc:postgresql://localhost:5432/dev_openaire_8280 openaire.exporter.jdbc.user = dnetapi openaire.exporter.jdbc.pwd = dnetPwd openaire.exporter.jdbc.minIdle = 1 diff --git a/libs/dnet-exporter-model/src/main/resources/sql/community-schema.sql b/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql similarity index 96% rename from libs/dnet-exporter-model/src/main/resources/sql/community-schema.sql rename to apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql index 0dac52bb..fbcff1a6 100644 --- a/libs/dnet-exporter-model/src/main/resources/sql/community-schema.sql +++ b/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql @@ -14,8 +14,8 @@ CREATE TABLE communities ( subjects text[], fos text[], sdg text[], - adv_constraints json, - remove_constraints json, + adv_constraints jsonb, + remove_constraints jsonb, main_zenodo_community text, other_zenodo_communities text[], creation_date timestamp NOT NULL DEFAULT now(), From cb7f5eb52c05ca5845f4d18a9058754746424e39 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 12 Jun 2023 14:47:27 +0200 Subject: [PATCH 04/78] deprecated previous core class --- .../community/CommunityApiController.java | 278 +++++++++--------- .../openaire/community/CommunityApiCore.java | 125 +++++--- .../community/db/CommunityService.java | 155 ++++++++++ .../CommunityDatasourceRepository.java | 2 + .../db/repository/CommunityOrgRepository.java | 2 + .../CommunityProjectRepository.java | 2 + .../db/repository/CommunityRepository.java | 2 + .../CommunitySupportOrgRepository.java | 2 + 8 files changed, 386 insertions(+), 182 deletions(-) diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java index 6793dd72..f0f986b9 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java @@ -10,6 +10,16 @@ import static eu.dnetlib.openaire.common.ExporterConstants.W; import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import eu.dnetlib.openaire.community.db.CommunityService; import eu.dnetlib.openaire.exporter.exceptions.CommunityException; import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException; import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider; @@ -21,16 +31,6 @@ import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties; import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity; import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -45,7 +45,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; public class CommunityApiController { @Autowired - private CommunityApiCore communityApiCore; + private CommunityService communityService; @RequestMapping(value = "/community/communities", produces = { "application/json" @@ -58,7 +58,7 @@ public class CommunityApiController { @ApiResponse(responseCode = "500", description = "unexpected error") }) public List listCommunities() throws CommunityException { - return communityApiCore.listCommunities(); + return communityService.listCommunities(); } @RequestMapping(value = "/community/{id}", produces = { @@ -73,7 +73,7 @@ public class CommunityApiController { @ApiResponse(responseCode = "500", description = "unexpected error") }) public CommunityDetails getCommunity(@PathVariable final String id) throws CommunityException, ResourceNotFoundException { - return communityApiCore.getCommunity(id); + return communityService.getCommunity(id); } @RequestMapping(value = "/community/{id}", produces = { @@ -91,7 +91,7 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final CommunityWritableProperties properties) throws CommunityException, ResourceNotFoundException { - communityApiCore.setCommunity(id, properties); + communityService.setCommunity(id, properties); } @RequestMapping(value = "/community/{id}/projects", produces = { @@ -106,7 +106,7 @@ public class CommunityApiController { @ApiResponse(responseCode = "500", description = "unexpected error") }) public List getCommunityProjects(@PathVariable final String id) throws CommunityException, ResourceNotFoundException { - return communityApiCore.getCommunityProjects(id); + return communityService.getCommunityProjects(id); } @RequestMapping(value = "/community/{id}/projects", produces = { @@ -124,7 +124,7 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final CommunityProject project) throws CommunityException, ResourceNotFoundException { - return communityApiCore.addCommunityProject(id, project); + return communityService.addCommunityProject(id, project); } @RequestMapping(value = "/community/{id}/projects", produces = { @@ -142,45 +142,43 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final Integer projectId) throws CommunityException, ResourceNotFoundException { - communityApiCore.removeCommunityProject(id, projectId); + communityService.removeCommunityProject(id, projectId); } @RequestMapping(value = "/community/{id}/projectList", produces = { - "application/json" + "application/json" }, method = RequestMethod.POST) - @Operation(summary = "associate a list of project to the community", - description = "associate a list of project to the community", tags = { - C_PJ, W + @Operation(summary = "associate a list of project to the community", description = "associate a list of project to the community", tags = { + C_PJ, W }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "not found"), - @ApiResponse(responseCode = "500", description = "unexpected error") + @ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "404", description = "not found"), + @ApiResponse(responseCode = "500", description = "unexpected error") }) public List addCommunityProjectList( - @PathVariable final String id, - @RequestBody final List projectList) throws CommunityException, ResourceNotFoundException { + @PathVariable final String id, + @RequestBody final List projectList) throws CommunityException, ResourceNotFoundException { - return communityApiCore.addCommunityProjectList(id, projectList); + return communityService.addCommunityProjectList(id, projectList); } @RequestMapping(value = "/community/{id}/projectList", produces = { - "application/json" + "application/json" }, method = RequestMethod.DELETE) - @Operation(summary = "remove a list of projects from the community", - description = "remove a list of projects from the community", tags = { - C_PJ, W + @Operation(summary = "remove a list of projects from the community", description = "remove a list of projects from the community", tags = { + C_PJ, W }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "not found"), - @ApiResponse(responseCode = "500", description = "unexpected error") + @ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "404", description = "not found"), + @ApiResponse(responseCode = "500", description = "unexpected error") }) public void deleteCommunityProjectList( - @PathVariable final String id, - @RequestBody final List projectIdList) throws CommunityException, ResourceNotFoundException { + @PathVariable final String id, + @RequestBody final List projectIdList) throws CommunityException, ResourceNotFoundException { - communityApiCore.removeCommunityProjectList(id, projectIdList); + communityService.removeCommunityProjectList(id, projectIdList); } @RequestMapping(value = "/community/{id}/contentproviders", produces = { @@ -195,7 +193,7 @@ public class CommunityApiController { @ApiResponse(responseCode = "500", description = "unexpected error") }) public List getCommunityContentproviders(@PathVariable final String id) throws CommunityException, ResourceNotFoundException { - return communityApiCore.getCommunityContentproviders(id); + return communityService.getCommunityContentproviders(id); } @RequestMapping(value = "/community/{id}/contentproviders", produces = { @@ -213,7 +211,7 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final CommunityContentprovider contentprovider) throws CommunityException, ResourceNotFoundException { - return communityApiCore.addCommunityContentprovider(id, contentprovider); + return communityService.addCommunityContentprovider(id, contentprovider); } @RequestMapping(value = "/community/{id}/contentproviders", produces = { @@ -231,45 +229,43 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final Integer contentproviderId) throws CommunityException, ResourceNotFoundException { - communityApiCore.removeCommunityContentProvider(id, contentproviderId); + communityService.removeCommunityContentProvider(id, contentproviderId); } @RequestMapping(value = "/community/{id}/contentprovidersList", produces = { - "application/json" + "application/json" }, method = RequestMethod.POST) - @Operation(summary = "associate a list of content providers to the community", - description = "associate a list of content providers to the community", tags = { - C_PJ, W + @Operation(summary = "associate a list of content providers to the community", description = "associate a list of content providers to the community", tags = { + C_PJ, W }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "not found"), - @ApiResponse(responseCode = "500", description = "unexpected error") + @ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "404", description = "not found"), + @ApiResponse(responseCode = "500", description = "unexpected error") }) public List addCommunityContentProvidersList( - @PathVariable final String id, - @RequestBody final List contentprovidersList) throws CommunityException, ResourceNotFoundException { + @PathVariable final String id, + @RequestBody final List contentprovidersList) throws CommunityException, ResourceNotFoundException { - return communityApiCore.addCommunityContentProvidersList(id, contentprovidersList); + return communityService.addCommunityContentProvidersList(id, contentprovidersList); } @RequestMapping(value = "/community/{id}/contentprovidersList", produces = { - "application/json" + "application/json" }, method = RequestMethod.DELETE) - @Operation(summary = "remove a list of content providers from the community", - description = "remove a list of content providers from the community", tags = { - C_PJ, W + @Operation(summary = "remove a list of content providers from the community", description = "remove a list of content providers from the community", tags = { + C_PJ, W }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "not found"), - @ApiResponse(responseCode = "500", description = "unexpected error") + @ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "404", description = "not found"), + @ApiResponse(responseCode = "500", description = "unexpected error") }) public void deleteCommunityContentProvidersList( - @PathVariable final String id, - @RequestBody final List contentProviderIdList) throws CommunityException, ResourceNotFoundException { + @PathVariable final String id, + @RequestBody final List contentProviderIdList) throws CommunityException, ResourceNotFoundException { - communityApiCore.removeCommunityContentProviderList(id, contentProviderIdList); + communityService.removeCommunityContentProviderList(id, contentProviderIdList); } // ADDING CODE FOR COMMUNITY ORGANIZATIONS @@ -286,7 +282,7 @@ public class CommunityApiController { @ApiResponse(responseCode = "500", description = "unexpected error") }) public List getCommunityOrganizations(@PathVariable final String id) throws CommunityException, ResourceNotFoundException { - return communityApiCore.getCommunityOrganizations(id); + return communityService.getCommunityOrganizations(id); } @RequestMapping(value = "/community/{id}/organizations", produces = { @@ -304,7 +300,7 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final CommunityOrganization organization) throws CommunityException, ResourceNotFoundException { - return communityApiCore.addCommunityOrganization(id, organization); + return communityService.addCommunityOrganization(id, organization); } @RequestMapping(value = "/community/{id}/organizations", produces = { @@ -322,7 +318,7 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final Integer organizationId) throws CommunityException, ResourceNotFoundException { - communityApiCore.removeCommunityOrganization(id, organizationId); + communityService.removeCommunityOrganization(id, organizationId); } // ********************** @@ -341,7 +337,7 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final List subjects) throws CommunityException, ResourceNotFoundException { - return communityApiCore.addCommunitySubjects(id, subjects); + return communityService.addCommunitySubjects(id, subjects); } @RequestMapping(value = "/community/{id}/subjects", produces = { @@ -359,102 +355,114 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final List subjects) throws CommunityException, ResourceNotFoundException { - return communityApiCore.removeCommunitySubjects(id, subjects); + return communityService.removeCommunitySubjects(id, subjects); } - @RequestMapping(value = "/community/{id}/fos", produces = { "application/json" }, method = RequestMethod.POST) - @Operation( - summary = "associate a fos to the community", - description = "associate a fos to the community", - tags = { C, W }) + + @RequestMapping(value = "/community/{id}/fos", produces = { + "application/json" + }, method = RequestMethod.POST) + @Operation(summary = "associate a fos to the community", description = "associate a fos to the community", tags = { + C, W + }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "not found"), - @ApiResponse(responseCode = "500", description = "unexpected error") }) + @ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "404", description = "not found"), + @ApiResponse(responseCode = "500", description = "unexpected error") + }) public CommunityDetails addCommunityFOS( - @PathVariable final String id, - @RequestBody final List subjects) throws CommunityException, ResourceNotFoundException { + @PathVariable final String id, + @RequestBody final List subjects) throws CommunityException, ResourceNotFoundException { - return communityApiCore.addCommunityFOS(id, subjects); + return communityService.addCommunityFOS(id, subjects); } - @RequestMapping(value = "/community/{id}/fos", produces = { "application/json" }, method = RequestMethod.DELETE) - @Operation( - summary = "remove fos from a community", - description = "remove fos from a community", - tags = { C, W }) + @RequestMapping(value = "/community/{id}/fos", produces = { + "application/json" + }, method = RequestMethod.DELETE) + @Operation(summary = "remove fos from a community", description = "remove fos from a community", tags = { + C, W + }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "not found"), - @ApiResponse(responseCode = "500", description = "unexpected error") }) + @ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "404", description = "not found"), + @ApiResponse(responseCode = "500", description = "unexpected error") + }) public CommunityDetails removeCommunityFOS( - @PathVariable final String id, - @RequestBody final List subjects) throws CommunityException, ResourceNotFoundException { + @PathVariable final String id, + @RequestBody final List subjects) throws CommunityException, ResourceNotFoundException { - return communityApiCore.removeCommunityFOS(id, subjects); + return communityService.removeCommunityFOS(id, subjects); } - - @RequestMapping(value = "/community/{id}/sdg", produces = { "application/json" }, method = RequestMethod.POST) - @Operation( - summary = "associate a sdg to the community", - description = "associate a sdg to the community", - tags = { C, W }) + @RequestMapping(value = "/community/{id}/sdg", produces = { + "application/json" + }, method = RequestMethod.POST) + @Operation(summary = "associate a sdg to the community", description = "associate a sdg to the community", tags = { + C, W + }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "not found"), - @ApiResponse(responseCode = "500", description = "unexpected error") }) + @ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "404", description = "not found"), + @ApiResponse(responseCode = "500", description = "unexpected error") + }) public CommunityDetails addCommunitySDG( - @PathVariable final String id, - @RequestBody final List subjects) throws CommunityException, ResourceNotFoundException { + @PathVariable final String id, + @RequestBody final List subjects) throws CommunityException, ResourceNotFoundException { - return communityApiCore.addCommunitySDG(id, subjects); + return communityService.addCommunitySDG(id, subjects); } - @RequestMapping(value = "/community/{id}/sdg", produces = { "application/json" }, method = RequestMethod.DELETE) - @Operation( - summary = "remove sdg from a community", - description = "remove sdg from a community", - tags = { C, W }) + @RequestMapping(value = "/community/{id}/sdg", produces = { + "application/json" + }, method = RequestMethod.DELETE) + @Operation(summary = "remove sdg from a community", description = "remove sdg from a community", tags = { + C, W + }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "not found"), - @ApiResponse(responseCode = "500", description = "unexpected error") }) + @ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "404", description = "not found"), + @ApiResponse(responseCode = "500", description = "unexpected error") + }) public CommunityDetails removeCommunitySDG( - @PathVariable final String id, - @RequestBody final List subjects) throws CommunityException, ResourceNotFoundException { + @PathVariable final String id, + @RequestBody final List subjects) throws CommunityException, ResourceNotFoundException { - return communityApiCore.removeCommunitySDG(id, subjects); + return communityService.removeCommunitySDG(id, subjects); } - @RequestMapping(value = "/community/{id}/advancedConstraint", produces = { "application/json" }, method = RequestMethod.POST) - @Operation( - summary = "the set of constraints to be used to extend the association between result and community", - description = "the set of constraints to be used to extend the association between result and community", - tags = { C, W }) + @RequestMapping(value = "/community/{id}/advancedConstraint", produces = { + "application/json" + }, method = RequestMethod.POST) + @Operation(summary = "the set of constraints to be used to extend the association between result and community", description = "the set of constraints to be used to extend the association between result and community", tags = { + C, W + }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "not found"), - @ApiResponse(responseCode = "500", description = "unexpected error") }) + @ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "404", description = "not found"), + @ApiResponse(responseCode = "500", description = "unexpected error") + }) public CommunityDetails addAdvancedConstraint( - @PathVariable final String id, - @RequestBody final SelectionCriteria advancedConstraint) throws CommunityException, ResourceNotFoundException { + @PathVariable final String id, + @RequestBody final SelectionCriteria advancedConstraint) throws CommunityException, ResourceNotFoundException { - return communityApiCore.addCommunityAdvancedConstraint(id, advancedConstraint); + return communityService.addCommunityAdvancedConstraint(id, advancedConstraint); } - @RequestMapping(value = "/community/{id}/advancedConstraint", produces = { "application/json" }, method = RequestMethod.DELETE) - @Operation( - summary = "remove the constraints to extend the association result community from a community", - description = "remove the constraints to extend the association result community from a community", - tags = { C, W }) + @RequestMapping(value = "/community/{id}/advancedConstraint", produces = { + "application/json" + }, method = RequestMethod.DELETE) + @Operation(summary = "remove the constraints to extend the association result community from a community", description = "remove the constraints to extend the association result community from a community", tags = { + C, W + }) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "not found"), - @ApiResponse(responseCode = "500", description = "unexpected error") }) + @ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "404", description = "not found"), + @ApiResponse(responseCode = "500", description = "unexpected error") + }) public CommunityDetails removeAdvancedConstraint( - @PathVariable final String id) throws CommunityException, ResourceNotFoundException { + @PathVariable final String id) throws CommunityException, ResourceNotFoundException { - return communityApiCore.removeCommunityAdvancedConstraint(id); + return communityService.removeCommunityAdvancedConstraint(id); } @RequestMapping(value = "/community/{id}/zenodocommunities", produces = { @@ -469,7 +477,7 @@ public class CommunityApiController { @ApiResponse(responseCode = "500", description = "unexpected error") }) public List getCommunityZenodoCommunities(@PathVariable final String id) throws CommunityException, ResourceNotFoundException { - return communityApiCore.getCommunityZenodoCommunities(id); + return communityService.getCommunityZenodoCommunities(id); } @RequestMapping(value = "/community/{id}/zenodocommunities", produces = { @@ -487,7 +495,7 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final CommunityZenodoCommunity zenodocommunity) throws CommunityException, ResourceNotFoundException { - return communityApiCore.addCommunityZenodoCommunity(id, zenodocommunity); + return communityService.addCommunityZenodoCommunity(id, zenodocommunity); } @@ -506,7 +514,7 @@ public class CommunityApiController { @PathVariable final String id, @RequestBody final Integer zenodoCommId) throws CommunityException, ResourceNotFoundException { - communityApiCore.removeCommunityZenodoCommunity(id, zenodoCommId); + communityService.removeCommunityZenodoCommunity(id, zenodoCommId); } @@ -524,7 +532,7 @@ public class CommunityApiController { public CommunityOpenAIRECommunities getOpenAireCommunities( @PathVariable final String zenodoId) throws CommunityException, ResourceNotFoundException { - return communityApiCore.getOpenAIRECommunities(zenodoId); + return communityService.getOpenAIRECommunities(zenodoId); } } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiCore.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiCore.java index 3f0d8dd5..be587eaf 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiCore.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiCore.java @@ -1,22 +1,42 @@ package eu.dnetlib.openaire.community; -import java.util.*; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_NAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_OFFICIALNAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_SELCRITERIA; +import static eu.dnetlib.openaire.community.CommunityConstants.CLABEL; +import static eu.dnetlib.openaire.community.CommunityConstants.CONTENTPROVIDERS_ID_SUFFIX; +import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_LOGOURL; +import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_NAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_WEBSITEURL; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_ADVANCED_CONSTRAINT; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_FOS; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_SDG; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_SUBJECT; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_ACRONYM; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_FULLNAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_FUNDER; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_NUMBER; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_DESCRIPTION; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_LOGOURL; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_NAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_STATUS; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_ZENODOC; +import static eu.dnetlib.openaire.community.CommunityConstants.CSV_DELIMITER; +import static eu.dnetlib.openaire.community.CommunityConstants.ID_SEPARATOR; +import static eu.dnetlib.openaire.community.CommunityConstants.OPENAIRE_ID; +import static eu.dnetlib.openaire.community.CommunityConstants.ORGANIZATION_ID_SUFFIX; +import static eu.dnetlib.openaire.community.CommunityConstants.PROJECTS_ID_SUFFIX; +import static eu.dnetlib.openaire.community.CommunityConstants.ZENODOCOMMUNITY_ID_SUFFIX; + +import java.util.ArrayList; +import java.util.Base64; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.TreeMap; import java.util.stream.Collectors; -import com.google.gson.Gson; - -import eu.dnetlib.openaire.exporter.exceptions.CommunityException; -import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException; -import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider; -import eu.dnetlib.openaire.exporter.model.community.CommunityDetails; -import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities; -import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization; -import eu.dnetlib.openaire.exporter.model.community.CommunityProject; -import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; -import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties; -import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity; -import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; - import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -29,13 +49,24 @@ import com.google.common.base.Functions; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import com.google.gson.Gson; import eu.dnetlib.openaire.common.ISClient; - -import static eu.dnetlib.openaire.community.CommunityConstants.*; +import eu.dnetlib.openaire.exporter.exceptions.CommunityException; +import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException; +import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider; +import eu.dnetlib.openaire.exporter.model.community.CommunityDetails; +import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities; +import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization; +import eu.dnetlib.openaire.exporter.model.community.CommunityProject; +import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; +import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties; +import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; @Component @ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") +@Deprecated public class CommunityApiCore {// implements CommunityClient{ private static final Log log = LogFactory.getLog(CommunityApiCore.class); @@ -59,7 +90,7 @@ public class CommunityApiCore {// implements CommunityClient{ } - private void removeAdvancedConstraint(String id) throws ResourceNotFoundException, CommunityException { + private void removeAdvancedConstraint(final String id) throws ResourceNotFoundException, CommunityException { cc.getCommunity(id); isClient.updateContextParam(id, CPROFILE_ADVANCED_CONSTRAINT, "", false); cc.removeAdvancedConstraint(id); @@ -127,56 +158,56 @@ public class CommunityApiCore {// implements CommunityClient{ } - private CommunityProject updateProject(String id, CommunityProject project) throws CommunityException, ResourceNotFoundException { + private CommunityProject updateProject(final String id, final CommunityProject project) throws CommunityException, ResourceNotFoundException { final TreeMap projects = getCommunityProjectMap(id); - String project_id = project.getId(); + final String project_id = project.getId(); - if (project_id != null && projects.keySet().contains(Integer.valueOf(project_id))){ + if (project_id != null && projects.keySet().contains(Integer.valueOf(project_id))) { if (project.getName() != null) { isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, CPROJECT_FULLNAME, project.getName()); } - if(project.getAcronym()!= null){ + if (project.getAcronym() != null) { isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, CPROJECT_ACRONYM, project.getAcronym()); } - if (project.getOpenaireId() != null){ + if (project.getOpenaireId() != null) { isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, OPENAIRE_ID, project.getOpenaireId()); } - if (project.getFunder() != null){ + if (project.getFunder() != null) { isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, CPROJECT_FUNDER, project.getFunder()); } - if(project.getGrantId() != null){ + if (project.getGrantId() != null) { isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, CPROJECT_NUMBER, project.getGrantId()); } - }else { + } else { project.setId(nextId(projects != null && !projects.isEmpty() ? projects.lastKey() : 0)); isClient.addConcept(id, id + PROJECTS_ID_SUFFIX, CommunityMappingUtils.asProjectXML(id, project)); } - cc.updateProject(id, project ); + cc.updateProject(id, project); return project; } - public List addCommunityProjectList(final String id, final List projectList) throws CommunityException, ResourceNotFoundException { - if(projectList == null || projectList.size() == 0){ + public List addCommunityProjectList(final String id, final List projectList) + throws CommunityException, ResourceNotFoundException { + if (projectList == null || projectList.size() == 0) { throw new CommunityException("parameter 'projectList' must be present and should contain at least one project"); } if (!StringUtils.equalsIgnoreCase(id, projectList.get(0).getCommunityId())) { throw new CommunityException("parameters 'id' and project.communityId must be coherent"); } - List projects = new ArrayList(); + final List projects = new ArrayList(); - for(CommunityProject project : projectList){ + for (final CommunityProject project : projectList) { projects.add(updateProject(id, project)); } - return projects; } @@ -194,7 +225,7 @@ public class CommunityApiCore {// implements CommunityClient{ } public void removeCommunityProjectList(final String id, final List projectIdList) throws CommunityException, ResourceNotFoundException { - for(Integer projectId: projectIdList){ + for (final Integer projectId : projectIdList) { removeCommunityProject(id, projectId); } } @@ -212,7 +243,8 @@ public class CommunityApiCore {// implements CommunityClient{ return updateContentprovider(id, cp); } - private CommunityContentprovider updateContentprovider(String id, CommunityContentprovider cp) throws CommunityException, ResourceNotFoundException { + private CommunityContentprovider updateContentprovider(final String id, final CommunityContentprovider cp) + throws CommunityException, ResourceNotFoundException { final TreeMap cps = getCommunityContentproviderMap(id); final String concept_id = cp.getId(); if (concept_id != null && cps.keySet().contains(Integer.valueOf(concept_id))) { @@ -248,26 +280,27 @@ public class CommunityApiCore {// implements CommunityClient{ cc.removeFromCategory(id, CONTENTPROVIDERS_ID_SUFFIX, String.valueOf(contentproviderId)); } - public List addCommunityContentProvidersList(String id, List contentprovidersList) throws CommunityException, ResourceNotFoundException { - if(contentprovidersList == null || contentprovidersList.size() == 0){ + public List addCommunityContentProvidersList(final String id, final List contentprovidersList) + throws CommunityException, ResourceNotFoundException { + if (contentprovidersList == null || contentprovidersList.size() == 0) { throw new CommunityException("parameter 'contentprovidersList' must be present and should contain at least one content provider"); } if (!StringUtils.equalsIgnoreCase(id, contentprovidersList.get(0).getCommunityId())) { throw new CommunityException("parameters 'id' and contentprovider.communityId must be coherent"); } - List contentproviders = new ArrayList(); + final List contentproviders = new ArrayList(); - for(CommunityContentprovider contentProvider : contentprovidersList){ + for (final CommunityContentprovider contentProvider : contentprovidersList) { contentproviders.add(updateContentprovider(id, contentProvider)); } - return contentproviders; } - public void removeCommunityContentProviderList(final String id, final List contentProviderIdList) throws CommunityException, ResourceNotFoundException { - for(Integer contentProviderId: contentProviderIdList){ + public void removeCommunityContentProviderList(final String id, final List contentProviderIdList) + throws CommunityException, ResourceNotFoundException { + for (final Integer contentProviderId : contentProviderIdList) { removeCommunityContentProvider(id, contentProviderId); } } @@ -326,7 +359,7 @@ public class CommunityApiCore {// implements CommunityClient{ final CommunityDetails cd = new CommunityDetails(); final Set current = Sets.newHashSet(); - if(Optional.ofNullable(cc.getCommunity(id).getFos()).isPresent()){ + if (Optional.ofNullable(cc.getCommunity(id).getFos()).isPresent()) { current.addAll(cc.getCommunity(id).getFos()); } @@ -358,7 +391,7 @@ public class CommunityApiCore {// implements CommunityClient{ final CommunityDetails cd = new CommunityDetails(); final Set current = Sets.newHashSet(); - if(Optional.ofNullable(cc.getCommunity(id).getSdg()).isPresent()){ + if (Optional.ofNullable(cc.getCommunity(id).getSdg()).isPresent()) { current.addAll(cc.getCommunity(id).getSdg()); } @@ -386,7 +419,8 @@ public class CommunityApiCore {// implements CommunityClient{ return cd; } - public CommunityDetails addCommunityAdvancedConstraint(final String id, final SelectionCriteria advancedCosntraint) throws CommunityException, ResourceNotFoundException { + public CommunityDetails addCommunityAdvancedConstraint(final String id, final SelectionCriteria advancedCosntraint) + throws CommunityException, ResourceNotFoundException { final CommunityDetails cd = new CommunityDetails(); @@ -404,8 +438,6 @@ public class CommunityApiCore {// implements CommunityClient{ return new CommunityDetails(); } - - @CacheEvict(value = "community-cache", allEntries = true) public void removeCommunityZenodoCommunity(final String id, final Integer zenodoCommId) throws CommunityException, ResourceNotFoundException { @@ -513,5 +545,4 @@ public class CommunityApiCore {// implements CommunityClient{ return organization; } - } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java index 84a01a97..9486a20b 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java @@ -1,6 +1,9 @@ package eu.dnetlib.openaire.community.db; +import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Service; import eu.dnetlib.openaire.community.db.repository.CommunityDatasourceRepository; @@ -8,8 +11,20 @@ import eu.dnetlib.openaire.community.db.repository.CommunityOrgRepository; import eu.dnetlib.openaire.community.db.repository.CommunityProjectRepository; import eu.dnetlib.openaire.community.db.repository.CommunityRepository; import eu.dnetlib.openaire.community.db.repository.CommunitySupportOrgRepository; +import eu.dnetlib.openaire.exporter.exceptions.CommunityException; +import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException; +import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider; +import eu.dnetlib.openaire.exporter.model.community.CommunityDetails; +import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities; +import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization; +import eu.dnetlib.openaire.exporter.model.community.CommunityProject; +import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; +import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties; +import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity; +import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; @Service +@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") public class CommunityService { @Autowired @@ -22,4 +37,144 @@ public class CommunityService { private CommunityOrgRepository communityOrgRepository; @Autowired private CommunitySupportOrgRepository communitySupportOrgRepository; + + public List listCommunities() throws CommunityException { + // TODO Auto-generated method stub + return null; + } + + public CommunityDetails getCommunity(final String id) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public void setCommunity(final String id, final CommunityWritableProperties details) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + } + + public List getCommunityProjects(final String id) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityProject addCommunityProject(final String id, final CommunityProject project) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public List addCommunityProjectList(final String id, final List projectList) + throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public void removeCommunityProject(final String id, final Integer projectId) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + } + + public void removeCommunityProjectList(final String id, final List projectIdList) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + } + + public List getCommunityContentproviders(final String id) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityContentprovider addCommunityContentprovider(final String id, final CommunityContentprovider cp) + throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public void removeCommunityContentProvider(final String id, final Integer contentproviderId) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + } + + public List addCommunityContentProvidersList(final String id, final List contentprovidersList) + throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public void removeCommunityContentProviderList(final String id, final List contentProviderIdList) + throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + } + + public void removeCommunityOrganization(final String id, final Integer organizationId) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + } + + public List getCommunityZenodoCommunities(final String id) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public List getCommunityOrganizations(final String id) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityDetails addCommunitySubjects(final String id, final List subjects) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityDetails removeCommunitySubjects(final String id, final List subjects) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityDetails addCommunityFOS(final String id, final List foss) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityDetails removeCommunityFOS(final String id, final List foss) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityDetails addCommunitySDG(final String id, final List sdgs) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityDetails removeCommunitySDG(final String id, final List sdgs) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityDetails addCommunityAdvancedConstraint(final String id, final SelectionCriteria advancedCosntraint) + throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityDetails removeCommunityAdvancedConstraint(final String id) throws ResourceNotFoundException, CommunityException { + // TODO Auto-generated method stub + return null; + } + + public void removeCommunityZenodoCommunity(final String id, final Integer zenodoCommId) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + } + + public CommunityZenodoCommunity addCommunityZenodoCommunity(final String id, final CommunityZenodoCommunity zc) + throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityOpenAIRECommunities getOpenAIRECommunities(final String zenodoId) throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + public CommunityOrganization addCommunityOrganization(final String id, final CommunityOrganization organization) + throws CommunityException, ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java index ef351a78..444a9afb 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java @@ -1,9 +1,11 @@ package eu.dnetlib.openaire.community.db.repository; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import eu.dnetlib.openaire.community.db.model.Community; +@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") public interface CommunityDatasourceRepository extends JpaRepository { } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java index 1a128c4e..8184d85f 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java @@ -1,10 +1,12 @@ package eu.dnetlib.openaire.community.db.repository; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import eu.dnetlib.openaire.community.db.model.CommunityOrg; import eu.dnetlib.openaire.community.db.model.CommunityOrgPK; +@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") public interface CommunityOrgRepository extends JpaRepository { } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java index e911826f..725903ae 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java @@ -1,10 +1,12 @@ package eu.dnetlib.openaire.community.db.repository; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import eu.dnetlib.openaire.community.db.model.CommunityProject; import eu.dnetlib.openaire.community.db.model.CommunityProjectPK; +@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") public interface CommunityProjectRepository extends JpaRepository { } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java index 1e4d5aee..f84795bf 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java @@ -1,9 +1,11 @@ package eu.dnetlib.openaire.community.db.repository; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import eu.dnetlib.openaire.community.db.model.Community; +@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") public interface CommunityRepository extends JpaRepository { } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java index e50b2c16..0036e35e 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java @@ -1,10 +1,12 @@ package eu.dnetlib.openaire.community.db.repository; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import eu.dnetlib.openaire.community.db.model.CommunitySupportOrg; import eu.dnetlib.openaire.community.db.model.CommunitySupportOrgPK; +@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") public interface CommunitySupportOrgRepository extends JpaRepository { } From f4c053c0e08bf11d052f85b4605dc9c172494198 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Wed, 14 Jun 2023 11:14:24 +0200 Subject: [PATCH 05/78] new fields --- .../community/db/CommunityClaimType.java | 7 ++++ .../db/CommunityClaimTypeConverter.java | 35 +++++++++++++++++++ .../community/db/CommunityMembershipType.java | 8 +++++ .../db/CommunityMembershipTypeConverter.java | 31 ++++++++++++++++ .../community/db/CommunityStatus.java | 1 + .../community/db/model/Community.java | 29 +++++++++++++++ .../main/resources/sql/community-schema.sql | 4 ++- 7 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimType.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimTypeConverter.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipType.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipTypeConverter.java diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimType.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimType.java new file mode 100644 index 00000000..7e9f0900 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimType.java @@ -0,0 +1,7 @@ +package eu.dnetlib.openaire.community.db; + +public enum CommunityClaimType { + managersOnly, + membersOnly, + all +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimTypeConverter.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimTypeConverter.java new file mode 100644 index 00000000..f04bb752 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimTypeConverter.java @@ -0,0 +1,35 @@ +package eu.dnetlib.openaire.community.db; + +import javax.persistence.AttributeConverter; + +import org.apache.commons.lang3.StringUtils; + +public class CommunityClaimTypeConverter implements AttributeConverter { + + @Override + public String convertToDatabaseColumn(final CommunityClaimType attribute) { + if (attribute == null) { + return null; + } else if (attribute == CommunityClaimType.managersOnly) { + return "managers-only"; + } else if (attribute == CommunityClaimType.membersOnly) { + return "members-only"; + } else { + return attribute.toString(); + } + } + + @Override + public CommunityClaimType convertToEntityAttribute(final String dbData) { + if (StringUtils.isBlank(dbData)) { + return null; + } else if (dbData.equalsIgnoreCase("managers-only")) { + return CommunityClaimType.managersOnly; + } else if (dbData.equalsIgnoreCase("members-only")) { + return CommunityClaimType.membersOnly; + } else { + return CommunityClaimType.valueOf(dbData); + } + } + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipType.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipType.java new file mode 100644 index 00000000..442cd080 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipType.java @@ -0,0 +1,8 @@ +package eu.dnetlib.openaire.community.db; + +public enum CommunityMembershipType { + + open, + byInvitation + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipTypeConverter.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipTypeConverter.java new file mode 100644 index 00000000..1b25e35c --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipTypeConverter.java @@ -0,0 +1,31 @@ +package eu.dnetlib.openaire.community.db; + +import javax.persistence.AttributeConverter; + +import org.apache.commons.lang3.StringUtils; + +public class CommunityMembershipTypeConverter implements AttributeConverter { + + @Override + public String convertToDatabaseColumn(final CommunityMembershipType attribute) { + if (attribute == null) { + return null; + } else if (attribute == CommunityMembershipType.byInvitation) { + return "by-invitation"; + } else { + return attribute.toString(); + } + } + + @Override + public CommunityMembershipType convertToEntityAttribute(final String dbData) { + if (StringUtils.isBlank(dbData)) { + return null; + } else if (dbData.equalsIgnoreCase("by-invitation")) { + return CommunityMembershipType.byInvitation; + } else { + return CommunityMembershipType.valueOf(dbData); + } + } + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java index 521da00e..1c5cb969 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java @@ -3,5 +3,6 @@ package eu.dnetlib.openaire.community.db; public enum CommunityStatus { all, manager, + members, hidden } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java index c107d608..5753220f 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java @@ -4,6 +4,7 @@ import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.Column; +import javax.persistence.Convert; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; @@ -20,6 +21,10 @@ import com.vladmihalcea.hibernate.type.array.StringArrayType; import com.vladmihalcea.hibernate.type.json.JsonBinaryType; import com.vladmihalcea.hibernate.type.json.JsonStringType; +import eu.dnetlib.openaire.community.db.CommunityClaimType; +import eu.dnetlib.openaire.community.db.CommunityClaimTypeConverter; +import eu.dnetlib.openaire.community.db.CommunityMembershipType; +import eu.dnetlib.openaire.community.db.CommunityMembershipTypeConverter; import eu.dnetlib.openaire.community.db.CommunityStatus; import eu.dnetlib.openaire.community.db.CommunityType; @@ -48,10 +53,18 @@ public class Community implements Serializable { @Enumerated(EnumType.STRING) private CommunityStatus status = CommunityStatus.hidden; + @Column(name = "membership") + @Convert(converter = CommunityMembershipTypeConverter.class) + private CommunityMembershipType membership = CommunityMembershipType.byInvitation; + @Column(name = "type") @Enumerated(EnumType.STRING) private CommunityType type; + @Column(name = "claim") + @Convert(converter = CommunityClaimTypeConverter.class) + private CommunityClaimType claim; + @Type(type = "string-array") @Column(name = "subjects", columnDefinition = "text[]") private String[] subjects; @@ -118,6 +131,14 @@ public class Community implements Serializable { this.status = status; } + public CommunityMembershipType getMembership() { + return membership; + } + + public void setMembership(final CommunityMembershipType membership) { + this.membership = membership; + } + public CommunityType getType() { return type; } @@ -126,6 +147,14 @@ public class Community implements Serializable { this.type = type; } + public CommunityClaimType getClaim() { + return claim; + } + + public void setClaim(final CommunityClaimType claim) { + this.claim = claim; + } + public String[] getSubjects() { return subjects; } diff --git a/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql b/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql index fbcff1a6..f6e06032 100644 --- a/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql +++ b/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql @@ -9,8 +9,10 @@ CREATE TABLE communities ( id text PRIMARY KEY, label text NOT NULL, description text NOT NULL DEFAULT '', - status text NOT NULL DEFAULT 'hidden', -- all, manager, hidden + status text NOT NULL DEFAULT 'hidden', -- all, manager, hidden, members + membership text NOT NULL DEFAULT 'by-invitation', -- open by-invitation type text NOT NULL, -- community, ri + claim text, -- managers-only, members-only, all subjects text[], fos text[], sdg text[], From 552d8ae566211f096a027998d400d08cfc73688b Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Wed, 14 Jun 2023 11:17:38 +0200 Subject: [PATCH 06/78] moved enums in a new package --- .../dnetlib/openaire/community/db/CommunityType.java | 6 ------ .../community/db/{ => enums}/CommunityClaimType.java | 2 +- .../db/{ => enums}/CommunityClaimTypeConverter.java | 2 +- .../db/{ => enums}/CommunityMembershipType.java | 2 +- .../CommunityMembershipTypeConverter.java | 2 +- .../community/db/{ => enums}/CommunityStatus.java | 2 +- .../openaire/community/db/enums/CommunityType.java | 6 ++++++ .../openaire/community/db/model/Community.java | 12 ++++++------ 8 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityType.java rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/{ => enums}/CommunityClaimType.java (59%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/{ => enums}/CommunityClaimTypeConverter.java (95%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/{ => enums}/CommunityMembershipType.java (57%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/{ => enums}/CommunityMembershipTypeConverter.java (94%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/{ => enums}/CommunityStatus.java (58%) create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityType.java diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityType.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityType.java deleted file mode 100644 index 65f2b175..00000000 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityType.java +++ /dev/null @@ -1,6 +0,0 @@ -package eu.dnetlib.openaire.community.db; - -public enum CommunityType { - community, - ri -} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimType.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimType.java similarity index 59% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimType.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimType.java index 7e9f0900..c4bbca02 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimType.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimType.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community.db; +package eu.dnetlib.openaire.community.db.enums; public enum CommunityClaimType { managersOnly, diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimTypeConverter.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimTypeConverter.java similarity index 95% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimTypeConverter.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimTypeConverter.java index f04bb752..d9940e49 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityClaimTypeConverter.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimTypeConverter.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community.db; +package eu.dnetlib.openaire.community.db.enums; import javax.persistence.AttributeConverter; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipType.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityMembershipType.java similarity index 57% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipType.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityMembershipType.java index 442cd080..c530a553 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipType.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityMembershipType.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community.db; +package eu.dnetlib.openaire.community.db.enums; public enum CommunityMembershipType { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipTypeConverter.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityMembershipTypeConverter.java similarity index 94% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipTypeConverter.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityMembershipTypeConverter.java index 1b25e35c..e959d2c3 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityMembershipTypeConverter.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityMembershipTypeConverter.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community.db; +package eu.dnetlib.openaire.community.db.enums; import javax.persistence.AttributeConverter; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityStatus.java similarity index 58% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityStatus.java index 1c5cb969..058a52ad 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityStatus.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityStatus.java @@ -1,4 +1,4 @@ -package eu.dnetlib.openaire.community.db; +package eu.dnetlib.openaire.community.db.enums; public enum CommunityStatus { all, diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityType.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityType.java new file mode 100644 index 00000000..9c59b8d1 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityType.java @@ -0,0 +1,6 @@ +package eu.dnetlib.openaire.community.db.enums; + +public enum CommunityType { + community, + ri +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java index 5753220f..dff15706 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java @@ -21,12 +21,12 @@ import com.vladmihalcea.hibernate.type.array.StringArrayType; import com.vladmihalcea.hibernate.type.json.JsonBinaryType; import com.vladmihalcea.hibernate.type.json.JsonStringType; -import eu.dnetlib.openaire.community.db.CommunityClaimType; -import eu.dnetlib.openaire.community.db.CommunityClaimTypeConverter; -import eu.dnetlib.openaire.community.db.CommunityMembershipType; -import eu.dnetlib.openaire.community.db.CommunityMembershipTypeConverter; -import eu.dnetlib.openaire.community.db.CommunityStatus; -import eu.dnetlib.openaire.community.db.CommunityType; +import eu.dnetlib.openaire.community.db.enums.CommunityClaimType; +import eu.dnetlib.openaire.community.db.enums.CommunityClaimTypeConverter; +import eu.dnetlib.openaire.community.db.enums.CommunityMembershipType; +import eu.dnetlib.openaire.community.db.enums.CommunityMembershipTypeConverter; +import eu.dnetlib.openaire.community.db.enums.CommunityStatus; +import eu.dnetlib.openaire.community.db.enums.CommunityType; @Entity @Table(name = "communities") From e604d406bd394e1f95acf6393a698e84bdef7401 Mon Sep 17 00:00:00 2001 From: Michele Artini Date: Wed, 14 Jun 2023 11:20:28 +0200 Subject: [PATCH 07/78] a comma --- .../src/main/resources/sql/community-schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql b/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql index f6e06032..8ae012c3 100644 --- a/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql +++ b/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql @@ -10,7 +10,7 @@ CREATE TABLE communities ( label text NOT NULL, description text NOT NULL DEFAULT '', status text NOT NULL DEFAULT 'hidden', -- all, manager, hidden, members - membership text NOT NULL DEFAULT 'by-invitation', -- open by-invitation + membership text NOT NULL DEFAULT 'by-invitation', -- open, by-invitation type text NOT NULL, -- community, ri claim text, -- managers-only, members-only, all subjects text[], From 9ef99f478593ef92241dfa3b8c8352bbf7a71722 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Wed, 14 Jun 2023 11:23:04 +0200 Subject: [PATCH 08/78] added 2 not null constraints --- .../src/main/resources/sql/community-schema.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql b/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql index 8ae012c3..a895f32d 100644 --- a/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql +++ b/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql @@ -43,7 +43,7 @@ CREATE TABLE community_datasources ( ); CREATE TABLE community_support_orgs ( - community text REFERENCES communities(id), + community text NOT NULL REFERENCES communities(id), org_name text NOT NULL, org_url text NOT NULL, org_logourl text NOT NULL, @@ -51,7 +51,7 @@ CREATE TABLE community_support_orgs ( ); CREATE TABLE community_orgs ( - community text REFERENCES communities(id), + community text NOT NULL REFERENCES communities(id), org_id text NOT NULL, PRIMARY KEY (community, org_id) ); From 71d3ed7ceeebe32ab983ddf5ed6a20f892eaab03 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Wed, 14 Jun 2023 13:53:59 +0200 Subject: [PATCH 09/78] renaming of some classes --- .../community/db/CommunityService.java | 51 ++++++++++++------- .../community/db/ConvertionUtils.java | 25 +++++++++ .../{Community.java => DbCommunity.java} | 2 +- ...unityDatasource.java => DbDatasource.java} | 8 +-- ...yDatasourcePK.java => DbDatasourcePK.java} | 6 +-- ...{CommunityOrg.java => DbOrganization.java} | 8 +-- ...munityOrgPK.java => DbOrganizationPK.java} | 6 +-- .../{CommunityProject.java => DbProject.java} | 8 +-- ...mmunityProjectPK.java => DbProjectPK.java} | 13 +++-- ...unitySupportOrg.java => DbSupportOrg.java} | 4 +- ...ySupportOrgPK.java => DbSupportOrgPK.java} | 6 +-- .../CommunityDatasourceRepository.java | 11 ---- .../db/repository/CommunityOrgRepository.java | 12 ----- .../CommunitySupportOrgRepository.java | 12 ----- ...sitory.java => DbCommunityRepository.java} | 4 +- .../db/repository/DbDatasourceRepository.java | 15 ++++++ .../repository/DbOrganizationRepository.java | 16 ++++++ ...pository.java => DbProjectRepository.java} | 10 ++-- .../db/repository/DbSupportOrgRepository.java | 16 ++++++ 19 files changed, 147 insertions(+), 86 deletions(-) create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/{Community.java => DbCommunity.java} (99%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/{CommunityDatasource.java => DbDatasource.java} (81%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/{CommunityDatasourcePK.java => DbDatasourcePK.java} (81%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/{CommunityOrg.java => DbOrganization.java} (80%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/{CommunityOrgPK.java => DbOrganizationPK.java} (83%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/{CommunityProject.java => DbProject.java} (87%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/{CommunityProjectPK.java => DbProjectPK.java} (74%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/{CommunitySupportOrg.java => DbSupportOrg.java} (92%) rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/{CommunitySupportOrgPK.java => DbSupportOrgPK.java} (82%) delete mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java delete mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java delete mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/{CommunityRepository.java => DbCommunityRepository.java} (67%) create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbDatasourceRepository.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbOrganizationRepository.java rename apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/{CommunityProjectRepository.java => DbProjectRepository.java} (51%) create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbSupportOrgRepository.java diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java index 9486a20b..92d8f7af 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java @@ -1,16 +1,18 @@ package eu.dnetlib.openaire.community.db; import java.util.List; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Service; -import eu.dnetlib.openaire.community.db.repository.CommunityDatasourceRepository; -import eu.dnetlib.openaire.community.db.repository.CommunityOrgRepository; -import eu.dnetlib.openaire.community.db.repository.CommunityProjectRepository; -import eu.dnetlib.openaire.community.db.repository.CommunityRepository; -import eu.dnetlib.openaire.community.db.repository.CommunitySupportOrgRepository; +import eu.dnetlib.openaire.community.db.model.DbProject; +import eu.dnetlib.openaire.community.db.repository.DbCommunityRepository; +import eu.dnetlib.openaire.community.db.repository.DbDatasourceRepository; +import eu.dnetlib.openaire.community.db.repository.DbOrganizationRepository; +import eu.dnetlib.openaire.community.db.repository.DbProjectRepository; +import eu.dnetlib.openaire.community.db.repository.DbSupportOrgRepository; import eu.dnetlib.openaire.exporter.exceptions.CommunityException; import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException; import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider; @@ -28,19 +30,21 @@ import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionC public class CommunityService { @Autowired - private CommunityRepository communityRepository; + private DbCommunityRepository dbCommunityRepository; @Autowired - private CommunityProjectRepository communityProjectRepository; + private DbProjectRepository dbProjectRepository; @Autowired - private CommunityDatasourceRepository communityDatasourceRepository; + private DbDatasourceRepository dbDatasourceRepository; @Autowired - private CommunityOrgRepository communityOrgRepository; + private DbOrganizationRepository dbOrganizationRepository; @Autowired - private CommunitySupportOrgRepository communitySupportOrgRepository; + private DbSupportOrgRepository dbSupportOrgRepository; public List listCommunities() throws CommunityException { - // TODO Auto-generated method stub - return null; + return dbCommunityRepository.findAll() + .stream() + .map(ConvertionUtils::toSummary) + .collect(Collectors.toList()); } public CommunityDetails getCommunity(final String id) throws CommunityException, ResourceNotFoundException { @@ -53,23 +57,32 @@ public class CommunityService { } public List getCommunityProjects(final String id) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + return dbProjectRepository.findByCommunity(id) + .stream() + .map(ConvertionUtils::toCommunityProject) + .collect(Collectors.toList()); } public CommunityProject addCommunityProject(final String id, final CommunityProject project) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + final DbProject p = ConvertionUtils.toDbProject(id, project); + dbProjectRepository.save(p); + return project; } public List addCommunityProjectList(final String id, final List projectList) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + + final List list = projectList.stream() + .map(p -> ConvertionUtils.toDbProject(id, p)) + .collect(Collectors.toList()); + + dbProjectRepository.saveAll(list); + + return projectList; } public void removeCommunityProject(final String id, final Integer projectId) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub + // dbProjectRepository.deleteById(new DbProjectPK(id, projectId)); } public void removeCommunityProjectList(final String id, final List projectIdList) throws CommunityException, ResourceNotFoundException { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java new file mode 100644 index 00000000..5dd3b015 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java @@ -0,0 +1,25 @@ +package eu.dnetlib.openaire.community.db; + +import eu.dnetlib.openaire.community.db.model.DbCommunity; +import eu.dnetlib.openaire.community.db.model.DbProject; +import eu.dnetlib.openaire.exporter.model.community.CommunityProject; +import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; + +public class ConvertionUtils { + + public static CommunitySummary toSummary(final DbCommunity dbEntry) { + // TODO + return null; + } + + public static CommunityProject toCommunityProject(final DbProject dbEntry) { + // TODO + return null; + } + + public static DbProject toDbProject(final String id, final CommunityProject project) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbCommunity.java similarity index 99% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbCommunity.java index dff15706..f78f73c3 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/Community.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbCommunity.java @@ -35,7 +35,7 @@ import eu.dnetlib.openaire.community.db.enums.CommunityType; @TypeDef(name = "json", typeClass = JsonStringType.class), @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) }) -public class Community implements Serializable { +public class DbCommunity implements Serializable { private static final long serialVersionUID = 1L; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasource.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasource.java similarity index 81% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasource.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasource.java index 8623cde8..39c1c003 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasource.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasource.java @@ -10,8 +10,8 @@ import javax.persistence.Table; @Entity @Table(name = "community_datasources") -@IdClass(CommunityDatasourcePK.class) -public class CommunityDatasource implements Serializable { +@IdClass(DbDatasourcePK.class) +public class DbDatasource implements Serializable { private static final long serialVersionUID = 1L; @@ -26,9 +26,9 @@ public class CommunityDatasource implements Serializable { @Column(name = "ds_name") private String dsName; - public CommunityDatasource() {} + public DbDatasource() {} - public CommunityDatasource(final String community, final String dsId, final String dsName) { + public DbDatasource(final String community, final String dsId, final String dsName) { this.community = community; this.dsId = dsId; this.dsName = dsName; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasourcePK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasourcePK.java similarity index 81% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasourcePK.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasourcePK.java index 848017db..ea857a97 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityDatasourcePK.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasourcePK.java @@ -3,7 +3,7 @@ package eu.dnetlib.openaire.community.db.model; import java.io.Serializable; import java.util.Objects; -public class CommunityDatasourcePK implements Serializable { +public class DbDatasourcePK implements Serializable { private static final long serialVersionUID = 1L; @@ -35,8 +35,8 @@ public class CommunityDatasourcePK implements Serializable { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } - if (!(obj instanceof CommunityDatasourcePK)) { return false; } - final CommunityDatasourcePK other = (CommunityDatasourcePK) obj; + if (!(obj instanceof DbDatasourcePK)) { return false; } + final DbDatasourcePK other = (DbDatasourcePK) obj; return Objects.equals(community, other.community) && Objects.equals(dsId, other.dsId); } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrg.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganization.java similarity index 80% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrg.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganization.java index 43569acf..bfe972ef 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrg.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganization.java @@ -10,8 +10,8 @@ import javax.persistence.Table; @Entity @Table(name = "community_orgs") -@IdClass(CommunityOrgPK.class) -public class CommunityOrg implements Serializable { +@IdClass(DbOrganizationPK.class) +public class DbOrganization implements Serializable { private static final long serialVersionUID = 1L; @@ -23,9 +23,9 @@ public class CommunityOrg implements Serializable { @Column(name = "org_id") private String orgId; - public CommunityOrg() {} + public DbOrganization() {} - public CommunityOrg(final String community, final String orgId) { + public DbOrganization(final String community, final String orgId) { this.community = community; this.orgId = orgId; } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrgPK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganizationPK.java similarity index 83% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrgPK.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganizationPK.java index aee8f753..91da15dd 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityOrgPK.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganizationPK.java @@ -3,7 +3,7 @@ package eu.dnetlib.openaire.community.db.model; import java.io.Serializable; import java.util.Objects; -public class CommunityOrgPK implements Serializable { +public class DbOrganizationPK implements Serializable { private static final long serialVersionUID = 1L; @@ -35,8 +35,8 @@ public class CommunityOrgPK implements Serializable { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } - if (!(obj instanceof CommunityDatasourcePK)) { return false; } - final CommunityOrgPK other = (CommunityOrgPK) obj; + if (!(obj instanceof DbDatasourcePK)) { return false; } + final DbOrganizationPK other = (DbOrganizationPK) obj; return Objects.equals(community, other.community) && Objects.equals(orgId, other.orgId); } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProject.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProject.java similarity index 87% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProject.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProject.java index 39322124..98b19b1e 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProject.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProject.java @@ -10,8 +10,8 @@ import javax.persistence.Table; @Entity @Table(name = "community_projects") -@IdClass(CommunityProjectPK.class) -public class CommunityProject implements Serializable { +@IdClass(DbProjectPK.class) +public class DbProject implements Serializable { private static final long serialVersionUID = 1L; @@ -35,9 +35,9 @@ public class CommunityProject implements Serializable { @Column(name = "project_funder") private String projectFunder; - public CommunityProject() {} + public DbProject() {} - public CommunityProject(final String community, final String projectId, final String projectCode, final String projectName, final String projectAcronym, + public DbProject(final String community, final String projectId, final String projectCode, final String projectName, final String projectAcronym, final String projectFunder) { this.community = community; this.projectId = projectId; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProjectPK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProjectPK.java similarity index 74% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProjectPK.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProjectPK.java index d12bb489..09f62ef6 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunityProjectPK.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProjectPK.java @@ -3,7 +3,7 @@ package eu.dnetlib.openaire.community.db.model; import java.io.Serializable; import java.util.Objects; -public class CommunityProjectPK implements Serializable { +public class DbProjectPK implements Serializable { private static final long serialVersionUID = 1L; @@ -11,6 +11,13 @@ public class CommunityProjectPK implements Serializable { private String projectId; + public DbProjectPK() {} + + public DbProjectPK(final String community, final String projectId) { + this.community = community; + this.projectId = projectId; + } + public String getCommunity() { return community; } @@ -35,8 +42,8 @@ public class CommunityProjectPK implements Serializable { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } - if (!(obj instanceof CommunityProjectPK)) { return false; } - final CommunityProjectPK other = (CommunityProjectPK) obj; + if (!(obj instanceof DbProjectPK)) { return false; } + final DbProjectPK other = (DbProjectPK) obj; return Objects.equals(community, other.community) && Objects.equals(projectId, other.projectId); } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrg.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrg.java similarity index 92% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrg.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrg.java index 06d508e2..d1f2c603 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrg.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrg.java @@ -10,8 +10,8 @@ import javax.persistence.Table; @Entity @Table(name = "community_support_orgs") -@IdClass(CommunitySupportOrgPK.class) -public class CommunitySupportOrg implements Serializable { +@IdClass(DbSupportOrgPK.class) +public class DbSupportOrg implements Serializable { private static final long serialVersionUID = 1L; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrgPK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrgPK.java similarity index 82% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrgPK.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrgPK.java index 78557fbf..00463739 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/CommunitySupportOrgPK.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrgPK.java @@ -3,7 +3,7 @@ package eu.dnetlib.openaire.community.db.model; import java.io.Serializable; import java.util.Objects; -public class CommunitySupportOrgPK implements Serializable { +public class DbSupportOrgPK implements Serializable { private static final long serialVersionUID = 1L; @@ -35,8 +35,8 @@ public class CommunitySupportOrgPK implements Serializable { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } - if (!(obj instanceof CommunitySupportOrgPK)) { return false; } - final CommunitySupportOrgPK other = (CommunitySupportOrgPK) obj; + if (!(obj instanceof DbSupportOrgPK)) { return false; } + final DbSupportOrgPK other = (DbSupportOrgPK) obj; return Objects.equals(community, other.community) && Objects.equals(orgName, other.orgName); } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java deleted file mode 100644 index 444a9afb..00000000 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityDatasourceRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package eu.dnetlib.openaire.community.db.repository; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.data.jpa.repository.JpaRepository; - -import eu.dnetlib.openaire.community.db.model.Community; - -@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") -public interface CommunityDatasourceRepository extends JpaRepository { - -} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java deleted file mode 100644 index 8184d85f..00000000 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityOrgRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package eu.dnetlib.openaire.community.db.repository; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.data.jpa.repository.JpaRepository; - -import eu.dnetlib.openaire.community.db.model.CommunityOrg; -import eu.dnetlib.openaire.community.db.model.CommunityOrgPK; - -@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") -public interface CommunityOrgRepository extends JpaRepository { - -} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java deleted file mode 100644 index 0036e35e..00000000 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunitySupportOrgRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package eu.dnetlib.openaire.community.db.repository; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.data.jpa.repository.JpaRepository; - -import eu.dnetlib.openaire.community.db.model.CommunitySupportOrg; -import eu.dnetlib.openaire.community.db.model.CommunitySupportOrgPK; - -@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") -public interface CommunitySupportOrgRepository extends JpaRepository { - -} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbCommunityRepository.java similarity index 67% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbCommunityRepository.java index f84795bf..bb1ec760 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityRepository.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbCommunityRepository.java @@ -3,9 +3,9 @@ package eu.dnetlib.openaire.community.db.repository; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; -import eu.dnetlib.openaire.community.db.model.Community; +import eu.dnetlib.openaire.community.db.model.DbCommunity; @ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") -public interface CommunityRepository extends JpaRepository { +public interface DbCommunityRepository extends JpaRepository { } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbDatasourceRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbDatasourceRepository.java new file mode 100644 index 00000000..cd6edeee --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbDatasourceRepository.java @@ -0,0 +1,15 @@ +package eu.dnetlib.openaire.community.db.repository; + +import java.util.List; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.data.jpa.repository.JpaRepository; + +import eu.dnetlib.openaire.community.db.model.DbDatasource; +import eu.dnetlib.openaire.community.db.model.DbDatasourcePK; + +@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") +public interface DbDatasourceRepository extends JpaRepository { + + List findByCommunity(String community); +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbOrganizationRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbOrganizationRepository.java new file mode 100644 index 00000000..79f1a734 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbOrganizationRepository.java @@ -0,0 +1,16 @@ +package eu.dnetlib.openaire.community.db.repository; + +import java.util.List; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.data.jpa.repository.JpaRepository; + +import eu.dnetlib.openaire.community.db.model.DbOrganization; +import eu.dnetlib.openaire.community.db.model.DbOrganizationPK; + +@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") +public interface DbOrganizationRepository extends JpaRepository { + + List findByCommunity(String community); + +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbProjectRepository.java similarity index 51% rename from apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java rename to apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbProjectRepository.java index 725903ae..1c7e59ba 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/CommunityProjectRepository.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbProjectRepository.java @@ -1,12 +1,16 @@ package eu.dnetlib.openaire.community.db.repository; +import java.util.List; + import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; -import eu.dnetlib.openaire.community.db.model.CommunityProject; -import eu.dnetlib.openaire.community.db.model.CommunityProjectPK; +import eu.dnetlib.openaire.community.db.model.DbProject; +import eu.dnetlib.openaire.community.db.model.DbProjectPK; @ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") -public interface CommunityProjectRepository extends JpaRepository { +public interface DbProjectRepository extends JpaRepository { + + List findByCommunity(String community); } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbSupportOrgRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbSupportOrgRepository.java new file mode 100644 index 00000000..04f07398 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbSupportOrgRepository.java @@ -0,0 +1,16 @@ +package eu.dnetlib.openaire.community.db.repository; + +import java.util.List; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.data.jpa.repository.JpaRepository; + +import eu.dnetlib.openaire.community.db.model.DbSupportOrg; +import eu.dnetlib.openaire.community.db.model.DbSupportOrgPK; + +@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") +public interface DbSupportOrgRepository extends JpaRepository { + + List findByCommunity(String community); + +} From c622c4cd537c8dbcfde3496c7f3edf61e15e2035 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Thu, 15 Jun 2023 10:18:18 +0200 Subject: [PATCH 10/78] implementation of some internal methods --- .../community/CommunityApiController.java | 10 +- .../community/db/CommunityService.java | 155 +++++++++++++----- .../community/db/ConvertionUtils.java | 24 +++ .../community/db/model/DbDatasourcePK.java | 7 + 4 files changed, 152 insertions(+), 44 deletions(-) diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java index f0f986b9..fa864c2b 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityApiController.java @@ -140,7 +140,7 @@ public class CommunityApiController { }) public void deleteCommunityProject( @PathVariable final String id, - @RequestBody final Integer projectId) throws CommunityException, ResourceNotFoundException { + @RequestBody final String projectId) throws CommunityException, ResourceNotFoundException { communityService.removeCommunityProject(id, projectId); } @@ -176,7 +176,7 @@ public class CommunityApiController { }) public void deleteCommunityProjectList( @PathVariable final String id, - @RequestBody final List projectIdList) throws CommunityException, ResourceNotFoundException { + @RequestBody final List projectIdList) throws CommunityException, ResourceNotFoundException { communityService.removeCommunityProjectList(id, projectIdList); } @@ -227,7 +227,7 @@ public class CommunityApiController { }) public void removeCommunityContentprovider( @PathVariable final String id, - @RequestBody final Integer contentproviderId) throws CommunityException, ResourceNotFoundException { + @RequestBody final String contentproviderId) throws CommunityException, ResourceNotFoundException { communityService.removeCommunityContentProvider(id, contentproviderId); } @@ -263,7 +263,7 @@ public class CommunityApiController { }) public void deleteCommunityContentProvidersList( @PathVariable final String id, - @RequestBody final List contentProviderIdList) throws CommunityException, ResourceNotFoundException { + @RequestBody final List contentProviderIdList) throws CommunityException, ResourceNotFoundException { communityService.removeCommunityContentProviderList(id, contentProviderIdList); } @@ -316,7 +316,7 @@ public class CommunityApiController { }) public void removeCommunityOrganization( @PathVariable final String id, - @RequestBody final Integer organizationId) throws CommunityException, ResourceNotFoundException { + @RequestBody final String organizationId) throws CommunityException, ResourceNotFoundException { communityService.removeCommunityOrganization(id, organizationId); } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java index 92d8f7af..addb7cbb 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java @@ -1,13 +1,26 @@ package eu.dnetlib.openaire.community.db; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.Function; import java.util.stream.Collectors; +import javax.transaction.Transactional; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Service; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import eu.dnetlib.openaire.community.db.model.DbCommunity; +import eu.dnetlib.openaire.community.db.model.DbDatasource; +import eu.dnetlib.openaire.community.db.model.DbDatasourcePK; import eu.dnetlib.openaire.community.db.model.DbProject; +import eu.dnetlib.openaire.community.db.model.DbProjectPK; import eu.dnetlib.openaire.community.db.repository.DbCommunityRepository; import eu.dnetlib.openaire.community.db.repository.DbDatasourceRepository; import eu.dnetlib.openaire.community.db.repository.DbOrganizationRepository; @@ -29,6 +42,14 @@ import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionC @ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") public class CommunityService { + // TODO + // 1) Aggiungere i campi membership e claim al modello delle api + // 2) Capire come gestire il campo Id (Integer) di CommunityProject + // 3) Gestire paginazione dei progetti + // 4) CommunityContentprovider sono le datasources? + // 5) Capire come gestire il campo Id (Integer) di CommunityContentprovider + // 5) Capire come gestire il campo Id (Integer) di CommunityOrganization + @Autowired private DbCommunityRepository dbCommunityRepository; @Autowired @@ -81,91 +102,118 @@ public class CommunityService { return projectList; } - public void removeCommunityProject(final String id, final Integer projectId) throws CommunityException, ResourceNotFoundException { - // dbProjectRepository.deleteById(new DbProjectPK(id, projectId)); + public void removeCommunityProject(final String id, final String projectId) throws CommunityException, ResourceNotFoundException { + dbProjectRepository.deleteById(new DbProjectPK(id, projectId)); } - public void removeCommunityProjectList(final String id, final List projectIdList) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub + public void removeCommunityProjectList(final String id, final List projectIdList) throws CommunityException, ResourceNotFoundException { + final List list = projectIdList.stream() + .map(projectId -> new DbProjectPK(id, projectId)) + .collect(Collectors.toList()); + dbProjectRepository.deleteAllById(list); } public List getCommunityContentproviders(final String id) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + return dbDatasourceRepository.findByCommunity(id) + .stream() + .map(ConvertionUtils::toCommunityContentprovider) + .collect(Collectors.toList()); } public CommunityContentprovider addCommunityContentprovider(final String id, final CommunityContentprovider cp) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; - } - - public void removeCommunityContentProvider(final String id, final Integer contentproviderId) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub + final DbDatasource ds = ConvertionUtils.toDbDatasource(id, cp); + dbDatasourceRepository.save(ds); + return cp; } public List addCommunityContentProvidersList(final String id, final List contentprovidersList) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + + final List list = contentprovidersList.stream() + .map(cp -> ConvertionUtils.toDbDatasource(id, cp)) + .collect(Collectors.toList()); + + dbDatasourceRepository.saveAll(list); + + return contentprovidersList; } - public void removeCommunityContentProviderList(final String id, final List contentProviderIdList) + public void removeCommunityContentProvider(final String id, final String contentproviderId) throws CommunityException, ResourceNotFoundException { + dbDatasourceRepository.deleteById(new DbDatasourcePK(id, contentproviderId)); + } + + public void removeCommunityContentProviderList(final String id, final List contentProviderIdList) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub + final List list = contentProviderIdList.stream() + .map(dsId -> new DbDatasourcePK(id, dsId)) + .collect(Collectors.toList()); + dbDatasourceRepository.deleteAllById(list); } - public void removeCommunityOrganization(final String id, final Integer organizationId) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - } - - public List getCommunityZenodoCommunities(final String id) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + public void removeCommunityOrganization(final String id, final String organizationId) throws CommunityException, ResourceNotFoundException { + dbDatasourceRepository.deleteById(new DbDatasourcePK(id, organizationId)); } public List getCommunityOrganizations(final String id) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + return dbOrganizationRepository.findByCommunity(id) + .stream() + .map(ConvertionUtils::toCommunityOrganiztion) + .collect(Collectors.toList()); } + @Transactional public CommunityDetails addCommunitySubjects(final String id, final List subjects) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + return modifyElementToArrayField(id, subjects, c -> c.getSubjects(), (c, subs) -> c.setSubjects(subs), false); } + @Transactional public CommunityDetails removeCommunitySubjects(final String id, final List subjects) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + return modifyElementToArrayField(id, subjects, c -> c.getSubjects(), (c, subs) -> c.setSubjects(subs), true); } + @Transactional public CommunityDetails addCommunityFOS(final String id, final List foss) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + return modifyElementToArrayField(id, foss, c -> c.getFos(), (c, fos) -> c.setFos(fos), false); } + @Transactional public CommunityDetails removeCommunityFOS(final String id, final List foss) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + return modifyElementToArrayField(id, foss, c -> c.getFos(), (c, fos) -> c.setFos(fos), true); } + @Transactional public CommunityDetails addCommunitySDG(final String id, final List sdgs) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + return modifyElementToArrayField(id, sdgs, c -> c.getSdg(), (c, sdg) -> c.setSdg(sdg), false); } + @Transactional public CommunityDetails removeCommunitySDG(final String id, final List sdgs) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + return modifyElementToArrayField(id, sdgs, c -> c.getSdg(), (c, sdg) -> c.setSdg(sdg), true); } public CommunityDetails addCommunityAdvancedConstraint(final String id, final SelectionCriteria advancedCosntraint) throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; + + try { + final DbCommunity dbEntry = dbCommunityRepository.findById(id).orElseThrow(() -> new ResourceNotFoundException("Community not found: " + id)); + dbEntry.setAdvancedConstraints(new ObjectMapper().writeValueAsString(advancedCosntraint)); + dbCommunityRepository.save(dbEntry); + return getCommunity(id); + } catch (final JsonProcessingException e) { + throw new CommunityException("Error converting json"); + } + } public CommunityDetails removeCommunityAdvancedConstraint(final String id) throws ResourceNotFoundException, CommunityException { + final DbCommunity dbEntry = dbCommunityRepository.findById(id).orElseThrow(() -> new ResourceNotFoundException("Community not found: " + id)); + dbEntry.setAdvancedConstraints(null); + dbCommunityRepository.save(dbEntry); + return getCommunity(id); + } + + public List getCommunityZenodoCommunities(final String id) throws CommunityException, ResourceNotFoundException { // TODO Auto-generated method stub return null; } @@ -190,4 +238,33 @@ public class CommunityService { // TODO Auto-generated method stub return null; } + + private CommunityDetails modifyElementToArrayField(final String id, + final List values, + final Function getter, + final BiConsumer setter, + final boolean remove) throws ResourceNotFoundException, CommunityException { + + final DbCommunity dbEntry = dbCommunityRepository.findById(id).orElseThrow(() -> new ResourceNotFoundException("Community not found: " + id)); + + final Set tmpList = new LinkedHashSet<>(); + final String[] oldValues = getter.apply(dbEntry); + if (oldValues != null) { + for (final String s : oldValues) { + tmpList.add(s); + } + } + if (remove) { + tmpList.removeAll(values); + } else { + tmpList.addAll(values); + } + + setter.accept(dbEntry, tmpList.toArray(new String[tmpList.size()])); + + dbCommunityRepository.save(dbEntry); + + return getCommunity(id); + } + } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java index 5dd3b015..8b25b173 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java @@ -1,7 +1,11 @@ package eu.dnetlib.openaire.community.db; import eu.dnetlib.openaire.community.db.model.DbCommunity; +import eu.dnetlib.openaire.community.db.model.DbDatasource; +import eu.dnetlib.openaire.community.db.model.DbOrganization; import eu.dnetlib.openaire.community.db.model.DbProject; +import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider; +import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization; import eu.dnetlib.openaire.exporter.model.community.CommunityProject; import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; @@ -22,4 +26,24 @@ public class ConvertionUtils { return null; } + public static CommunityContentprovider toCommunityContentprovider(final DbDatasource dbEntry) { + // TODO + return null; + } + + public static DbDatasource toDbDatasource(final String id, final CommunityContentprovider provider) { + // TODO Auto-generated method stub + return null; + } + + public static CommunityOrganization toCommunityOrganiztion(final DbOrganization dbEntry) { + // TODO + return null; + } + + public static DbOrganization toDbOrganization(final String id, final CommunityOrganization org) { + // TODO Auto-generated method stub + return null; + } + } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasourcePK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasourcePK.java index ea857a97..b1f9af8f 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasourcePK.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasourcePK.java @@ -11,6 +11,13 @@ public class DbDatasourcePK implements Serializable { private String dsId; + public DbDatasourcePK() {} + + public DbDatasourcePK(final String community, final String dsId) { + this.community = community; + this.dsId = dsId; + } + public String getCommunity() { return community; } From 9e2638c9e4fd98ebfca251bdbac52651870ea5a7 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Thu, 15 Jun 2023 10:30:23 +0200 Subject: [PATCH 11/78] implementation of some internal methods --- .../openaire/community/db/CommunityService.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java index addb7cbb..1c04c8c4 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import eu.dnetlib.openaire.community.db.model.DbCommunity; import eu.dnetlib.openaire.community.db.model.DbDatasource; import eu.dnetlib.openaire.community.db.model.DbDatasourcePK; +import eu.dnetlib.openaire.community.db.model.DbOrganization; import eu.dnetlib.openaire.community.db.model.DbProject; import eu.dnetlib.openaire.community.db.model.DbProjectPK; import eu.dnetlib.openaire.community.db.repository.DbCommunityRepository; @@ -48,7 +49,8 @@ public class CommunityService { // 3) Gestire paginazione dei progetti // 4) CommunityContentprovider sono le datasources? // 5) Capire come gestire il campo Id (Integer) di CommunityContentprovider - // 5) Capire come gestire il campo Id (Integer) di CommunityOrganization + // 6) Capire come gestire il campo Id (Integer) di CommunityOrganization + // 7) Modificare le api per gestire le ZenodoCommunities (main + others) @Autowired private DbCommunityRepository dbCommunityRepository; @@ -162,6 +164,13 @@ public class CommunityService { .collect(Collectors.toList()); } + public CommunityOrganization addCommunityOrganization(final String id, final CommunityOrganization organization) + throws CommunityException, ResourceNotFoundException { + final DbOrganization o = ConvertionUtils.toDbOrganization(id, organization); + dbOrganizationRepository.save(o); + return organization; + } + @Transactional public CommunityDetails addCommunitySubjects(final String id, final List subjects) throws CommunityException, ResourceNotFoundException { return modifyElementToArrayField(id, subjects, c -> c.getSubjects(), (c, subs) -> c.setSubjects(subs), false); @@ -233,12 +242,6 @@ public class CommunityService { return null; } - public CommunityOrganization addCommunityOrganization(final String id, final CommunityOrganization organization) - throws CommunityException, ResourceNotFoundException { - // TODO Auto-generated method stub - return null; - } - private CommunityDetails modifyElementToArrayField(final String id, final List values, final Function getter, From 3edd995e9dfb3b960465d084475f9ff9a8505b2b Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Thu, 15 Jun 2023 11:27:59 +0200 Subject: [PATCH 12/78] mapping functions --- .../openaire/community/CommunityClient.java | 5 +- .../community/CommunityClientImpl.java | 79 +- .../openaire/community/CommunityCommon.java | 1009 +++++++++-------- .../community/CommunityConstants.java | 6 +- .../community/CommunityMappingUtils.java | 135 ++- .../community/db/CommunityService.java | 5 + .../community/db/ConvertionUtils.java | 70 +- .../db/enums/CommunityClaimType.java | 25 +- .../db/enums/CommunityClaimTypeConverter.java | 12 +- .../db/enums/CommunityMembershipType.java | 20 +- .../CommunityMembershipTypeConverter.java | 8 +- .../community/db/enums/CommunityStatus.java | 8 - .../community/db/model/DbCommunity.java | 2 +- .../model/community/CommunityStatus.java | 5 +- .../model/community/CommunitySummary.java | 18 +- 15 files changed, 797 insertions(+), 610 deletions(-) delete mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityStatus.java diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClient.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClient.java index 4b028a20..a6296ce7 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClient.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClient.java @@ -6,10 +6,11 @@ import java.util.Set; import eu.dnetlib.openaire.exporter.exceptions.CommunityException; import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException; +@Deprecated public interface CommunityClient { - Map> getInverseZenodoCommunityMap() throws CommunityException, ResourceNotFoundException; + Map> getInverseZenodoCommunityMap() throws CommunityException, ResourceNotFoundException; - void dropCache(); + void dropCache(); } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClientImpl.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClientImpl.java index 06ff04f6..5434f943 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClientImpl.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityClientImpl.java @@ -1,5 +1,11 @@ package eu.dnetlib.openaire.community; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -13,51 +19,50 @@ import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException; import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity; -import java.util.*; - @Component +@Deprecated public class CommunityClientImpl implements CommunityClient { - private static final Log log = LogFactory.getLog(CommunityClient.class); + private static final Log log = LogFactory.getLog(CommunityClient.class); - @Autowired - private CommunityCommon communityCommon; + @Autowired + private CommunityCommon communityCommon; - @Override - @Cacheable("community-cache") - public Map> getInverseZenodoCommunityMap () throws CommunityException, ResourceNotFoundException { - log.info("Creating the data structure. Not using cache"); - final Map> inverseListMap = new HashMap<>(); + @Override + @Cacheable("community-cache") + public Map> getInverseZenodoCommunityMap() throws CommunityException, ResourceNotFoundException { + log.info("Creating the data structure. Not using cache"); + final Map> inverseListMap = new HashMap<>(); - final List communityList = communityCommon.listCommunities(); + final List communityList = communityCommon.listCommunities(); - for(CommunitySummary cs :communityList){ - final String communityId = cs.getId(); - List czc = communityCommon.getCommunityZenodoCommunities(communityId); - for(CommunityZenodoCommunity zc:czc){ - final String zenodoId = zc.getZenodoid(); - if(!inverseListMap.containsKey(zenodoId)) { - inverseListMap.put(zc.getZenodoid(),new HashSet<>()); - } - inverseListMap.get(zc.getZenodoid()).add(communityId); - } - final String zenodoMainCommunity = communityCommon.getCommunity(communityId).getZenodoCommunity(); - if(!inverseListMap.containsKey(zenodoMainCommunity)) { - inverseListMap.put(zenodoMainCommunity,new HashSet<>()); - } + for (final CommunitySummary cs : communityList) { + final String communityId = cs.getId(); + final List czc = communityCommon.getCommunityZenodoCommunities(communityId); + for (final CommunityZenodoCommunity zc : czc) { + final String zenodoId = zc.getZenodoid(); + if (!inverseListMap.containsKey(zenodoId)) { + inverseListMap.put(zc.getZenodoid(), new HashSet<>()); + } + inverseListMap.get(zc.getZenodoid()).add(communityId); + } + final String zenodoMainCommunity = communityCommon.getCommunity(communityId).getZenodoCommunity(); + if (!inverseListMap.containsKey(zenodoMainCommunity)) { + inverseListMap.put(zenodoMainCommunity, new HashSet<>()); + } - inverseListMap.get(zenodoMainCommunity).add(communityId); - } - return inverseListMap; - } + inverseListMap.get(zenodoMainCommunity).add(communityId); + } + return inverseListMap; + } - - - @Override - @CacheEvict(cacheNames = { "community-cache", "context-cache-community"}, allEntries = true) - @Scheduled(fixedDelayString = "${openaire.exporter.cache.ttl}") - public void dropCache(){ - log.debug("dropped community cache"); - } + @Override + @CacheEvict(cacheNames = { + "community-cache", "context-cache-community" + }, allEntries = true) + @Scheduled(fixedDelayString = "${openaire.exporter.cache.ttl}") + public void dropCache() { + log.debug("dropped community cache"); + } } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityCommon.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityCommon.java index 1274e058..6b9dac23 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityCommon.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityCommon.java @@ -1,8 +1,50 @@ package eu.dnetlib.openaire.community; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_NAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_OFFICIALNAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_SELCRITERIA; +import static eu.dnetlib.openaire.community.CommunityConstants.CONTENTPROVIDERS_ID_SUFFIX; +import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_LOGOURL; +import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_NAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_WEBSITEURL; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_ADVANCED_CONSTRAINT; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_FOS; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_SDG; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_SUBJECT; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_ACRONYM; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_FULLNAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_FUNDER; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_NUMBER; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_DESCRIPTION; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_LOGOURL; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_NAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_STATUS; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_ZENODOC; +import static eu.dnetlib.openaire.community.CommunityConstants.CSV_DELIMITER; +import static eu.dnetlib.openaire.community.CommunityConstants.CZENODOCOMMUNITY_ID; +import static eu.dnetlib.openaire.community.CommunityConstants.ID_SEPARATOR; +import static eu.dnetlib.openaire.community.CommunityConstants.OPENAIRE_ID; +import static eu.dnetlib.openaire.community.CommunityConstants.ORGANIZATION_ID_SUFFIX; +import static eu.dnetlib.openaire.community.CommunityConstants.PROJECTS_ID_SUFFIX; +import static eu.dnetlib.openaire.community.CommunityConstants.ZENODOCOMMUNITY_ID_SUFFIX; +import static eu.dnetlib.openaire.community.CommunityConstants.communityBlackList; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Base64; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.gson.Gson; + import eu.dnetlib.openaire.common.ISClient; import eu.dnetlib.openaire.exporter.exceptions.CommunityException; import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException; @@ -18,472 +60,511 @@ import eu.dnetlib.openaire.exporter.model.context.Concept; import eu.dnetlib.openaire.exporter.model.context.Context; import eu.dnetlib.openaire.exporter.model.context.Param; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static eu.dnetlib.openaire.community.CommunityConstants.*; - - @Component +@Deprecated public class CommunityCommon { - @Autowired - private ISClient isClient; - - public Map getContextMap() throws CommunityException { - try { - return isClient.getCommunityContextMap(); - } catch (IOException e) { - throw new CommunityException(e); - } - } - - public List listCommunities() throws CommunityException { - return getContextMap().values().stream() - .filter(context -> !communityBlackList.contains(context.getId())) - .map(CommunityMappingUtils::asCommunitySummary) - .collect(Collectors.toList()); - } - - - public List getCommunityInfo(final String id, final String idSuffix, final Function mapping) throws CommunityException { - final Map contextMap = getContextMap(); - final Context context = contextMap.get(id); - if (context != null) { - final Map categories = context.getCategories(); - final Category category = categories.get(id + idSuffix); - if (category != null) { - return category.getConcepts().stream() - .map(mapping) - .collect(Collectors.toList()); - } - } - return Lists.newArrayList(); - } - - public CommunityDetails getCommunity(final String id) throws CommunityException, ResourceNotFoundException { - final Context context = getContextMap().get(id); - if (context == null || CommunityConstants.communityBlackList.contains(id)) { - //ResponseStatusException(NOT_FOUND, "Unable to find resource"); - throw new ResourceNotFoundException(); - } - return CommunityMappingUtils.asCommunityProfile(context); - } - - public List getCommunityZenodoCommunities(final String id) throws CommunityException, ResourceNotFoundException { - getCommunity(id); // ensure the community exists. - return getCommunityInfo(id, ZENODOCOMMUNITY_ID_SUFFIX, c -> CommunityMappingUtils.asCommunityZenodoCommunity(id, c)); - } - - - public void updateProject(String communityId, CommunityProject project) throws CommunityException { - final Context context = getContextMap().get(communityId); - Category prj = context.getCategories().get(communityId + PROJECTS_ID_SUFFIX); - if (prj.getConcepts().stream().map(c -> c.getId()).collect(Collectors.toList()) - .contains(communityId + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project.getId())){ - prj.getConcepts().forEach(concept -> { - if (concept.getId().equals(communityId + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project.getId())) { - if (project.getName() != null) { - - concept.getParams().replace(CPROJECT_FULLNAME, Arrays.asList(new Param() - .setName(CPROJECT_FULLNAME).setValue(project.getName()))); - } - if (project.getAcronym() != null) { - if(concept.getParams().keySet().contains(CPROJECT_ACRONYM)){ - concept.getParams().replace(CPROJECT_ACRONYM, Arrays.asList(new Param() - .setName(CPROJECT_ACRONYM).setValue(project.getAcronym()))); - } - else{ - concept.getParams().put(CPROJECT_ACRONYM, Arrays.asList(new Param() - .setName(CPROJECT_ACRONYM).setValue(project.getAcronym()))); - } - - } - if (project.getOpenaireId() != null) { - if(concept.getParams().keySet().contains(OPENAIRE_ID)){ - concept.getParams().replace(OPENAIRE_ID, Arrays.asList(new Param() - .setName(OPENAIRE_ID).setValue(project.getOpenaireId()))); - } - else{ - concept.getParams().put(OPENAIRE_ID, Arrays.asList(new Param() - .setName(OPENAIRE_ID).setValue(project.getOpenaireId()))); - } - - } - if (project.getFunder() != null) { - concept.getParams().replace(CPROJECT_FUNDER, Arrays.asList(new Param() - .setName(CPROJECT_FUNDER).setValue(project.getFunder()))); - } - if (project.getGrantId() != null) { - concept.getParams().replace(CPROJECT_NUMBER, Arrays.asList(new Param() - .setName(CPROJECT_NUMBER).setValue(project.getGrantId()))); - - } - } - }); - } - else{ - Concept concept = new Concept(); - concept.setId(communityId + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project.getId()); - concept.setClaim(false); - if(project.getAcronym() != null) - concept.setLabel(project.getAcronym()); - else - concept.setLabel(""); - - Map> params = new TreeMap<>(); - - if(project.getAcronym() != null){ - params.put(CPROJECT_ACRONYM, Arrays.asList(new Param().setName(CPROJECT_ACRONYM) - .setValue(project.getAcronym()))); - } - - if (project.getName() != null){ - params.put(CPROJECT_FULLNAME, Arrays.asList(new Param() - .setName(CPROJECT_FULLNAME) - .setValue(project.getName()) - )); - } - - if (project.getOpenaireId() != null){ - params.put(OPENAIRE_ID, Arrays.asList(new Param() - .setName(OPENAIRE_ID) - .setValue(project.getOpenaireId()) - )); - } - - if(project.getFunder() != null){ - params.put(CPROJECT_FUNDER, Arrays.asList(new Param() - .setName(CPROJECT_FUNDER) - .setValue(project.getFunder()) - )); - } - - if (project.getGrantId()!=null){ - params.put(CPROJECT_NUMBER, Arrays.asList(new Param() - .setName(CPROJECT_NUMBER) - .setValue(project.getGrantId()) - )); - } - - concept.setParams(params); - prj.getConcepts().add(concept); - - - } - - } - - public void removeAdvancedConstraint(String id) throws CommunityException { - final Context context = getContextMap().get(id); - context.getParams() - .replace(CPROFILE_ADVANCED_CONSTRAINT, Arrays.asList(new Param() - .setName(CPROFILE_ADVANCED_CONSTRAINT).setValue(null))); - } - - public void updateCommunity(String id, CommunityWritableProperties community) throws CommunityException { - final Context context = getContextMap().get(id); - - if(community.getShortName() != null) { - context.setLabel(community.getShortName()); - } - - if (community.getName() != null){ - context.getParams().replace(CSUMMARY_NAME, Arrays.asList(new Param() - .setValue(community.getName()).setName(CSUMMARY_NAME))); - } - if(community.getDescription() != null) { - context.getParams() - .replace(CSUMMARY_DESCRIPTION, Arrays.asList(new Param() - .setName(CSUMMARY_DESCRIPTION).setValue(community.getDescription()))); - } - if(community.getLogoUrl() != null){ - context.getParams() - .replace(CSUMMARY_LOGOURL, Arrays.asList(new Param() - .setName(CSUMMARY_LOGOURL).setValue(community.getLogoUrl()))); - - } - if (community.getStatus() != null) { - context.getParams() - .replace(CSUMMARY_STATUS, Arrays.asList(new Param() - .setName(CSUMMARY_STATUS).setValue(community.getStatus().name()))); - } - if (community.getSubjects() != null) { - context.getParams() - .replace(CPROFILE_SUBJECT, Arrays.asList(new Param().setName(CPROFILE_SUBJECT) - .setValue(Joiner.on(CSV_DELIMITER) - .join(community.getSubjects())))); - } - if(community.getFos() != null){ - if (context.getParams().containsKey(CPROFILE_FOS)) - context.getParams() - .replace(CPROFILE_FOS, Arrays.asList(new Param().setName(CPROFILE_FOS) - .setValue(Joiner.on(CSV_DELIMITER) - .join(community.getFos())))); - else - context.getParams().put(CPROFILE_FOS, Arrays.asList(new Param().setName(CPROFILE_FOS) - .setValue(Joiner.on(CSV_DELIMITER) - .join(community.getFos())))); - } - if(community.getSdg() != null){ - if(context.getParams().containsKey(CPROFILE_SDG)) - context.getParams() - .replace(CPROFILE_SDG, Arrays.asList(new Param().setName(CPROFILE_SDG) - .setValue(Joiner.on(CSV_DELIMITER) - .join(community.getSdg())))); - else - context.getParams().put(CPROFILE_SDG, Arrays.asList(new Param().setName(CPROFILE_SDG) - .setValue(Joiner.on(CSV_DELIMITER) - .join(community.getSdg())))); - } - if (community.getAdvancedConstraints() != null) { - if(context.getParams().containsKey(CPROFILE_ADVANCED_CONSTRAINT)) - context.getParams() - .replace(CPROFILE_ADVANCED_CONSTRAINT, Arrays.asList(new Param() - .setName(CPROFILE_ADVANCED_CONSTRAINT).setValue(new Gson().toJson(community.getAdvancedConstraints())))); - else - context.getParams().put(CPROFILE_ADVANCED_CONSTRAINT, Arrays.asList(new Param() - .setName(CPROFILE_ADVANCED_CONSTRAINT).setValue(new Gson().toJson(community.getAdvancedConstraints())))); - } - if(community.getMainZenodoCommunity() != null){ - context.getParams() - .replace(CSUMMARY_ZENODOC, Arrays.asList(new Param() - .setName(CSUMMARY_ZENODOC).setValue(community.getMainZenodoCommunity()))); - - } - - } - - - public void removeFromCategory(String communityId, String category, String conceptId) throws CommunityException { - Map cmap = getContextMap(); - Context context = cmap.get(communityId); - Map cat = context.getCategories(); - - List concepts = cat.get(communityId + category).getConcepts() - .stream().filter(c -> !c.getId().equals(communityId + category + ID_SEPARATOR + conceptId)).collect(Collectors.toList()); - - cat.get(communityId + category).setConcepts(concepts); - } - - public void updateDatasource(String communityId, CommunityContentprovider cp) throws CommunityException { - final Context context = getContextMap().get(communityId); - Category dts = context.getCategories().get(communityId + CONTENTPROVIDERS_ID_SUFFIX); - if (dts.getConcepts().stream().map(c -> c.getId()).collect(Collectors.toList()) - .contains(communityId + CONTENTPROVIDERS_ID_SUFFIX + ID_SEPARATOR + cp.getId())){ - dts.getConcepts().forEach(concept -> { - if (concept.getId().equals(communityId + CONTENTPROVIDERS_ID_SUFFIX + ID_SEPARATOR + cp.getId())) { - - - if (cp.getName() != null) { - if(concept.getParams().keySet().contains(CCONTENTPROVIDER_NAME)){ - concept.getParams().replace(CCONTENTPROVIDER_NAME, Arrays.asList(new Param() - .setName(CCONTENTPROVIDER_NAME).setValue(cp.getName()))); - } - else{ - concept.getParams().put(CCONTENTPROVIDER_NAME, Arrays.asList(new Param() - .setName(CCONTENTPROVIDER_NAME).setValue(cp.getName()))); - } - - } - if (cp.getOfficialname() != null) { - if(concept.getParams().keySet().contains(CCONTENTPROVIDER_OFFICIALNAME)){ - concept.getParams().replace(CCONTENTPROVIDER_OFFICIALNAME, Arrays.asList(new Param() - .setName(CCONTENTPROVIDER_OFFICIALNAME).setValue(cp.getOfficialname()))); - } - else{ - concept.getParams().put(CCONTENTPROVIDER_OFFICIALNAME, Arrays.asList(new Param() - .setName(CCONTENTPROVIDER_OFFICIALNAME).setValue(cp.getOfficialname()))); - } - - } - - - if (cp.getOpenaireId() != null) { - if(concept.getParams().keySet().contains(OPENAIRE_ID)){ - concept.getParams().replace(OPENAIRE_ID, Arrays.asList(new Param() - .setName(OPENAIRE_ID).setValue(cp.getOpenaireId()))); - } - else{ - concept.getParams().put(OPENAIRE_ID, Arrays.asList(new Param() - .setName(OPENAIRE_ID).setValue(cp.getOpenaireId()))); - } - - } - - if (cp.getSelectioncriteria() != null) { - if(concept.getParams().keySet().contains(CCONTENTPROVIDER_SELCRITERIA)){ - concept.getParams().replace(CCONTENTPROVIDER_SELCRITERIA, Arrays.asList(new Param() - .setName(CCONTENTPROVIDER_SELCRITERIA).setValue(cp.toJson()))); - } - else{ - concept.getParams().put(CCONTENTPROVIDER_SELCRITERIA, Arrays.asList(new Param() - .setName(CCONTENTPROVIDER_SELCRITERIA).setValue(cp.toJson()))); - } - - } - } - }); - } - else{ - Concept concept = new Concept(); - concept.setId(communityId + CONTENTPROVIDERS_ID_SUFFIX + ID_SEPARATOR + cp.getId()); - concept.setClaim(false); - concept.setLabel(""); - - Map> params = new TreeMap<>(); - - if (cp.getName() != null) { - params.put( CCONTENTPROVIDER_NAME, Arrays.asList(new Param().setValue(cp.getName()).setName(CCONTENTPROVIDER_NAME))); - } - if(cp.getOfficialname()!= null){ - params.put( CCONTENTPROVIDER_OFFICIALNAME, Arrays.asList(new Param().setValue(cp.getOfficialname()).setName(CCONTENTPROVIDER_OFFICIALNAME))); - } - if (cp.getOpenaireId() != null){ - params.put( OPENAIRE_ID, Arrays.asList(new Param().setValue(cp.getOpenaireId()).setName(OPENAIRE_ID))); - } - if(cp.getSelectioncriteria() != null){ - params.put( CCONTENTPROVIDER_SELCRITERIA, Arrays.asList(new Param().setValue(cp.toJson()).setName(CCONTENTPROVIDER_SELCRITERIA))); - - } - - concept.setParams(params); - dts.getConcepts().add(concept); - - - } - - } - - public void updateOrganization(String communityId, CommunityOrganization organization) throws CommunityException { - - final Context context = getContextMap().get(communityId); - Category orgs = context.getCategories().get(communityId + ORGANIZATION_ID_SUFFIX); - if (orgs.getConcepts().stream().map(c -> c.getId()).collect(Collectors.toList()) - .contains(communityId + ORGANIZATION_ID_SUFFIX + ID_SEPARATOR + organization.getId())){ - orgs.getConcepts().forEach(concept -> { - if (concept.getId().equals(communityId + ORGANIZATION_ID_SUFFIX + ID_SEPARATOR + organization.getId())) { - - - if (organization.getName() != null) { - if(concept.getParams().keySet().contains(CORGANIZATION_NAME)){ - concept.getParams().replace(CORGANIZATION_NAME, Arrays.asList(new Param() - .setName(CORGANIZATION_NAME).setValue(organization.getName()))); - } - else{ - concept.getParams().put(CORGANIZATION_NAME, Arrays.asList(new Param() - .setName(CORGANIZATION_NAME).setValue(organization.getName()))); - } - - } - if (organization.getLogo_url() != null) { - if(concept.getParams().keySet().contains(CORGANIZATION_LOGOURL)){ - concept.getParams().replace(CORGANIZATION_LOGOURL, Arrays.asList(new Param() - .setName(CORGANIZATION_LOGOURL).setValue(Base64.getEncoder().encodeToString(organization.getLogo_url().getBytes())))); - } - else{ - concept.getParams().put(CORGANIZATION_LOGOURL, Arrays.asList(new Param() - .setName(CORGANIZATION_LOGOURL).setValue(Base64.getEncoder().encodeToString(organization.getLogo_url().getBytes())))); - } - - } - - - if (organization.getWebsite_url() != null) { - if(concept.getParams().keySet().contains(CORGANIZATION_WEBSITEURL)){ - concept.getParams().replace(CORGANIZATION_WEBSITEURL, Arrays.asList(new Param() - .setName(CORGANIZATION_WEBSITEURL).setValue(Base64.getEncoder().encodeToString(organization.getWebsite_url().getBytes())))); - } - else{ - concept.getParams().put(CORGANIZATION_WEBSITEURL, Arrays.asList(new Param() - .setName(CORGANIZATION_WEBSITEURL).setValue(Base64.getEncoder().encodeToString(organization.getWebsite_url().getBytes())))); - } - - } - - } - - }); - } - else{ - - Concept concept = new Concept(); - concept.setId(communityId + ORGANIZATION_ID_SUFFIX + ID_SEPARATOR + organization.getId()); - concept.setClaim(false); - concept.setLabel(""); - - Map> params = new TreeMap<>(); - - if (organization.getName() != null) { - params.put( CORGANIZATION_NAME, Arrays.asList(new Param().setValue(organization.getName()).setName(CORGANIZATION_NAME))); - } - if(organization.getLogo_url()!= null){ - - params.put( CORGANIZATION_LOGOURL, Arrays.asList(new Param().setValue(Base64.getEncoder().encodeToString(organization.getLogo_url().getBytes())).setName(CORGANIZATION_LOGOURL))); - } - if (organization.getWebsite_url() != null){ - params.put( CORGANIZATION_WEBSITEURL, Arrays.asList(new Param().setValue(Base64.getEncoder().encodeToString(organization.getWebsite_url().getBytes())).setName(CORGANIZATION_WEBSITEURL))); - } - - - concept.setParams(params); - orgs.getConcepts().add(concept); - - - } - - } - - public void updateZenodoCommunity(String communityId, CommunityZenodoCommunity zc) throws CommunityException { - final Context context = getContextMap().get(communityId); - Category zcs = context.getCategories().get(communityId + ZENODOCOMMUNITY_ID_SUFFIX); - if (zcs.getConcepts().stream().map(c -> c.getId()).collect(Collectors.toList()) - .contains(communityId + ZENODOCOMMUNITY_ID_SUFFIX + ID_SEPARATOR + zc.getId())){ - zcs.getConcepts().forEach(concept -> { - if (concept.getId().equals(communityId + ZENODOCOMMUNITY_ID_SUFFIX + ID_SEPARATOR + zc.getId())) { - - - if (zc.getZenodoid() != null) { - if(concept.getParams().keySet().contains(CZENODOCOMMUNITY_ID)){ - concept.getParams().replace(CZENODOCOMMUNITY_ID, Arrays.asList(new Param() - .setName(CZENODOCOMMUNITY_ID).setValue(zc.getZenodoid()))); - } - else{ - concept.getParams().put(CZENODOCOMMUNITY_ID, Arrays.asList(new Param() - .setName(CZENODOCOMMUNITY_ID).setValue(zc.getZenodoid()))); - } - - } - - } - - }); - } - else{ - - Concept concept = new Concept(); - concept.setId(communityId + ZENODOCOMMUNITY_ID_SUFFIX + ID_SEPARATOR + zc.getId()); - concept.setClaim(false); - - - Map> params = new TreeMap<>(); - - if (zc.getZenodoid() != null) { - params.put( CZENODOCOMMUNITY_ID, Arrays.asList(new Param().setValue(zc.getZenodoid()).setName(CZENODOCOMMUNITY_ID))); - concept.setLabel(zc.getZenodoid()); - }else{ - concept.setLabel(""); - } - concept.setParams(params); - zcs.getConcepts().add(concept); - - } - - } + @Autowired + private ISClient isClient; + + public Map getContextMap() throws CommunityException { + try { + return isClient.getCommunityContextMap(); + } catch (final IOException e) { + throw new CommunityException(e); + } + } + + public List listCommunities() throws CommunityException { + return getContextMap().values() + .stream() + .filter(context -> !communityBlackList.contains(context.getId())) + .map(CommunityMappingUtils::asCommunitySummary) + .collect(Collectors.toList()); + } + + public List getCommunityInfo(final String id, final String idSuffix, final Function mapping) throws CommunityException { + final Map contextMap = getContextMap(); + final Context context = contextMap.get(id); + if (context != null) { + final Map categories = context.getCategories(); + final Category category = categories.get(id + idSuffix); + if (category != null) { return category.getConcepts() + .stream() + .map(mapping) + .collect(Collectors.toList()); } + } + return Lists.newArrayList(); + } + + public CommunityDetails getCommunity(final String id) throws CommunityException, ResourceNotFoundException { + final Context context = getContextMap().get(id); + if (context == null || CommunityConstants.communityBlackList.contains(id)) { + // ResponseStatusException(NOT_FOUND, "Unable to find resource"); + throw new ResourceNotFoundException(); + } + return CommunityMappingUtils.asCommunityProfile(context); + } + + public List getCommunityZenodoCommunities(final String id) throws CommunityException, ResourceNotFoundException { + getCommunity(id); // ensure the community exists. + return getCommunityInfo(id, ZENODOCOMMUNITY_ID_SUFFIX, c -> CommunityMappingUtils.asCommunityZenodoCommunity(id, c)); + } + + public void updateProject(final String communityId, final CommunityProject project) throws CommunityException { + final Context context = getContextMap().get(communityId); + final Category prj = context.getCategories().get(communityId + PROJECTS_ID_SUFFIX); + if (prj.getConcepts() + .stream() + .map(c -> c.getId()) + .collect(Collectors.toList()) + .contains(communityId + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project.getId())) { + prj.getConcepts().forEach(concept -> { + if (concept.getId().equals(communityId + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project.getId())) { + if (project.getName() != null) { + + concept.getParams() + .replace(CPROJECT_FULLNAME, Arrays.asList(new Param() + .setName(CPROJECT_FULLNAME) + .setValue(project.getName()))); + } + if (project.getAcronym() != null) { + if (concept.getParams().keySet().contains(CPROJECT_ACRONYM)) { + concept.getParams() + .replace(CPROJECT_ACRONYM, Arrays.asList(new Param() + .setName(CPROJECT_ACRONYM) + .setValue(project.getAcronym()))); + } else { + concept.getParams() + .put(CPROJECT_ACRONYM, Arrays.asList(new Param() + .setName(CPROJECT_ACRONYM) + .setValue(project.getAcronym()))); + } + + } + if (project.getOpenaireId() != null) { + if (concept.getParams().keySet().contains(OPENAIRE_ID)) { + concept.getParams() + .replace(OPENAIRE_ID, Arrays.asList(new Param() + .setName(OPENAIRE_ID) + .setValue(project.getOpenaireId()))); + } else { + concept.getParams() + .put(OPENAIRE_ID, Arrays.asList(new Param() + .setName(OPENAIRE_ID) + .setValue(project.getOpenaireId()))); + } + + } + if (project.getFunder() != null) { + concept.getParams() + .replace(CPROJECT_FUNDER, Arrays.asList(new Param() + .setName(CPROJECT_FUNDER) + .setValue(project.getFunder()))); + } + if (project.getGrantId() != null) { + concept.getParams() + .replace(CPROJECT_NUMBER, Arrays.asList(new Param() + .setName(CPROJECT_NUMBER) + .setValue(project.getGrantId()))); + + } + } + }); + } else { + final Concept concept = new Concept(); + concept.setId(communityId + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project.getId()); + concept.setClaim(false); + if (project.getAcronym() != null) { + concept.setLabel(project.getAcronym()); + } else { + concept.setLabel(""); + } + + final Map> params = new TreeMap<>(); + + if (project.getAcronym() != null) { + params.put(CPROJECT_ACRONYM, Arrays.asList(new Param().setName(CPROJECT_ACRONYM) + .setValue(project.getAcronym()))); + } + + if (project.getName() != null) { + params.put(CPROJECT_FULLNAME, Arrays.asList(new Param() + .setName(CPROJECT_FULLNAME) + .setValue(project.getName()))); + } + + if (project.getOpenaireId() != null) { + params.put(OPENAIRE_ID, Arrays.asList(new Param() + .setName(OPENAIRE_ID) + .setValue(project.getOpenaireId()))); + } + + if (project.getFunder() != null) { + params.put(CPROJECT_FUNDER, Arrays.asList(new Param() + .setName(CPROJECT_FUNDER) + .setValue(project.getFunder()))); + } + + if (project.getGrantId() != null) { + params.put(CPROJECT_NUMBER, Arrays.asList(new Param() + .setName(CPROJECT_NUMBER) + .setValue(project.getGrantId()))); + } + + concept.setParams(params); + prj.getConcepts().add(concept); + + } + + } + + public void removeAdvancedConstraint(final String id) throws CommunityException { + final Context context = getContextMap().get(id); + context.getParams() + .replace(CPROFILE_ADVANCED_CONSTRAINT, Arrays.asList(new Param() + .setName(CPROFILE_ADVANCED_CONSTRAINT) + .setValue(null))); + } + + public void updateCommunity(final String id, final CommunityWritableProperties community) throws CommunityException { + final Context context = getContextMap().get(id); + + if (community.getShortName() != null) { + context.setLabel(community.getShortName()); + } + + if (community.getName() != null) { + context.getParams() + .replace(CSUMMARY_NAME, Arrays.asList(new Param() + .setValue(community.getName()) + .setName(CSUMMARY_NAME))); + } + if (community.getDescription() != null) { + context.getParams() + .replace(CSUMMARY_DESCRIPTION, Arrays.asList(new Param() + .setName(CSUMMARY_DESCRIPTION) + .setValue(community.getDescription()))); + } + if (community.getLogoUrl() != null) { + context.getParams() + .replace(CSUMMARY_LOGOURL, Arrays.asList(new Param() + .setName(CSUMMARY_LOGOURL) + .setValue(community.getLogoUrl()))); + + } + if (community.getStatus() != null) { + context.getParams() + .replace(CSUMMARY_STATUS, Arrays.asList(new Param() + .setName(CSUMMARY_STATUS) + .setValue(community.getStatus().name()))); + } + if (community.getSubjects() != null) { + context.getParams() + .replace(CPROFILE_SUBJECT, Arrays.asList(new Param().setName(CPROFILE_SUBJECT) + .setValue(Joiner.on(CSV_DELIMITER) + .join(community.getSubjects())))); + } + if (community.getFos() != null) { + if (context.getParams().containsKey(CPROFILE_FOS)) { + context.getParams() + .replace(CPROFILE_FOS, Arrays.asList(new Param().setName(CPROFILE_FOS) + .setValue(Joiner.on(CSV_DELIMITER) + .join(community.getFos())))); + } else { + context.getParams() + .put(CPROFILE_FOS, Arrays.asList(new Param().setName(CPROFILE_FOS) + .setValue(Joiner.on(CSV_DELIMITER) + .join(community.getFos())))); + } + } + if (community.getSdg() != null) { + if (context.getParams().containsKey(CPROFILE_SDG)) { + context.getParams() + .replace(CPROFILE_SDG, Arrays.asList(new Param().setName(CPROFILE_SDG) + .setValue(Joiner.on(CSV_DELIMITER) + .join(community.getSdg())))); + } else { + context.getParams() + .put(CPROFILE_SDG, Arrays.asList(new Param().setName(CPROFILE_SDG) + .setValue(Joiner.on(CSV_DELIMITER) + .join(community.getSdg())))); + } + } + if (community.getAdvancedConstraints() != null) { + if (context.getParams().containsKey(CPROFILE_ADVANCED_CONSTRAINT)) { + context.getParams() + .replace(CPROFILE_ADVANCED_CONSTRAINT, Arrays.asList(new Param() + .setName(CPROFILE_ADVANCED_CONSTRAINT) + .setValue(new Gson().toJson(community.getAdvancedConstraints())))); + } else { + context.getParams() + .put(CPROFILE_ADVANCED_CONSTRAINT, Arrays.asList(new Param() + .setName(CPROFILE_ADVANCED_CONSTRAINT) + .setValue(new Gson().toJson(community.getAdvancedConstraints())))); + } + } + if (community.getMainZenodoCommunity() != null) { + context.getParams() + .replace(CSUMMARY_ZENODOC, Arrays.asList(new Param() + .setName(CSUMMARY_ZENODOC) + .setValue(community.getMainZenodoCommunity()))); + + } + + } + + public void removeFromCategory(final String communityId, final String category, final String conceptId) throws CommunityException { + final Map cmap = getContextMap(); + final Context context = cmap.get(communityId); + final Map cat = context.getCategories(); + + final List concepts = cat.get(communityId + category) + .getConcepts() + .stream() + .filter(c -> !c.getId().equals(communityId + category + ID_SEPARATOR + conceptId)) + .collect(Collectors.toList()); + + cat.get(communityId + category).setConcepts(concepts); + } + + public void updateDatasource(final String communityId, final CommunityContentprovider cp) throws CommunityException { + final Context context = getContextMap().get(communityId); + final Category dts = context.getCategories().get(communityId + CONTENTPROVIDERS_ID_SUFFIX); + if (dts.getConcepts() + .stream() + .map(c -> c.getId()) + .collect(Collectors.toList()) + .contains(communityId + CONTENTPROVIDERS_ID_SUFFIX + ID_SEPARATOR + cp.getId())) { + dts.getConcepts().forEach(concept -> { + if (concept.getId().equals(communityId + CONTENTPROVIDERS_ID_SUFFIX + ID_SEPARATOR + cp.getId())) { + + if (cp.getName() != null) { + if (concept.getParams().keySet().contains(CCONTENTPROVIDER_NAME)) { + concept.getParams() + .replace(CCONTENTPROVIDER_NAME, Arrays.asList(new Param() + .setName(CCONTENTPROVIDER_NAME) + .setValue(cp.getName()))); + } else { + concept.getParams() + .put(CCONTENTPROVIDER_NAME, Arrays.asList(new Param() + .setName(CCONTENTPROVIDER_NAME) + .setValue(cp.getName()))); + } + + } + if (cp.getOfficialname() != null) { + if (concept.getParams().keySet().contains(CCONTENTPROVIDER_OFFICIALNAME)) { + concept.getParams() + .replace(CCONTENTPROVIDER_OFFICIALNAME, Arrays.asList(new Param() + .setName(CCONTENTPROVIDER_OFFICIALNAME) + .setValue(cp.getOfficialname()))); + } else { + concept.getParams() + .put(CCONTENTPROVIDER_OFFICIALNAME, Arrays.asList(new Param() + .setName(CCONTENTPROVIDER_OFFICIALNAME) + .setValue(cp.getOfficialname()))); + } + + } + + if (cp.getOpenaireId() != null) { + if (concept.getParams().keySet().contains(OPENAIRE_ID)) { + concept.getParams() + .replace(OPENAIRE_ID, Arrays.asList(new Param() + .setName(OPENAIRE_ID) + .setValue(cp.getOpenaireId()))); + } else { + concept.getParams() + .put(OPENAIRE_ID, Arrays.asList(new Param() + .setName(OPENAIRE_ID) + .setValue(cp.getOpenaireId()))); + } + + } + + if (cp.getSelectioncriteria() != null) { + if (concept.getParams().keySet().contains(CCONTENTPROVIDER_SELCRITERIA)) { + concept.getParams() + .replace(CCONTENTPROVIDER_SELCRITERIA, Arrays.asList(new Param() + .setName(CCONTENTPROVIDER_SELCRITERIA) + .setValue(cp.toJson()))); + } else { + concept.getParams() + .put(CCONTENTPROVIDER_SELCRITERIA, Arrays.asList(new Param() + .setName(CCONTENTPROVIDER_SELCRITERIA) + .setValue(cp.toJson()))); + } + + } + } + }); + } else { + final Concept concept = new Concept(); + concept.setId(communityId + CONTENTPROVIDERS_ID_SUFFIX + ID_SEPARATOR + cp.getId()); + concept.setClaim(false); + concept.setLabel(""); + + final Map> params = new TreeMap<>(); + + if (cp.getName() != null) { + params.put(CCONTENTPROVIDER_NAME, Arrays.asList(new Param().setValue(cp.getName()).setName(CCONTENTPROVIDER_NAME))); + } + if (cp.getOfficialname() != null) { + params.put(CCONTENTPROVIDER_OFFICIALNAME, Arrays.asList(new Param().setValue(cp.getOfficialname()).setName(CCONTENTPROVIDER_OFFICIALNAME))); + } + if (cp.getOpenaireId() != null) { + params.put(OPENAIRE_ID, Arrays.asList(new Param().setValue(cp.getOpenaireId()).setName(OPENAIRE_ID))); + } + if (cp.getSelectioncriteria() != null) { + params.put(CCONTENTPROVIDER_SELCRITERIA, Arrays.asList(new Param().setValue(cp.toJson()).setName(CCONTENTPROVIDER_SELCRITERIA))); + + } + + concept.setParams(params); + dts.getConcepts().add(concept); + + } + + } + + public void updateOrganization(final String communityId, final CommunityOrganization organization) throws CommunityException { + + final Context context = getContextMap().get(communityId); + final Category orgs = context.getCategories().get(communityId + ORGANIZATION_ID_SUFFIX); + if (orgs.getConcepts() + .stream() + .map(c -> c.getId()) + .collect(Collectors.toList()) + .contains(communityId + ORGANIZATION_ID_SUFFIX + ID_SEPARATOR + organization.getId())) { + orgs.getConcepts().forEach(concept -> { + if (concept.getId().equals(communityId + ORGANIZATION_ID_SUFFIX + ID_SEPARATOR + organization.getId())) { + + if (organization.getName() != null) { + if (concept.getParams().keySet().contains(CORGANIZATION_NAME)) { + concept.getParams() + .replace(CORGANIZATION_NAME, Arrays.asList(new Param() + .setName(CORGANIZATION_NAME) + .setValue(organization.getName()))); + } else { + concept.getParams() + .put(CORGANIZATION_NAME, Arrays.asList(new Param() + .setName(CORGANIZATION_NAME) + .setValue(organization.getName()))); + } + + } + if (organization.getLogo_url() != null) { + if (concept.getParams().keySet().contains(CORGANIZATION_LOGOURL)) { + concept.getParams() + .replace(CORGANIZATION_LOGOURL, Arrays.asList(new Param() + .setName(CORGANIZATION_LOGOURL) + .setValue(Base64.getEncoder().encodeToString(organization.getLogo_url().getBytes())))); + } else { + concept.getParams() + .put(CORGANIZATION_LOGOURL, Arrays.asList(new Param() + .setName(CORGANIZATION_LOGOURL) + .setValue(Base64.getEncoder().encodeToString(organization.getLogo_url().getBytes())))); + } + + } + + if (organization.getWebsite_url() != null) { + if (concept.getParams().keySet().contains(CORGANIZATION_WEBSITEURL)) { + concept.getParams() + .replace(CORGANIZATION_WEBSITEURL, Arrays.asList(new Param() + .setName(CORGANIZATION_WEBSITEURL) + .setValue(Base64.getEncoder().encodeToString(organization.getWebsite_url().getBytes())))); + } else { + concept.getParams() + .put(CORGANIZATION_WEBSITEURL, Arrays.asList(new Param() + .setName(CORGANIZATION_WEBSITEURL) + .setValue(Base64.getEncoder().encodeToString(organization.getWebsite_url().getBytes())))); + } + + } + + } + + }); + } else { + + final Concept concept = new Concept(); + concept.setId(communityId + ORGANIZATION_ID_SUFFIX + ID_SEPARATOR + organization.getId()); + concept.setClaim(false); + concept.setLabel(""); + + final Map> params = new TreeMap<>(); + + if (organization.getName() != null) { + params.put(CORGANIZATION_NAME, Arrays.asList(new Param().setValue(organization.getName()).setName(CORGANIZATION_NAME))); + } + if (organization.getLogo_url() != null) { + + params.put(CORGANIZATION_LOGOURL, Arrays + .asList(new Param().setValue(Base64.getEncoder().encodeToString(organization.getLogo_url().getBytes())).setName(CORGANIZATION_LOGOURL))); + } + if (organization.getWebsite_url() != null) { + params.put(CORGANIZATION_WEBSITEURL, Arrays + .asList(new Param().setValue(Base64.getEncoder().encodeToString(organization.getWebsite_url().getBytes())) + .setName(CORGANIZATION_WEBSITEURL))); + } + + concept.setParams(params); + orgs.getConcepts().add(concept); + + } + + } + + public void updateZenodoCommunity(final String communityId, final CommunityZenodoCommunity zc) throws CommunityException { + final Context context = getContextMap().get(communityId); + final Category zcs = context.getCategories().get(communityId + ZENODOCOMMUNITY_ID_SUFFIX); + if (zcs.getConcepts() + .stream() + .map(c -> c.getId()) + .collect(Collectors.toList()) + .contains(communityId + ZENODOCOMMUNITY_ID_SUFFIX + ID_SEPARATOR + zc.getId())) { + zcs.getConcepts().forEach(concept -> { + if (concept.getId().equals(communityId + ZENODOCOMMUNITY_ID_SUFFIX + ID_SEPARATOR + zc.getId())) { + + if (zc.getZenodoid() != null) { + if (concept.getParams().keySet().contains(CZENODOCOMMUNITY_ID)) { + concept.getParams() + .replace(CZENODOCOMMUNITY_ID, Arrays.asList(new Param() + .setName(CZENODOCOMMUNITY_ID) + .setValue(zc.getZenodoid()))); + } else { + concept.getParams() + .put(CZENODOCOMMUNITY_ID, Arrays.asList(new Param() + .setName(CZENODOCOMMUNITY_ID) + .setValue(zc.getZenodoid()))); + } + + } + + } + + }); + } else { + + final Concept concept = new Concept(); + concept.setId(communityId + ZENODOCOMMUNITY_ID_SUFFIX + ID_SEPARATOR + zc.getId()); + concept.setClaim(false); + + final Map> params = new TreeMap<>(); + + if (zc.getZenodoid() != null) { + params.put(CZENODOCOMMUNITY_ID, Arrays.asList(new Param().setValue(zc.getZenodoid()).setName(CZENODOCOMMUNITY_ID))); + concept.setLabel(zc.getZenodoid()); + } else { + concept.setLabel(""); + } + concept.setParams(params); + zcs.getConcepts().add(concept); + + } + + } } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityConstants.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityConstants.java index 2bbd751e..1aa84835 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityConstants.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityConstants.java @@ -4,6 +4,7 @@ import java.util.Set; import com.google.common.collect.Sets; +@Deprecated public class CommunityConstants { public final static Set communityBlackList = Sets.newHashSet("fet-fp7", "fet-h2020"); @@ -49,13 +50,12 @@ public class CommunityConstants { public final static String CCONTENTPROVIDERENABLED_DEFAULT = "true"; public final static String CCONTENTPROVIDER_SELCRITERIA = "selcriteria"; - //community zenodo community + // community zenodo community public final static String CZENODOCOMMUNITY_ID = "zenodoid"; - //community organization + // community organization public final static String CORGANIZATION_NAME = "name"; public final static String CORGANIZATION_LOGOURL = "logourl"; public final static String CORGANIZATION_WEBSITEURL = "websiteurl"; - } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityMappingUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityMappingUtils.java index fb5da147..291e011d 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityMappingUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/CommunityMappingUtils.java @@ -1,10 +1,50 @@ package eu.dnetlib.openaire.community; +import static eu.dnetlib.openaire.common.Utils.escape; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDERENABLED_DEFAULT; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_ENABLED; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_NAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_OFFICIALNAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_SELCRITERIA; +import static eu.dnetlib.openaire.community.CommunityConstants.CONTENTPROVIDERS_ID_SUFFIX; +import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_LOGOURL; +import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_NAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_WEBSITEURL; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_ADVANCED_CONSTRAINT; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_CREATIONDATE; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_FOS; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_SDG; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_SUBJECT; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_ACRONYM; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_FULLNAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_FUNDER; +import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_NUMBER; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_DESCRIPTION; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_LOGOURL; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_NAME; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_STATUS; +import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_ZENODOC; +import static eu.dnetlib.openaire.community.CommunityConstants.CSV_DELIMITER; +import static eu.dnetlib.openaire.community.CommunityConstants.CZENODOCOMMUNITY_ID; +import static eu.dnetlib.openaire.community.CommunityConstants.ID_SEPARATOR; +import static eu.dnetlib.openaire.community.CommunityConstants.OPENAIRE_ID; +import static eu.dnetlib.openaire.community.CommunityConstants.ORGANIZATION_ID_SUFFIX; +import static eu.dnetlib.openaire.community.CommunityConstants.PIPE_SEPARATOR; +import static eu.dnetlib.openaire.community.CommunityConstants.PROJECTS_ID_SUFFIX; +import static eu.dnetlib.openaire.community.CommunityConstants.ZENODOCOMMUNITY_ID_SUFFIX; + import java.text.ParseException; -import java.util.*; +import java.util.Arrays; +import java.util.Base64; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.google.common.escape.Escaper; import com.google.common.xml.XmlEscapers; @@ -20,13 +60,7 @@ import eu.dnetlib.openaire.exporter.model.context.Concept; import eu.dnetlib.openaire.exporter.model.context.Context; import eu.dnetlib.openaire.exporter.model.context.Param; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import static eu.dnetlib.openaire.common.Utils.escape; -import static eu.dnetlib.openaire.community.CommunityConstants.*; - +@Deprecated public class CommunityMappingUtils { private final static String pattern = "yyyy-MM-dd'T'hh:mm:ss"; @@ -38,8 +72,8 @@ public class CommunityMappingUtils { summary.setId(c.getId()); summary.setShortName(c.getLabel()); - summary.setLastUpdateDate(c.getLastUpdateDate()); - summary.setCreationDate(c.getCreationDate()); + // summary.setLastUpdateDate(c.getLastUpdateDate()); + // summary.setCreationDate(c.getCreationDate()); summary.setQueryId(c.getId() + PIPE_SEPARATOR + c.getLabel()); summary.setType(c.getType()); @@ -63,7 +97,7 @@ public class CommunityMappingUtils { return summary; } - public static CommunityDetails asCommunityProfile(final Context c) { + public static CommunityDetails asCommunityProfile(final Context c) { final CommunityDetails p = new CommunityDetails(asCommunitySummary(c)); p.setLastUpdateDate(c.getLastUpdateDate()); @@ -78,14 +112,14 @@ public class CommunityMappingUtils { p.setSdg(splitValues(asValues(params.get(CPROFILE_SDG)), CSV_DELIMITER)); } if (params.containsKey(CPROFILE_ADVANCED_CONSTRAINT)) { - //In the map the string is the serialization of the json representing the selection criteria so it is a valid json + // In the map the string is the serialization of the json representing the selection criteria so it is a valid json p.setAdvancedConstraints(SelectionCriteria.fromJson(asCsv(params.get(CPROFILE_ADVANCED_CONSTRAINT)))); } - if (params.containsKey(CPROFILE_CREATIONDATE)){ + if (params.containsKey(CPROFILE_CREATIONDATE)) { try { p.setCreationDate(org.apache.commons.lang3.time.DateUtils.parseDate(asCsv(params.get(CPROFILE_CREATIONDATE)), pattern)); - }catch(ParseException e) { + } catch (final ParseException e) { log.debug("Exception on date format: " + e.getMessage()); } } @@ -121,44 +155,40 @@ public class CommunityMappingUtils { return d; } - public static CommunityZenodoCommunity asCommunityZenodoCommunity(final String communityId, final Concept c){ + public static CommunityZenodoCommunity asCommunityZenodoCommunity(final String communityId, final Concept c) { final CommunityZenodoCommunity z = new CommunityZenodoCommunity(); final Map> p = c.getParams(); z.setCommunityId(communityId); z.setId(StringUtils.substringAfterLast(c.getId(), ID_SEPARATOR)); - z.setZenodoid(firstValue(p,CZENODOCOMMUNITY_ID)); - //z.setName(c.getLabel()); + z.setZenodoid(firstValue(p, CZENODOCOMMUNITY_ID)); + // z.setName(c.getLabel()); return z; } - - public static CommunityOrganization asCommunityOrganization(String id, Concept c) { + public static CommunityOrganization asCommunityOrganization(final String id, final Concept c) { final Map> p = c.getParams(); final CommunityOrganization o = new CommunityOrganization(); o.setCommunityId(id); o.setId(StringUtils.substringAfterLast(c.getId(), ID_SEPARATOR)); - o.setName(firstValue(p,CORGANIZATION_NAME)); - o.setLogo_url(getDecodedUrl(firstValue(p,CORGANIZATION_LOGOURL))); - o.setWebsite_url(getDecodedUrl(firstValue(p,CORGANIZATION_WEBSITEURL))); + o.setName(firstValue(p, CORGANIZATION_NAME)); + o.setLogo_url(getDecodedUrl(firstValue(p, CORGANIZATION_LOGOURL))); + o.setWebsite_url(getDecodedUrl(firstValue(p, CORGANIZATION_WEBSITEURL))); return o; } - private static String getDecodedUrl(final String encoded_url){ - if(encoded_url == null){ - return encoded_url; - } + private static String getDecodedUrl(final String encoded_url) { + if (encoded_url == null) { return encoded_url; } return new String(Base64.getDecoder().decode(encoded_url)); } - private static List splitValues(final Stream stream, final String separator) { return stream.map(s -> s.split(separator)) - .map(Arrays::asList) - .flatMap(List::stream) - .filter(StringUtils::isNotBlank) - .map(StringUtils::trim) - .collect(Collectors.toList()); + .map(Arrays::asList) + .flatMap(List::stream) + .filter(StringUtils::isNotBlank) + .map(StringUtils::trim) + .collect(Collectors.toList()); } private static String firstValue(final Map> p, final String paramName) { @@ -167,11 +197,12 @@ public class CommunityMappingUtils { private static String asCsv(final List params) { return asValues(params) - .collect(Collectors.joining(CSV_DELIMITER)); + .collect(Collectors.joining(CSV_DELIMITER)); } private static Stream asValues(final List params) { - return params == null ? Stream.empty() : params.stream() + return params == null ? Stream.empty() + : params.stream() .map(Param::getValue) .map(StringUtils::trim) .distinct(); @@ -180,10 +211,9 @@ public class CommunityMappingUtils { public static String asProjectXML(final String contextId, final CommunityProject project) { final Escaper esc = XmlEscapers.xmlAttributeEscaper(); final StringBuilder sb = new StringBuilder(); - sb.append( - String.format( - "\n", - escape(esc, contextId), PROJECTS_ID_SUFFIX, ID_SEPARATOR, escape(esc, String.valueOf(project.getId())), escape(esc, project.getAcronym()))); + sb.append(String + .format("\n", escape(esc, contextId), PROJECTS_ID_SUFFIX, ID_SEPARATOR, escape(esc, String + .valueOf(project.getId())), escape(esc, project.getAcronym()))); sb.append(paramXML(CPROJECT_FULLNAME, project.getName())); sb.append(paramXML(CPROJECT_ACRONYM, project.getAcronym())); sb.append(paramXML(CPROJECT_NUMBER, project.getGrantId())); @@ -197,14 +227,13 @@ public class CommunityMappingUtils { log.info("creating the XML for the content provider"); final Escaper esc = XmlEscapers.xmlAttributeEscaper(); final StringBuilder sb = new StringBuilder(); - sb.append( - String.format( - "\n", - escape(esc, contextId), CONTENTPROVIDERS_ID_SUFFIX, ID_SEPARATOR, escape(esc, String.valueOf(ccp.getId())), escape(esc, ccp.getName()))); + sb.append(String + .format("\n", escape(esc, contextId), CONTENTPROVIDERS_ID_SUFFIX, ID_SEPARATOR, escape(esc, String + .valueOf(ccp.getId())), escape(esc, ccp.getName()))); sb.append(paramXML(OPENAIRE_ID, ccp.getOpenaireId())); sb.append(paramXML(CCONTENTPROVIDER_NAME, ccp.getName())); sb.append(paramXML(CCONTENTPROVIDER_OFFICIALNAME, ccp.getOfficialname())); - sb.append(paramXML(CCONTENTPROVIDER_ENABLED,CCONTENTPROVIDERENABLED_DEFAULT)); + sb.append(paramXML(CCONTENTPROVIDER_ENABLED, CCONTENTPROVIDERENABLED_DEFAULT)); sb.append(paramXMLNoEscape(CCONTENTPROVIDER_SELCRITERIA, ccp.toXML())); sb.append("\n"); log.info(sb.toString()); @@ -214,32 +243,28 @@ public class CommunityMappingUtils { public static String asZenodoCommunityXML(final String contextId, final CommunityZenodoCommunity zc) { final Escaper esc = XmlEscapers.xmlAttributeEscaper(); final StringBuilder sb = new StringBuilder(); - sb.append( - String.format( - "\n", - escape(esc, contextId), ZENODOCOMMUNITY_ID_SUFFIX, ID_SEPARATOR, escape(esc, String.valueOf(zc.getId())), escape(esc, zc.getZenodoid()))); + sb.append(String + .format("\n", escape(esc, contextId), ZENODOCOMMUNITY_ID_SUFFIX, ID_SEPARATOR, escape(esc, String + .valueOf(zc.getId())), escape(esc, zc.getZenodoid()))); sb.append(paramXML(CZENODOCOMMUNITY_ID, zc.getZenodoid())); sb.append("\n"); return sb.toString(); } - - public static String asOrganizationXML(final String contextId, CommunityOrganization organization) { + public static String asOrganizationXML(final String contextId, final CommunityOrganization organization) { final Escaper esc = XmlEscapers.xmlAttributeEscaper(); final StringBuilder sb = new StringBuilder(); - sb.append( - String.format( - "\n", - escape(esc, contextId), ORGANIZATION_ID_SUFFIX, ID_SEPARATOR, escape(esc, String.valueOf(organization.getId())), escape(esc, organization.getName()))); + sb.append(String + .format("\n", escape(esc, contextId), ORGANIZATION_ID_SUFFIX, ID_SEPARATOR, escape(esc, String + .valueOf(organization.getId())), escape(esc, organization.getName()))); sb.append(paramXML(CORGANIZATION_NAME, organization.getName())); sb.append(paramXML(CORGANIZATION_LOGOURL, Base64.getEncoder().encodeToString(organization.getLogo_url().getBytes()))); - sb.append(paramXML(CORGANIZATION_WEBSITEURL,Base64.getEncoder().encodeToString(organization.getWebsite_url().getBytes()))); + sb.append(paramXML(CORGANIZATION_WEBSITEURL, Base64.getEncoder().encodeToString(organization.getWebsite_url().getBytes()))); sb.append("\n"); return sb.toString(); } - private static String paramXML(final String paramName, final String value) { return String.format("%s\n", paramName, escape(XmlEscapers.xmlContentEscaper(), value)); } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java index 1c04c8c4..b57909ab 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/CommunityService.java @@ -51,6 +51,11 @@ public class CommunityService { // 5) Capire come gestire il campo Id (Integer) di CommunityContentprovider // 6) Capire come gestire il campo Id (Integer) di CommunityOrganization // 7) Modificare le api per gestire le ZenodoCommunities (main + others) + // 8) i campi name e lastUpdate mancano nel nuovo modello delle communities, si aggiungono? + // 9) i campi officialName e selectioncriteria mancano nel nuovo modello delle datasource, si aggiungono? + // 10) i campi name, logoUrl e websiteUrl mancano nel nuovo modello delle organization, + // esistono solo in quello delle support_org, occorre rivedere le api e i mapping + // 11) Move enums in dnet-exporter-model @Autowired private DbCommunityRepository dbCommunityRepository; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java index 8b25b173..bf3d2d30 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/ConvertionUtils.java @@ -1,5 +1,7 @@ package eu.dnetlib.openaire.community.db; +import static eu.dnetlib.openaire.community.CommunityConstants.PIPE_SEPARATOR; + import eu.dnetlib.openaire.community.db.model.DbCommunity; import eu.dnetlib.openaire.community.db.model.DbDatasource; import eu.dnetlib.openaire.community.db.model.DbOrganization; @@ -11,14 +13,40 @@ import eu.dnetlib.openaire.exporter.model.community.CommunitySummary; public class ConvertionUtils { - public static CommunitySummary toSummary(final DbCommunity dbEntry) { - // TODO - return null; + public static CommunitySummary toSummary(final DbCommunity c) { + final CommunitySummary summary = new CommunitySummary(); + + summary.setId(c.getId()); + summary.setShortName(c.getLabel()); + summary.setName(null); // TODO: the field is missing in the db model + summary.setLastUpdateDate(null); // TODO: the field is missing in the db model + summary.setCreationDate(c.getCreationDate()); + summary.setQueryId(c.getId() + PIPE_SEPARATOR + c.getLabel()); + summary.setType(c.getType().toString()); + summary.setDescription(c.getDescription()); + summary.setLogoUrl(c.getLogoUrl()); + summary.setStatus(c.getStatus()); + summary.setZenodoCommunity(c.getMainZenodoCommunity()); + + return summary; } public static CommunityProject toCommunityProject(final DbProject dbEntry) { - // TODO - return null; + final CommunityProject cp = new CommunityProject(); + + cp.setCommunityId(dbEntry.getCommunity()); + + // TODO id e openaireId sono uguali + cp.setId(dbEntry.getProjectId()); + cp.setOpenaireId(dbEntry.getProjectId()); + + cp.setName(dbEntry.getProjectName()); + cp.setAcronym(dbEntry.getProjectAcronym()); + + cp.setFunder(dbEntry.getProjectFunder()); + cp.setGrantId(dbEntry.getProjectCode()); + + return cp; } public static DbProject toDbProject(final String id, final CommunityProject project) { @@ -27,8 +55,22 @@ public class ConvertionUtils { } public static CommunityContentprovider toCommunityContentprovider(final DbDatasource dbEntry) { - // TODO - return null; + final CommunityContentprovider ccp = new CommunityContentprovider(); + + ccp.setCommunityId(dbEntry.getCommunity()); + + // TODO id e openaireId sono uguali + ccp.setId(dbEntry.getDsId()); + ccp.setOpenaireId(dbEntry.getDsId()); + + // TODO name e officialName sono uguali + ccp.setName(dbEntry.getDsName()); + ccp.setOfficialname(dbEntry.getDsName()); + + // TODO il campo manca nel nuovo modello + ccp.setSelectioncriteria(null); + + return ccp; } public static DbDatasource toDbDatasource(final String id, final CommunityContentprovider provider) { @@ -37,8 +79,18 @@ public class ConvertionUtils { } public static CommunityOrganization toCommunityOrganiztion(final DbOrganization dbEntry) { - // TODO - return null; + final CommunityOrganization co = new CommunityOrganization(); + co.setCommunityId(dbEntry.getCommunity()); + co.setId(dbEntry.getOrgId()); + + // TODO: + // queste informazioni sono mancanti nel modello delle organizations + // ma esitono in quello delle support_organizations + co.setLogo_url(null); + co.setName(null); + co.setWebsite_url(null); + + return co; } public static DbOrganization toDbOrganization(final String id, final CommunityOrganization org) { diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimType.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimType.java index c4bbca02..077342ce 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimType.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimType.java @@ -1,7 +1,26 @@ package eu.dnetlib.openaire.community.db.enums; public enum CommunityClaimType { - managersOnly, - membersOnly, - all + + managersOnly("managers-only"), + membersOnly("members-only"), + all("all"); + + private final String description; + + private CommunityClaimType(final String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public static CommunityClaimType fromDescription(final String dbData) { + for (final CommunityClaimType t : CommunityClaimType.values()) { + if (t.description.equalsIgnoreCase(dbData)) { return t; } + } + return null; + } + } diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimTypeConverter.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimTypeConverter.java index d9940e49..bacda019 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimTypeConverter.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/enums/CommunityClaimTypeConverter.java @@ -10,12 +10,8 @@ public class CommunityClaimTypeConverter implements AttributeConverter