new fields
This commit is contained in:
parent
cb7f5eb52c
commit
f4c053c0e0
|
@ -0,0 +1,7 @@
|
|||
package eu.dnetlib.openaire.community.db;
|
||||
|
||||
public enum CommunityClaimType {
|
||||
managersOnly,
|
||||
membersOnly,
|
||||
all
|
||||
}
|
|
@ -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<CommunityClaimType, String> {
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package eu.dnetlib.openaire.community.db;
|
||||
|
||||
public enum CommunityMembershipType {
|
||||
|
||||
open,
|
||||
byInvitation
|
||||
|
||||
}
|
|
@ -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<CommunityMembershipType, String> {
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -3,5 +3,6 @@ package eu.dnetlib.openaire.community.db;
|
|||
public enum CommunityStatus {
|
||||
all,
|
||||
manager,
|
||||
members,
|
||||
hidden
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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[],
|
||||
|
|
Loading…
Reference in New Issue