Iterator<Element> it = elements.iterator();
//ModuleGroupsLocal moduleGroupsManagement = (ModuleGroupsLocal) context.lookup("ModuleGroupsBean/local");
while (it.hasNext()) {
Element elGroup = it.next();
ModuleGroup group = new ModuleGroup();
group.setId(elGroup.getAttribute("id").getLongValue());
group.setName(elGroup.getAttribute("name").getValue());
//If the group doesn't exist then create it
ModuleGroup existingGroup = moduleGroupsManagement.find(group.getId());
if (existingGroup==null) {
logger.debug("Creating group "+group.getName());
group.setOwner(user);
group.setGroup(user.getMainGroup());
moduleGroupsManagement.createDataset(group);