new_model_for_communities #15
|
@ -29,10 +29,10 @@ import eu.dnetlib.openaire.community.db.CommunityService;
|
|||
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
||||
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.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.SubCommunity;
|
||||
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
||||
|
@ -73,6 +73,7 @@ public class CommunityImporterController {
|
|||
private final static String CPROFILE_FOS = "fos";
|
||||
private final static String CPROFILE_SDG = "sdg";
|
||||
private final static String CPROFILE_ADVANCED_CONSTRAINT = "advancedConstraints";
|
||||
private final static String CPROFILE_REMOVE_CONSTRAINT = "removeConstraints";
|
||||
|
||||
// community project
|
||||
private final static String CPROJECT_FUNDER = "funder";
|
||||
|
@ -145,7 +146,7 @@ public class CommunityImporterController {
|
|||
private void importCommunity(final Context context) {
|
||||
try {
|
||||
|
||||
final CommunityDetails community = asCommunityProfile(context);
|
||||
final CommunityDetails community = asCommunityDetails(context);
|
||||
|
||||
final List<CommunityContentprovider> datasources =
|
||||
getCommunityInfo(context, CONTENTPROVIDERS_ID_SUFFIX, c -> asCommunityDataprovider(context.getId(), c));
|
||||
|
@ -156,12 +157,18 @@ public class CommunityImporterController {
|
|||
final List<CommunityOrganization> orgs =
|
||||
getCommunityInfo(context, ORGANIZATION_ID_SUFFIX, c -> asCommunityOrganization(context.getId(), c));
|
||||
|
||||
final List<String> otherZenodoCimmunities =
|
||||
getCommunityInfo(context, ZENODOCOMMUNITY_ID_SUFFIX, c -> asZenodoCommunity(c));
|
||||
|
||||
community.setOtherZenodoCommunities(otherZenodoCimmunities);
|
||||
|
||||
final List<SubCommunity> subs = context.getCategories()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(e -> !e.getKey().equals(context.getId() + CONTENTPROVIDERS_ID_SUFFIX))
|
||||
.filter(e -> !e.getKey().equals(context.getId() + PROJECTS_ID_SUFFIX))
|
||||
.filter(e -> !e.getKey().equals(context.getId() + ORGANIZATION_ID_SUFFIX))
|
||||
.filter(e -> !e.getKey().equals(context.getId() + ZENODOCOMMUNITY_ID_SUFFIX))
|
||||
.map(e -> e.getValue())
|
||||
.map(cat -> asSubCommunities(context.getId(), null, cat.getLabel(), cat.getConcepts()))
|
||||
.flatMap(List::stream)
|
||||
|
@ -177,74 +184,64 @@ public class CommunityImporterController {
|
|||
}
|
||||
}
|
||||
|
||||
private static CommunitySummary asCommunitySummary(final Context c) {
|
||||
final CommunitySummary summary = new CommunitySummary();
|
||||
private static CommunityDetails asCommunityDetails(final Context c) {
|
||||
|
||||
summary.setId(c.getId());
|
||||
summary.setShortName(c.getLabel());
|
||||
summary.setLastUpdateDate(convertToLocalDateTime(c.getLastUpdateDate()));
|
||||
summary.setCreationDate(convertToLocalDateTime(c.getCreationDate()));
|
||||
summary.setQueryId(c.getId() + PIPE_SEPARATOR + c.getLabel());
|
||||
summary.setType(CommunityType.valueOf(c.getType()));
|
||||
final CommunityDetails details = new CommunityDetails();
|
||||
|
||||
details.setId(c.getId());
|
||||
details.setShortName(c.getLabel());
|
||||
details.setLastUpdateDate(convertToLocalDateTime(c.getLastUpdateDate()));
|
||||
details.setCreationDate(convertToLocalDateTime(c.getCreationDate()));
|
||||
details.setQueryId(c.getId() + PIPE_SEPARATOR + c.getLabel());
|
||||
details.setType(CommunityType.valueOf(c.getType()));
|
||||
details.setMembership(CommunityMembershipType.open);
|
||||
// TODO: Considerare anche i campi claim
|
||||
|
||||
final Map<String, List<Param>> params = c.getParams();
|
||||
if (params.containsKey(CSUMMARY_DESCRIPTION)) {
|
||||
summary.setDescription(asCsv(params.get(CSUMMARY_DESCRIPTION)));
|
||||
details.setDescription(asCsv(params.get(CSUMMARY_DESCRIPTION)));
|
||||
}
|
||||
if (params.containsKey(CSUMMARY_LOGOURL)) {
|
||||
summary.setLogoUrl(asCsv(params.get(CSUMMARY_LOGOURL)));
|
||||
details.setLogoUrl(asCsv(params.get(CSUMMARY_LOGOURL)));
|
||||
}
|
||||
if (params.containsKey(CSUMMARY_STATUS)) {
|
||||
summary.setStatus(CommunityStatus.valueOf(firstValue(params, CSUMMARY_STATUS)));
|
||||
details.setStatus(CommunityStatus.valueOf(firstValue(params, CSUMMARY_STATUS)));
|
||||
}
|
||||
if (params.containsKey(CSUMMARY_NAME)) {
|
||||
summary.setName(asCsv(params.get(CSUMMARY_NAME)));
|
||||
details.setName(asCsv(params.get(CSUMMARY_NAME)));
|
||||
} else {
|
||||
summary.setName(c.getLabel());
|
||||
details.setName(c.getLabel());
|
||||
}
|
||||
|
||||
// TODO: gestire meglio le zenodo communities (main + other)
|
||||
if (params.containsKey(CSUMMARY_ZENODOC)) {
|
||||
summary.setZenodoCommunity(asCsv(params.get(CSUMMARY_ZENODOC)));
|
||||
details.setZenodoCommunity(asCsv(params.get(CSUMMARY_ZENODOC)));
|
||||
}
|
||||
|
||||
// TODO: Considerare anche i campi membership e claim
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
private static CommunityDetails asCommunityProfile(final Context c) {
|
||||
|
||||
final CommunityDetails p = new CommunityDetails(asCommunitySummary(c));
|
||||
p.setLastUpdateDate(convertToLocalDateTime(c.getLastUpdateDate()));
|
||||
final Map<String, List<Param>> params = c.getParams();
|
||||
if (params.containsKey(CPROFILE_SUBJECT)) {
|
||||
p.setSubjects(splitValues(asValues(params.get(CPROFILE_SUBJECT)), CSV_DELIMITER));
|
||||
details.setSubjects(splitValues(asValues(params.get(CPROFILE_SUBJECT)), CSV_DELIMITER));
|
||||
}
|
||||
if (params.containsKey(CPROFILE_FOS)) {
|
||||
p.setFos(splitValues(asValues(params.get(CPROFILE_FOS)), CSV_DELIMITER));
|
||||
details.setFos(splitValues(asValues(params.get(CPROFILE_FOS)), CSV_DELIMITER));
|
||||
}
|
||||
if (params.containsKey(CPROFILE_SDG)) {
|
||||
p.setSdg(splitValues(asValues(params.get(CPROFILE_SDG)), CSV_DELIMITER));
|
||||
details.setSdg(splitValues(asValues(params.get(CPROFILE_SDG)), CSV_DELIMITER));
|
||||
}
|
||||
if (params.containsKey(CPROFILE_ADVANCED_CONSTRAINT)) {
|
||||
// In the map the string is the serialization of the json representing the selection criteria so it is a valid json
|
||||
p.setAdvancedConstraints(SelectionCriteria.fromJson(asCsv(params.get(CPROFILE_ADVANCED_CONSTRAINT))));
|
||||
|
||||
details.setAdvancedConstraints(SelectionCriteria.fromJson(asCsv(params.get(CPROFILE_ADVANCED_CONSTRAINT))));
|
||||
}
|
||||
if (params.containsKey(CPROFILE_REMOVE_CONSTRAINT)) {
|
||||
// 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(params.get(CPROFILE_REMOVE_CONSTRAINT))));
|
||||
}
|
||||
|
||||
// TODO Vanno considerati anche i REMOVE_CONSTRAINTS ?
|
||||
|
||||
if (params.containsKey(CPROFILE_CREATIONDATE)) {
|
||||
try {
|
||||
final Date d = org.apache.commons.lang3.time.DateUtils.parseDate(asCsv(params.get(CPROFILE_CREATIONDATE)), pattern);
|
||||
p.setCreationDate(convertToLocalDateTime(d));
|
||||
details.setCreationDate(convertToLocalDateTime(d));
|
||||
} catch (final Exception e) {
|
||||
log.debug("Exception on date format: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
return details;
|
||||
}
|
||||
|
||||
private static CommunityProject asCommunityProject(final String communityId, final Concept c) {
|
||||
|
@ -281,6 +278,10 @@ public class CommunityImporterController {
|
|||
return o;
|
||||
}
|
||||
|
||||
private static String asZenodoCommunity(final Concept c) {
|
||||
return firstValue(c.getParams(), CZENODOCOMMUNITY_ID);
|
||||
}
|
||||
|
||||
private static List<SubCommunity> asSubCommunities(final String communityId, final String parent, final String category, final List<Concept> concepts) {
|
||||
final List<SubCommunity> list = new ArrayList<>();
|
||||
for (final Concept c : concepts) {
|
||||
|
|
|
@ -49,7 +49,8 @@ public class CommunityService {
|
|||
// 1) Import tramite profili:
|
||||
// 1.1) Completare CommunityImporterController
|
||||
// 2) Subcommunities: visualizzazione tramite le context api
|
||||
// 3) Come ritornare i campi delle community_orgs ?
|
||||
// 3) Come ritornare i campi delle community_orgs ? // Creare un metodo nuovo i valori devono arrivare dal wf di provision, esempio:
|
||||
// https://services.openaire.eu/is/mvc/ui/isManager.do#/profile/4801c33c-66ca-4ab6-af64-aa812194ec61_V29ya2Zsb3dEU1Jlc291cmNlcy9Xb3JrZmxvd0RTUmVzb3VyY2VUeXBl
|
||||
// 4) Verificare Tickets: #8835, #8854, #6483, #3259, #3494
|
||||
|
||||
@Autowired
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue