private static Attends findAttend( final ExecutionCourse executionCourse, final String studentNumber, final List<DomainException> exceptionList) { final List<Attends> activeAttends = new ArrayList<Attends>(2); for (final Attends attend : executionCourse.getAttendsSet()) { final Student student = attend.getRegistration().getStudent(); if ((student.getPerson().getUsername().equals(studentNumber) || student.getNumber().toString().equals(studentNumber)) && (isActive(attend) || belongsToActiveExternalCycle(attend))) { activeAttends.add(attend); } } if (activeAttends.size() == 1) { return activeAttends.iterator().next(); } if (activeAttends.isEmpty()) { exceptionList.add( new DomainException("errors.student.without.active.attends", studentNumber)); } else { exceptionList.add( new DomainException("errors.student.with.several.active.attends", studentNumber)); } return null; }
@Override public HtmlComponent render(Object targetObject, Class type) { if (targetObject == null) { return super.render(null, type); } else { Student student = (Student) targetObject; return super.render(student.getNumber(), type); } }
private static boolean belongsToActiveExternalCycle(final Attends attend) { if (attend.hasEnrolment()) { final CycleCurriculumGroup cycle = attend.getEnrolment().getParentCycleCurriculumGroup(); if (cycle != null && cycle.isExternal()) { final Student student = attend.getRegistration().getStudent(); return student.getActiveRegistrationFor(cycle.getDegreeCurricularPlanOfDegreeModule()) != null; } } return false; }
private void setBestMatchingStudent() { Person personByFullDocumentId = null; Person personByPartialDocumentId = null; Collection<Person> fullDocumentIdPersonsCollection = readPersonsByCompleteDocumentId(); Collection<Person> partialDocumentIdPersonsCollection = readPersonsByPartialDocumentId(); if (fullDocumentIdPersonsCollection.size() > 1) { this.multiplePersonsFound = true; return; } if (fullDocumentIdPersonsCollection.size() == 1) { personByFullDocumentId = fullDocumentIdPersonsCollection.iterator().next(); } if (partialDocumentIdPersonsCollection.size() == 1) { personByPartialDocumentId = partialDocumentIdPersonsCollection.iterator().next(); } /* * We couldnt found the person with full and partial document id. Search * with with and check if the names are equals */ Student studentReadByNumber = this.studentNumber != null ? Student.readStudentByNumber(this.studentNumber) : null; Person personFoundByStudent = null; if (studentReadByNumber != null) { personFoundByStudent = studentReadByNumber.getPerson(); } if (personByFullDocumentId != null && personFoundByStudent != null && personByFullDocumentId != personFoundByStudent) { this.multiplePersonsFound = true; return; } else if (personByPartialDocumentId != null && personFoundByStudent != null && personByPartialDocumentId != personFoundByStudent) { this.multiplePersonsFound = true; return; } if (personByFullDocumentId != null) { this.person = personByFullDocumentId; this.student = this.person.getStudent(); } else if (personByPartialDocumentId != null) { this.person = personByPartialDocumentId; this.student = this.person.getStudent(); } else if (personFoundByStudent != null) { this.person = personFoundByStudent; this.student = this.person.getStudent(); } }
public static String createNewLine( final Person person, final CardGenerationBatch cardGenerationBatch) { final Student student = person.getStudent(); if (student != null && !student.getActiveRegistrations().isEmpty()) { final StudentCurricularPlan studentCurricularPlan = findStudentCurricularPlan(cardGenerationBatch, student); if (studentCurricularPlan != null) { final String line = CardGenerationEntry.createLine(studentCurricularPlan); return line; } } return null; }
public BigDecimal getNumberOfApprovedEctsOneYearAgo() { ExecutionYear oneYearAgo = getForExecutionYear().getPreviousExecutionYear(); BigDecimal result = BigDecimal.ZERO; if (student == null) { return BigDecimal.ZERO; } for (final Registration registration : student.getRegistrationsSet()) { if (registration.isBolonha() && registration.hasAnyEnrolmentsIn(oneYearAgo)) { result = result .add( calculateApprovedECTS( registration .getLastStudentCurricularPlan() .getAprovedEnrolmentsInExecutionPeriod( oneYearAgo.getFirstExecutionPeriod()))) .add( calculateApprovedECTS( registration .getLastStudentCurricularPlan() .getAprovedEnrolmentsInExecutionPeriod( oneYearAgo.getLastExecutionPeriod()))); } } return result; }
private Registration getActiveRegistration(Student student) { List<Registration> activeRegistrations = student.getActiveRegistrations(); if (activeRegistrations.isEmpty()) { return student.getLastRegistration(); } for (Registration registration : activeRegistrations) { if (registration.getDegree().getDegreeType().isEmpty()) { continue; } return registration; } return student.getLastRegistration(); }
private String getDegrees(final Person person) { final StringBuilder stringBuilder = new StringBuilder(); final Student student = person.getStudent(); if (student != null) { final Set<String> names = new TreeSet<String>(); for (final Registration registration : student.getRegistrationsSet()) { final Degree degree = registration.getDegree(); names.add(degree.getSigla()); } for (final String name : names) { if (stringBuilder.length() > 0) { stringBuilder.append(", "); } stringBuilder.append(name); } } return stringBuilder.toString(); }
@Atomic private CareerWorkshopApplication retrieveThisWorkshopApplication( Student student, CareerWorkshopApplicationEvent event) { for (CareerWorkshopApplication application : student.getCareerWorkshopApplicationsSet()) { if (application.getCareerWorkshopApplicationEvent() == event) { return application; } } return new CareerWorkshopApplication(student, event); }
@Override public Object convert(Class type, Object value) { try { IntegerNumberConverter converter = new IntegerNumberConverter(); Integer studentNumber = (Integer) converter.convert(type, value); return Student.readStudentByNumber(studentNumber); } catch (ConversionException e) { return null; } }
@Atomic private CareerWorkshopConfirmation retrieveThisWorskhopApplicationConfirmation( Student student, CareerWorkshopConfirmationEvent confirmationEvent, CareerWorkshopApplication application) { for (CareerWorkshopConfirmation confirmation : student.getCareerWorkshopConfirmationsSet()) { if (confirmation.getCareerWorkshopConfirmationEvent() == confirmationEvent) { return confirmation; } } return new CareerWorkshopConfirmation(student, confirmationEvent, application); }
@EntryPoint public ActionForward prepare( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { final Student student = getLoggedStudent(request); CareerWorkshopApplicationEvent openApplicationEvent = CareerWorkshopApplicationEvent.getActualEvent(); List<CareerWorkshopApplicationEvent> openApplicationEvents = new ArrayList<CareerWorkshopApplicationEvent>(); if (openApplicationEvent != null) { openApplicationEvents.add(openApplicationEvent); } List<CareerWorkshopConfirmationEvent> pendingForConfirmation = student.getApplicationsWaitingForConfirmation(); request.setAttribute("openApplicationEvents", openApplicationEvents); request.setAttribute("pendingForConfirmation", pendingForConfirmation); return actionMapping.findForward("careerWorkshop"); }
public boolean fillWithStudent(final ExecutionYear forExecutionYear, Student student) { this.forExecutionYear = forExecutionYear; try { this.institutionCode = getDefaultInstitutionCode(); this.institutionName = getDefaultInstitutionName(); this.candidacyNumber = ""; this.studentNumber = student.getNumber(); this.studentName = student.getPerson().getName(); this.documentTypeName = student.getPerson().getIdDocumentType().getLocalizedName(); this.documentNumber = student.getPerson().getDocumentIdNumber(); Registration activeRegistration = getActiveRegistration(student); this.degreeCode = activeRegistration.getDegree().getMinistryCode(); if ("9999".equals(this.degreeCode)) { this.degreeCode = ""; } this.degreeName = activeRegistration.getDegree().getNameI18N().getContent(); this.degreeTypeName = activeRegistration.getDegree().getDegreeTypeName(); this.upperObservations = ""; this.person = student.getPerson(); this.student = student; enrolledInAnualCoursesLastYear = false; } catch (Exception e) { logger.error(e.getMessage(), e); return false; } return true; }
public BigDecimal getNumberOfEnrolledEctsOneYearAgo() { ExecutionYear oneYearAgo = getForExecutionYear().getPreviousExecutionYear(); BigDecimal result = BigDecimal.ZERO; if (student == null) { return BigDecimal.ZERO; } for (final Registration registration : student.getRegistrationsSet()) { if (registration.isBolonha() && registration.hasAnyEnrolmentsIn(oneYearAgo)) { result = result.add(new BigDecimal(getEnrolmentsEctsCredits(registration, oneYearAgo))); } } return result; }
public static Collection<ExecutionYear> getEnrolmentsExecutionYears(final Student student) { Set<ExecutionYear> executionYears = new HashSet<ExecutionYear>(); for (final Registration registration : student.getRegistrationsSet()) { if (RegistrationStateType.CANCELED.equals(registration.getLastActiveState())) { continue; } if (RegistrationStateType.TRANSITION.equals(registration.getLastActiveState())) { continue; } executionYears.addAll(registration.getEnrolmentsExecutionYears()); } return executionYears; }
public Integer getCountNumberOfDegreeChanges() { int numberOfDegreeChanges = 0; if (student == null) { return 0; } List<Registration> registrations = new ArrayList<Registration>(student.getRegistrationsSet()); Collections.sort(registrations, Registration.COMPARATOR_BY_START_DATE); for (final Registration iter : registrations) { final SortedSet<RegistrationState> states = new TreeSet<RegistrationState>(RegistrationState.DATE_COMPARATOR); states.addAll(iter.getRegistrationStates(RegistrationStateType.INTERNAL_ABANDON)); if (!states.isEmpty()) { numberOfDegreeChanges++; } } return numberOfDegreeChanges; }
public Integer getCurricularYearInCurrentYear() { ExecutionYear currentYear = getForExecutionYear(); if (student == null) { return 0; } Registration lastRegistration = student.getLastActiveRegistration(); if (lastRegistration == null) { return null; } if (lastRegistration.getDegreeType().equals(DegreeType.BOLONHA_DEGREE)) { return lastRegistration .getCurriculum(new DateTime(), currentYear, CycleType.FIRST_CYCLE) .getCurricularYear(); } else if (lastRegistration .getDegreeType() .equals(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE)) { if (lastRegistration.hasConcludedFirstCycle()) { return lastRegistration.getCurricularYear(currentYear); } else { if (lastRegistration.getLastStudentCurricularPlan().getCycle(CycleType.FIRST_CYCLE) != null) { return lastRegistration .getCurriculum(new DateTime(), currentYear, CycleType.FIRST_CYCLE) .getCurricularYear(); } else { return lastRegistration .getCurriculum(new DateTime(), currentYear, CycleType.SECOND_CYCLE) .getCurricularYear(); } } } else if (lastRegistration.getDegreeType().equals(DegreeType.BOLONHA_MASTER_DEGREE)) { return lastRegistration.getCurricularYear(currentYear); } return lastRegistration.getCurricularYear(currentYear); }
private Registration findRegistration(final Student student) { return student.getLastRegistration(); }
@SuppressWarnings("unchecked") private ByteArrayOutputStream createAcademicAdminProcessSheet(Person person) throws JRException { InputStream istream = getClass().getResourceAsStream(ACADEMIC_ADMIN_SHEET_REPORT_PATH); JasperReport report = (JasperReport) JRLoader.loadObject(istream); @SuppressWarnings("rawtypes") HashMap map = new HashMap(); try { final Student student = person.getStudent(); final Registration registration = findRegistration(student); map.put("executionYear", ExecutionYear.readCurrentExecutionYear().getYear()); if (registration != null) { map.put("course", registration.getDegree().getNameI18N().toString()); } map.put("studentNumber", student.getNumber().toString()); map.put("fullName", person.getName()); try { map.put( "photo", new ByteArrayInputStream(person.getPersonalPhotoEvenIfPending().getDefaultAvatar())); } catch (Exception e) { // nothing; print everything else } map.put( "sex", BundleUtil.getStringFromResourceBundle( "resources/EnumerationResources", person.getGender().name())); map.put("maritalStatus", person.getMaritalStatus().getPresentationName()); map.put("profession", person.getProfession()); map.put("idDocType", person.getIdDocumentType().getLocalizedName()); map.put("idDocNumber", person.getDocumentIdNumber()); YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay(); if (emissionDate != null) { map.put( "idDocEmissionDate", emissionDate.toString(DateTimeFormat.forPattern("dd/MM/yyyy"))); } map.put( "idDocExpirationDate", person .getExpirationDateOfDocumentIdYearMonthDay() .toString(DateTimeFormat.forPattern("dd/MM/yyyy"))); map.put("idDocEmissionLocation", person.getEmissionLocationOfDocumentId()); String nif = person.getSocialSecurityNumber(); if (nif != null) { map.put("NIF", nif); } map.put( "birthDate", person.getDateOfBirthYearMonthDay().toString(DateTimeFormat.forPattern("dd/MM/yyyy"))); map.put("nationality", person.getCountryOfBirth().getCountryNationality().toString()); map.put("parishOfBirth", person.getParishOfBirth()); map.put("districtSubdivisionOfBirth", person.getDistrictSubdivisionOfBirth()); map.put("districtOfBirth", person.getDistrictOfBirth()); map.put("countryOfBirth", person.getCountryOfBirth().getName()); map.put("fathersName", person.getNameOfFather()); map.put("mothersName", person.getNameOfMother()); map.put("address", person.getAddress()); map.put("postalCode", person.getPostalCode()); map.put("locality", person.getAreaOfAreaCode()); map.put("cellphoneNumber", person.getDefaultMobilePhoneNumber()); map.put("telephoneNumber", person.getDefaultPhoneNumber()); map.put("emailAddress", getMail(person)); map.put( "currentDate", new java.text.SimpleDateFormat( "'Lisboa, 'dd' de 'MMMM' de 'yyyy", new java.util.Locale("PT", "pt")) .format(new java.util.Date())); } catch (NullPointerException e) { // nothing; will cause printing of incomplete form // better than no form at all } JasperPrint print = JasperFillManager.fillReport(report, map); ByteArrayOutputStream output = new ByteArrayOutputStream(); JasperExportManager.exportReportToPdfStream(print, output); return output; }
public static StyledExcelSpreadsheet exportElectionsResultsToFile( List<Degree> degrees, ExecutionYear executionYear) throws IOException { StyledExcelSpreadsheet spreadsheet = new StyledExcelSpreadsheet(); final ResourceBundle BUNDLE = ResourceBundle.getBundle( "resources.PedagogicalCouncilResources", Language.getDefaultLocale()); for (Degree degree : degrees) { spreadsheet.getSheet(degree.getSigla()); List<YearDelegateElection> elections = sortByYear(degree.getYearDelegateElectionsGivenExecutionYear(executionYear)); for (YearDelegateElection election : elections) { if (election.hasLastVotingPeriod()) { DelegateElectionVotingPeriod votingPeriod = election.getLastVotingPeriod(); spreadsheet.newHeaderRow(); int fistHeaderRow = spreadsheet.getRow().getRowNum(); spreadsheet.addHeader( String.format( "%s - %s (%s)", BUNDLE.getString("label.elections.excel.curricularYear"), election.getCurricularYear().getYear(), votingPeriod.getPeriod()), 10000); spreadsheet .getSheet() .addMergedRegion(new Region(fistHeaderRow, (short) 0, fistHeaderRow, (short) 5)); spreadsheet.newRow(); if (votingPeriod.getVotesCount() == 0) { spreadsheet.addCell(BUNDLE.getString("label.elections.excel.not.have.votes")); } else { spreadsheet.addHeader(BUNDLE.getString("label.elections.excel.studentNumber"), 6000); spreadsheet.addHeader(BUNDLE.getString("label.elections.excel.studentName"), 10000); spreadsheet.addHeader(BUNDLE.getString("label.phone"), 4000); spreadsheet.addHeader(BUNDLE.getString("label.email"), 6000); spreadsheet.addHeader(BUNDLE.getString("label.address"), 12000); spreadsheet.addHeader(BUNDLE.getString("label.elections.excel.nrTotalVotes"), 5000); List<DelegateElectionResultsByStudentDTO> resultsByStudent = sortByResults(votingPeriod.getDelegateElectionResults()); for (DelegateElectionResultsByStudentDTO resultByStudent : resultsByStudent) { Student student = resultByStudent.getStudent(); Person person = student.getPerson(); String phone = (StringUtils.isEmpty(person.getDefaultPhoneNumber())) ? "-" : person.getDefaultPhoneNumber(); String email = (StringUtils.isEmpty(person.getDefaultEmailAddressValue())) ? "-" : person.getDefaultEmailAddressValue(); String address = (StringUtils.isEmpty(person.getAddress())) ? "-" : person.getAddress(); spreadsheet.newRow(); spreadsheet.addCell(student.getNumber()); spreadsheet.addCell(student.getName()); spreadsheet.addCell(phone); spreadsheet.addCell(email); spreadsheet.addCell(address); spreadsheet.addCell(resultByStudent.getVotesNumber()); } spreadsheet.setRegionBorder(fistHeaderRow, spreadsheet.getRow().getRowNum() + 1, 0, 2); spreadsheet.newRow(); spreadsheet.newRow(); spreadsheet.addCell(BUNDLE.getString("label.elections.excel.nrBlankTotalVotes")); spreadsheet.addCell( votingPeriod.getBlankVotesElection(), spreadsheet.getExcelStyle().getValueStyle()); } } spreadsheet.newRow(); spreadsheet.newRow(); } } return spreadsheet; }