throw new Exception("No predefined user functionalities found!!!");
}
Iterator it = userFunctionalitiesList.iterator();
while (it.hasNext()) {
SourceBean aUSerFunctionalitySB = (SourceBean) it.next();
SbiUserFunctionality aUserFunctionality = new SbiUserFunctionality();
String userFunctionality = (String) aUSerFunctionalitySB.getAttribute("name");
aUserFunctionality.setName(userFunctionality);
aUserFunctionality.setDescription((String) aUSerFunctionalitySB.getAttribute("description"));
Object roleTypesObject = roleTypeUserFunctionalitiesSB.getFilteredSourceBeanAttribute("ROLE_TYPE_USER_FUNCTIONALITY", "userFunctionality", userFunctionality);
if (roleTypesObject == null) {
throw new Exception("No role type found for user functionality [" + userFunctionality + "]!!!");
}
StringBuffer roleTypesStrBuffer = new StringBuffer();
Set roleTypes = new HashSet();
if (roleTypesObject instanceof SourceBean) {
SourceBean roleTypeSB = (SourceBean) roleTypesObject;
String roleTypeCd = (String) roleTypeSB.getAttribute("roleType");
roleTypesStrBuffer.append(roleTypeCd);
SbiDomains domainRoleType = findDomain(aSession, roleTypeCd, "ROLE_TYPE");
roleTypes.add(domainRoleType);
} else if (roleTypesObject instanceof List) {
List roleTypesSB = (List) roleTypesObject;
Iterator roleTypesIt = roleTypesSB.iterator();
while (roleTypesIt.hasNext()) {
SourceBean roleTypeSB = (SourceBean) roleTypesIt.next();
String roleTypeCd = (String) roleTypeSB.getAttribute("roleType");
roleTypesStrBuffer.append(roleTypeCd);
if (roleTypesIt.hasNext()) {
roleTypesStrBuffer.append(";");
}
SbiDomains domainRoleType = findDomain(aSession, roleTypeCd, "ROLE_TYPE");
roleTypes.add(domainRoleType);
}
}
aUserFunctionality.setRoleType(roleTypes);
logger.debug("Inserting UserFunctionality with name = [" + aUSerFunctionalitySB.getAttribute("name") + "] associated to role types [" + roleTypesStrBuffer.toString() + "]...");
aSession.save(aUserFunctionality);
}