use of fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme in project pyramus by otavanopisto.
the class ChangeStudentStudyProgrammeJSONRequestController method process.
public void process(JSONRequestContext requestContext) {
StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
StudyProgrammeDAO studyProgrammeDAO = DAOFactory.getInstance().getStudyProgrammeDAO();
StaffMember loggedUser = staffMemberDAO.findById(requestContext.getLoggedUserId());
Long studentId = requestContext.getLong("studentId");
Long studyProgrammeId = requestContext.getLong("studyProgrammeId");
Student student = studentDAO.findById(studentId);
StudyProgramme studyProgramme = studyProgrammeDAO.findById(studyProgrammeId);
if (!(UserUtils.canAccessOrganization(loggedUser, student.getOrganization()) && UserUtils.canAccessOrganization(loggedUser, studyProgramme.getOrganization()))) {
throw new SmvcRuntimeException(PyramusStatusCode.UNAUTHORIZED, "Invalid studyprogramme.");
}
Long oldStudyProgrammeId = student.getStudyProgramme() != null ? student.getStudyProgramme().getId() : null;
logger.info(String.format("Changing study programme for student %d from %d to %d.", studentId, oldStudyProgrammeId, studyProgrammeId));
KoskiClient client = CDI.current().select(KoskiClient.class).get();
try {
client.invalidateAllStudentOIDs(student);
} catch (Exception ex) {
logger.log(Level.SEVERE, String.format("Invalidation of study permits for student %d failed", studentId), ex);
}
studentDAO.updateStudyProgramme(student, studyProgramme);
}
use of fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme in project pyramus by otavanopisto.
the class StudyProgrammeCopyPopupViewController method process.
/**
* Processes the page request.
*/
public void process(PageRequestContext pageRequestContext) {
TransferCreditDAO transferCreditDAO = DAOFactory.getInstance().getTransferCreditDAO();
CourseAssessmentDAO courseAssessmentDAO = DAOFactory.getInstance().getCourseAssessmentDAO();
CreditLinkDAO creditLinkDAO = DAOFactory.getInstance().getCreditLinkDAO();
StudyProgrammeDAO studyProgrammeDAO = DAOFactory.getInstance().getStudyProgrammeDAO();
StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
Long studentId = pageRequestContext.getLong("student");
Student student = studentDAO.findById(studentId);
StaffMember loggedUser = staffMemberDAO.findById(pageRequestContext.getLoggedUserId());
List<StudyProgramme> studyProgrammes = UserUtils.canAccessAllOrganizations(loggedUser) ? studyProgrammeDAO.listUnarchived() : studyProgrammeDAO.listByOrganization(loggedUser.getOrganization(), Archived.UNARCHIVED);
Collections.sort(studyProgrammes, new StringAttributeComparator("getName"));
Long courseAssessmentCount = courseAssessmentDAO.countByStudent(student);
Long transferCreditCount = transferCreditDAO.countByStudent(student);
Long creditLinkCount = creditLinkDAO.countByStudent(student);
pageRequestContext.getRequest().setAttribute("courseAssessmentCount", courseAssessmentCount);
pageRequestContext.getRequest().setAttribute("transferCreditCount", transferCreditCount);
pageRequestContext.getRequest().setAttribute("creditLinkCount", creditLinkCount);
pageRequestContext.getRequest().setAttribute("studyProgrammes", studyProgrammes);
pageRequestContext.setIncludeJSP("/templates/students/studyprogrammecopypopup.jsp");
}
use of fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme in project pyramus by otavanopisto.
the class ChangeStudentStudyProgammeDialogViewController method process.
public void process(PageRequestContext requestContext) {
StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
StudyProgrammeDAO studyProgrammeDAO = DAOFactory.getInstance().getStudyProgrammeDAO();
StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
Long studentId = requestContext.getLong("studentId");
if (studentId == null) {
logger.log(Level.WARNING, "Unable to load dialog with missing studentId.");
try {
requestContext.getResponse().sendError(HttpServletResponse.SC_BAD_REQUEST);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error sending response", e);
}
return;
}
StaffMember loggedUser = staffMemberDAO.findById(requestContext.getLoggedUserId());
Student student = studentDAO.findById(studentId);
if (!UserUtils.canAccessOrganization(loggedUser, student.getOrganization())) {
try {
requestContext.getResponse().sendError(HttpServletResponse.SC_FORBIDDEN);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error sending response", e);
}
return;
}
List<StudyProgramme> studyProgrammes = UserUtils.canAccessAllOrganizations(loggedUser) ? studyProgrammeDAO.listUnarchived() : studyProgrammeDAO.listByOrganization(loggedUser.getOrganization(), Archived.UNARCHIVED);
Collections.sort(studyProgrammes, new StringAttributeComparator("getName"));
requestContext.getRequest().setAttribute("student", student);
requestContext.getRequest().setAttribute("studyProgrammes", studyProgrammes);
requestContext.setIncludeJSP("/templates/students/changestudentstudyprogrammedialog.jsp");
}
Aggregations