use of fi.otavanopisto.pyramus.domainmodel.base.Defaults in project pyramus by otavanopisto.
the class CourseStudentAPI method create.
public Long create(Long courseId, Long studentId) throws InvalidScriptException {
CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
Defaults defaults = DAOFactory.getInstance().getDefaultsDAO().getDefaults();
Course course = courseDAO.findById(courseId);
if (course == null) {
throw new InvalidScriptException("Course #" + courseId + " not found.");
}
Student student = studentDAO.findById(studentId);
if (student == null) {
throw new InvalidScriptException("Student #" + studentId + " not found.");
}
Room room = null;
BigDecimal lodgingFee = null;
Currency lodgingFeeCurrency = null;
BigDecimal reservationFee = null;
Currency reservationFeeCurrency = null;
String organization = null;
String additionalInfo = null;
try {
return courseStudentDAO.create(course, student, defaults.getInitialCourseEnrolmentType(), defaults.getInitialCourseParticipationType(), new Date(), false, CourseOptionality.OPTIONAL, null, organization, additionalInfo, room, lodgingFee, lodgingFeeCurrency, reservationFee, reservationFeeCurrency, Boolean.FALSE).getId();
} catch (DuplicateCourseStudentException dcse) {
throw new InvalidScriptException("Student #" + studentId + " has an already existing coursestudent.");
}
}
use of fi.otavanopisto.pyramus.domainmodel.base.Defaults in project pyramus by otavanopisto.
the class UserUtils method hasManagementOrganizationAccess.
public static boolean hasManagementOrganizationAccess(User user) {
if (user == null) {
return false;
}
if (user.getRole() == Role.ADMINISTRATOR) {
return true;
} else {
DefaultsDAO defaultsDAO = DAOFactory.getInstance().getDefaultsDAO();
Defaults defaults = defaultsDAO.getDefaults();
Long managementOrganizationId = defaults.getOrganization() != null ? defaults.getOrganization().getId() : null;
Long userOrganizationId = (user != null && user.getOrganization() != null) ? user.getOrganization().getId() : null;
if (managementOrganizationId != null && Objects.equals(userOrganizationId, managementOrganizationId)) {
return true;
}
}
return false;
}
use of fi.otavanopisto.pyramus.domainmodel.base.Defaults in project pyramus by otavanopisto.
the class AdminPasswordSetupWizardViewController method save.
@Override
public void save(PageRequestContext requestContext) throws SetupWizardException {
String username = requestContext.getString("username");
String password = requestContext.getString("password1");
String firstName = requestContext.getString("firstName");
String lastName = requestContext.getString("lastName");
String passwordMD5 = DigestUtils.md5Hex(password);
StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
InternalAuthDAO internalAuthDAO = DAOFactory.getInstance().getInternalAuthDAO();
PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
UserIdentificationDAO userIdentificationDAO = DAOFactory.getInstance().getUserIdentificationDAO();
DefaultsDAO defaultsDAO = DAOFactory.getInstance().getDefaultsDAO();
Defaults defaults = defaultsDAO.getDefaults();
InternalAuth internalAuth = internalAuthDAO.create(username, passwordMD5);
Person person = personDAO.create(null, null, null, null, Boolean.FALSE);
userIdentificationDAO.create(person, "internal", String.valueOf(internalAuth.getId()));
User user = userDAO.create(defaults.getOrganization(), firstName, lastName, Role.ADMINISTRATOR, person, false);
personDAO.updateDefaultUser(person, user);
}
Aggregations