public ResponsePojo updateLastSetup(String profileID, String communityIdStrList, String query, String openModules)
{
ResponsePojo rp = new ResponsePojo();
try
{
UISetupPojo up = new UISetupPojo();
List<WidgetPojo> modulesList = new ArrayList<WidgetPojo>();
if ( !openModules.equals("null"))
{
String[] modules = openModules.split("]");
for ( String s : modules )
{
String[] name = s.split(",");
WidgetPojo wp = new WidgetPojo();
wp.setWidgetTitle(name[0]);
wp.setWidgetUrl(name[1]);
wp.setWidgetDisplay(name[2]);
wp.setWidgetImageUrl(name[3]);
wp.setWidgetX(name[4]);
wp.setWidgetY(name[5]);
wp.setWidgetWidth(name[6]);
wp.setWidgetHeight(name[7]);
if ( !name[8].equals("null") )
wp.setWidgetOptions(s.substring(s.indexOf(name[6] + "," + name[7]) + name[6].length() + name[7].length() + 2));
modulesList.add(wp);
}
}
UISetupPojo querySetup = new UISetupPojo();
querySetup.setProfileID(new ObjectId(profileID));
DBObject dbo = DbManager.getSocial().getUISetup().findOne(querySetup.toDb());
if ( dbo == null )
{
//add new entry
up.setProfileID(querySetup.getProfileID());
up.addWidgets(modulesList);
up.setQueryString(query);
up.setCommunityIds(communityIdStrList);
DbManager.getSocial().getUISetup().insert(up.toDb());
}
else
{
//update old entry
up = UISetupPojo.fromDb(dbo, UISetupPojo.class);
up.addWidgets(modulesList);
up.setQueryString(query);
up.setCommunityIds(communityIdStrList);
DbManager.getSocial().getUISetup().update(querySetup.toDb(), up.toDb());
}
rp.setResponse(new ResponseObject("Update UISetup",true,"modules updated successfully"));
}
catch (Exception ex)
{