*
* @throws EMFUserError
*/
private void importRoles() throws EMFUserError {
logger.debug("IN");
SbiExtRoles role = null;
try {
List exportedRoles = importer.getAllExportedSbiObjects(sessionExpDB, "SbiExtRoles", null);
Iterator iterSbiRoles = exportedRoles.iterator();
while (iterSbiRoles.hasNext()) {
role = (SbiExtRoles) iterSbiRoles.next();
Integer oldId = role.getExtRoleId();
Map roleIdAss = metaAss.getRoleIDAssociation();
Set roleIdAssSet = roleIdAss.keySet();
if (roleIdAssSet.contains(oldId)) {
metaLog.log("Exported role " + role.getName() + " not inserted"
+ " because it has been associated to an existing role or it has the same name "
+ " of an existing role");
continue;
}
SbiExtRoles newRole = ImportUtilities.makeNewSbiExtRole(role);
String roleCd = role.getRoleTypeCode();
Map unique = new HashMap();
unique.put("valuecd", roleCd);
unique.put("domaincd", "ROLE_TYPE");
SbiDomains existDom = (SbiDomains) importer.checkExistence(unique, sessionCurrDB, new SbiDomains());
if (existDom != null) {
newRole.setRoleType(existDom);
newRole.setRoleTypeCode(existDom.getValueCd());
}
sessionCurrDB.save(newRole);
metaLog.log("Inserted new role " + newRole.getName());
Integer newId = newRole.getExtRoleId();
metaAss.insertCoupleRole(oldId, newId);
}
} catch (Exception e) {
if (role != null) {
logger.error("Error while importing exported role with name [" + role.getName() + "].", e);