public void createSelfCommunity(PersonPojo person)
{
try
{
//create community
CommunityPojo selfCommunity = new CommunityPojo();
selfCommunity.setId(person.get_id()); //set to same as users
selfCommunity.setName(person.getDisplayName() + "'s Personal Community");
selfCommunity.setDescription(person.getDisplayName() + "'s Personal Community");
selfCommunity.setCreated(new Date());
selfCommunity.setModified(new Date());
selfCommunity.setIsPersonalCommunity(true);
Map<String,CommunityAttributePojo> commAttributes = new HashMap<String,CommunityAttributePojo>();
commAttributes.put("isPublic", new CommunityAttributePojo("boolean","false") );
commAttributes.put("usersCanSelfRegister", new CommunityAttributePojo("boolean","false") );
commAttributes.put("registrationRequiresApproval", new CommunityAttributePojo("boolean","false") );
commAttributes.put("usersCanCreateSubCommunities", new CommunityAttributePojo("boolean","false") );
selfCommunity.setCommunityAttributes(commAttributes);
Map<String,CommunityUserAttributePojo> commUserAttributes = new HashMap<String,CommunityUserAttributePojo>();
commUserAttributes.put("publishLoginToActivityFeed", new CommunityUserAttributePojo("boolean","true",true));
commUserAttributes.put("publishCommentsToActivityFeed", new CommunityUserAttributePojo("boolean","true",true));
commUserAttributes.put("publishSharingToActivityFeed", new CommunityUserAttributePojo("boolean","true",true));
commUserAttributes.put("publishQueriesToActivityFeed", new CommunityUserAttributePojo("boolean","true",true));
commUserAttributes.put("publishCommentsPublicly", new CommunityUserAttributePojo("boolean","false",true));
selfCommunity.setCommunityUserAttribute(commUserAttributes);
selfCommunity.setNumberOfMembers(0);
// Create the index form of the community:
try {
GenericProcessingController.createCommunityDocIndex(selfCommunity.getId().toString(), null, true, false, false);
//TESTED
}
catch (Exception e) {} // Do nothing, will have to update the user to stop bad things from happening on query though
//write community to db
DbManager.getSocial().getCommunity().insert(selfCommunity.toDb());
//update user to be in this community
PersonCommunityPojo pcpSelf = new PersonCommunityPojo(person.get_id(), selfCommunity.getName());
person.getCommunities().add(pcpSelf);
/////////////////////////////////////////////////////////////////////////////////////////////////
// TODO (INF-1214): Make this code more robust to handle changes to the community that need to
// Caleb: this means change update to $set
/////////////////////////////////////////////////////////////////////////////////////////////////