public ActionForward fillCandidacyInformation( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { final IndividualCandidacyProcessBean bean = getIndividualCandidacyProcessBean(); request.setAttribute(getIndividualCandidacyProcessBeanName(), bean); if (!StringUtils.isEmpty(bean.getPersonBean().getSocialSecurityNumber())) { Party existingSocialSecurityNumberParty = Person.readByContributorNumber(bean.getPersonBean().getSocialSecurityNumber()); if (existingSocialSecurityNumberParty != null && existingSocialSecurityNumberParty != bean.getPersonBean().getPerson()) { // found person with same contributor number addActionMessage(request, "error.party.existing.contributor.number"); return mapping.findForward("fill-personal-information"); } } try { DegreeOfficePublicCandidacyHashCode candidacyHashCode = DegreeOfficePublicCandidacyHashCodeOperations.getUnusedOrCreateNewHashCode( getProcessType(), getParentProcess(request), bean.getPersonBean().getEmail()); bean.setPublicCandidacyHashCode(candidacyHashCode); } catch (HashCodeForEmailAndProcessAlreadyBounded e) { addActionMessage(request, "error.candidacy.hash.code.already.bounded"); return mapping.findForward("fill-personal-information"); } return mapping.findForward("fill-candidacy-information"); }
@Service public static void validateEmailBean(PhdProgramEmailBean bean) { final ResourceBundle resourceBundle = ResourceBundle.getBundle("resources.ApplicationResources", Language.getLocale()); if (bean.getSelectedElements().isEmpty() && StringUtils.isEmpty(bean.getBccs())) { throw new DomainException(resourceBundle.getString("error.email.validation.no.recipients")); } if (StringUtils.isEmpty(bean.getSubject())) { throw new DomainException(resourceBundle.getString("error.email.validation.subject.empty")); } if (StringUtils.isEmpty(bean.getMessage())) { throw new DomainException(resourceBundle.getString("error.email.validation.message.empty")); } }
private ExecutionYear getExecutionYear(final HttpServletRequest httpServletRequest) { final String OIDString = httpServletRequest.getParameter("executionYearID"); return StringUtils.isEmpty(OIDString) ? null : rootDomainObject.readExecutionYearByOID(Integer.valueOf(OIDString)); }
private DegreeType getDegreeType(final HttpServletRequest httpServletRequest) { final String degreeTypeString = httpServletRequest.getParameter("degreeType"); return StringUtils.isEmpty(degreeTypeString) ? null : DegreeType.valueOf(degreeTypeString); }
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; }
public ActionForward create( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaActionForm createContributorForm = (DynaActionForm) form; IUserView userView = getUserView(request); final String contributorName = (String) createContributorForm.get("contributorName"); try { Integer.valueOf((String) createContributorForm.get("contributorName")); ActionErrors errors = new ActionErrors(); errors.add("error.invalid.contributorName", new ActionError("error.invalid.contributorName")); saveErrors(request, errors); return mapping.getInputForward(); } catch (NumberFormatException e) { // do nothing, name is not a number, it's correct } Integer contributorNumber = null; try { contributorNumber = Integer.valueOf((String) createContributorForm.get("contributorNumber")); if (contributorNumber.intValue() == 0) { ActionErrors errors = new ActionErrors(); errors.add( "error.invalid.contributorNumber", new ActionError("error.invalid.contributorNumber")); saveErrors(request, errors); return mapping.getInputForward(); } } catch (NumberFormatException e) { ActionErrors errors = new ActionErrors(); errors.add( "error.invalid.contributorNumber", new ActionError("error.invalid.contributorNumber")); saveErrors(request, errors); return mapping.getInputForward(); } if (StringUtils.isEmpty(createContributorForm.getString("contributorType"))) { ActionErrors errors = new ActionErrors(); errors.add("error.invalid.contributorType", new ActionError("error.invalid.contributorType")); saveErrors(request, errors); return mapping.getInputForward(); } InfoContributor infoContributor = new InfoContributor(); infoContributor.setContributorType( ContributorType.valueOf((String) createContributorForm.get("contributorType"))); infoContributor.setContributorName(contributorName); infoContributor.setContributorNumber(contributorNumber.toString()); infoContributor.setContributorAddress((String) createContributorForm.get("contributorAddress")); infoContributor.setAreaCode((String) createContributorForm.get("areaCode")); infoContributor.setAreaOfAreaCode((String) createContributorForm.get("areaOfAreaCode")); infoContributor.setArea((String) createContributorForm.get("area")); infoContributor.setParishOfResidence((String) createContributorForm.get("parishOfResidence")); infoContributor.setDistrictSubdivisionOfResidence( (String) createContributorForm.get("districtSubdivisionOfResidence")); infoContributor.setDistrictOfResidence( (String) createContributorForm.get("districtOfResidence")); Object args[] = {infoContributor}; try { infoContributor.createContributor(); } catch (InvalidArgumentsServiceException e) { throw new ExistingActionException("O Contribuinte", e); } return mapping.findForward("CreateSuccess"); }