uga.setStatus(AjaxWidgetAnswer.STATUS_NOSERVICE);
return uga;
}
User user = Dispatcher.getInstance().getUser(userId);
// we have access carry on...
UsergroupBean userGroupBean = ugr.getUserGroup();
Collection<String> groupRelations = ugr.getGroupRelations();
uga.setUserGroup(userGroupBean);
Connection con = null;
try {
try {
//add default answer text, listboxtexts, guisettings, containers
addDefaultAnswer(user, ugr, uga);
con = DbHandler.getConnection();
con.setAutoCommit(false);
userGroupBean.setUpdatedby(userId);
userGroupBean.setTsupdated(new Timestamp(System
.currentTimeMillis()));
userGroupBean.store(con);
// userGroup groups
Collection<GrouprelationBean> col = GrouprelationFinder
.findByUsergroupid(con, userGroupBean.getId());
// loop exsisting groupRelations update or remove based on status
for (GrouprelationBean sBean : col) {
if (!groupRelations.contains(sBean.getRelatestoid())) {
sBean.remove(con);
groupRelations.remove(sBean.getRelatestoid());
} else {
groupRelations.remove(sBean.getRelatestoid());
}
}
// loop remaining groupRelations and create them
for (String ugId : groupRelations) {
GrouprelationBean sBean = new GrouprelationBean();
sBean.setCreatedby(userId);
sBean.setUsergroupid(userGroupBean.getId());
sBean.setRelatestoid(ugId);
sBean.setStatus(Integer.valueOf(1));
sBean.setTscreated(new Timestamp(System.currentTimeMillis()));
sBean.create(con);
}