subcommunities
This commit is contained in:
parent
de36ad03e6
commit
b509e13560
|
@ -156,15 +156,22 @@ public class CommunityImporterController {
|
|||
final List<CommunityOrganization> orgs =
|
||||
getCommunityInfo(context, ORGANIZATION_ID_SUFFIX, c -> asCommunityOrganization(context.getId(), c));
|
||||
|
||||
final List<SubCommunity> subs = new ArrayList<>();
|
||||
// TODO populate the subs using all the other categories (ie: not projects, organizations and contentproviders)
|
||||
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))
|
||||
.map(e -> e.getValue())
|
||||
.map(cat -> asSubCommunities(context.getId(), null, cat.getLabel(), cat.getConcepts()))
|
||||
.flatMap(List::stream)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
service.saveCommunity(community);
|
||||
service.addCommunityProjectList(context.getId(), projects);
|
||||
service.addCommunityContentProvidersList(context.getId(), datasources);
|
||||
service.addCommunityOrganizationList(context.getId(), orgs);
|
||||
service.addSubCommunityList(subs);
|
||||
// TODO MANAGE new fields and tables
|
||||
} catch (final Exception e) {
|
||||
throw new RuntimeException("Error importing community: " + context.getId(), e);
|
||||
}
|
||||
|
@ -274,8 +281,9 @@ public class CommunityImporterController {
|
|||
return o;
|
||||
}
|
||||
|
||||
// TODO
|
||||
private static List<SubCommunity> asSubCommunities(final String communityId, final String parent, final String category, final Concept c) {
|
||||
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) {
|
||||
final SubCommunity sc = new SubCommunity();
|
||||
sc.setSubCommunityId(c.getId());
|
||||
sc.setCommunityId(communityId);
|
||||
|
@ -283,10 +291,9 @@ public class CommunityImporterController {
|
|||
sc.setCategory(category);
|
||||
sc.setLabel(c.getLabel());
|
||||
sc.setParams(c.getParams());
|
||||
|
||||
final List<SubCommunity> list = new ArrayList<>();
|
||||
list.add(sc);
|
||||
c.getConcepts().forEach(child -> list.addAll(asSubCommunities(communityId, c.getId(), category, child)));
|
||||
list.addAll(asSubCommunities(communityId, c.getId(), category, c.getConcepts()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ public class CommunityService {
|
|||
// TODO
|
||||
// 1) Import tramite profili:
|
||||
// 1.1) Completare CommunityImporterController
|
||||
// 1.2) Considerare anche le Subcommunities: importazione tramite profili
|
||||
// 2) Subcommunities: visualizzazione tramite le context api
|
||||
// 3) Come ritornare i campi delle community_orgs ?
|
||||
// 4) Verificare Tickets: #8835, #8854, #6483, #3259, #3494
|
||||
|
|
Loading…
Reference in New Issue