moved claim and membership to parent class

This commit is contained in:
Michele Artini 2023-07-14 14:23:57 +02:00
parent 1a4dcddbe3
commit 970eff3926
4 changed files with 26 additions and 30 deletions

View File

@ -111,7 +111,7 @@ public class CommunityService {
public CommunityDetails getCommunity(final String id) throws CommunityException { public CommunityDetails getCommunity(final String id) throws CommunityException {
try { try {
final DbCommunity c = dbCommunityRepository.findById(id).orElseThrow(() -> new ResourceNotFoundException("Community not found: " + id)); final DbCommunity c = dbCommunityRepository.findById(id).orElseThrow(() -> new ResourceNotFoundException("Community not found: " + id));
return CommunityMappingUtils.CommunityDetails(c); return CommunityMappingUtils.toCommunityDetails(c);
} catch (final Throwable e) { } catch (final Throwable e) {
log.error(e); log.error(e);
throw new CommunityException(e); throw new CommunityException(e);

View File

@ -115,7 +115,7 @@ public class CommunityMappingUtils {
c.setLastUpdateDate(LocalDateTime.now()); c.setLastUpdateDate(LocalDateTime.now());
} }
public static CommunityDetails CommunityDetails(final DbCommunity c) { public static CommunityDetails toCommunityDetails(final DbCommunity c) {
final CommunityDetails details = new CommunityDetails(); final CommunityDetails details = new CommunityDetails();
populateSummary(details, c); populateSummary(details, c);
details.setAdvancedConstraints(c.getAdvancedConstraints()); details.setAdvancedConstraints(c.getAdvancedConstraints());
@ -123,8 +123,6 @@ public class CommunityMappingUtils {
details.setFos(Arrays.asList(c.getFos())); details.setFos(Arrays.asList(c.getFos()));
details.setSdg(Arrays.asList(c.getSdg())); details.setSdg(Arrays.asList(c.getSdg()));
details.setSubjects(Arrays.asList(c.getSubjects())); details.setSubjects(Arrays.asList(c.getSubjects()));
details.setClaim(c.getClaim());
details.setMembership(c.getMembership());
details.setOtherZenodoCommunities(Arrays.asList(c.getOtherZenodoCommunities())); details.setOtherZenodoCommunities(Arrays.asList(c.getOtherZenodoCommunities()));
return details; return details;
} }
@ -140,6 +138,8 @@ public class CommunityMappingUtils {
summary.setDescription(c.getDescription()); summary.setDescription(c.getDescription());
summary.setLogoUrl(c.getLogoUrl()); summary.setLogoUrl(c.getLogoUrl());
summary.setStatus(c.getStatus()); summary.setStatus(c.getStatus());
summary.setClaim(c.getClaim());
summary.setMembership(c.getMembership());
summary.setZenodoCommunity(c.getMainZenodoCommunity()); summary.setZenodoCommunity(c.getMainZenodoCommunity());
} }

View File

@ -32,12 +32,6 @@ public class CommunityDetails extends CommunitySummary {
@Schema(description = "list of the remove criteria") @Schema(description = "list of the remove criteria")
private SelectionCriteria removeConstraints; private SelectionCriteria removeConstraints;
@Schema(description = "type of claim")
private CommunityClaimType claim;
@Schema(description = "type of membership")
private CommunityMembershipType membership;
@Schema(description = "other zenodo communities") @Schema(description = "other zenodo communities")
private List<String> otherZenodoCommunities; private List<String> otherZenodoCommunities;
@ -107,22 +101,6 @@ public class CommunityDetails extends CommunitySummary {
this.removeConstraints = removeConstraints; this.removeConstraints = removeConstraints;
} }
public CommunityClaimType getClaim() {
return claim;
}
public void setClaim(final CommunityClaimType claim) {
this.claim = claim;
}
public CommunityMembershipType getMembership() {
return membership;
}
public void setMembership(final CommunityMembershipType membership) {
this.membership = membership;
}
public List<String> getOtherZenodoCommunities() { public List<String> getOtherZenodoCommunities() {
return otherZenodoCommunities; return otherZenodoCommunities;
} }
@ -148,10 +126,6 @@ public class CommunityDetails extends CommunitySummary {
.append(advancedConstraints) .append(advancedConstraints)
.append(",\n\tremoveConstraints = ") .append(",\n\tremoveConstraints = ")
.append(removeConstraints) .append(removeConstraints)
.append(",\n\tclaim = ")
.append(claim)
.append(",\n\tmembership = ")
.append(membership)
.append(",\n\totherZenodoCommunities = ") .append(",\n\totherZenodoCommunities = ")
.append(otherZenodoCommunities) .append(otherZenodoCommunities)
.append(",\n\tid = ") .append(",\n\tid = ")

View File

@ -39,6 +39,12 @@ public class CommunitySummary {
@Schema(description = "status of the community, drives its visibility") @Schema(description = "status of the community, drives its visibility")
protected CommunityStatus status; protected CommunityStatus status;
@Schema(description = "type of claim")
private CommunityClaimType claim;
@Schema(description = "type of membership")
private CommunityMembershipType membership;
@Schema(description = "Zenodo community associated to this community") @Schema(description = "Zenodo community associated to this community")
protected String zenodoCommunity; protected String zenodoCommunity;
@ -163,6 +169,22 @@ public class CommunitySummary {
this.status = status; this.status = status;
} }
public CommunityClaimType getClaim() {
return claim;
}
public void setClaim(final CommunityClaimType claim) {
this.claim = claim;
}
public CommunityMembershipType getMembership() {
return membership;
}
public void setMembership(final CommunityMembershipType membership) {
this.membership = membership;
}
public String getZenodoCommunity() { public String getZenodoCommunity() {
return zenodoCommunity; return zenodoCommunity;
} }