.getBean("jobFunctionManager");
if (user == null) {
UserTypeManager userTypeManager = (UserTypeManager) ModelUtil
.getBean("userTypeManager");
JobFunction jobFunction = new JobFunction();
jobFunction.setJobFunctionName("Transport");
List<JobFunction> jobFunctions = jobFunctionManager
.findByObject(jobFunction);
jobFunction = jobFunctions.get(0);
user = new ApplicationUser(null, "avviktransport",
"avviktransport", "avviktransport", "avviktransport", null,
"Nei", jobFunction, productArea, null);
applicationUserManager.saveObject(user);
UserType userType = new UserType();
userType.setDescription("Avvik");
List<UserType> userTypes = userTypeManager.findByObject(userType);
userType = userTypes.get(0);
Set<UserRole> userRoles = new HashSet<UserRole>();
UserRole userRole = new UserRole(null, userType, user);
userRoles.add(userRole);
user.setUserRoles(userRoles);
applicationUserManager.saveObject(user);
}
JobFunction jobFunction = user.getJobFunction();
if (!jobFunction.getManager().equals(user)) {
jobFunction.setManager(user);
jobFunctionManager.saveObject(jobFunction);
}
Login login = new LoginImpl(user, user.getUserRoles().iterator().next()
.getUserType());