classes for sub communities

This commit is contained in:
Michele Artini 2023-06-20 10:48:53 +02:00
parent f3ac95b54f
commit 0e6de52307
12 changed files with 126 additions and 10 deletions

View File

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

View File

@ -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")

View File

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

View File

@ -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")

View File

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

View File

@ -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")

View File

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

View File

@ -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<String, String> 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<String, String> getParams() {
return params;
}
public void setParams(final Map<String, String> params) {
this.params = params;
}
public String getParent() {
return parent;
}
public void setParent(final String parent) {
this.parent = parent;
}
}

View File

@ -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")

View File

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

View File

@ -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<DbSubCommunity, String> {
List<DbSubCommunityRepository> findByCommunity(String community);
List<DbSubCommunityRepository> findByCommunityAndParent(String community, String parent);
}

View File

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