deviationManager = (DeviationManager) ModelUtil
.getBean("deviationManager");
final ApplicationUserManager applicationUserManager = (ApplicationUserManager) ModelUtil
.getBean("applicationUserManager");
ApplicationUser user;
user = applicationUserManager.login("avviktransport", "avviktransport");
applicationUserManager.lazyLoad(user, new LazyLoadEnum[][] { {
LazyLoadEnum.USER_ROLES, LazyLoadEnum.NONE } });
JobFunctionManager jobFunctionManager = (JobFunctionManager) ModelUtil
.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());
final PreventiveActionManager preventiveActionManager = (PreventiveActionManager) ModelUtil
.getBean(PreventiveActionManager.MANAGER_NAME);
final DeviationManager deviationManager = (DeviationManager) ModelUtil