community db classes

This commit is contained in:
Michele Artini 2023-06-12 14:30:42 +02:00
parent 827dec7a29
commit cdc8084cb6
20 changed files with 758 additions and 4 deletions

View File

@ -141,6 +141,12 @@
<artifactId>spring-web</artifactId> <artifactId>spring-web</artifactId>
<version>5.3.8</version> <version>5.3.8</version>
</dependency> </dependency>
<dependency>
<groupId>com.vladmihalcea</groupId>
<artifactId>hibernate-types-52</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -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;
}

View File

@ -0,0 +1,7 @@
package eu.dnetlib.openaire.community.db;
public enum CommunityStatus {
all,
manager,
hidden
}

View File

@ -0,0 +1,6 @@
package eu.dnetlib.openaire.community.db;
public enum CommunityType {
community,
ri
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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<Community, String> {
}

View File

@ -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<CommunityOrg, CommunityOrgPK> {
}

View File

@ -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<CommunityProject, CommunityProjectPK> {
}

View File

@ -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<Community, String> {
}

View File

@ -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<CommunitySupportOrg, CommunitySupportOrgPK> {
}

View File

@ -15,8 +15,8 @@ openaire.exporter.cxfClientConnectTimeout = 60000
openaire.exporter.cxfClientReceiveTimeout = 120000 openaire.exporter.cxfClientReceiveTimeout = 120000
# JDBC # JDBC
#openaire.exporter.jdbc.url = jdbc:postgresql://localhost:5432/dnet_openaireplus 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/dev_openaire_8280
openaire.exporter.jdbc.user = dnetapi openaire.exporter.jdbc.user = dnetapi
openaire.exporter.jdbc.pwd = dnetPwd openaire.exporter.jdbc.pwd = dnetPwd
openaire.exporter.jdbc.minIdle = 1 openaire.exporter.jdbc.minIdle = 1

View File

@ -14,8 +14,8 @@ CREATE TABLE communities (
subjects text[], subjects text[],
fos text[], fos text[],
sdg text[], sdg text[],
adv_constraints json, adv_constraints jsonb,
remove_constraints json, remove_constraints jsonb,
main_zenodo_community text, main_zenodo_community text,
other_zenodo_communities text[], other_zenodo_communities text[],
creation_date timestamp NOT NULL DEFAULT now(), creation_date timestamp NOT NULL DEFAULT now(),