new mapping method
This commit is contained in:
parent
f071321b3d
commit
71ba41a94c
|
@ -51,6 +51,7 @@ import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
|
|||
import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityStatus;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityType;
|
||||
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||
import eu.dnetlib.openaire.exporter.model.context.Concept;
|
||||
|
@ -72,7 +73,7 @@ public class CommunityMappingUtils {
|
|||
summary.setLastUpdateDate(convertToLocalDateTime(c.getLastUpdateDate()));
|
||||
summary.setCreationDate(convertToLocalDateTime(c.getCreationDate()));
|
||||
summary.setQueryId(c.getId() + PIPE_SEPARATOR + c.getLabel());
|
||||
summary.setType(c.getType());
|
||||
summary.setType(CommunityType.valueOf(c.getType()));
|
||||
|
||||
final Map<String, List<Param>> params = c.getParams();
|
||||
if (params.containsKey(CSUMMARY_DESCRIPTION)) {
|
||||
|
|
|
@ -48,10 +48,9 @@ public class CommunityService {
|
|||
// 1.2) Estrarre dalle classi deprecate (CommunityCommon e CommunityMappingUtils) i metodi necessari all'import
|
||||
// 1.3) Considerare anche le Subcommunities: importazione tramite profili
|
||||
// 2) Subcommunities: visualizzazione tramite le context api
|
||||
// 3) Implemtare il metodo ConvertionUtils.toCommunity
|
||||
// 4) Implemtare il metodo CommunityService.setCommunity
|
||||
// 5) ricontrollare se tutti i campi del database sono esposti dalle api (modello + mapping)
|
||||
// 6) Verificare Tickets: #8835, #8854, #6483, #3259, #3494
|
||||
// 3) Implemtare il metodo CommunityService.setCommunity
|
||||
// 4) ricontrollare se tutti i campi del database sono esposti dalle api (modello + mapping)
|
||||
// 5) Verificare Tickets: #8835, #8854, #6483, #3259, #3494
|
||||
|
||||
@Autowired
|
||||
private DbCommunityRepository dbCommunityRepository;
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package eu.dnetlib.openaire.community.db.utils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import eu.dnetlib.openaire.community.db.model.DbCommunity;
|
||||
import eu.dnetlib.openaire.community.db.model.DbDatasource;
|
||||
|
@ -23,14 +27,37 @@ public class ConvertionUtils {
|
|||
}
|
||||
|
||||
public static DbCommunity toCommunity(final CommunityDetails details) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
final DbCommunity c = new DbCommunity();
|
||||
c.setId(details.getId());
|
||||
c.setName(details.getName());
|
||||
c.setShortName(details.getShortName());
|
||||
c.setDescription(details.getDescription());
|
||||
c.setStatus(details.getStatus());
|
||||
c.setMembership(details.getMembership());
|
||||
c.setType(details.getType());
|
||||
c.setClaim(details.getClaim());
|
||||
c.setSubjects(toStringArray(details.getSubjects()));
|
||||
c.setFos(toStringArray(details.getFos()));
|
||||
c.setSdg(toStringArray(details.getSdg()));
|
||||
c.setAdvancedConstraints(details.getAdvancedConstraints());
|
||||
c.setRemoveConstraints(details.getRemoveConstraints());
|
||||
c.setMainZenodoCommunity(details.getZenodoCommunity());
|
||||
c.setOtherZenodoCommunities(toStringArray(details.getOtherZenodoCommunities()));
|
||||
c.setCreationDate(ObjectUtils.firstNonNull(details.getCreationDate(), LocalDateTime.now()));
|
||||
c.setLastUpdateDate(LocalDateTime.now());
|
||||
c.setLogoUrl(details.getLogoUrl());
|
||||
return c;
|
||||
}
|
||||
|
||||
private static String[] toStringArray(final List<String> list) {
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
public static CommunityDetails CommunityDetails(final DbCommunity c) {
|
||||
final CommunityDetails details = new CommunityDetails();
|
||||
populateSummary(details, c);
|
||||
details.setAdvancedConstraints(c.getAdvancedConstraints());
|
||||
details.setRemoveConstraints(c.getRemoveConstraints());
|
||||
details.setFos(Arrays.asList(c.getFos()));
|
||||
details.setSdg(Arrays.asList(c.getSdg()));
|
||||
details.setSubjects(Arrays.asList(c.getSubjects()));
|
||||
|
@ -47,7 +74,7 @@ public class ConvertionUtils {
|
|||
summary.setLastUpdateDate(c.getLastUpdateDate());
|
||||
summary.setCreationDate(c.getCreationDate());
|
||||
summary.setQueryId(c.getId() + PIPE_SEPARATOR + c.getShortName());
|
||||
summary.setType(c.getType().toString());
|
||||
summary.setType(c.getType());
|
||||
summary.setDescription(c.getDescription());
|
||||
summary.setLogoUrl(c.getLogoUrl());
|
||||
summary.setStatus(c.getStatus());
|
||||
|
|
|
@ -29,6 +29,9 @@ public class CommunityDetails extends CommunitySummary {
|
|||
@Schema(description = "list of advanced criteria to associate results to this community")
|
||||
private SelectionCriteria advancedConstraints;
|
||||
|
||||
@Schema(description = "list of the remove criteria")
|
||||
private SelectionCriteria removeConstraints;
|
||||
|
||||
@Schema(description = "type of claim")
|
||||
private CommunityClaimType claim;
|
||||
|
||||
|
@ -96,6 +99,14 @@ public class CommunityDetails extends CommunitySummary {
|
|||
this.advancedConstraints = advancedConstraints;
|
||||
}
|
||||
|
||||
public SelectionCriteria getRemoveConstraints() {
|
||||
return removeConstraints;
|
||||
}
|
||||
|
||||
public void setRemoveConstraints(final SelectionCriteria removeConstraints) {
|
||||
this.removeConstraints = removeConstraints;
|
||||
}
|
||||
|
||||
public CommunityClaimType getClaim() {
|
||||
return claim;
|
||||
}
|
||||
|
@ -119,4 +130,5 @@ public class CommunityDetails extends CommunitySummary {
|
|||
public void setOtherZenodoCommunities(final List<String> otherZenodoCommunities) {
|
||||
this.otherZenodoCommunities = otherZenodoCommunities;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class CommunitySummary {
|
|||
protected String queryId;
|
||||
|
||||
@Schema(description = "community type")
|
||||
protected String type;
|
||||
protected CommunityType type;
|
||||
|
||||
@Schema(description = "community name")
|
||||
protected String name;
|
||||
|
@ -47,7 +47,7 @@ public class CommunitySummary {
|
|||
public CommunitySummary(
|
||||
final String id,
|
||||
final String queryId,
|
||||
final String type,
|
||||
final CommunityType type,
|
||||
final String name,
|
||||
final String shortName,
|
||||
final LocalDateTime creationDate,
|
||||
|
@ -99,11 +99,11 @@ public class CommunitySummary {
|
|||
this.queryId = queryId;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
public CommunityType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(final String type) {
|
||||
public void setType(final CommunityType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue