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.CommunityProject;
|
||||||
import eu.dnetlib.openaire.exporter.model.community.CommunityStatus;
|
import eu.dnetlib.openaire.exporter.model.community.CommunityStatus;
|
||||||
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
|
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.CommunityZenodoCommunity;
|
||||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||||
import eu.dnetlib.openaire.exporter.model.context.Concept;
|
import eu.dnetlib.openaire.exporter.model.context.Concept;
|
||||||
|
@ -72,7 +73,7 @@ public class CommunityMappingUtils {
|
||||||
summary.setLastUpdateDate(convertToLocalDateTime(c.getLastUpdateDate()));
|
summary.setLastUpdateDate(convertToLocalDateTime(c.getLastUpdateDate()));
|
||||||
summary.setCreationDate(convertToLocalDateTime(c.getCreationDate()));
|
summary.setCreationDate(convertToLocalDateTime(c.getCreationDate()));
|
||||||
summary.setQueryId(c.getId() + PIPE_SEPARATOR + c.getLabel());
|
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();
|
final Map<String, List<Param>> params = c.getParams();
|
||||||
if (params.containsKey(CSUMMARY_DESCRIPTION)) {
|
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.2) Estrarre dalle classi deprecate (CommunityCommon e CommunityMappingUtils) i metodi necessari all'import
|
||||||
// 1.3) Considerare anche le Subcommunities: importazione tramite profili
|
// 1.3) Considerare anche le Subcommunities: importazione tramite profili
|
||||||
// 2) Subcommunities: visualizzazione tramite le context api
|
// 2) Subcommunities: visualizzazione tramite le context api
|
||||||
// 3) Implemtare il metodo ConvertionUtils.toCommunity
|
// 3) Implemtare il metodo CommunityService.setCommunity
|
||||||
// 4) Implemtare il metodo CommunityService.setCommunity
|
// 4) ricontrollare se tutti i campi del database sono esposti dalle api (modello + mapping)
|
||||||
// 5) ricontrollare se tutti i campi del database sono esposti dalle api (modello + mapping)
|
// 5) Verificare Tickets: #8835, #8854, #6483, #3259, #3494
|
||||||
// 6) Verificare Tickets: #8835, #8854, #6483, #3259, #3494
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DbCommunityRepository dbCommunityRepository;
|
private DbCommunityRepository dbCommunityRepository;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package eu.dnetlib.openaire.community.db.utils;
|
package eu.dnetlib.openaire.community.db.utils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Arrays;
|
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.DbCommunity;
|
||||||
import eu.dnetlib.openaire.community.db.model.DbDatasource;
|
import eu.dnetlib.openaire.community.db.model.DbDatasource;
|
||||||
|
@ -23,14 +27,37 @@ public class ConvertionUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DbCommunity toCommunity(final CommunityDetails details) {
|
public static DbCommunity toCommunity(final CommunityDetails details) {
|
||||||
// TODO Auto-generated method stub
|
final DbCommunity c = new DbCommunity();
|
||||||
return null;
|
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) {
|
public static CommunityDetails CommunityDetails(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());
|
||||||
|
details.setRemoveConstraints(c.getRemoveConstraints());
|
||||||
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()));
|
||||||
|
@ -47,7 +74,7 @@ public class ConvertionUtils {
|
||||||
summary.setLastUpdateDate(c.getLastUpdateDate());
|
summary.setLastUpdateDate(c.getLastUpdateDate());
|
||||||
summary.setCreationDate(c.getCreationDate());
|
summary.setCreationDate(c.getCreationDate());
|
||||||
summary.setQueryId(c.getId() + PIPE_SEPARATOR + c.getShortName());
|
summary.setQueryId(c.getId() + PIPE_SEPARATOR + c.getShortName());
|
||||||
summary.setType(c.getType().toString());
|
summary.setType(c.getType());
|
||||||
summary.setDescription(c.getDescription());
|
summary.setDescription(c.getDescription());
|
||||||
summary.setLogoUrl(c.getLogoUrl());
|
summary.setLogoUrl(c.getLogoUrl());
|
||||||
summary.setStatus(c.getStatus());
|
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")
|
@Schema(description = "list of advanced criteria to associate results to this community")
|
||||||
private SelectionCriteria advancedConstraints;
|
private SelectionCriteria advancedConstraints;
|
||||||
|
|
||||||
|
@Schema(description = "list of the remove criteria")
|
||||||
|
private SelectionCriteria removeConstraints;
|
||||||
|
|
||||||
@Schema(description = "type of claim")
|
@Schema(description = "type of claim")
|
||||||
private CommunityClaimType claim;
|
private CommunityClaimType claim;
|
||||||
|
|
||||||
|
@ -96,6 +99,14 @@ public class CommunityDetails extends CommunitySummary {
|
||||||
this.advancedConstraints = advancedConstraints;
|
this.advancedConstraints = advancedConstraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SelectionCriteria getRemoveConstraints() {
|
||||||
|
return removeConstraints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemoveConstraints(final SelectionCriteria removeConstraints) {
|
||||||
|
this.removeConstraints = removeConstraints;
|
||||||
|
}
|
||||||
|
|
||||||
public CommunityClaimType getClaim() {
|
public CommunityClaimType getClaim() {
|
||||||
return claim;
|
return claim;
|
||||||
}
|
}
|
||||||
|
@ -119,4 +130,5 @@ public class CommunityDetails extends CommunitySummary {
|
||||||
public void setOtherZenodoCommunities(final List<String> otherZenodoCommunities) {
|
public void setOtherZenodoCommunities(final List<String> otherZenodoCommunities) {
|
||||||
this.otherZenodoCommunities = otherZenodoCommunities;
|
this.otherZenodoCommunities = otherZenodoCommunities;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class CommunitySummary {
|
||||||
protected String queryId;
|
protected String queryId;
|
||||||
|
|
||||||
@Schema(description = "community type")
|
@Schema(description = "community type")
|
||||||
protected String type;
|
protected CommunityType type;
|
||||||
|
|
||||||
@Schema(description = "community name")
|
@Schema(description = "community name")
|
||||||
protected String name;
|
protected String name;
|
||||||
|
@ -47,7 +47,7 @@ public class CommunitySummary {
|
||||||
public CommunitySummary(
|
public CommunitySummary(
|
||||||
final String id,
|
final String id,
|
||||||
final String queryId,
|
final String queryId,
|
||||||
final String type,
|
final CommunityType type,
|
||||||
final String name,
|
final String name,
|
||||||
final String shortName,
|
final String shortName,
|
||||||
final LocalDateTime creationDate,
|
final LocalDateTime creationDate,
|
||||||
|
@ -99,11 +99,11 @@ public class CommunitySummary {
|
||||||
this.queryId = queryId;
|
this.queryId = queryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public CommunityType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(final String type) {
|
public void setType(final CommunityType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue