community plan as enum

This commit is contained in:
Michele Artini 2024-05-09 10:11:50 +02:00
parent 3cbce1024c
commit 550baf79e4
6 changed files with 45 additions and 37 deletions

View File

@ -38,6 +38,7 @@ import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider;
import eu.dnetlib.openaire.exporter.model.community.CommunityDetails; import eu.dnetlib.openaire.exporter.model.community.CommunityDetails;
import eu.dnetlib.openaire.exporter.model.community.CommunityMembershipType; import eu.dnetlib.openaire.exporter.model.community.CommunityMembershipType;
import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization; import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
import eu.dnetlib.openaire.exporter.model.community.CommunityPlanType;
import eu.dnetlib.openaire.exporter.model.community.CommunityProject; import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
import eu.dnetlib.openaire.exporter.model.community.CommunityStatus; import eu.dnetlib.openaire.exporter.model.community.CommunityStatus;
import eu.dnetlib.openaire.exporter.model.community.CommunityType; import eu.dnetlib.openaire.exporter.model.community.CommunityType;
@ -268,7 +269,7 @@ public class CommunityImporterService {
// 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
details.setRemoveConstraints(SelectionCriteria.fromJson(asCsv(CPROFILE_REMOVE_CONSTRAINT, c.getParams()))); details.setRemoveConstraints(SelectionCriteria.fromJson(asCsv(CPROFILE_REMOVE_CONSTRAINT, c.getParams())));
details.setSuggestedAcknowledgements(splitValues(asValues(CPROFILE_SUGGESTED_ACKNOWLEDGEMENT, c.getParams()), CSV_DELIMITER)); details.setSuggestedAcknowledgements(splitValues(asValues(CPROFILE_SUGGESTED_ACKNOWLEDGEMENT, c.getParams()), CSV_DELIMITER));
details.setPlan(null); details.setPlan(CommunityPlanType.Default);
try { try {
details.setCreationDate(CommunityMappingUtils.asLocalDateTime(asCsv(CPROFILE_CREATIONDATE, c.getParams()))); details.setCreationDate(CommunityMappingUtils.asLocalDateTime(asCsv(CPROFILE_CREATIONDATE, c.getParams())));
} catch (final Exception e) { } catch (final Exception e) {

View File

@ -27,6 +27,7 @@ import eu.dnetlib.openaire.community.utils.CommunityClaimTypeConverter;
import eu.dnetlib.openaire.community.utils.CommunityMembershipTypeConverter; import eu.dnetlib.openaire.community.utils.CommunityMembershipTypeConverter;
import eu.dnetlib.openaire.exporter.model.community.CommunityClaimType; import eu.dnetlib.openaire.exporter.model.community.CommunityClaimType;
import eu.dnetlib.openaire.exporter.model.community.CommunityMembershipType; import eu.dnetlib.openaire.exporter.model.community.CommunityMembershipType;
import eu.dnetlib.openaire.exporter.model.community.CommunityPlanType;
import eu.dnetlib.openaire.exporter.model.community.CommunityStatus; import eu.dnetlib.openaire.exporter.model.community.CommunityStatus;
import eu.dnetlib.openaire.exporter.model.community.CommunityType; import eu.dnetlib.openaire.exporter.model.community.CommunityType;
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria; import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
@ -34,9 +35,9 @@ import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionC
@Entity @Entity
@Table(name = "communities") @Table(name = "communities")
@TypeDefs({ @TypeDefs({
@TypeDef(name = "string-array", typeClass = StringArrayType.class), @TypeDef(name = "string-array", typeClass = StringArrayType.class),
@TypeDef(name = "json", typeClass = JsonStringType.class), @TypeDef(name = "json", typeClass = JsonStringType.class),
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
}) })
public class DbCommunity implements Serializable { public class DbCommunity implements Serializable {
@ -115,7 +116,8 @@ public class DbCommunity implements Serializable {
private String[] suggestedAcknowledgements; private String[] suggestedAcknowledgements;
@Column(name = "plan") @Column(name = "plan")
private String plan; @Enumerated(EnumType.STRING)
private CommunityPlanType plan;
public String getId() { public String getId() {
return id; return id;
@ -269,11 +271,11 @@ public class DbCommunity implements Serializable {
this.suggestedAcknowledgements = suggestedAcknowledgements; this.suggestedAcknowledgements = suggestedAcknowledgements;
} }
public String getPlan() { public CommunityPlanType getPlan() {
return plan; return plan;
} }
public void setPlan(final String plan) { public void setPlan(final CommunityPlanType plan) {
this.plan = plan; this.plan = plan;
} }

View File

@ -25,7 +25,7 @@ CREATE TABLE communities (
last_update timestamp NOT NULL DEFAULT now(), last_update timestamp NOT NULL DEFAULT now(),
logo_url text, logo_url text,
suggested_acknowledgements text[], suggested_acknowledgements text[],
plan text plan text NOT NULL DEFAULT 'Default'
); );
CREATE TABLE community_projects ( CREATE TABLE community_projects (

View File

@ -0,0 +1,5 @@
package eu.dnetlib.openaire.exporter.model.community;
public enum CommunityPlanType {
Standard, Advanced, Premium, National, Default
}

View File

@ -49,23 +49,23 @@ public class CommunitySummary {
protected String zenodoCommunity; protected String zenodoCommunity;
@Schema(description = "community plan") @Schema(description = "community plan")
protected String plan; protected CommunityPlanType plan;
public CommunitySummary() {} public CommunitySummary() {}
public CommunitySummary( public CommunitySummary(
final String id, final String id,
final String queryId, final String queryId,
final CommunityType type, final CommunityType type,
final String name, final String name,
final String shortName, final String shortName,
final LocalDateTime creationDate, final LocalDateTime creationDate,
final LocalDateTime lastUpdateDate, final LocalDateTime lastUpdateDate,
final String description, final String description,
final String logoUrl, final String logoUrl,
final CommunityStatus status, final CommunityStatus status,
final String zenodoCommunity, final String zenodoCommunity,
final String plan) { final CommunityPlanType plan) {
this.id = id; this.id = id;
this.queryId = queryId; this.queryId = queryId;
this.type = type; this.type = type;
@ -82,17 +82,17 @@ public class CommunitySummary {
public CommunitySummary(final CommunitySummary summary) { public CommunitySummary(final CommunitySummary summary) {
this(summary.getId(), this(summary.getId(),
summary.getQueryId(), summary.getQueryId(),
summary.getType(), summary.getType(),
summary.getName(), summary.getName(),
summary.getShortName(), summary.getShortName(),
summary.getCreationDate(), summary.getCreationDate(),
summary.getLastUpdateDate(), summary.getLastUpdateDate(),
summary.getDescription(), summary.getDescription(),
summary.getLogoUrl(), summary.getLogoUrl(),
summary.getStatus(), summary.getStatus(),
summary.getZenodoCommunity(), summary.getZenodoCommunity(),
summary.getPlan()); summary.getPlan());
} }
public String getId() { public String getId() {
@ -199,11 +199,11 @@ public class CommunitySummary {
this.zenodoCommunity = zenodoCommunity; this.zenodoCommunity = zenodoCommunity;
} }
public String getPlan() { public CommunityPlanType getPlan() {
return plan; return plan;
} }
public void setPlan(final String plan) { public void setPlan(final CommunityPlanType plan) {
this.plan = plan; this.plan = plan;
} }

View File

@ -56,7 +56,7 @@ public class CommunityWritableProperties {
private CommunityClaimType claim; private CommunityClaimType claim;
@Schema(description = "community plan") @Schema(description = "community plan")
private String plan; private CommunityPlanType plan;
public List<String> getFos() { public List<String> getFos() {
return fos; return fos;
@ -178,11 +178,11 @@ public class CommunityWritableProperties {
this.otherZenodoCommunities = otherZenodoCommunities; this.otherZenodoCommunities = otherZenodoCommunities;
} }
public String getPlan() { public CommunityPlanType getPlan() {
return plan; return plan;
} }
public void setPlan(final String plan) { public void setPlan(final CommunityPlanType plan) {
this.plan = plan; this.plan = plan;
} }
} }