From 0e6de52307db9aa6054d28fd513fcf03344742eb Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Tue, 20 Jun 2023 10:48:53 +0200 Subject: [PATCH] classes for sub communities --- .../community/db/model/DbCommunity.java | 4 +- .../community/db/model/DbDatasource.java | 2 +- .../community/db/model/DbDatasourcePK.java | 2 +- .../community/db/model/DbOrganization.java | 2 +- .../community/db/model/DbOrganizationPK.java | 2 +- .../community/db/model/DbProject.java | 2 +- .../community/db/model/DbProjectPK.java | 2 +- .../community/db/model/DbSubCommunity.java | 97 +++++++++++++++++++ .../community/db/model/DbSupportOrg.java | 2 +- .../community/db/model/DbSupportOrgPK.java | 2 +- .../repository/DbSubCommunityRepository.java | 17 ++++ .../main/resources/sql/community-schema.sql | 2 + 12 files changed, 126 insertions(+), 10 deletions(-) create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSubCommunity.java create mode 100644 apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbSubCommunityRepository.java diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbCommunity.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbCommunity.java index c6809018..5fe43395 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbCommunity.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbCommunity.java @@ -40,7 +40,7 @@ import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionC }) public class DbCommunity implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 4315597783109726539L; @Id @Column(name = "id") @@ -103,7 +103,7 @@ public class DbCommunity implements Serializable { private LocalDateTime creationDate; @LastModifiedDate - @Column(name = "last_udate") + @Column(name = "last_update") @GeneratedValue(strategy = GenerationType.IDENTITY) private LocalDateTime lastUpdateDate; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasource.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasource.java index da268a08..a76ad833 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasource.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbDatasource.java @@ -17,7 +17,7 @@ import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionC @IdClass(DbDatasourcePK.class) public class DbDatasource implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -8782576185861694228L; @Id @Column(name = "community") 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 b1f9af8f..4e18288b 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 @@ -5,7 +5,7 @@ import java.util.Objects; public class DbDatasourcePK implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -8073510491611213955L; private String community; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganization.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganization.java index bfe972ef..430f2709 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganization.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganization.java @@ -13,7 +13,7 @@ import javax.persistence.Table; @IdClass(DbOrganizationPK.class) public class DbOrganization implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -602114117980437763L; @Id @Column(name = "community") diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganizationPK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganizationPK.java index 91da15dd..2922fee4 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganizationPK.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbOrganizationPK.java @@ -5,7 +5,7 @@ import java.util.Objects; public class DbOrganizationPK implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -6720182815397534837L; private String community; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProject.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProject.java index 98b19b1e..33fa1402 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProject.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProject.java @@ -13,7 +13,7 @@ import javax.persistence.Table; @IdClass(DbProjectPK.class) public class DbProject implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1649065971750517925L; @Id @Column(name = "community") diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProjectPK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProjectPK.java index 09f62ef6..2dd424cf 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProjectPK.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbProjectPK.java @@ -5,7 +5,7 @@ import java.util.Objects; public class DbProjectPK implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -4236577148534835803L; private String community; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSubCommunity.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSubCommunity.java new file mode 100644 index 00000000..d5f60ef8 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSubCommunity.java @@ -0,0 +1,97 @@ +package eu.dnetlib.openaire.community.db.model; + +import java.io.Serializable; +import java.util.Map; + +import javax.persistence.Column; +import javax.persistence.Entity; +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; + +@Entity +@Table(name = "community_subs") +@TypeDefs({ + @TypeDef(name = "string-array", typeClass = StringArrayType.class), + @TypeDef(name = "json", typeClass = JsonStringType.class), + @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) +}) +public class DbSubCommunity implements Serializable { + + private static final long serialVersionUID = 7104936574383307358L; + + @Id + @Column(name = "sub_id") + private String id; + + @Column(name = "community") + private String community; + + @Column(name = "label") + private String label; + + @Column(name = "category") + private String category; + + @Type(type = "jsonb") + @Column(name = "params") + private Map params; + + @Column(name = "parent") + private String parent; + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getCommunity() { + return community; + } + + public void setCommunity(final String community) { + this.community = community; + } + + public String getLabel() { + return label; + } + + public void setLabel(final String label) { + this.label = label; + } + + public String getCategory() { + return category; + } + + public void setCategory(final String category) { + this.category = category; + } + + public Map getParams() { + return params; + } + + public void setParams(final Map params) { + this.params = params; + } + + public String getParent() { + return parent; + } + + public void setParent(final String parent) { + this.parent = parent; + } +} diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrg.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrg.java index d1f2c603..d037a94f 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrg.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrg.java @@ -13,7 +13,7 @@ import javax.persistence.Table; @IdClass(DbSupportOrgPK.class) public class DbSupportOrg implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1308759097276753411L; @Id @Column(name = "community") diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrgPK.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrgPK.java index 00463739..63355dff 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrgPK.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/model/DbSupportOrgPK.java @@ -5,7 +5,7 @@ import java.util.Objects; public class DbSupportOrgPK implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -4117154543803798310L; private String community; diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbSubCommunityRepository.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbSubCommunityRepository.java new file mode 100644 index 00000000..a9c9a0a6 --- /dev/null +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/db/repository/DbSubCommunityRepository.java @@ -0,0 +1,17 @@ +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.DbSubCommunity; + +@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") +public interface DbSubCommunityRepository extends JpaRepository { + + List findByCommunity(String community); + + List findByCommunityAndParent(String community, String parent); + +} 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 a24bf41e..982af224 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 @@ -72,3 +72,5 @@ CREATE INDEX community_projects_community ON community_projects(community); CREATE INDEX community_datasources_community ON community_datasources(community); CREATE INDEX community_support_orgs_community ON community_support_orgs(community); CREATE INDEX community_orgs_community ON community_orgs(community); +CREATE INDEX community_subs_community ON community_subs(community); +CREATE INDEX community_subs_parent ON community_subs(parent);