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