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.CommunityMembershipType;
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.CommunityStatus;
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
details.setRemoveConstraints(SelectionCriteria.fromJson(asCsv(CPROFILE_REMOVE_CONSTRAINT, c.getParams())));
details.setSuggestedAcknowledgements(splitValues(asValues(CPROFILE_SUGGESTED_ACKNOWLEDGEMENT, c.getParams()), CSV_DELIMITER));
details.setPlan(null);
details.setPlan(CommunityPlanType.Default);
try {
details.setCreationDate(CommunityMappingUtils.asLocalDateTime(asCsv(CPROFILE_CREATIONDATE, c.getParams())));
} 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.exporter.model.community.CommunityClaimType;
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.CommunityType;
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
@ -34,9 +35,9 @@ import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionC
@Entity
@Table(name = "communities")
@TypeDefs({
@TypeDef(name = "string-array", typeClass = StringArrayType.class),
@TypeDef(name = "json", typeClass = JsonStringType.class),
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
@TypeDef(name = "string-array", typeClass = StringArrayType.class),
@TypeDef(name = "json", typeClass = JsonStringType.class),
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
})
public class DbCommunity implements Serializable {
@ -115,7 +116,8 @@ public class DbCommunity implements Serializable {
private String[] suggestedAcknowledgements;
@Column(name = "plan")
private String plan;
@Enumerated(EnumType.STRING)
private CommunityPlanType plan;
public String getId() {
return id;
@ -269,11 +271,11 @@ public class DbCommunity implements Serializable {
this.suggestedAcknowledgements = suggestedAcknowledgements;
}
public String getPlan() {
public CommunityPlanType getPlan() {
return plan;
}
public void setPlan(final String plan) {
public void setPlan(final CommunityPlanType plan) {
this.plan = plan;
}

View File

@ -25,7 +25,7 @@ CREATE TABLE communities (
last_update timestamp NOT NULL DEFAULT now(),
logo_url text,
suggested_acknowledgements text[],
plan text
plan text NOT NULL DEFAULT 'Default'
);
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;
@Schema(description = "community plan")
protected String plan;
protected CommunityPlanType plan;
public CommunitySummary() {}
public CommunitySummary(
final String id,
final String queryId,
final CommunityType type,
final String name,
final String shortName,
final LocalDateTime creationDate,
final LocalDateTime lastUpdateDate,
final String description,
final String logoUrl,
final CommunityStatus status,
final String zenodoCommunity,
final String plan) {
final String id,
final String queryId,
final CommunityType type,
final String name,
final String shortName,
final LocalDateTime creationDate,
final LocalDateTime lastUpdateDate,
final String description,
final String logoUrl,
final CommunityStatus status,
final String zenodoCommunity,
final CommunityPlanType plan) {
this.id = id;
this.queryId = queryId;
this.type = type;
@ -82,17 +82,17 @@ public class CommunitySummary {
public CommunitySummary(final CommunitySummary summary) {
this(summary.getId(),
summary.getQueryId(),
summary.getType(),
summary.getName(),
summary.getShortName(),
summary.getCreationDate(),
summary.getLastUpdateDate(),
summary.getDescription(),
summary.getLogoUrl(),
summary.getStatus(),
summary.getZenodoCommunity(),
summary.getPlan());
summary.getQueryId(),
summary.getType(),
summary.getName(),
summary.getShortName(),
summary.getCreationDate(),
summary.getLastUpdateDate(),
summary.getDescription(),
summary.getLogoUrl(),
summary.getStatus(),
summary.getZenodoCommunity(),
summary.getPlan());
}
public String getId() {
@ -199,11 +199,11 @@ public class CommunitySummary {
this.zenodoCommunity = zenodoCommunity;
}
public String getPlan() {
public CommunityPlanType getPlan() {
return plan;
}
public void setPlan(final String plan) {
public void setPlan(final CommunityPlanType plan) {
this.plan = plan;
}

View File

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