Java tutorial
/* * */ package pagecode.jsp.actions.scheduling; import java.util.ArrayList; import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; import java.util.logging.Logger; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; import pagecode.PageCodeBase; import pagecode.RPTs.EarlyResolutionMeetingParameterFields; import pagecode.RPTs.FirstAttendanceNoticeParameterFields; import pagecode.RPTs.FirstAttendanceNoticeSchema; import pagecode.RPTs.IconDateUtil; import pagecode.RPTs.NoticeOfTrialParameterFields; import pagecode.RPTs.NoticeOfTrialSchema; import pagecode.jsp.actions.AbstractActionBase; import pagecode.jsp.scheduling.RequestForTrialAdditionalCaseNumber; import pagecode.jsp.scheduling.RequestForTrialAppearanceDateRecord; import pagecode.jsp.scheduling.RequestForTrialManagedBean; import IntegrationObject.BackToMenu_Access; import IntegrationObject.RequestForTrialGetAdditionalCases_Access; import IntegrationObject.RequestForTrialGetAppearanceCriteria_Access; import IntegrationObject.RequestForTrialGetAppearancePossibleDates_Access; import IntegrationObject.RequestForTrialProcess_Access; import IntegrationObject.RequestForTrial_Access; import businessobjects.ReportWrapper; import ca.on.gov.jus.icon.common.screenfieldmapping.ICONDataValidationException; /** * @author Anan Mazzawi * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class RequestForTrialAction extends AbstractActionBase { private static final Logger logger = Logger.getLogger(RequestForTrialAction.class.getName()); public static void executeSearch(RequestForTrialManagedBean requestForTrialManagedBean, Map sessionScope) throws Exception { logger.info("In RequestForTrialAction::executeSearch"); //FIRST clear existing list //TODO fix this //enforcementOfficerIndexManagedBean.getEnforcementOfficerIndexList().clear(); try { //First go to ICON main screen BackToMenu_Access backToMenu_Access = new BackToMenu_Access(); PageCodeBase.executeEJB(backToMenu_Access, sessionScope); String returnMessage = ""; RequestForTrial_Access requestForTrial_Access = new RequestForTrial_Access(); requestForTrial_Access.setCrt(StringUtils.rightPad(requestForTrialManagedBean.getCrt().trim(), 4)); requestForTrial_Access.setJur(StringUtils.rightPad(requestForTrialManagedBean.getJur().trim(), 4)); requestForTrial_Access.setYr(StringUtils.rightPad(requestForTrialManagedBean.getYr().trim(), 4)); requestForTrial_Access .setInf(StringUtils.rightPad(requestForTrialManagedBean.getInfoPart1().trim(), 4)); requestForTrial_Access .setSuffix(StringUtils.rightPad(requestForTrialManagedBean.getInfoPart2().trim(), 4)); PageCodeBase.executeEJB(requestForTrial_Access, sessionScope); String screenAcronym = requestForTrial_Access.getScreenAcronym().trim(); if ("ISRFT".equalsIgnoreCase(screenAcronym)) { //get screen data getRequestForTrialScreenData(requestForTrialManagedBean, sessionScope); } returnMessage = requestForTrial_Access.getReturnMessage().trim(); if (!returnMessage.equals("")) { //handleICONDataValidationException(returnMessage, archivesSearch_Access, "IAPIX"); throw new Exception(returnMessage); } } catch (Exception e) { throw e; } finally { } } public static void executeProcess(RequestForTrialManagedBean requestForTrialManagedBean, Map sessionScope) throws ICONDataValidationException, Exception { logger.info("In RequestForTrialAction::executeProcess"); boolean isValidationException = false; String returnMessage = ""; try { RequestForTrialProcess_Access requestForTrialProcess_Access = new RequestForTrialProcess_Access(); requestForTrialProcess_Access.setAppearanceType( StringUtils.rightPad(requestForTrialManagedBean.getAppearanceType().trim(), 2)); requestForTrialProcess_Access.setPreferredCourt( StringUtils.rightPad(requestForTrialManagedBean.getPreferredCourt().trim(), 4)); requestForTrialProcess_Access.setPreferredRoom( StringUtils.rightPad(requestForTrialManagedBean.getPreferredRoom().trim(), 4)); requestForTrialProcess_Access .setDatesAfter(StringUtils.rightPad(requestForTrialManagedBean.getDatesAfter().trim(), 3)); requestForTrialProcess_Access .setDayOrNight(StringUtils.rightPad(requestForTrialManagedBean.getDayOrNight().trim(), 1)); requestForTrialProcess_Access .setLanguage(StringUtils.rightPad(requestForTrialManagedBean.getLanguage().trim(), 1)); requestForTrialProcess_Access .setJudiciary(StringUtils.rightPad(requestForTrialManagedBean.getJudiciary().trim(), 4)); requestForTrialProcess_Access .setCrown(StringUtils.rightPad(requestForTrialManagedBean.getCrown().trim(), 4)); requestForTrialProcess_Access .setIgnoreBadge(StringUtils.rightPad(requestForTrialManagedBean.getIgnoreBadge().trim(), 1)); requestForTrialProcess_Access.setDatesRequested( StringUtils.rightPad(requestForTrialManagedBean.getDatesRequested().trim(), 1)); requestForTrialProcess_Access.setEstimatedDurationHour( StringUtils.rightPad(requestForTrialManagedBean.getEstimatedDurationHour().trim(), 1)); requestForTrialProcess_Access.setEstimatedDurationMinute( StringUtils.rightPad(requestForTrialManagedBean.getEstimatedDurationMinute().trim(), 2)); requestForTrialProcess_Access.setEstimatedDurationDay( StringUtils.rightPad(requestForTrialManagedBean.getEstimatedDurationDay().trim(), 4)); requestForTrialProcess_Access .setInterpreter(StringUtils.rightPad(requestForTrialManagedBean.getInterpreter().trim(), 4)); requestForTrialProcess_Access .setUsageCode(StringUtils.rightPad(requestForTrialManagedBean.getUsageCode().trim(), 2)); String selectOptions = ""; for (int i = 0; i <= requestForTrialManagedBean.getSelectedRecordIndex(); i++) { if (i == requestForTrialManagedBean.getSelectedRecordIndex()) { selectOptions += "S"; //selectOptions += actionType; //possible values: S, A, D, C break; } else { selectOptions += " "; } } logger.info("selectOption: " + selectOptions); requestForTrialProcess_Access.setSelectOptions(selectOptions); requestForTrialProcess_Access.setAdditionalCases( StringUtils.rightPad(requestForTrialManagedBean.getAdditionalCases().trim(), 1)); requestForTrialProcess_Access.setAdditionalCaseNumber1( requestForTrialManagedBean.getAdditionalCaseNumber1().getPaddedNumber()); requestForTrialProcess_Access.setAdditionalCaseNumber2( requestForTrialManagedBean.getAdditionalCaseNumber2().getPaddedNumber()); requestForTrialProcess_Access.setAdditionalCaseNumber3( requestForTrialManagedBean.getAdditionalCaseNumber3().getPaddedNumber()); requestForTrialProcess_Access.setAdditionalCaseNumber4( requestForTrialManagedBean.getAdditionalCaseNumber4().getPaddedNumber()); requestForTrialProcess_Access.setAdditionalCaseNumber5( requestForTrialManagedBean.getAdditionalCaseNumber5().getPaddedNumber()); requestForTrialProcess_Access.setAdditionalCaseNumber6( requestForTrialManagedBean.getAdditionalCaseNumber6().getPaddedNumber()); requestForTrialProcess_Access.setAdditionalCaseNumber7( requestForTrialManagedBean.getAdditionalCaseNumber7().getPaddedNumber()); requestForTrialProcess_Access.setAdditionalCaseNumber8( requestForTrialManagedBean.getAdditionalCaseNumber8().getPaddedNumber()); requestForTrialProcess_Access.setAdditionalCaseNumber9( requestForTrialManagedBean.getAdditionalCaseNumber9().getPaddedNumber()); PageCodeBase.executeEJB(requestForTrialProcess_Access, sessionScope); returnMessage = requestForTrialProcess_Access.getReturnMessage().trim(); //must clear all "select" values to prevent duplicate entries //when TRANSACTION COMPLETED. if (-1 != returnMessage.indexOf("TRANSACTION COMPLETED")) { for (Iterator iter = requestForTrialManagedBean.getPossibleAppearanceDatesList().iterator(); iter .hasNext();) { RequestForTrialAppearanceDateRecord element = (RequestForTrialAppearanceDateRecord) iter.next(); element.setSelect(null); } } if (!returnMessage.equals("")) { handleICONDataValidationException(returnMessage, requestForTrialProcess_Access, "ISRFT"); throw new Exception(returnMessage); } } catch (ICONDataValidationException iCONDataValidationException) { isValidationException = true; throw iCONDataValidationException; } catch (Exception e) { throw e; } finally { //logger.info("returnMessage: " + returnMessage); if (!"TRANSACTION COMPLETED.".equalsIgnoreCase(returnMessage) && !isValidationException) { getRequestForTrialScreenData(requestForTrialManagedBean, sessionScope); //try { executePFCommand("[pf5]", sessionScope); } catch (Exception e) { } // try { // CourtRoomAvailabilityClearSelect_Access courtRoomAvailabilityClearSelect_Access = new CourtRoomAvailabilityClearSelect_Access(); // PageCodeBase.executeEJB(courtRoomAvailabilityClearSelect_Access, sessionScope); // } catch (Exception e) { } } else { //getEnforcementOfficerAvailabilityList(enforcementOfficerAvailabilityManagedBean, sessionScope); //TRANSACTION COMPLETED. == true } } } public static void getRequestForTrialScreenData(RequestForTrialManagedBean requestForTrialManagedBean, Map sessionScope) throws Exception { logger.info("In RequestForTrialAction::getRequestForTrialScreenData"); getAppearancePossibleDates(requestForTrialManagedBean, sessionScope); getAdditionalCases(requestForTrialManagedBean, sessionScope); getAppearanceCriteria(requestForTrialManagedBean, sessionScope); } public static void getAppearanceCriteria(RequestForTrialManagedBean requestForTrialManagedBean, Map sessionScope) throws Exception { logger.info("In RequestForTrialAction::getAppearanceCriteria"); String returnMessage = ""; RequestForTrialGetAppearanceCriteria_Access getAppearanceCriteria_Access = new RequestForTrialGetAppearanceCriteria_Access(); PageCodeBase.executeEJB(getAppearanceCriteria_Access, sessionScope); requestForTrialManagedBean.setCaseNumber(getAppearanceCriteria_Access.getCaseNumber().trim()); requestForTrialManagedBean.setOffence(getAppearanceCriteria_Access.getOffence().trim()); requestForTrialManagedBean.setOffenderName(getAppearanceCriteria_Access.getOffender().trim()); requestForTrialManagedBean.setBadge(getAppearanceCriteria_Access.getBadge().trim()); requestForTrialManagedBean.setAppearanceType(getAppearanceCriteria_Access.getAppearanceType().trim()); requestForTrialManagedBean.setPreferredCourt(getAppearanceCriteria_Access.getPreferCourt().trim()); requestForTrialManagedBean.setPreferredRoom(getAppearanceCriteria_Access.getPreferRoom().trim()); requestForTrialManagedBean.setDatesAfter(getAppearanceCriteria_Access.getDatesAfter().trim()); requestForTrialManagedBean.setDayOrNight(getAppearanceCriteria_Access.getDayOrNight().trim()); requestForTrialManagedBean.setLanguage(getAppearanceCriteria_Access.getLangCode().trim()); requestForTrialManagedBean.setJudiciary(getAppearanceCriteria_Access.getJudiciary().trim()); requestForTrialManagedBean.setCrown(getAppearanceCriteria_Access.getCrown().trim()); requestForTrialManagedBean.setIgnoreBadge(getAppearanceCriteria_Access.getIgnoreBadge().trim()); requestForTrialManagedBean.setDatesRequested(getAppearanceCriteria_Access.getDatesRequested().trim()); requestForTrialManagedBean.setEstimatedDurationHour(getAppearanceCriteria_Access.getEstDuration1().trim()); requestForTrialManagedBean .setEstimatedDurationMinute(getAppearanceCriteria_Access.getEstDuration2().trim()); requestForTrialManagedBean.setEstimatedDurationDay(getAppearanceCriteria_Access.getEstDuration3().trim()); requestForTrialManagedBean.setInterpreter(getAppearanceCriteria_Access.getInterpreter().trim()); requestForTrialManagedBean.setUsageCode(getAppearanceCriteria_Access.getUsageCode().trim()); returnMessage = getAppearanceCriteria_Access.getReturnMessage().trim(); if (!returnMessage.equals("")) { throw new Exception(returnMessage); } } public static void getAppearancePossibleDates(RequestForTrialManagedBean requestForTrialManagedBean, Map sessionScope) throws Exception { logger.info("In RequestForTrialAction::getAppearancePossibleDates"); //FIRST clear existing list requestForTrialManagedBean.getPossibleAppearanceDatesList().clear(); RequestForTrialGetAppearancePossibleDates_Access getAppearancePossibleDates_Access = new RequestForTrialGetAppearancePossibleDates_Access(); PageCodeBase.executeEJB(getAppearancePossibleDates_Access, sessionScope); IconDateUtil iconDateUtil = new IconDateUtil(); iconDateUtil.setIsEnglish(true); iconDateUtil.setFlipYearDay(true); iconDateUtil.setIconTime("0000"); for (int i = 0; i < 4; i++) { String date = getAppearancePossibleDates_Access.getAppearancePossibleDatesListDate(i).trim(); if (date.length() > 0) { RequestForTrialAppearanceDateRecord appearanceDateRecord = new RequestForTrialAppearanceDateRecord(); //set cur recordIndex appearanceDateRecord.setRecordIndex(i); iconDateUtil.setIconDateCheck(StringUtils.replace( getAppearancePossibleDates_Access.getAppearancePossibleDatesListDate(i).trim(), " ", "")); appearanceDateRecord.setDate(iconDateUtil.getValidDateOrNull()); appearanceDateRecord .setDateStr(getAppearancePossibleDates_Access.getAppearancePossibleDatesListDate(i).trim()); appearanceDateRecord .setTimeStr(getAppearancePossibleDates_Access.getAppearancePossibleDatesListTime(i).trim()); appearanceDateRecord .setRoom(getAppearancePossibleDates_Access.getAppearancePossibleDatesListRoom(i).trim()); appearanceDateRecord .setCourt(getAppearancePossibleDates_Access.getAppearancePossibleDatesListCourt(i).trim()); appearanceDateRecord.setLocation( getAppearancePossibleDates_Access.getAppearancePossibleDatesListLocation(i).trim()); requestForTrialManagedBean.getPossibleAppearanceDatesList().add(appearanceDateRecord); } } //end for } public static void getAdditionalCases(RequestForTrialManagedBean requestForTrialManagedBean, Map sessionScope) throws Exception { logger.info("In RequestForTrialAction::getAdditionalCases"); //String returnMessage = ""; //FIRST clear the cases requestForTrialManagedBean.getAdditionalCaseNumber1().clear(); requestForTrialManagedBean.getAdditionalCaseNumber2().clear(); requestForTrialManagedBean.getAdditionalCaseNumber3().clear(); requestForTrialManagedBean.getAdditionalCaseNumber4().clear(); requestForTrialManagedBean.getAdditionalCaseNumber5().clear(); requestForTrialManagedBean.getAdditionalCaseNumber6().clear(); requestForTrialManagedBean.getAdditionalCaseNumber7().clear(); requestForTrialManagedBean.getAdditionalCaseNumber8().clear(); requestForTrialManagedBean.getAdditionalCaseNumber9().clear(); RequestForTrialGetAdditionalCases_Access getAdditionalCases_Access = new RequestForTrialGetAdditionalCases_Access(); PageCodeBase.executeEJB(getAdditionalCases_Access, sessionScope); requestForTrialManagedBean .setAdditionalCases(getAdditionalCases_Access.getAdditionalCasesIndicator().trim()); requestForTrialManagedBean.setAdditionalCaseNumber1( new RequestForTrialAdditionalCaseNumber(getAdditionalCases_Access.getCaseNumber1())); requestForTrialManagedBean.setAdditionalCaseNumber2( new RequestForTrialAdditionalCaseNumber(getAdditionalCases_Access.getCaseNumber2())); requestForTrialManagedBean.setAdditionalCaseNumber3( new RequestForTrialAdditionalCaseNumber(getAdditionalCases_Access.getCaseNumber3())); requestForTrialManagedBean.setAdditionalCaseNumber4( new RequestForTrialAdditionalCaseNumber(getAdditionalCases_Access.getCaseNumber4())); requestForTrialManagedBean.setAdditionalCaseNumber5( new RequestForTrialAdditionalCaseNumber(getAdditionalCases_Access.getCaseNumber5())); requestForTrialManagedBean.setAdditionalCaseNumber6( new RequestForTrialAdditionalCaseNumber(getAdditionalCases_Access.getCaseNumber6())); requestForTrialManagedBean.setAdditionalCaseNumber7( new RequestForTrialAdditionalCaseNumber(getAdditionalCases_Access.getCaseNumber7())); requestForTrialManagedBean.setAdditionalCaseNumber8( new RequestForTrialAdditionalCaseNumber(getAdditionalCases_Access.getCaseNumber8())); requestForTrialManagedBean.setAdditionalCaseNumber9( new RequestForTrialAdditionalCaseNumber(getAdditionalCases_Access.getCaseNumber9())); } public static void executePrintNotices(RequestForTrialManagedBean requestForTrialManagedBean, Map sessionScope, ReportWrapper reportWrapper, HttpServletRequest request) throws Exception { logger.info("In RequestForTrialAction::executePrintNotices"); //TODO this is the start of the French NoT if (true) { //return("requestForTrial"); } Vector requestForTrialToPrintVector = new Vector(); RequestForTrialAdditionalCaseNumber additionalCaseNumber = new RequestForTrialAdditionalCaseNumber(); additionalCaseNumber.setCrt(requestForTrialManagedBean.getCrt()); additionalCaseNumber.setJur(requestForTrialManagedBean.getJur()); additionalCaseNumber.setYr(requestForTrialManagedBean.getYr()); additionalCaseNumber.setInfoPart1(requestForTrialManagedBean.getInfoPart1()); additionalCaseNumber.setInfoPart2(requestForTrialManagedBean.getInfoPart2()); String crt_org, jur_org, yr_org, info1_org, info2_org; crt_org = additionalCaseNumber.getCrt(); jur_org = additionalCaseNumber.getJur(); yr_org = additionalCaseNumber.getYr(); info1_org = additionalCaseNumber.getInfoPart1(); info2_org = additionalCaseNumber.getInfoPart2(); requestForTrialToPrintVector.add(additionalCaseNumber); requestForTrialToPrintVector.add(requestForTrialManagedBean.getAdditionalCaseNumber1()); requestForTrialToPrintVector.add(requestForTrialManagedBean.getAdditionalCaseNumber2()); requestForTrialToPrintVector.add(requestForTrialManagedBean.getAdditionalCaseNumber3()); requestForTrialToPrintVector.add(requestForTrialManagedBean.getAdditionalCaseNumber4()); requestForTrialToPrintVector.add(requestForTrialManagedBean.getAdditionalCaseNumber5()); requestForTrialToPrintVector.add(requestForTrialManagedBean.getAdditionalCaseNumber6()); requestForTrialToPrintVector.add(requestForTrialManagedBean.getAdditionalCaseNumber7()); requestForTrialToPrintVector.add(requestForTrialManagedBean.getAdditionalCaseNumber8()); requestForTrialToPrintVector.add(requestForTrialManagedBean.getAdditionalCaseNumber9()); ArrayList notices = new ArrayList(); //IF FirstAttendanceNotice if ("AH".equalsIgnoreCase(requestForTrialManagedBean.getAppearanceType())) { FirstAttendanceNoticeParameterFields firstAttendanceNoticeParameterFields = new FirstAttendanceNoticeParameterFields(); notices = processFirstAttendanceNotice(requestForTrialToPrintVector, firstAttendanceNoticeParameterFields, request); //getReportWrapper(session).displayReportInSameBrowserWindowNoneJSF(noticeOfTrialParameterFields, request, response, servlet, notices, "pagecode.RPTs.NoticeOfTrialSchema"); //reportWrapper.displayReportInSameBrowserWindowNoneJSF(firstAttendanceNoticeParameterFields, request, response, servlet, notices, "pagecode.RPTs.FirstAttendanceNoticeSchema"); reportWrapper.displayReportInSameBrowserWindowNoneJSF(firstAttendanceNoticeParameterFields, notices, "pagecode.RPTs.FirstAttendanceNoticeSchema"); //IF EarlyResolutionMeetingInPersonParameterFields } else if ("EP".equalsIgnoreCase(requestForTrialManagedBean.getAppearanceType())) { EarlyResolutionMeetingParameterFields earlyResolutionMeetingParameterFields = new EarlyResolutionMeetingParameterFields(); notices = processFirstAttendanceNotice(requestForTrialToPrintVector, earlyResolutionMeetingParameterFields, request); //EARLY_RESOLUTION_MEETING_INPERSON_NOTICE earlyResolutionMeetingParameterFields.setEarlyResolutionMeetingFormType("71"); reportWrapper.displayReportInSameBrowserWindowNoneJSF(earlyResolutionMeetingParameterFields, notices, "pagecode.RPTs.FirstAttendanceNoticeSchema"); //IF EarlyResolutionMeetingElectronicParameterFields } else if ("ER".equalsIgnoreCase(requestForTrialManagedBean.getAppearanceType())) { EarlyResolutionMeetingParameterFields earlyResolutionMeetingParameterFields = new EarlyResolutionMeetingParameterFields(); notices = processFirstAttendanceNotice(requestForTrialToPrintVector, earlyResolutionMeetingParameterFields, request); //EARLY_RESOLUTION_MEETING_ELECTRONIC_NOTICE earlyResolutionMeetingParameterFields.setEarlyResolutionMeetingFormType("72"); reportWrapper.displayReportInSameBrowserWindowNoneJSF(earlyResolutionMeetingParameterFields, notices, "pagecode.RPTs.FirstAttendanceNoticeSchema"); } else { NoticeOfTrialParameterFields noticeOfTrialParameterFields = new NoticeOfTrialParameterFields(); notices = processNoticeOfTrial(requestForTrialToPrintVector, noticeOfTrialParameterFields, request); //getReportWrapper(session).displayReportInSameBrowserWindowNoneJSF(noticeOfTrialParameterFields, request, response, servlet, notices, "pagecode.RPTs.NoticeOfTrialSchema"); reportWrapper.displayReportInSameBrowserWindowNoneJSF(noticeOfTrialParameterFields, notices, "pagecode.RPTs.NoticeOfTrialSchema"); } } private static ArrayList processNoticeOfTrial(Vector requestForTrialToPrintVector, NoticeOfTrialParameterFields noticeOfTrialParameterFields, HttpServletRequest request) { logger.info("In RequestForTrialAction::processNoticeOfTrial"); ArrayList notices = new ArrayList(); NoticeOfTrialSchema notice; String crt, jur, yr, info1, info2; for (Iterator iter = requestForTrialToPrintVector.iterator(); iter.hasNext();) { RequestForTrialAdditionalCaseNumber additionalCaseNumber = (RequestForTrialAdditionalCaseNumber) iter .next(); crt = additionalCaseNumber.getCrt(); jur = additionalCaseNumber.getJur(); yr = additionalCaseNumber.getYr(); info1 = additionalCaseNumber.getInfoPart1(); info2 = additionalCaseNumber.getInfoPart2(); //if there is a case number i.e. it might be empty thus must check if (null != crt && !crt.equals("") && null != jur && !jur.equals("")) { noticeOfTrialParameterFields = new NoticeOfTrialParameterFields(); try { noticeOfTrialParameterFields.setTrailScheduleDetails(crt, jur, yr, info1, info2, //TODO set boolean runAsStandAlone properly false, request); noticeOfTrialParameterFields.processParameterFieldsData(); notice = new NoticeOfTrialSchema(); notice.setOffenceNumber(noticeOfTrialParameterFields.getParamOffenceNumber()); notice.setOffenceDate(noticeOfTrialParameterFields.getParamOffenceDate()); notice.setOfficerNumber(noticeOfTrialParameterFields.getParamOfficerNumber()); notice.setDriversLicenseNumber(noticeOfTrialParameterFields.getParamDriversLicenseNumber()); notice.setPlateNumber(noticeOfTrialParameterFields.getParamPlateNumber()); notice.setEnforcementAgency(noticeOfTrialParameterFields.getParamEnforcementAgency()); notice.setSex(noticeOfTrialParameterFields.getParamSex()); notice.setDateOfBirth(noticeOfTrialParameterFields.getParamDateOfBirth()); notice.setCvor(noticeOfTrialParameterFields.getParamCVOR()); notice.setUnit(noticeOfTrialParameterFields.getParamUnit()); notice.setOffenderFullName(noticeOfTrialParameterFields.getParamOffenderFullName()); notice.setAddressLine1(noticeOfTrialParameterFields.getParamAddressLine1()); notice.setAddressLine2(noticeOfTrialParameterFields.getParamAddressLine2()); notice.setAddressLine3(noticeOfTrialParameterFields.getParamAddressLine3()); notice.setOffenceDay(noticeOfTrialParameterFields.getParamOffenceDay()); notice.setOffenceMonth(noticeOfTrialParameterFields.getParamOffenceMonth()); notice.setOffenceYear(noticeOfTrialParameterFields.getParamOffenceYear()); notice.setOffenceTime(noticeOfTrialParameterFields.getParamOffenceTime()); notice.setOffenceLocation(noticeOfTrialParameterFields.getParamOffenceLocation()); /* 2010-11-23 CR4372 French NoT FORM modifications * Added offenceDescLine2 to the NoticeOfTrialSchema class * This is the best place to manipulate the data i.e. split the * Offence Desc param into two lines. At this point the logic * is concerned with the View (in the MVC) so we are massaging * the data to meet the View requirements. Again the only place * concerned with the View business logic is this part and * isolating it from affecting other business logic not concerned * with the View requirements and how we display the data. */ String offenceDescLine1 = "", offenceDescLine2 = ""; String setOffenceDesc = noticeOfTrialParameterFields.getParamOffenceDesc(); logger.info("setOffenceDesc.length: " + setOffenceDesc.length()); //Line accommodates exactly 88 chars if (null != setOffenceDesc && setOffenceDesc.trim().length() <= 88) { offenceDescLine1 = setOffenceDesc; } else { setOffenceDesc = setOffenceDesc.trim(); StringTokenizer tokens = new StringTokenizer(setOffenceDesc); String token = ""; //build offenceDescLine1 first then offenceDescLine2 while (tokens.hasMoreTokens()) { token = tokens.nextToken(); if ((offenceDescLine1.length() + token.length()) <= 88) { offenceDescLine1 += " " + token; } else { //add token to next line since we already fetched it offenceDescLine2 += token; break; } } while (tokens.hasMoreTokens()) { token = tokens.nextToken(); offenceDescLine2 += " " + token; } logger.info("setOffenceDesc--: " + setOffenceDesc); logger.info("offenceDescLine1: " + offenceDescLine1); logger.info("offenceDescLine2: " + offenceDescLine2); } notice.setOffenceDesc(offenceDescLine1); notice.setOffenceDescLine2(offenceDescLine2); notice.setOffenceStatue(noticeOfTrialParameterFields.getParamOffenceStatue()); notice.setOffenceSection(noticeOfTrialParameterFields.getParamOffenceSection()); notice.setOffenceTotalPayable(noticeOfTrialParameterFields.getParamOffenceTotalPayable()); notice.setTrialDay(noticeOfTrialParameterFields.getParamTrialDay()); notice.setTrialMonth(noticeOfTrialParameterFields.getParamTrialMonth()); notice.setTrailYear(noticeOfTrialParameterFields.getParamTrailYear()); notice.setTrailTime(noticeOfTrialParameterFields.getParamTrailTime()); notice.setTrailLocationCourtOffice( noticeOfTrialParameterFields.getParamTrailLocationCourtOfficeId()); notice.setIssuedAt(noticeOfTrialParameterFields.getParamIssuedAt()); notice.setIssuedDay(noticeOfTrialParameterFields.getParamIssuedDay()); notice.setIssuedMonth(noticeOfTrialParameterFields.getParamIssuedMonth()); notice.setIssuedYear(noticeOfTrialParameterFields.getParamIssuedYear()); notice.setFormNumberLabel(noticeOfTrialParameterFields.getParamFormNumberLabel()); //Added Sep 13. 2011 - Anan notice.setNoticeHeaderEN(noticeOfTrialParameterFields.getParamNoticeHeaderEN()); notice.setNoticeHeaderFR(noticeOfTrialParameterFields.getParamNoticeHeaderFR()); notices.add(notice); } catch (Exception e) { e.printStackTrace(); //returnMessage = "Request for Trial Was Not Retrieving Successful"; } } //END if (null != crt && !crt.equals("")... } //END for (Iterator iter = requestForTrialToPrintVector.iterator()... return notices; } private static ArrayList processFirstAttendanceNotice(Vector requestForTrialToPrintVector, FirstAttendanceNoticeParameterFields firstAttendanceNoticeParameterFields, HttpServletRequest request) { logger.info("In RequestForTrialAction::processFirstAttendanceNotice"); ArrayList notices = new ArrayList(); FirstAttendanceNoticeSchema notice; String crt, jur, yr, info1, info2; for (Iterator iter = requestForTrialToPrintVector.iterator(); iter.hasNext();) { RequestForTrialAdditionalCaseNumber additionalCaseNumber = (RequestForTrialAdditionalCaseNumber) iter .next(); crt = additionalCaseNumber.getCrt(); jur = additionalCaseNumber.getJur(); yr = additionalCaseNumber.getYr(); info1 = additionalCaseNumber.getInfoPart1(); info2 = additionalCaseNumber.getInfoPart2(); //if there is a case number i.e. it might be empty thus must check if (null != crt && !crt.equals("") && null != jur && !jur.equals("")) { firstAttendanceNoticeParameterFields = new FirstAttendanceNoticeParameterFields(); try { firstAttendanceNoticeParameterFields.setTrailScheduleDetails(crt, jur, yr, info1, info2, //TODO set boolean runAsStandAlone properly false, request); firstAttendanceNoticeParameterFields.processParameterFieldsData(); notice = new FirstAttendanceNoticeSchema(); notice.setOffenceNumber(firstAttendanceNoticeParameterFields.getParamOffenceNumber()); notice.setOffenceDate(firstAttendanceNoticeParameterFields.getParamOffenceDate()); notice.setOfficerNumber(firstAttendanceNoticeParameterFields.getParamOfficerNumber()); notice.setDriversLicenseNumber( firstAttendanceNoticeParameterFields.getParamDriversLicenseNumber()); notice.setPlateNumber(firstAttendanceNoticeParameterFields.getParamPlateNumber()); notice.setEnforcementAgency(firstAttendanceNoticeParameterFields.getParamEnforcementAgency()); notice.setSex(firstAttendanceNoticeParameterFields.getParamSex()); notice.setDateOfBirth(firstAttendanceNoticeParameterFields.getParamDateOfBirth()); notice.setCvor(firstAttendanceNoticeParameterFields.getParamCVOR()); notice.setUnit(firstAttendanceNoticeParameterFields.getParamUnit()); notice.setOffenderFullName(firstAttendanceNoticeParameterFields.getParamOffenderFullName()); notice.setAddressLine1(firstAttendanceNoticeParameterFields.getParamAddressLine1()); notice.setAddressLine2(firstAttendanceNoticeParameterFields.getParamAddressLine2()); notice.setAddressLine3(firstAttendanceNoticeParameterFields.getParamAddressLine3()); notice.setLanguageDesc(firstAttendanceNoticeParameterFields.getParamLanguageDesc()); notice.setLanguageDesc_FR(firstAttendanceNoticeParameterFields.getParamLanguageDesc_FR()); notice.setTrialDay(firstAttendanceNoticeParameterFields.getParamTrialDay()); notice.setTrialMonth(firstAttendanceNoticeParameterFields.getParamTrialMonth()); notice.setTrailYear(firstAttendanceNoticeParameterFields.getParamTrailYear()); notice.setTrailTime(firstAttendanceNoticeParameterFields.getParamTrailTime()); notice.setTrailLocation(firstAttendanceNoticeParameterFields.getParamTrailLocation()); notice.setPhoneNumer(firstAttendanceNoticeParameterFields.getParamPhoneNumer()); notice.setOffenceDesc(firstAttendanceNoticeParameterFields.getParamOffenceDesc()); /* 2010-11-23 CR4372 French NoT FORM modifications * This is the best place to manipulate the data i.e. pad the * statute description and offence description with spaces * given the total length is greater than 71 char * At this point the logic is concerned with the View * (in the MVC) so we are massaging the data to meet the * View requirements. Again the only place * concerned with the View business logic is this part and * isolating it from affecting other business logic not concerned * with the View requirements and how we display the data. */ String offenceStatDescCombined = firstAttendanceNoticeParameterFields.getParamOffenceDesc() .trim() + ", " + firstAttendanceNoticeParameterFields.getParamOffenceStatue().trim(); if (offenceStatDescCombined.length() <= 71) { //offenceStatDescCombined = StringUtils.leftPad(offenceStatDescCombined, 120, "E"); offenceStatDescCombined = "\n" + offenceStatDescCombined; } notice.setOffenceStatue(offenceStatDescCombined); notice.setOffenceSection(firstAttendanceNoticeParameterFields.getParamOffenceSection()); //2012-09-19 French NoT, Red NoT, ER, and EP Changes notice.setOffenceLocation(firstAttendanceNoticeParameterFields.getParamOffenceLocation()); notice.setInterpreterLanguage( firstAttendanceNoticeParameterFields.getParamInterpreterLanguage()); //Added Apr 20, 2012 - Anan notice.setIssuedDay(firstAttendanceNoticeParameterFields.getParamIssuedDay()); notice.setIssuedMonth(firstAttendanceNoticeParameterFields.getParamIssuedMonth()); notice.setIssuedYear(firstAttendanceNoticeParameterFields.getParamIssuedYear()); //2012-09-19 French NoT, Red NoT, ER, and EP Changes notice.setIssuedAt(firstAttendanceNoticeParameterFields.getParamIssuedAt()); notices.add(notice); } catch (Exception e) { e.printStackTrace(); //returnMessage = "Request for Trial Was Not Retrieving Successful"; } } //END if (null != crt && !crt.equals("")... } //END for (Iterator iter = requestForTrialToPrintVector.iterator()... return notices; } }