/******************************************************** Form Class: Spr01SeelotRegForm.java Purpose: Revision History Pangaea Date Comments ----------------- --------- ----------------------- ********************************************************** * @(#) Spr01SeedlotRegForm * Copyright (c) 2005, B.C. Ministry of Forests * All rights reserved. *********************************************************/ package ca.bc.gov.mof.spar.web.form; import java.sql.CallableStatement; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.StringTokenizer; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import ca.bc.gov.mof.sil.common.validators.DBFieldValidator; import ca.bc.gov.mof.sil.common.validators.CodeExpiryValidator; import ca.bc.gov.mof.sil.common.validators.FloatFieldValidator; import ca.bc.gov.mof.sil.common.validators.FloatRangeValidator; import ca.bc.gov.mof.sil.common.validators.GreaterThanLessThanValidator; import ca.bc.gov.mof.sil.common.validators.IntegerFieldValidator; import ca.bc.gov.mof.sil.common.validators.IntegerLimitsValidator; import ca.bc.gov.mof.sil.common.validators.RequiredFieldValidator; import ca.bc.gov.mof.sil.common.web.frame.SilUser; import ca.bc.gov.mof.spar.common.GeneticWorthFormat; import ca.bc.gov.mof.spar.data.SparCodeBean; import ca.bc.gov.mof.spar.data.beans.Spr001SeedlotRegBean; import ca.bc.gov.mof.spar.data.beans.SilGetOrgUnitBean; import ca.bc.gov.mof.spar.data.validators.LatLongValidator; import ca.bc.gov.mof.spar.db.CurrentSpeciesStore; import ca.bc.gov.mof.spar.db.FunctionStore; import ca.bc.gov.mof.spar.db.SparStore; import ca.bc.gov.mof.spar.web.frame.SparForm; import ca.bc.gov.mof.spar.web.frame.SparUser; import ca.bc.gov.mof.sil.webade.db.BasicStore; import ca.bc.gov.mof.sil.webade.db.CodesManager; import ca.bc.gov.mof.sil.webade.db.DataAccessInt; import ca.bc.gov.mof.sil.webade.db.DataBean; import ca.bc.gov.mof.sil.webade.db.FunctionBean; import ca.bc.gov.mof.sil.webade.db.OptionBean; import ca.bc.gov.mof.sil.webade.db.PackageMap; import ca.bc.gov.mof.sil.webade.db.Parameter; import ca.bc.gov.mof.sil.webade.db.StoreException; import ca.bc.gov.mof.sil.common.ui.BECDisplayField; import ca.bc.gov.mof.sil.common.ui.BECFieldContainer; import ca.bc.gov.mof.sil.common.ui.ClientDisplayField; import ca.bc.gov.mof.sil.common.ui.ClientFieldContainer; import ca.bc.gov.mof.sil.common.ui.ValidatingBECDisplayField; import ca.bc.gov.mof.sil.common.ui.ValidatingClientDisplayField; import ca.bc.gov.mof.sil.common.util.StringUtils; import ca.bc.gov.mof.sil.common.validators.DateValidator; import ca.bc.gov.mof.spar.data.validators.EmailValidator; import ca.bc.gov.mof.sil.webade.db.exceptions.SessionKeyInUseException; import ca.bc.gov.mof.sil.http.HttpErrorHandler; import ca.bc.gov.mof.sil.webade.db.ui.ErrorHandler; import ca.bc.gov.mof.sil.webade.db.ui.ErrorMessage; import ca.bc.gov.mof.sil.webade.db.util.SessionSnoop; import ca.bc.gov.mof.sil.webade.db.util.TextFormatter; import ca.bc.gov.mof.sil.webade.db.validators.ANDFieldValidator; import ca.bc.gov.mof.sil.webade.db.validators.DateRangeCompareValidator; import ca.bc.gov.mof.sil.webade.db.validators.FieldValidator; import ca.bc.gov.mof.sil.webade.db.validators.NotInStrValidator; import ca.bc.gov.mof.sil.webade.db.validators.NumericValidator; import ca.bc.gov.mof.sil.webade.db.validators.StringLengthValidator; import ca.bc.gov.mof.sil.webade.db.validators.ValidatingForm; public class Spr01SeedlotRegForm extends SparForm implements ValidatingForm { public Spr01SeedlotRegForm() { } // Member variables Spr001SeedlotRegBean dataBean = new Spr001SeedlotRegBean(); Spr001SeedlotRegBean itemBean = new Spr001SeedlotRegBean(); // Form Declaration private ValidatingForm validateForm = new ValidatingForm() { public DataBean getBean() { return itemBean; } public String getUserAction() { return null; } }; /*declarations**/ CurrentSpeciesStore speciesStore = null; //droplist objects private OptionBean[] seedlotStatusCodes; private OptionBean[] speciesCodes; private OptionBean[] geneticClassCodes; private OptionBean[] seedlotSourceCodes; private OptionBean[] orgUnitCodes; private OptionBean[] provenanceCodes; private OptionBean[] geoCodes; private OptionBean[] collectionMethodCodes; private OptionBean[] latCodes; private OptionBean[] longCodes; private OptionBean[] numTreesCollectedFrom; private OptionBean[] spzBCodes; private OptionBean[] spzACodes; private OptionBean[] storageFaciltyTypeCodes; private OptionBean[] fundingSourceCodes; private OptionBean[] paymentMethodCodes; private OptionBean[] corpCaptureMethodCodes; //Code Illegal Strings Declartaions String[] seedlotStatusCodesIllegalValues = null; String[] speciesCodesIllegalValues = null; String[] geneticClassCodesIllegalValues = null; String[] seedlotSourceCodesIllegalValues = null; String[] orgUnitCodesIllegalValues = null; String[] provenanceCodesIllegalValues = null; String[] geoCodesIllegalValues = null; String[] collectionMethodCodesIllegalValues = null; String[] latCodesIllegalValues = null; String[] longCodesIllegalValues = null; String[] numTreesCollectedFromIllegalValues = null; String[] spzBCodesIllegalValues = null; String[] spzACodesIllegalValues = null; String[] storageFaciltyTypeCodesIllegalValues = null; String[] fundingSourceCodesIllegalValues = null; String[] paymentMethodCodesIllegalValues = null; String[] corpCaptureMethodCodesIllegalValues = null; //Code Validators CodeExpiryValidator seedlotStatusCodesValidator; CodeExpiryValidator spzBCodesValidator; CodeExpiryValidator speciesCodesValidator; CodeExpiryValidator geneticClassCodesValidator; CodeExpiryValidator seedlotSourceCodesValidator; CodeExpiryValidator orgUnitCodesValidator; CodeExpiryValidator provenanceCodesValidator; CodeExpiryValidator geoCodesValidator; CodeExpiryValidator collectionMethodCodesValidator; CodeExpiryValidator latCodesValidator; CodeExpiryValidator longCodesValidator; CodeExpiryValidator numTreesCollectedFromValidator; CodeExpiryValidator storageFaciltyTypeCodesValidator; CodeExpiryValidator corpCaptureMethodCodesValidator; //view control flags private boolean showFormEnabled = false; private String showFormAorB = ""; private String searchRowIndex = ""; //role based permission flags private boolean userHasAdminAuthority = false; private boolean userHasTreeAdmin = false; private String geneticWorthEnabled = ""; private String areaOfUseEnabled = ""; private String specifiyLotNumberOnAdd = ""; private String approvedEnabled = ""; private String cancelEnabled = ""; //seed planning zones 1-9. //This is returned as a delimited string from the package private String spz_code_0 = ""; private String spz_code_1 = ""; private String spz_code_2 = ""; private String spz_code_3 = ""; private String spz_code_4 = ""; private String spz_code_5 = ""; private String spz_code_6 = ""; private String spz_code_7 = ""; private String spz_code_8 = ""; private String backForward = ""; private String jspFocus = ""; private String declaredCheckBox = ""; private String dirtyFlg = "N"; private String originalSeedlotStatus = ""; private String originalSeedlotNumber = ""; private String originalBCSource = ""; private String originalCollectionProvenance = ""; private String originalSpecies = ""; private String originalClassASource = ""; private String originalSupProvenance = ""; private String originalSpzList = ""; private String originalClientId = ""; private String errorsOnRecalc = "N"; // The seedmap link based on the longitude and latitude. private String seedMapLink = ""; // This boolean value will be set to true if the spz does not match the coordinates. private boolean displaySeedmapWarning = false; private String [] originalFundingSource = null; private String [] originalMethOfPayment = null; private boolean preCFSStandardForm = false; private boolean declarationCheckBoxEnabled = false; //Date declaration used for validations public final static String cfsStandardDate = "2005-04-01"; public static boolean dateIsPreCfsStandardDate(String seedlotApprovalDate) { if(! StringUtils.getInstance().hasAValue(seedlotApprovalDate) || cfsStandardDate.compareTo(seedlotApprovalDate) <= 0) { return false; } else { return true; } } private boolean validatorsInitialized = false; public Spr001SeedlotRegBean getDataBean() { return dataBean; } public void setDataBean(Spr001SeedlotRegBean dataBean) { this.dataBean = dataBean; //Set code validators into the bean if (seedlotStatusCodesValidator != null) { seedlotStatusCodesValidator.setBean(dataBean); spzBCodesValidator.setBean(dataBean); speciesCodesValidator.setBean(dataBean); geneticClassCodesValidator.setBean(dataBean); seedlotSourceCodesValidator.setBean(dataBean); orgUnitCodesValidator.setBean(dataBean); provenanceCodesValidator.setBean(dataBean); geoCodesValidator.setBean(dataBean); collectionMethodCodesValidator.setBean(dataBean); latCodesValidator.setBean(dataBean); longCodesValidator.setBean(dataBean); numTreesCollectedFromValidator.setBean(dataBean); storageFaciltyTypeCodesValidator.setBean(dataBean); corpCaptureMethodCodesValidator.setBean(dataBean); } } public void clearDataBean() { this.dataBean = new Spr001SeedlotRegBean(); } public Spr001SeedlotRegBean getItemBean() { return itemBean; } public void setItemBean(Spr001SeedlotRegBean itemBean) { this.itemBean = itemBean; } public void clearItemBean() { this.itemBean = new Spr001SeedlotRegBean(); } public DataBean getBean() { return dataBean; } public void setBean( DataBean bean ) { dataBean = (Spr001SeedlotRegBean)bean; //Set code validators into the bean if(seedlotStatusCodesValidator!= null) { seedlotStatusCodesValidator.setBean(dataBean); spzBCodesValidator.setBean(dataBean); speciesCodesValidator.setBean(dataBean); geneticClassCodesValidator.setBean(dataBean); seedlotSourceCodesValidator.setBean(dataBean); orgUnitCodesValidator.setBean(dataBean); provenanceCodesValidator.setBean(dataBean); geoCodesValidator.setBean(dataBean); collectionMethodCodesValidator.setBean(dataBean); latCodesValidator.setBean(dataBean); longCodesValidator.setBean(dataBean); numTreesCollectedFromValidator.setBean(dataBean); storageFaciltyTypeCodesValidator.setBean(dataBean); corpCaptureMethodCodesValidator.setBean(dataBean); } } private SilUser user() { return super.getUser(); } public void clear() { dataBean = new Spr001SeedlotRegBean(); itemBean = new Spr001SeedlotRegBean(); applicantAgencyDisplayField.clear(); coneCollectorAgencyDisplayField.clear(); interimStorageAgencyDisplayField.clear(); extractoryAgencyDisplayField.clear(); seedStorageAgencyDisplayField.clear(); becDisplayField.clear(); clearResultList(); clearSpzCodes(); clearOriginalFields(); errorsOnRecalc = "N"; } public void clearOriginalFields() { originalSeedlotStatus = ""; originalSeedlotNumber = ""; originalBCSource = ""; originalCollectionProvenance = ""; originalSpecies = ""; originalClassASource = ""; originalSupProvenance = ""; originalSpzList = ""; } public void setDefaults() { SparUser user = (SparUser)super.getUser(); if(dataBean.getP_revision_count().equals("")) { //set the status to INC for new records dataBean.setP_seedlot_status_code("INC"); //will be locked from updates so only need to set it once applicantAgencyDisplayField.setId(((SparUser)getUser()).getUser_client()); applicantAgencyDisplayField.setLocationCode(((SparUser)getUser()).getUser_client_locn()); // If user is a client set the application address info if(user.getUser_type() != null && ! user.getUser_type().equals("M")) { //set the original value so we can see if user tries to select another client illegally this.setOriginalClientId(((SparUser)getUser()).getUser_client()); } // If user is ministry set the collection org unit and the //applicant information based on the org unit if(!StringUtils.getInstance().hasAValue(applicantAgencyDisplayField.getId()) && user.getUser_type().equals("M")) { dataBean.setP_org_unit_no(user.getUser_org_unit()); try { setMinistryUserApplicationAgency(user.getUser_org_unit(), user.getName()); } catch (Exception e) { e.printStackTrace(); } } } //collection lat and long codes are always default if BC source = Y if(dataBean.getP_bc_source_ind().equals("Y")) { dataBean.setP_collection_latitude_code("N"); dataBean.setP_collection_longitude_code("W"); } //to be registered will always be defaulted to Y if it has no value and the status is INC if(! StringUtils.getInstance().hasAValue(dataBean.getP_to_be_registrd_ind()) && dataBean.getP_seedlot_comment().equals("INC")) { dataBean.setP_to_be_registrd_ind("Y"); } if(!StringUtils.getInstance().hasAValue(dataBean.getP_revision_count()) && dataBean.getP_applicant_email_address().equals("")) {// PT# 35298 - default e-mail address to user address, when none provided. dataBean.setP_applicant_email_address(this.getUser().getEmailAddress()); } } public void clearSpzCodes() { spz_code_0 = ""; spz_code_1 = ""; spz_code_2 = ""; spz_code_3 = ""; spz_code_4 = ""; spz_code_5 = ""; spz_code_6 = ""; spz_code_7 = ""; spz_code_8 = ""; } //Called if we have done a recalc. //If the bc source is N clear the bgc container public void clearBegContainer() { if(dataBean.getP_bc_source_ind().equalsIgnoreCase("N")) { becDisplayField.setZone(""); becDisplayField.setSubzone(""); becDisplayField.setVariant(""); dataBean.setP_bgc_zone_code(""); dataBean.setP_bgc_subzone_code(""); dataBean.setP_variant(""); } } //Sets all original values that may fire a recalc action //Needed so we can set the original value back if there are //validation errors public void setOriginalValidationFields(boolean setValueToBean) { if(setValueToBean) { dataBean.setP_bc_source_ind(originalBCSource); dataBean.setP_provenance_id(originalCollectionProvenance); dataBean.setP_vegetation_code(originalSpecies); dataBean.setP_seedlot_source_code(originalClassASource); dataBean.setP_superior_prvnc_ind(originalSupProvenance); } else { originalBCSource = dataBean.getP_bc_source_ind(); originalCollectionProvenance = dataBean.getP_provenance_id(); originalSpecies = dataBean.getP_vegetation_code(); originalClassASource = dataBean.getP_seedlot_source_code(); originalSupProvenance = dataBean.getP_superior_prvnc_ind(); } } /** */ public void forceFormats() { if(userAction.equalsIgnoreCase("Save")) { //collection methods - If there is a value in the second drop down but not the first //shuffle the values if(! StringUtils.getInstance().hasAValue(dataBean.getP_cone_collection_method_code()) && StringUtils.getInstance().hasAValue(dataBean.getP_cone_collection_method2_code())) { dataBean.setP_cone_collection_method_code(dataBean.getP_cone_collection_method2_code()); dataBean.setP_cone_collection_method2_code(""); } if (!(dataBean.getP_applicant_email_address().equals(""))) { dataBean.setP_applicant_email_address(dataBean.getP_applicant_email_address().toUpperCase()); } if (!(dataBean.getP_collection_locn_desc().equals(""))) { dataBean.setP_collection_locn_desc(dataBean.getP_collection_locn_desc().toUpperCase()); } if (!(dataBean.getP_seedlot_comment().equals(""))) { dataBean.setP_seedlot_comment(dataBean.getP_seedlot_comment().toUpperCase()); } if (!(dataBean.getP_interm_strg_locn().equals(""))) { dataBean.setP_interm_strg_locn(dataBean.getP_interm_strg_locn().toUpperCase()); } } formatGeneticWorthValues(); /* Padding for seedlot number. */ if (!dataBean.getP_seedlot_number().trim().equals("")) { dataBean.setP_seedlot_number(TextFormatter.pad(dataBean.getP_seedlot_number(), 5, '0', TextFormatter.left)); } /* Padding for copy seedlot number. */ if (!dataBean.getP_new_copy_seedlot_number().trim().equals("")) { dataBean.setP_new_copy_seedlot_number(TextFormatter.pad(dataBean.getP_new_copy_seedlot_number(), 5, '0', TextFormatter.left)); } /* Padding for all Lat, Long min and sec fields*/ //Collection if(!dataBean.getP_collection_lat_min().trim().equals("")) { dataBean.setP_collection_lat_min(TextFormatter.pad(dataBean.getP_collection_lat_min(), 2, '0', TextFormatter.left)); } if(!dataBean.getP_collection_lat_sec().trim().equals("")) { dataBean.setP_collection_lat_sec(TextFormatter.pad(dataBean.getP_collection_lat_sec(), 2, '0', TextFormatter.left)); } if(!dataBean.getP_collection_long_min().trim().equals("")) { dataBean.setP_collection_long_min(TextFormatter.pad(dataBean.getP_collection_long_min(), 2, '0', TextFormatter.left)); } if(!dataBean.getP_collection_long_sec().trim().equals("")) { dataBean.setP_collection_long_sec(TextFormatter.pad(dataBean.getP_collection_long_sec(), 2, '0', TextFormatter.left)); } //Area of Use if(!dataBean.getP_latitude_min_min().trim().equals("")) { dataBean.setP_latitude_min_min(TextFormatter.pad(dataBean.getP_latitude_min_min(), 2, '0', TextFormatter.left)); } if(!dataBean.getP_latitude_sec_min().trim().equals("")) { dataBean.setP_latitude_sec_min(TextFormatter.pad(dataBean.getP_latitude_sec_min(), 2, '0', TextFormatter.left)); } if(!dataBean.getP_latitude_min_max().trim().equals("")) { dataBean.setP_latitude_min_max(TextFormatter.pad(dataBean.getP_latitude_min_max(), 2, '0', TextFormatter.left)); } if(!dataBean.getP_latitude_sec_max().trim().equals("")) { dataBean.setP_latitude_sec_max(TextFormatter.pad(dataBean.getP_latitude_sec_max(), 2, '0', TextFormatter.left)); } if(!dataBean.getP_longitude_min_min().trim().equals("")) { dataBean.setP_longitude_min_min(TextFormatter.pad(dataBean.getP_longitude_min_min(), 2, '0', TextFormatter.left)); } if(!dataBean.getP_longitude_sec_min().trim().equals("")) { dataBean.setP_longitude_sec_min(TextFormatter.pad(dataBean.getP_longitude_sec_min(), 2, '0', TextFormatter.left)); } if(!dataBean.getP_longitude_min_max().trim().equals("")) { dataBean.setP_longitude_min_max(TextFormatter.pad(dataBean.getP_longitude_min_max(), 2, '0', TextFormatter.left)); } if(!dataBean.getP_longitude_sec_max().trim().equals("")) { dataBean.setP_longitude_sec_max(TextFormatter.pad(dataBean.getP_longitude_sec_max(), 2, '0', TextFormatter.left)); } } //Add + to gw values that are positive and pad with leading zeros public void formatGeneticWorthValues() { dataBean.setP_gw_g(GeneticWorthFormat.formatGeneticWorthValues(dataBean.getP_gw_g())); dataBean.setP_gw_d(GeneticWorthFormat.formatGeneticWorthValues(dataBean.getP_gw_d())); dataBean.setP_gw_r(GeneticWorthFormat.formatGeneticWorthValues(dataBean.getP_gw_r())); dataBean.setP_gw_m(GeneticWorthFormat.formatGeneticWorthValues(dataBean.getP_gw_m())); } /* Validators. */ //General Validation: private class RequiredUnlessSeedlotStatusIncValidator extends RequiredFieldValidator { public RequiredUnlessSeedlotStatusIncValidator(ValidatingForm form, String fieldname, String fieldLabel) { super(form, fieldname, fieldLabel); } public ErrorMessage validate() { //Spr001SeedlotRegBean bean = (Spr001SeedlotRegBean)this.form.getBean(); if (dataBean.getP_seedlot_status_code().equalsIgnoreCase("INC")) { return null; } else { return super.validate(); } } } private class RequiredUnlessSeedlotStatusIncOrPndValidator extends RequiredFieldValidator { public RequiredUnlessSeedlotStatusIncOrPndValidator(ValidatingForm form, String fieldname, String fieldLabel) { super(form, fieldname, fieldLabel); } public ErrorMessage validate() { //Spr001SeedlotRegBean bean = (Spr001SeedlotRegBean)this.form.getBean(); if (dataBean.getP_seedlot_status_code().equalsIgnoreCase("INC") || dataBean.getP_seedlot_status_code().equalsIgnoreCase("PND")) { return null; } else { return super.validate(); } } } private class RequiredUnlessSeedlotStatusIncOrPndTptValidator extends RequiredFieldValidator { public RequiredUnlessSeedlotStatusIncOrPndTptValidator(ValidatingForm form, String fieldname, String fieldLabel) { super(form, fieldname, fieldLabel); } public ErrorMessage validate() { if(!(dataBean.getP_seedlot_status_code().equalsIgnoreCase("INC") || dataBean.getP_seedlot_status_code().equalsIgnoreCase("PND")) && dataBean.getP_seedlot_source_code().equalsIgnoreCase("TPT")) { return super.validate(); } else { return null; } } } private RequiredFieldValidator becOverrideRequired = new RequiredFieldValidator(this, "p_bec_override_comment", "BEC Override"); //bec override required private FieldValidator becOverrideEntryRequiredValidation = new FieldValidator() { public ErrorMessage validate() { //if seedlot has been blanked out return null. The mandotory test will catch it if(StringUtils.getInstance().hasAValue(dataBean.getP_bec_override_ind()) && dataBean.getP_bec_override_ind().equalsIgnoreCase("Y")) { // if they had changed values on the screen, don't require override, and revalidate. if(!getDirtyFlg().equalsIgnoreCase("Y")) { return becOverrideRequired.validate(); } else { dataBean.setP_bec_override_ind("N"); } } return null; } }; //seed lot private RequiredFieldValidator seedlotNumberRequired = new RequiredFieldValidator(this, "p_seedlot_number", "Seedlot Number"); private IntegerFieldValidator seedlotNumberNumeric = new IntegerFieldValidator(this, "p_seedlot_number", "Seedlot Number",false,false); private FieldValidator seedlotRequiredForExistingRecords = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(StringUtils.getInstance().hasAValue(dataBean.getP_revision_count()) && ! StringUtils.getInstance().hasAValue(dataBean.getP_seedlot_number())) { return new ErrorMessage("sil.error.usr.required", "Seedlot Number" ); } return null; } }; private FieldValidator seedlotNumberEntryUpdateValidation = new FieldValidator() { public ErrorMessage validate() { //if seedlot has been blanked out return null. The mandotory test will catch it if(!StringUtils.getInstance().hasAValue(dataBean.getP_seedlot_number())) { return null; } //can't update an existing seedlot number if(StringUtils.getInstance().hasAValue(dataBean.getP_revision_count()) && StringUtils.getInstance().hasAValue(originalSeedlotNumber) && ! originalSeedlotNumber.equals(dataBean.getP_seedlot_number())) { return new ErrorMessage("sil.web.error.usr.key.changed" ); } //only proper authority can manual enter a seedlot number for a new record if(StringUtils.getInstance().hasAValue(dataBean.getP_seedlot_number()) && ! StringUtils.getInstance().hasAValue(originalSeedlotNumber) && ! specifiyLotNumberOnAdd.equals("Y") ) { return new ErrorMessage("spar.web.error.usr.seedlotstatus.noauthoritytoenterseedlot"); } return null; } }; private RequiredUnlessSeedlotStatusIncValidator toBeRegisteredRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_to_be_registrd_ind", "To Be Registered"); //status private RequiredFieldValidator statusRequired = new RequiredFieldValidator(this, "p_seedlot_status_code", "Status"); //COM and EXP status values may only be set by batch //Only Tree Seed Center Admin can set a lot to APP //If class A and status = APP at least one record must exist in SEEDLOT_PARENT_TREE. private FieldValidator allowableStatusValues = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; String statusList = null; //Can not set a status to COM or EXP if((dataBean.getP_seedlot_status_code().equals("COM") && ! originalSeedlotStatus.equals("COM")) || (dataBean.getP_seedlot_status_code().equals("EXP") && ! originalSeedlotStatus.equals("EXP"))) { return new ErrorMessage("spar.web.error.usr.status.com_or_exp"); } //Only proper auth can APP if(dataBean.getP_seedlot_status_code().equals("APP") && !originalSeedlotStatus.equals("APP") && ! approvedEnabled.equals("Y")) { return new ErrorMessage("spar.web.error.usr.seedlotstatus.insufficientauthoritytoapprove"); } //Can not set status back to INC if(dataBean.getP_seedlot_status_code().equals("INC") && StringUtils.getInstance().hasAValue(originalSeedlotStatus) && !originalSeedlotStatus.equals("INC")) { return new ErrorMessage("spar.web.error.usr.seedlotstatus.changeToInc"); } return null; } }; private RequiredUnlessSeedlotStatusIncValidator speciesRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_vegetation_code", "Species"); private RequiredFieldValidator geneticCodeRequired = new RequiredFieldValidator(this, "p_genetic_class_code", "Genetic Class"); private RequiredUnlessSeedlotStatusIncValidator superiorProvenanceRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_superior_prvnc_ind", "Superior Provenance"); //Not pre CFS Standard private FieldValidator superiorProvenanceFormBRequired = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired() && dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { return superiorProvenanceRequired.validate(); } return null; } }; private RequiredUnlessSeedlotStatusIncValidator classASourceRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_seedlot_source_code", "Class A Source"); private FieldValidator classASourceFormARequired = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired() && dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return classASourceRequired.validate(); } return null; } }; private RequiredUnlessSeedlotStatusIncValidator bcSourceRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_bc_source_ind", "BC Source"); private FieldValidator bcSourceCFSStanadardRequired = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired()) { return bcSourceRequired.validate(); } return null; } }; private RequiredFieldValidator applicantClientNumberRequired = new RequiredFieldValidator(this, "p_applicant_client_number", "Applicant Agency"); private FieldValidator applicantClientNumberCFSStanadardRequired = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired()) { return applicantClientNumberRequired.validate(); } return null; } }; private RequiredFieldValidator applicantClientLocationRequired = new RequiredFieldValidator(this, "p_applicant_client_locn", "Applicant Agency Location"); private IntegerFieldValidator applicantClientLocnInteger = new IntegerFieldValidator(this, "p_applicant_client_locn" , "Applicant Agency Location", false); private FieldValidator applicantClientLocationCFSStanadardRequired = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired()) { return applicantClientLocationRequired.validate(); } return null; } }; private FieldValidator applicantEmailValidation = new FieldValidator() { public ErrorMessage validate() { return new EmailValidator(dataBean.getP_applicant_email_address(), "Applicant Email Address", false).validate(); } }; private FieldValidator gw_gIntegerAndRangeValidator = new FieldValidator() { public ErrorMessage validate() { int gw_gInt; if(StringUtils.getInstance().hasAValue(dataBean.getP_gw_g())) { try { // strip out the plus if(dataBean.getP_gw_g().indexOf("+") == 0) { gw_gInt = Integer.parseInt((dataBean.getP_gw_g().substring(1, dataBean.getP_gw_g().length()))); } else { gw_gInt = Integer.parseInt((dataBean.getP_gw_g())); } if(gw_gInt > 99999) { return new ErrorMessage("spar.web.error.usr.numeric.int.type.and.range", "GW-G", "-99999, 99999"); } } catch(NumberFormatException e) { return new ErrorMessage("spar.web.error.usr.numeric.int.type.and.range", "GW-G", "-99999, 99999"); } } return null; } }; private FieldValidator gw_dIntegerAndRangeValidator = new FieldValidator() { public ErrorMessage validate() { int gw_dInt; if(StringUtils.getInstance().hasAValue(dataBean.getP_gw_d())) { try { // strip out the plus if(dataBean.getP_gw_d().indexOf("+") == 0) { gw_dInt = Integer.parseInt((dataBean.getP_gw_d().substring(1, dataBean.getP_gw_d().length()))); } else { gw_dInt = Integer.parseInt((dataBean.getP_gw_d())); } if(gw_dInt > 99999) { return new ErrorMessage("spar.web.error.usr.numeric.int.type.and.range", "GW-D", "-99999, 99999"); } } catch(NumberFormatException e) { return new ErrorMessage("spar.web.error.usr.numeric.int.type.and.range", "GW-D", "-99999, 99999"); } } return null; } }; private FieldValidator gw_rIntegerAndRangeValidator = new FieldValidator() { public ErrorMessage validate() { int gw_rInt; if(StringUtils.getInstance().hasAValue(dataBean.getP_gw_r())) { try { // strip out the plus if(dataBean.getP_gw_r().indexOf("+") == 0) { gw_rInt = Integer.parseInt((dataBean.getP_gw_r().substring(1, dataBean.getP_gw_r().length()))); } else { gw_rInt = Integer.parseInt((dataBean.getP_gw_r())); } if(gw_rInt > 99999) { return new ErrorMessage("spar.web.error.usr.numeric.int.type.and.range", "GW-R", "-99999, 99999"); } } catch(NumberFormatException e) { return new ErrorMessage("spar.web.error.usr.numeric.int.type.and.range", "GW-R", "-99999, 99999"); } } return null; } }; private FieldValidator gw_mIntegerAndRangeValidator = new FieldValidator() { public ErrorMessage validate() { int gw_mInt; if(StringUtils.getInstance().hasAValue(dataBean.getP_gw_m())) { try { // strip out the plus if(dataBean.getP_gw_m().indexOf("+") == 0) { gw_mInt = Integer.parseInt((dataBean.getP_gw_m().substring(1, dataBean.getP_gw_m().length()))); } else { gw_mInt = Integer.parseInt((dataBean.getP_gw_m())); } if(gw_mInt > 99999) { return new ErrorMessage("spar.web.error.usr.numeric.int.type.and.range", "GW-M", "-99999, 99999"); } } catch(NumberFormatException e) { return new ErrorMessage("spar.web.error.usr.numeric.int.type.and.range", "GW-M", "-99999, 99999"); } } return null; } }; private RequiredUnlessSeedlotStatusIncValidator cfsMetNotIncRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_standard_met_ind", "CFS Appendix 5 Criteria Met?"); /* mandatory if status is not INC, superior provenance is Y*, and the form has to met CFS Standard (ie entry date is after April 01/2005*/ private FieldValidator CFSMetRequired = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(isLotSplitORPreCFSValidationRequired() && dataBean.getP_superior_prvnc_ind().equalsIgnoreCase("Y")) { return cfsMetNotIncRequired.validate(); } return null; } }; //Collection Elevation Mean validation - Form B private RequiredUnlessSeedlotStatusIncValidator requiredCollectionElevMeanValidator = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_elevation", "Collection Elevation Mean"); private NumericValidator numericCollectionElevMeanValidator = new NumericValidator(this, "p_collection_elevation", "Collection Elevation Mean", "sil.error.usr.numeric.int.type", false, false,false); private IntegerLimitsValidator collectionElevMeanRange = new IntegerLimitsValidator(this, "p_collection_elevation", "Collection Elevation Mean", 0, 2500, false); //Parent Tree Elevation Mean - Form A private NumericValidator numericMeanParentElevValidator = new NumericValidator(this, "p_collection_elevation", "Mean Elevation of Parent Trees", "sil.error.usr.numeric.int.type", false, false,false); private IntegerLimitsValidator meanParentElevRange = new IntegerLimitsValidator(this, "p_collection_elevation", "Mean Elevation of Parent Trees", 0, 2500, false); private RequiredUnlessSeedlotStatusIncOrPndTptValidator orchardRequired = new RequiredUnlessSeedlotStatusIncOrPndTptValidator(this, "p_orchard_id", "Orchard Id"); private RequiredUnlessSeedlotStatusIncOrPndTptValidator seedPlanUnitRequired = new RequiredUnlessSeedlotStatusIncOrPndTptValidator(this, "p_spu_display", "Primary Seed Planning Unit"); private FieldValidator requiredElevationMeanValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_bc_source_ind().equals("Y")) { return requiredCollectionElevMeanValidator.validate(); } return null; } }; private FieldValidator rangeElevationMeanValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return meanParentElevRange.validate(); } else { return collectionElevMeanRange.validate(); } } }; private FieldValidator numericElevationMeanValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return numericMeanParentElevValidator.validate(); } else { return numericCollectionElevMeanValidator.validate(); } } }; /* * Form A specific validation */ //Orchard ID Validator DBFieldValidator orchardValid; //effective population size private FloatFieldValidator floatEffectivePopSizeValidator = new FloatFieldValidator(this, "p_effective_pop_size", "Effective Population Size", false); private FloatRangeValidator floatEffectivePopSizeRange = new FloatRangeValidator(this, "p_effective_pop_size", "Effective Population Size", 0.1, 999.9, false, false); //chain the errors withing the fieldValidator private FieldValidator effectivePopSizeFormAValidate = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { testError = floatEffectivePopSizeValidator.validate(); if(testError != null) { return new ErrorMessage("sil.error.usr.numeric.float.type", "Effective Population Size"); } else { return floatEffectivePopSizeRange.validate(); } } return null; } }; /* * Form B specific validation */ //org unit - Form B and bc source is Y private RequiredUnlessSeedlotStatusIncValidator collectionOrgUnitRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_org_unit_no", "Collection Org Unit"); private FieldValidator collectionOrgUnitFormBValidate = new FieldValidator() { public ErrorMessage validate() { ErrorMessage error = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { if (dataBean.getP_bc_source_ind().equalsIgnoreCase("Y")) { error = collectionOrgUnitRequired.validate(); } if(StringUtils.getInstance().hasAValue(dataBean.getP_org_unit_no())) { try { //Get the Org Unit Code and make sure it starts with 'D' BasicStore store = new BasicStore("ca.bc.gov.mof", getUser().getName(), "POPULATE_FORM" ); SilGetOrgUnitBean descBean = new SilGetOrgUnitBean(); descBean.setP_user_org_unit(dataBean.getP_org_unit_no()); descBean.getPackageMapping().procedure = "SIL_GET_ORG_UNIT_CODE"; FunctionBean result = (FunctionBean) store.get(descBean); String orgCode = result.getValues()[0]; if(!orgCode.startsWith("D")) { if(StringUtils.getInstance().hasAValue(dataBean.getP_revision_count())) { error = new ErrorMessage("spar.web.error.usr.org_code.district"); } else { // don't default org unit for new records, if default org unit is not a District. dataBean.setP_org_unit_no(""); } } } catch (Exception e) { e.printStackTrace(); } } } else { // blank-out org unit for genetic class A records. dataBean.setP_org_unit_no(""); } return error; } }; //Collection Provenance private RequiredUnlessSeedlotStatusIncValidator collectionProvenanceRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_provenance_id", "Collection Provenance"); /* mandatory if form B, status is not INC, * superior provenance is Y, and the entry date is after April 01/2005 (CFS standards)*/ private FieldValidator collectionProvenanceFormBValidate = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired() && dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_superior_prvnc_ind().equalsIgnoreCase("Y")) { return collectionProvenanceRequired.validate(); } return null; } }; //Location private RequiredUnlessSeedlotStatusIncValidator collectionLocationRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_locn_desc", "Collection Location"); /* mandatory if form B, status is not INC, and superior provenance is N*/ private FieldValidator collectionLocationFormBValidate = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_superior_prvnc_ind().equalsIgnoreCase("N")) { testError = collectionLocationRequired.validate(); } if (testError!=null) { return new ErrorMessage("spar.web.error.usr.provenance.no.required", "Collection Location"); } return null; } }; //Elevation private RequiredUnlessSeedlotStatusIncValidator requiredCollectElevationMinValidator = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_elevation_min", "Collection Elevation Min"); private RequiredUnlessSeedlotStatusIncValidator requiredCollectElevationMaxValidator = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_elevation_max", "Collection Elevation Max"); private NumericValidator numericCollectElevationMinValidator = new NumericValidator(this, "p_collection_elevation_min", "Collection Elevation Min", "sil.error.usr.numeric.int.type", false, false,false); private NumericValidator numericCollectElevationMaxValidator = new NumericValidator(this, "p_collection_elevation_max", "Collection Elevation Max", "sil.error.usr.numeric.int.type", false, false,false); private IntegerLimitsValidator collectionElevMinRange = new IntegerLimitsValidator(this, "p_collection_elevation_min", "Collection Elevation Min", 0, 2500, false); private IntegerLimitsValidator collectionElevMaxRange = new IntegerLimitsValidator(this, "p_collection_elevation_max", "Collection Elevation Max", 0, 2500, false); private GreaterThanLessThanValidator elevCollectMeanGreaterElevMin = new GreaterThanLessThanValidator(this, "p_collection_elevation_min", "p_collection_elevation", true, false, "Collection Elevation Mean", "Collection Elevation Min"); private GreaterThanLessThanValidator elevCollectMaxGreaterElevMean = new GreaterThanLessThanValidator(this, "p_collection_elevation", "p_collection_elevation_max", true, false, "Collection Elevation Max", "Collection Elevation Mean"); private FieldValidator collectionElevMinFormBRequired = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_bc_source_ind().equals("Y")) { return requiredCollectElevationMinValidator.validate(); } return null; } }; /* chain the errors within the class. mandatory if form B and status is not INC*/ private FieldValidator collectionElevationMinFormBValidate = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { testError = numericCollectElevationMinValidator.validate(); if (testError!=null) { return new ErrorMessage("sil.error.usr.numeric.int.type", "Collection Elevation Min"); } testError = collectionElevMinRange.validate(); if (testError!=null) { return new ErrorMessage("ca.bc.gov.mof.sil.webade.db.error.usr.field.range", "Collection Elevation Min", "0", "2500"); } } return null; } }; private FieldValidator collectionElevMaxFormBRequired = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_bc_source_ind().equals("Y")) { return requiredCollectElevationMaxValidator.validate(); } return null; } }; /* chain the errors within the class. mandatory if form B and status is not INC*/ private FieldValidator collectionElevationMaxFormBValidate = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { testError = numericCollectElevationMaxValidator.validate(); if (testError!=null) { return new ErrorMessage("sil.error.usr.numeric.int.type", "Collection Elevation Max"); } testError = collectionElevMaxRange.validate(); if (testError!=null) { return new ErrorMessage("ca.bc.gov.mof.sil.webade.db.error.usr.field.range", "Collection Elevation Max", "0", "2500"); } } return null; } }; private FieldValidator collectionElevationMinMeanFormBValidate = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { return elevCollectMeanGreaterElevMin.validate(); } return null; } }; private FieldValidator collectionElevationMaxMeanFormBValidate = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { return elevCollectMaxGreaterElevMean.validate(); } return null; } }; //Collection Radius private RequiredUnlessSeedlotStatusIncValidator collectionRadiusRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_area_radius", "Collection Radius"); private FloatFieldValidator collectionRadiusFloat = new FloatFieldValidator(this, "p_collection_area_radius", "Collection Radius", false); private FloatRangeValidator collectionRadiusRange = new FloatRangeValidator(this, "p_collection_area_radius", "Collection Radius", 0.1, 999.9, false, false); /* Mandatory if form B, it has to be CFS standards compliant, * status is not INC or if To be registered is N*/ private FieldValidator collectionRadiusFormBValidate = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired() && dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_to_be_registrd_ind().equalsIgnoreCase("Y")) { return collectionRadiusRequired.validate(); } return null; } }; private RequiredUnlessSeedlotStatusIncValidator collectionSpzAreaRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_seed_plan_zone_code","Seed Planning Zone of Collection Area" ); /* Mandatory if form B, it has to be CFS standards compliant, * status is not INC and BC source is Y*/ private FieldValidator collectionSpzAreaRequiredFormB = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired() && dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_bc_source_ind().equalsIgnoreCase("Y")) { return collectionSpzAreaRequired.validate(); } return null; } }; private RequiredUnlessSeedlotStatusIncValidator collectionAllFromSameSpzRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_spz_ind","Is the collection all from within the same SPZ?" ) { public ErrorMessage validate() { if (! isLotSplitORPreCFSValidationRequired()) { return null; } else { return super.validate(); } } }; /* Mandatory if form B, it has to be CFS standards compliant, * status is not INC and BC source is Y*/ private FieldValidator collectionAllFromSameSpzRequiredFormB = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired() && dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_bc_source_ind().equalsIgnoreCase("Y")) { return collectionAllFromSameSpzRequired.validate(); } return null; } }; //Geographic Area - Form B only - //Man if not INC, Seed Planning Zone of Collection Area = M, and BC source = Y //Must be blank if Seed Planning Zone of Collection Area is not M private RequiredUnlessSeedlotStatusIncValidator geographicAreaRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_seed_coast_area_code","Geographic Area" ); private FieldValidator geographicAreaRequiredFormB = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_seed_plan_zone_code().equalsIgnoreCase("M") && dataBean.getP_bc_source_ind().equalsIgnoreCase("Y")) { return geographicAreaRequired.validate(); } if(!dataBean.getP_seed_plan_zone_code().equalsIgnoreCase("M") && StringUtils.getInstance().hasAValue(dataBean.getP_seed_coast_area_code())) { return new ErrorMessage("spar.web.error.usr.collection.spz.not.m.notRequired"); } return null; } }; //, Subzone, Variant private RequiredUnlessSeedlotStatusIncValidator bgcZoneRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_bgc_zone_code","BGC Zone" ); private FieldValidator bgcZoneRequiredFormB = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if (dataBean.getP_genetic_class_code().equals("B") && dataBean.getP_bc_source_ind().equals("Y")) { return bgcZoneRequired.validate(); } return null; } }; private RequiredUnlessSeedlotStatusIncValidator collectionAllFromSameBgcZoneRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_bgc_ind","Is the collection all from within the same BGC Zone?" ); /* Mandatory if form B, it has to be CFS standards compliant, * status is not INC and BC source is Y*/ private FieldValidator collectionAllFromSameBgcZoneRequiredFormB = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(isLotSplitORPreCFSValidationRequired() && dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_bc_source_ind().equalsIgnoreCase("Y")) { return collectionAllFromSameBgcZoneRequired.validate(); } return null; } }; /* NOTE: THE FOLLOWING SIX FIELDS ARE IN BOTH A AND B FORMS WITH DIFFERENT LABELS * p_collection_lat_deg, p_collection_lat_min ,p_collection_lat_sec * p_collection_long_deg, p_collection_long_min ,p_collection_long_sec * * THEREFORE THERE ARE TWO VALIDATIONS NEEDED FOR EACH AND A FIELD VALIDATOR THAT CALLS THE CORRECT * VALIDATOR DEPENDEING ON THE VALUE OF p_genetic_class_code. */ //Collection Latitude - Form B private LatLongValidator collectionLatValidatorStatusInc = new LatLongValidator(this, new String[]{"p_collection_lat_deg","p_collection_lat_min","p_collection_lat_sec"}, "Collection Latitude", "Degrees, Minutes, Seconds", false); private LatLongValidator collectionLatValidatorStatusNotInc = new LatLongValidator(this, new String[]{"p_collection_lat_deg","p_collection_lat_min","p_collection_lat_sec"}, "Collection Latitude", "Degrees, Minutes, Seconds", true); //Parent Tree Latitude - Form A private LatLongValidator parentTreeLatValidator = new LatLongValidator(this, new String[]{"p_collection_lat_deg","p_collection_lat_min","p_collection_lat_sec"}, "Mean Latitude of Parent Trees", "Degrees, Minutes, Seconds", false); //private LatLongValidator parentTreeLatValidatorStatusNotIncorPnd = new LatLongValidator(this, new String[]{"p_collection_lat_deg","p_collection_lat_min","p_collection_lat_sec"}, "Mean Latitude of Parent Trees", "Degrees, Minutes, Seconds", true); private FieldValidator latitudeValidatorRequired = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return parentTreeLatValidator.validate(); } else { if(dataBean.getP_seedlot_status_code().equals("INC")) { return collectionLatValidatorStatusInc.validate(); } else { return collectionLatValidatorStatusNotInc.validate(); } } } }; //Collection Lat - Form B private NumericValidator numericCollectionLatDegValidator = new NumericValidator(this, "p_collection_lat_deg", "Collection Latitude Degrees", "sil.error.usr.numeric.int.type", false, false,false); //Parent Tree Lat - Form A private NumericValidator numericParentTreeLatDegValidator = new NumericValidator(this, "p_collection_lat_deg", "Mean Latitude of Parent Trees Degrees", "sil.error.usr.numeric.int.type", false, false,false); private FieldValidator numericLatitudeDegValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return numericParentTreeLatDegValidator.validate(); } else { return numericCollectionLatDegValidator.validate(); } } }; //Collection Lat - Form B private NumericValidator numericCollectionLatMinValidator = new NumericValidator(this, "p_collection_lat_min", "Collection Latitude Minutes", "sil.error.usr.numeric.int.type", false, false,false); //Parent Tree Lat - Form A private NumericValidator numericParentTreeLatMinValidator = new NumericValidator(this, "p_collection_lat_min", "Mean Latitude of Parent Trees Minutes", "sil.error.usr.numeric.int.type", false, false,false); private FieldValidator numericLatitudeMinValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return numericParentTreeLatMinValidator.validate(); } else { return numericCollectionLatMinValidator.validate(); } } }; //Collection Lat - Form B private NumericValidator numericCollectionLatSecValidator = new NumericValidator(this, "p_collection_lat_sec", "Collection Latitude Seconds", "sil.error.usr.numeric.int.type", false, false,false); //Parent Tree Lat- Form A private NumericValidator numericParentTreeLatSecValidator = new NumericValidator(this, "p_collection_lat_sec", "Mean Latitude of Parent Trees Seconds", "sil.error.usr.numeric.int.type", false, false,false); private FieldValidator numericLatitudeSecValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return numericParentTreeLatSecValidator.validate(); } else { return numericCollectionLatSecValidator.validate(); } } }; //Parent Tree Lat - From A private IntegerLimitsValidator parentTreeLatMinRange = new IntegerLimitsValidator( this, "p_collection_lat_min", "Mean Latitude of Parent Trees Minutes", 0, 59, false); //Collection Lat - Form B private IntegerLimitsValidator collectionLatMinRange = new IntegerLimitsValidator( this, "p_collection_lat_min", "Collection Latitude Minutes", 0, 59, false); private FieldValidator rangeLatitudeMinValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return parentTreeLatMinRange.validate(); } else { return collectionLatMinRange.validate(); } } }; //Parent Tree Lat - Form A private IntegerLimitsValidator parentTreeLatSecRange = new IntegerLimitsValidator( this, "p_collection_lat_sec", "Mean Latitude of Parent Trees Seconds", 0, 59, false); //Collection Lat - From B private IntegerLimitsValidator collectionLatSecRange = new IntegerLimitsValidator( this, "p_collection_lat_sec", "Collection Latitude Seconds", 0, 59, false); private FieldValidator rangeLatitudeSecValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return parentTreeLatSecRange.validate(); } else { return collectionLatSecRange.validate(); } } }; //Parent Tree - Form A private IntegerLimitsValidator parentTreeLatRangeDegreesBCSource = new IntegerLimitsValidator( this, "p_collection_lat_deg", "Mean Latitude of Parent Trees Degrees", 48, 60, false); private IntegerLimitsValidator parentTreeLatRangeDegreesNonBCSource = new IntegerLimitsValidator( this, "p_collection_lat_deg", "Mean Latitude of Parent Trees Degrees", 0, 90, false); //Collection - Form B private IntegerLimitsValidator collectionLatRangeDegreesBCSource = new IntegerLimitsValidator( this, "p_collection_lat_deg", "Collection Latitude Degrees", 48, 60, false); private IntegerLimitsValidator collectionLatRangeDegreesNonBCSource = new IntegerLimitsValidator( this, "p_collection_lat_deg", "Collection Latitude Degrees", 0, 90, false); private FieldValidator latitudeDegreesRangeValidation = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { if(dataBean.getP_bc_source_ind().equalsIgnoreCase("Y")) { return parentTreeLatRangeDegreesBCSource.validate(); } else { return parentTreeLatRangeDegreesNonBCSource.validate(); } } else { if(dataBean.getP_bc_source_ind().equalsIgnoreCase("Y")) { return collectionLatRangeDegreesBCSource.validate(); } else { return collectionLatRangeDegreesNonBCSource.validate(); } } } }; //Parent Tree - From A //Collection Form B private RequiredUnlessSeedlotStatusIncValidator collectionLatitudeCodeRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_latitude_code","Collection Latitude Code" ); private FieldValidator collectionLatitudeCodeRequiredFormB = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { return collectionLatitudeCodeRequired.validate(); } return null; } }; //Parent Tree - Form A private LatLongValidator parentTreeLongValidator = new LatLongValidator(this, new String[]{"p_collection_long_deg","p_collection_long_min","p_collection_long_sec"}, "Mean Longitude of Parent Trees", "Degrees, Minutes, Seconds", false); // private LatLongValidator parentTreeLongValidatorStatusNotIncOrPnd = new LatLongValidator(this, new String[]{"p_collection_long_deg","p_collection_long_min","p_collection_long_sec"}, "Mean Longitude of Parent Trees", "Degrees, Minutes, Seconds", true); private FieldValidator longitudeValidatorRequired = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return parentTreeLongValidator.validate(); } else { if(dataBean.getP_seedlot_status_code().equals("INC")) { return collectionLongValidatorStatusInc.validate(); } else { return collectionLongValidatorStatusNotInc.validate(); } } } }; //Collection Longitude - Form B private LatLongValidator collectionLongValidatorStatusInc = new LatLongValidator(this, new String[]{"p_collection_long_deg","p_collection_long_min","p_collection_long_sec"}, "Collection Longitude", "Degrees, Minutes, Seconds", false); private LatLongValidator collectionLongValidatorStatusNotInc = new LatLongValidator(this, new String[]{"p_collection_long_deg","p_collection_long_min","p_collection_long_sec"}, "Collection Longitude", "Degrees, Minutes, Seconds", true); //Parent Tree - Form A private NumericValidator numericParentTreeLongDegValidator = new NumericValidator(this, "p_collection_long_deg", "Mean Longitude of Parent Trees Degrees", "sil.error.usr.numeric.int.type", false, false,false); //Collection Longitude - Form B private NumericValidator numericCollectionLongDegValidator = new NumericValidator(this, "p_collection_long_deg", "Collection Longitude Degrees", "sil.error.usr.numeric.int.type", false, false,false); private FieldValidator numericLongitudeDegValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return numericParentTreeLongDegValidator.validate(); } else { return numericCollectionLongDegValidator.validate(); } } }; //Parent Tree - Form A private NumericValidator numericParentTreeLongMinValidator = new NumericValidator(this, "p_collection_long_min", "Mean Longitude of Parent Trees Minutes", "sil.error.usr.numeric.int.type", false, false,false); //Collection Longitude - Form B private NumericValidator numericCollectionLongMinValidator = new NumericValidator(this, "p_collection_long_min", "Collection Longitude Minutes", "sil.error.usr.numeric.int.type", false, false,false); private FieldValidator numericLongitudeMinValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return numericParentTreeLongMinValidator.validate(); } else { return numericCollectionLongMinValidator.validate(); } } }; //Parent Tree - Form A private NumericValidator numericParentTreeLongSecValidator = new NumericValidator(this, "p_collection_long_sec", "Mean Longitude of Parent Trees Seconds", "sil.error.usr.numeric.int.type", false, false,false); //Collection Longitude - Form B private NumericValidator numericCollectionLongSecValidator = new NumericValidator(this, "p_collection_long_sec", "Collection Longitude Seconds", "sil.error.usr.numeric.int.type", false, false,false); private FieldValidator numericLongitudeSecValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return numericParentTreeLongSecValidator.validate(); } else { return numericCollectionLongSecValidator.validate(); } } }; //Parent Tree - Form A private IntegerLimitsValidator parentTreeLongMinRange = new IntegerLimitsValidator( this, "p_collection_long_min", "Mean Longitude of Parent Trees Minutes", 0, 59, false); //Collection - Form B private IntegerLimitsValidator collectionLongMinRange = new IntegerLimitsValidator( this, "p_collection_long_min", "Collection Longitude Minutes", 0, 59, false); private FieldValidator rangeLongitudeMinValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return parentTreeLongMinRange.validate(); } else { return collectionLongMinRange.validate(); } } }; //Parent Tree - Form A private IntegerLimitsValidator parentTreeLongSecRange = new IntegerLimitsValidator( this, "p_collection_long_sec", "Mean Longitude of Parent Trees Seconds", 0, 59, false); //Collection - Form B private IntegerLimitsValidator collectionLongSecRange = new IntegerLimitsValidator( this, "p_collection_long_sec", "Collection Longitude Seconds", 0, 59, false); private FieldValidator rangeLongitudeSecValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { return parentTreeLongSecRange.validate(); } else { return collectionLongSecRange.validate(); } } }; //Parent Tree - Form A private IntegerLimitsValidator parentTreeLongRangeDegreesBCSource = new IntegerLimitsValidator( this, "p_collection_long_deg", "Mean Longitude of Parent Trees Degrees", 114, 140, false); private IntegerLimitsValidator parentTreeLongRangeDegreesNoBCSource = new IntegerLimitsValidator( this, "p_collection_long_deg", "Mean Longitude of Parent Trees Degrees", 0, 180, false); //Collection - Form B private IntegerLimitsValidator collectionLongRangeDegreesBCSource = new IntegerLimitsValidator( this, "p_collection_long_deg", "Collection Longitude Degrees", 114, 140, false); private IntegerLimitsValidator collectionLongRangeDegreesNoBCSource = new IntegerLimitsValidator( this, "p_collection_long_deg", "Collection Longitude Degrees", 0, 180, false); private FieldValidator longitudeDegreesRangeValidation = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("A")) { if(dataBean.getP_bc_source_ind().equalsIgnoreCase("Y")) { return parentTreeLongRangeDegreesBCSource.validate(); } else { return parentTreeLongRangeDegreesNoBCSource.validate(); } } else { if(dataBean.getP_bc_source_ind().equalsIgnoreCase("Y")) { return collectionLongRangeDegreesBCSource.validate(); } else { return collectionLongRangeDegreesNoBCSource.validate(); } } } }; //Collection Form B private RequiredUnlessSeedlotStatusIncValidator collectionLongitudeCodeRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_longitude_code","Collection Longitude Code" ); private FieldValidator collectionLongitudeCodeRequiredFormB = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testError = null; if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { return collectionLongitudeCodeRequired.validate(); } return null; } }; private FieldValidator longAndLatRequiredForCaptureMethod = new FieldValidator() { public ErrorMessage validate() { ErrorMessage latErrors = null; ErrorMessage longErrors = null; if (StringUtils.getInstance().hasAValue(dataBean.getP_capture_method_code())) { latErrors = collectionLatValidatorStatusNotInc.validate(); longErrors = collectionLongValidatorStatusNotInc.validate(); } if(latErrors != null || longErrors != null) { return new ErrorMessage("spar.web.error.usr.date.compare.required", "Collection Latitude and Longitude (Mean)", "Capture Method"); } else { return null; } } }; //Collection Start and End Date private RequiredUnlessSeedlotStatusIncValidator collectionStartDateRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_start_date", "Collection Start Date"); private RequiredUnlessSeedlotStatusIncValidator collectionEndDateRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_end_date","Collection End Date"); private ANDFieldValidator collectionStartANDEnd = new ANDFieldValidator( this, new String[]{"p_collection_start_date", "p_collection_end_date"}, new String[]{"Collection Started", "Collection Ended"}, "spar.web.error.usr.field.and", false); private FieldValidator collectionStartANDEndStatusNotINC = new FieldValidator() { public ErrorMessage validate() { if (! dataBean.getP_seedlot_status_code().equals("INC")) { return collectionStartANDEnd.validate(); } return null; } }; private DateValidator collectionStartDate = new DateValidator(this, "p_collection_start_date", "Collection Started", "yyyy-MM-dd", false); private DateValidator collectionEndDate = new DateValidator(this, "p_collection_end_date", "Collection Ended", "yyyy-MM-dd", false); private DateRangeCompareValidator collectionStartLessEndDate = new DateRangeCompareValidator (this, "spar.web.error.usr.date.range.flip_or_on", "Collection Start Date", "Collection End Date", "yyyy-MM-dd", "p_collection_start_date", "p_collection_end_date", "<=", false); private FieldValidator collectionStartlessTodayValidator = new FieldValidator() { public ErrorMessage validate() { if (StringUtils.getInstance().hasAValue(dataBean.getP_collection_start_date())) { //check to make sure date is greater than today. try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String date1 = dataBean.getP_collection_start_date(); String date2 = formatter.format (new Date()); Date d1 = null; Date d2 = null; formatter.parse(date1); formatter.parse(date2); d1 = formatter.parse(date1); d2 = formatter.parse(date2); if (d1.compareTo(d2) >0) // if date greater than today { return new ErrorMessage("spar.web.error.usr.date.format.compare", "Collection Start Date", "Today's Date", "<="); } } catch (Exception e) { // leave for validator } } return null; } }; private FieldValidator collectionEndlessTodayValidator = new FieldValidator() { public ErrorMessage validate() { if (StringUtils.getInstance().hasAValue(dataBean.getP_collection_end_date())) { //check to make sure date is greater than today. try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String date1 = dataBean.getP_collection_end_date(); String date2 = formatter.format (new Date()); Date d1 = null; Date d2 = null; formatter.parse(date1); formatter.parse(date2); d1 = formatter.parse(date1); d2 = formatter.parse(date2); if (d1.compareTo(d2) >0) // if date greater than today { return new ErrorMessage("spar.web.error.usr.date.format.compare", "Collection End Date", "Today's Date", "<="); } } catch (Exception e) { // leave for validator } } return null; } }; private RequiredUnlessSeedlotStatusIncValidator collectionMethodRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_cone_collection_method_code", "Collection Method"); private FieldValidator collectionMethodDuplicateValidation = new FieldValidator() { public ErrorMessage validate() { //ErrorMessage testError = null; String method_one = dataBean.getP_cone_collection_method_code(); String method_two = dataBean.getP_cone_collection_method2_code(); if(StringUtils.getInstance().hasAValue(method_one) && StringUtils.getInstance().hasAValue(method_two) && method_one.equalsIgnoreCase(method_two)) { return new ErrorMessage("spar.web.error.usr.not.same", "Collection Method(1)", "Collection Method(2)"); } return null; } }; //Form B only private RequiredUnlessSeedlotStatusIncValidator noTreesCollectedRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_nmbr_trees_from_code", "No. Trees Collected From"); private FieldValidator noTreesCollectedRequiredFormB = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { return noTreesCollectedRequired.validate(); } return null; } }; private RequiredUnlessSeedlotStatusIncValidator noContainersRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_no_of_containers", "No. of Containers"); private FloatFieldValidator noContainersFloat = new FloatFieldValidator(this, "p_no_of_containers", "No. of Containers", false); private FloatRangeValidator noContainersRange = new FloatRangeValidator(this, "p_no_of_containers" , "No. of Containers", 0.01, 9999.99, false, false); private RequiredUnlessSeedlotStatusIncValidator volumeContainersRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_vol_per_container", "Volume per Container"); private FloatFieldValidator volumeContainersFloat = new FloatFieldValidator(this, "p_vol_per_container", "Volume per Container", false); private FloatRangeValidator volumeContainersRange = new FloatRangeValidator(this, "p_vol_per_container" , "Volume per Container", 0.01, 99.99, false, false); private RequiredUnlessSeedlotStatusIncValidator volumeConesRequired = new RequiredUnlessSeedlotStatusIncValidator(this, "p_clctn_volume", "Volume of Cones"); private FloatFieldValidator volumeConesFloat = new FloatFieldValidator(this, "p_clctn_volume", "Volume of Cones", false); private FloatRangeValidator volumeConesRange = new FloatRangeValidator(this, "p_clctn_volume" , "Volume of Cones", 0.01, 9999.99, false, false); //Comments private NotInStrValidator commentsValidate = new NotInStrValidator(this, "p_seedlot_comment", "\"", "spar.web.error.usr.field.invalidChars", false, "Comments"); private StringLengthValidator commentsLength = new StringLengthValidator(this, "p_seedlot_comment", 2000, "spar.web.error.user.field.string.length", "Comments"); private StringLengthValidator ownershipCommentsLength = new StringLengthValidator(this, "p_ownership_comment", 4000, "spar.web.error.user.field.string.length", "Area of Use Comment"); //cone collector agency private RequiredUnlessSeedlotStatusIncValidator coneCollectorAgencyId = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_cli_number", "Cone Collector Agency"); private RequiredUnlessSeedlotStatusIncValidator coneCollectorAgencyLoc = new RequiredUnlessSeedlotStatusIncValidator(this, "p_collection_cli_locn_cd", "Cone Collector Agency Location"); private ANDFieldValidator coneCollectorAndLocationValidator = new ANDFieldValidator(this, new String[]{"p_collection_cli_number", "p_collection_cli_locn_cd"}, new String[]{"Cone Collector Agency", "Cone Collector Agency Location"}, "spar.web.error.usr.client.and.location", false); /*AREA of USE*/ //spz1- 9 :Note spz0 is for Genetic Class A records only private FieldValidator spzDuplicateValidation = new FieldValidator() { public ErrorMessage validate() { boolean foundDuplicate = validateNoDuplicateSpzs(); if(foundDuplicate) { return new ErrorMessage("spar.web.error.usr.seedplanzone.noduplicate"); } return null; } }; //Elevation private NumericValidator numericAreaofUseElevationMinValidator = new NumericValidator(this, "p_elevation_min", "Area of Use Elevation Min", "sil.error.usr.numeric.int.type", false, false,false); private NumericValidator numericAreaofUseElevationMaxValidator = new NumericValidator(this, "p_elevation_max", "Area of Use Elevation Max", "sil.error.usr.numeric.int.type", false, false,false); private IntegerLimitsValidator areaofUseElevMinRange = new IntegerLimitsValidator(this, "p_elevation_min", "Area of Use Elevation Min", 0, 2500, false); private IntegerLimitsValidator areaofUseElevMaxRange = new IntegerLimitsValidator(this, "p_elevation_max", "Area of Use Elevation Max", 0, 2500, false); private GreaterThanLessThanValidator areaofUseMaxGreaterMin = new GreaterThanLessThanValidator(this, "p_elevation_min", "p_elevation_max", true, false, "Area of Use Elevation Max", "Area of Use Elevation Min"); //Latitude Min private LatLongValidator areaOfUseMinLatitudeValidator = new LatLongValidator(this, new String[]{"p_latitude_deg_min","p_latitude_min_min","p_latitude_sec_min"}, "Area Of Use Min Latitude", "Degrees, Minutes, Seconds", false); private NumericValidator numericAreaOfUseMinLatDegValidator = new NumericValidator(this, "p_latitude_deg_min", "Area of Use Min Latitude Degrees", "sil.error.usr.numeric.int.type", false, false,false); private NumericValidator numericAreaOfUseMinLatMinValidator = new NumericValidator(this, "p_latitude_min_min", "Area of Use Min Latitude Minutes", "sil.error.usr.numeric.int.type", false, false,false); private NumericValidator numericAreaOfUseMinLatSecValidator = new NumericValidator(this, "p_latitude_sec_min", "Area of Use Min Latitude Seconds", "sil.error.usr.numeric.int.type", false, false,false); private IntegerLimitsValidator areaOfUseMinLatMinRange = new IntegerLimitsValidator(this, "p_latitude_min_min","Area of Use Min Latitude Minutes", 0,59, false); private IntegerLimitsValidator areaOfUseMinLatSecRange = new IntegerLimitsValidator(this, "p_latitude_sec_min","Area of Use Min Latitude Seconds", 0,59, false); private IntegerLimitsValidator areaOfUseMinLatDegRange = new IntegerLimitsValidator(this, "p_latitude_deg_min", "Area of Use Min Latitude Degrees", 48, 60, false); //Latitude Max private LatLongValidator areaOfUseMaxLatitudeValidator = new LatLongValidator(this, new String[]{"p_latitude_deg_max","p_latitude_min_max","p_latitude_sec_max"}, "Area Of Use Max Latitude", "Degrees, Minutes, Seconds", false); private NumericValidator numericAreaOfUseMaxLatDegValidator = new NumericValidator(this, "p_latitude_deg_max", "Area of Use Max Latitude Degrees", "sil.error.usr.numeric.int.type", false, false,false); private NumericValidator numericAreaOfUseMaxLatMinValidator = new NumericValidator(this, "p_latitude_min_max", "Area of Use Max Latitude Minutes", "sil.error.usr.numeric.int.type", false, false,false); private NumericValidator numericAreaOfUseMaxLatSecValidator = new NumericValidator(this, "p_latitude_sec_max", "Area of Use Max Latitude Seconds", "sil.error.usr.numeric.int.type", false, false,false); private IntegerLimitsValidator areaOfUseMaxLatMinRange = new IntegerLimitsValidator(this, "p_latitude_min_max","Area of Use Max Latitude Minutes", 0,59, false); private IntegerLimitsValidator areaOfUseMaxLatSecRange = new IntegerLimitsValidator(this, "p_latitude_sec_max","Area of Use Max Latitude Seconds", 0,59, false); private IntegerLimitsValidator areaOfUseMaxLatDegRange = new IntegerLimitsValidator(this, "p_latitude_deg_max", "Area of Use Max Latitude Degrees", 48, 60, false); //Latitude Range private FieldValidator areaOfUseMaxLatGreaterThenMinLatValidator = new FieldValidator() { public ErrorMessage validate() { boolean foundError = false; String maxDeg = dataBean.getP_latitude_deg_max(); String minDeg = dataBean.getP_latitude_deg_min(); if(StringUtils.getInstance().hasAValue(maxDeg) && StringUtils.getInstance().hasAValue(minDeg)) { if(maxDeg.compareTo(minDeg) < 0 ) { return new ErrorMessage("sil.error.usr.field.greaterthanOrEqual", "Area of Use Latitude Max", "Area of Use Latitude Min"); } else if( maxDeg.compareTo(minDeg) > 0 )//don't compare the minutes and seconds { return null; } } String maxMin = dataBean.getP_latitude_min_max(); String minMin = dataBean.getP_latitude_min_min(); // if(StringUtils.getInstance().hasAValue(maxMin) && StringUtils.getInstance().hasAValue(minMin)) { if(maxMin.compareTo(minMin) < 0 ) { return new ErrorMessage("sil.error.usr.field.greaterthanOrEqual", "Area of Use Latitude Max", "Area of Use Latitude Min"); } else if(maxMin.compareTo(minMin) > 0 )//don't compare the seconds { return null; } } String maxSec = dataBean.getP_latitude_sec_max(); String minSec = dataBean.getP_latitude_sec_min(); if(StringUtils.getInstance().hasAValue(maxSec) && StringUtils.getInstance().hasAValue(minSec)) { if(maxSec.compareTo(minSec) < 0 ) { return new ErrorMessage("sil.error.usr.field.greaterthanOrEqual", "Area of Use Latitude Max", "Area of Use Latitude Min"); } } return null; } }; //Longitude Min private LatLongValidator areaOfUseMinLongitudeValidator = new LatLongValidator(this, new String[]{"p_longitude_deg_min","p_longitude_min_min","p_longitude_sec_min"}, "Area Of Use Min Longitude", "Degrees, Minutes, Seconds", false); private NumericValidator numericAreaOfUseMinLongDegValidator = new NumericValidator(this, "p_longitude_deg_min", "Area of Use Min Longitude Degrees", "sil.error.usr.numeric.int.type", false, false,false); private NumericValidator numericAreaOfUseMinLongMinValidator = new NumericValidator(this, "p_longitude_min_min", "Area of Use Min Longitude Minutes", "sil.error.usr.numeric.int.type", false, false,false); private NumericValidator numericAreaOfUseMinLongSecValidator = new NumericValidator(this, "p_longitude_sec_min", "Area of Use Min Longitude Seconds", "sil.error.usr.numeric.int.type", false, false,false); private IntegerLimitsValidator areaOfUseMinLongMinRange = new IntegerLimitsValidator(this, "p_longitude_min_min","Area of Use Min Longitude Minutes", 0,59, false); private IntegerLimitsValidator areaOfUseMinLongSecRange = new IntegerLimitsValidator(this, "p_longitude_sec_min","Area of Use Min Longitude Seconds", 0,59, false); private IntegerLimitsValidator areaOfUseMinLongDegRange = new IntegerLimitsValidator(this, "p_longitude_deg_min", "Area of Use Min Longitude Degrees", 114, 140, false); //Longitude Max private LatLongValidator areaOfUseMaxLongitudeValidator = new LatLongValidator(this, new String[]{"p_longitude_deg_max","p_longitude_min_max","p_longitude_sec_max"}, "Area Of Use Max Longitude", "Degrees, Minutes, Seconds", false); private NumericValidator numericAreaOfUseMaxLongDegValidator = new NumericValidator(this, "p_longitude_deg_max", "Area of Use Max Longitude Degrees", "sil.error.usr.numeric.int.type", false, false,false); private NumericValidator numericAreaOfUseMaxLongMinValidator = new NumericValidator(this, "p_longitude_min_max", "Area of Use Max Longitude Minutes", "sil.error.usr.numeric.int.type", false, false,false); private NumericValidator numericAreaOfUseMaxLongSecValidator = new NumericValidator(this, "p_longitude_sec_max", "Area of Use Max Longitude Seconds", "sil.error.usr.numeric.int.type", false, false,false); private IntegerLimitsValidator areaOfUseMaxLongMinRange = new IntegerLimitsValidator(this, "p_longitude_min_max","Area of Use Max Longitude Minutes", 0,59, false); private IntegerLimitsValidator areaOfUseMaxLongSecRange = new IntegerLimitsValidator(this, "p_longitude_sec_max","Area of Use Max Longitude Seconds", 0,59, false); private IntegerLimitsValidator areaOfUseMaxLongDegRange = new IntegerLimitsValidator(this, "p_longitude_deg_max", "Area of Use Max Longitude Degrees", 114, 140, false); //Latitude Range private FieldValidator areaOfUseMaxLongGreaterThenMinLongValidator = new FieldValidator() { public ErrorMessage validate() { boolean foundError = false; String maxDeg = dataBean.getP_longitude_deg_max(); String minDeg = dataBean.getP_longitude_deg_min(); if(StringUtils.getInstance().hasAValue(maxDeg) && StringUtils.getInstance().hasAValue(minDeg)) { if(maxDeg.compareTo(minDeg) < 0 ) { return new ErrorMessage("sil.error.usr.field.greaterthanOrEqual", "Area of Use Longitude Max", "Area of Use Longitude Min"); } else if(maxDeg.compareTo(minDeg) > 0 )//don't compare the minutes and seconds { return null; } } String maxMin = dataBean.getP_longitude_min_max(); String minMin = dataBean.getP_longitude_min_min(); if(StringUtils.getInstance().hasAValue(maxMin) && StringUtils.getInstance().hasAValue(minMin)) { if(maxMin.compareTo(minMin) < 0 ) { return new ErrorMessage("sil.error.usr.field.greaterthanOrEqual", "Area of Use Longitude Max", "Area of Use Longitude Min"); } else if(maxMin.compareTo(minMin) > 0 )//don't compare the seconds { return null; } } String maxSec = dataBean.getP_longitude_sec_max(); String minSec = dataBean.getP_longitude_sec_min(); if(StringUtils.getInstance().hasAValue(maxSec) && StringUtils.getInstance().hasAValue(minSec)) { if(maxSec.compareTo(minSec) < 0 ) { return new ErrorMessage("sil.error.usr.field.greaterthanOrEqual", "Area of Use Longitude Max", "Area of Use Longitude Min"); } } return null; } }; //Interim private RequiredUnlessSeedlotStatusIncOrPndValidator interimClientIdRequired = new RequiredUnlessSeedlotStatusIncOrPndValidator(this, "p_interm_strg_client_number", "Interim Agency Number"); private RequiredUnlessSeedlotStatusIncOrPndValidator interimClientLocRequired = new RequiredUnlessSeedlotStatusIncOrPndValidator(this, "p_interm_strg_client_locn", "Interim Agency Location"); private ANDFieldValidator interimAndLocationValidator = new ANDFieldValidator(this, new String[]{"p_interm_strg_client_number", "p_interm_strg_client_locn"}, new String[]{"Interim Agency", "Interim Agency Location"}, "spar.web.error.usr.client.and.location", false); private RequiredUnlessSeedlotStatusIncOrPndValidator interimLocationRequired = new RequiredUnlessSeedlotStatusIncOrPndValidator(this, "p_interm_strg_locn","Interim Storage Location"); private RequiredUnlessSeedlotStatusIncOrPndValidator interimLocationTypeRequired = new RequiredUnlessSeedlotStatusIncOrPndValidator(this, "p_interm_facility_code","Interim Storage Facility Type"); //Either Client Agency Number and Client Agency Location OR //Storage Location information is required if the status is not INC //and date if post CFS standards required private FieldValidator interimAgencyOrLocationRequired = new FieldValidator() { public ErrorMessage validate() { ErrorMessage testAgencyError = null; ErrorMessage testLocationError = null; //required if not pre Cfs standards if(isLotSplitORPreCFSValidationRequired()) { testAgencyError = interimClientIdRequired.validate(); if(testAgencyError == null) { testAgencyError = interimClientLocRequired.validate(); } testLocationError = interimLocationRequired.validate(); if(testAgencyError != null && testLocationError != null) { return new ErrorMessage("sil.error.usr.isrequired", "Either Interim Agency Client Number and Client Location OR Interim Storage Location"); } } return null; } }; private FieldValidator interimLocationTypeRequiredPostCFS = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired()) { return interimLocationTypeRequired.validate(); } return null; } }; private RequiredUnlessSeedlotStatusIncOrPndValidator interimFromDateRequired = new RequiredUnlessSeedlotStatusIncOrPndValidator(this, "p_interm_strg_st_date", "Interim Storage From Date"); private FieldValidator interimFromDateRequiredPostCFS = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired()) { return interimFromDateRequired.validate(); } return null; } }; private RequiredUnlessSeedlotStatusIncOrPndValidator interimToDateRequired = new RequiredUnlessSeedlotStatusIncOrPndValidator(this, "p_interm_strg_end_date","Interim Storage To Date"); private FieldValidator interimToDateRequiredPostCFS = new FieldValidator() { public ErrorMessage validate() { if(isLotSplitORPreCFSValidationRequired()) { return interimToDateRequired.validate(); } return null; } }; private ANDFieldValidator interimFromANDTo = new ANDFieldValidator( this, new String[]{"p_interm_strg_st_date", "p_interm_strg_end_date"}, new String[]{"Interim Storage From Date", "Interim Storage To Date"}, "spar.web.error.usr.field.and", false); private DateValidator interimFromDate = new DateValidator(this, "p_interm_strg_st_date", "Interim Storage From Date", "yyyy-MM-dd", false); private DateValidator interimToDate = new DateValidator(this, "p_interm_strg_end_date", "Interim Storage To Date", "yyyy-MM-dd", false); private DateRangeCompareValidator interimFromLessToDate = new DateRangeCompareValidator (this, "spar.web.error.usr.date.range.flip_or_on", "Interim Storage From Date", "Interim Storage To Date", "yyyy-MM-dd", "p_interm_strg_st_date", "p_interm_strg_end_date", "<=", false); private FieldValidator interimFromLessTodayValidator = new FieldValidator() { public ErrorMessage validate() { if (StringUtils.getInstance().hasAValue(dataBean.getP_interm_strg_st_date())) { //check to make sure date is greater than today. try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String date1 = dataBean.getP_interm_strg_st_date(); String date2 = formatter.format (new Date()); Date d1 = null; Date d2 = null; formatter.parse(date1); formatter.parse(date2); d1 = formatter.parse(date1); d2 = formatter.parse(date2); if (d1.compareTo(d2) >0) // if date greater than today { return new ErrorMessage("spar.web.error.usr.date.format.compare", "Interim Storage From Date", "Today's Date", "<="); } } catch (Exception e) { // leave for validator } } return null; } }; private FieldValidator interimToLessTodayValidator = new FieldValidator() { public ErrorMessage validate() { if (StringUtils.getInstance().hasAValue(dataBean.getP_interm_strg_end_date())) { //check to make sure date is greater than today. try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String date1 = dataBean.getP_interm_strg_end_date(); String date2 = formatter.format (new Date()); Date d1 = null; Date d2 = null; formatter.parse(date1); formatter.parse(date2); d1 = formatter.parse(date1); d2 = formatter.parse(date2); if (d1.compareTo(d2) >0) // if date greater than today { return new ErrorMessage("spar.web.error.usr.date.format.compare", "Interim Storage To Date", "Today's Date", "<="); } } catch (Exception e) { // leave for validator } } return null; } }; /*Extraction*/ private ANDFieldValidator extractionAndLocationValidator = new ANDFieldValidator(this, new String[]{"p_extrct_cli_number", "p_extrct_cli_locn_cd"}, new String[]{"Extractory Agency", "Extractory Agency Location"}, "spar.web.error.usr.client.and.location", false); private ANDFieldValidator extractionFromANDTo = new ANDFieldValidator( this, new String[]{"p_extraction_st_date", "p_extraction_end_date"}, new String[]{"Extraction End Date", "Extraction Start Date"}, "spar.web.error.usr.field.and", false); private DateValidator extractionFromDate = new DateValidator(this, "p_extraction_st_date", "Extraction From Date", "yyyy-MM-dd", false); private DateValidator extractionToDate = new DateValidator(this, "p_extraction_end_date", "Extraction To Date", "yyyy-MM-dd", false); private DateRangeCompareValidator extractionFromLessToDate = new DateRangeCompareValidator (this, "spar.web.error.usr.date.range.flip_or_on", "Extraction Date From", "Extraction Date To", "yyyy-MM-dd", "p_extraction_st_date", "p_extraction_end_date", "<=", false); /*Temporay Seed Storage*/ private ANDFieldValidator seedStorageAndLocationValidator = new ANDFieldValidator(this, new String[]{"p_seed_store_client_number", "p_seed_store_client_locn"}, new String[]{"Seed Storage Agency", "Seed Storage Agency Location"}, "spar.web.error.usr.client.and.location", false); //private ANDFieldValidator seedStorageFromANDTo = new ANDFieldValidator( this, new String[]{"p_temporary_storage_start_date", "p_temporary_storage_end_date"}, new String[]{"Storage Date From", "Storage Date To"}, "spar.web.error.usr.field.and", false); private DateValidator seedStorageFromDate = new DateValidator(this, "p_temporary_storage_start_date", "Storage Date From", "yyyy-MM-dd", false); private DateValidator seedStorageToDate = new DateValidator(this, "p_temporary_storage_end_date", "Storage Date To", "yyyy-MM-dd", false); private DateRangeCompareValidator seedStorageFromLessToDate = new DateRangeCompareValidator (this, "spar.web.error.usr.date.range.flip_or_on", "Storage Date From", "Storage Date To", "yyyy-MM-dd", "p_temporary_storage_start_date", "p_temporary_storage_end_date", "<=", false); //Owner validators private RequiredFieldValidator ownerClientNumberRequired = new RequiredFieldValidator(validateForm, "client_number", "Owner Agency Number"); private RequiredFieldValidator ownerClientAcronymRequired = new RequiredFieldValidator(validateForm, "client_acronym", "Owner Agency Number"); private RequiredFieldValidator ownerClientLocnRequired = new RequiredFieldValidator(validateForm, "client_locn_code", "Owner Agency Location"); private IntegerFieldValidator ownerClientLocnInteger = new IntegerFieldValidator(validateForm, "client_locn_code" , "Owner Agency Location", false); private RequiredFieldValidator ownerPortionRequired = new RequiredFieldValidator(validateForm, "original_pct_owned", "Owner Portion"); private FloatFieldValidator ownerPortionFloat = new FloatFieldValidator(validateForm, "original_pct_owned", "Owner Portion", false); private FloatRangeValidator ownerPortionRange = new FloatRangeValidator(validateForm, "original_pct_owned", "Owner Portion", 0.0, 100, false, false); private RequiredFieldValidator ownerReservedRequired = new RequiredFieldValidator(validateForm, "original_pct_rsrvd", "Owner Portion"); private FloatFieldValidator ownerReservedFloat = new FloatFieldValidator(validateForm, "original_pct_rsrvd", "Owner Reserved %", false); private FloatRangeValidator ownerReservedRange = new FloatRangeValidator(validateForm, "original_pct_rsrvd", "Owner Reserved", 0.0, 100, false, false); private RequiredFieldValidator ownerSurplusRequired = new RequiredFieldValidator(validateForm, "original_pct_srpls", "Owner Portion"); private FloatFieldValidator ownerSurplusFloat = new FloatFieldValidator(validateForm, "original_pct_srpls", "Owner Surplus %", false); private FloatRangeValidator ownerSurplusRange = new FloatRangeValidator(validateForm, "original_pct_srpls", "Owner Surplus", 0.0, 100, false, false); private ValidatingForm saveForm = new ValidatingForm() { public DataBean getBean() { return dataBean; } public String getUserAction() { return userAction(); } }; public String userAction() { return userAction; } /* Container Inner Classes and validators*/ private ClientFieldContainer applicantAgencyDisplayFieldContainer = new ClientFieldContainer () { public String getP_client_id() { return dataBean.getP_applicant_client_number(); } public String getP_locn_code() { return dataBean.getP_applicant_client_locn(); } public String getP_client_acronym() { return dataBean.getP_applicant_client_acroynm(); } public void setP_locn_code(String val) { dataBean.setP_applicant_client_locn(val); } public void setP_client_id(String val) { dataBean.setP_applicant_client_number(val); } public void setP_client_acronym(String val) {dataBean.setP_applicant_client_acroynm(val); } public SilUser getUser() { return getSilUser(); } }; private ClientFieldContainer coneCollectorAgencyDisplayFieldContainer = new ClientFieldContainer () { public String getP_client_id() { return dataBean.getP_collection_cli_number(); } public String getP_locn_code() { return dataBean.getP_collection_cli_locn_cd(); } public String getP_client_acronym() { return dataBean.getP_collection_cli_acroynm(); } public void setP_locn_code(String val) { dataBean.setP_collection_cli_locn_cd(val); } public void setP_client_id(String val) { dataBean.setP_collection_cli_number(val); } public void setP_client_acronym(String val) {dataBean.setP_collection_cli_acroynm(val); } public SilUser getUser() { return getSilUser(); } }; private ClientFieldContainer interimStorageAgencyDisplayFieldContainer = new ClientFieldContainer () { public String getP_client_id() { return dataBean.getP_interm_strg_client_number(); } public String getP_locn_code() { return dataBean.getP_interm_strg_client_locn(); } public String getP_client_acronym() { return dataBean.getP_interm_strg_client_acronym(); } public void setP_locn_code(String val) { dataBean.setP_interm_strg_client_locn(val); } public void setP_client_id(String val) { dataBean.setP_interm_strg_client_number(val); } public void setP_client_acronym(String val) {dataBean.setP_interm_strg_client_acronym(val); } public SilUser getUser() { return getSilUser(); } }; private ClientFieldContainer extractoryAgencyDisplayFieldContainer = new ClientFieldContainer () { public String getP_client_id() { return dataBean.getP_extrct_cli_number(); } public String getP_locn_code() { return dataBean.getP_extrct_cli_locn_cd(); } public String getP_client_acronym() { return dataBean.getP_extrct_cli_acronym(); } public void setP_locn_code(String val) { dataBean.setP_extrct_cli_locn_cd(val); } public void setP_client_id(String val) { dataBean.setP_extrct_cli_number(val); } public void setP_client_acronym(String val) {dataBean.setP_extrct_cli_acronym(val); } public SilUser getUser() { return getSilUser(); } }; private ClientFieldContainer seedStorageAgencyDisplayFieldContainer = new ClientFieldContainer () { public String getP_client_id() { return dataBean.getP_seed_store_client_number(); } public String getP_locn_code() { return dataBean.getP_seed_store_client_locn(); } public String getP_client_acronym() { return dataBean.getP_seed_store_client_acronym(); } public void setP_locn_code(String val) { dataBean.setP_seed_store_client_locn(val); } public void setP_client_id(String val) { dataBean.setP_seed_store_client_number(val); } public void setP_client_acronym(String val) {dataBean.setP_seed_store_client_acronym(val); } public SilUser getUser() { return getSilUser(); } }; //BECFieldContainer Implementation private BECFieldContainer becContainer = new BECFieldContainer() { public String getP_bec_id(){return dataBean.getP_bgc_zone_code();} public String getP_zone(){return dataBean.getP_bgc_zone_code();} public String getP_subzone(){return dataBean.getP_bgc_subzone_code();} public String getP_variant(){return dataBean.getP_variant();} public void setP_bec_id(String val) {dataBean.setP_bgc_zone_code(val);} public void setP_zone(String val ){ dataBean.setP_bgc_zone_code(val);} public void setP_subzone( String val ){ dataBean.setP_bgc_subzone_code(val);} public void setP_variant(String val){ dataBean.setP_variant(val);} public String getUserid(){return user().getName();} }; private ValidatingClientDisplayField applicantAgencyDisplayField; private ValidatingClientDisplayField coneCollectorAgencyDisplayField; private ValidatingClientDisplayField interimStorageAgencyDisplayField; private ValidatingClientDisplayField extractoryAgencyDisplayField; private ValidatingClientDisplayField seedStorageAgencyDisplayField; private ValidatingBECDisplayField becDisplayField = new ValidatingBECDisplayField(becContainer); public void initClientContainers(HttpServletRequest request) { CodesManager codesManager = CodesManager.get( request.getSession()); //client containers applicantAgencyDisplayField = new ValidatingClientDisplayField( applicantAgencyDisplayFieldContainer, codesManager, "Applicant Agency", "Applicant Agency Location"); coneCollectorAgencyDisplayField = new ValidatingClientDisplayField( coneCollectorAgencyDisplayFieldContainer, codesManager, "Cone Collector Agency", "Cone Collector Agency Location"); interimStorageAgencyDisplayField = new ValidatingClientDisplayField( interimStorageAgencyDisplayFieldContainer, codesManager, "Interim Agency", "Interim Agency Location"); extractoryAgencyDisplayField = new ValidatingClientDisplayField( extractoryAgencyDisplayFieldContainer, codesManager, "Extraction Agency", "Extraction Agency Location"); seedStorageAgencyDisplayField = new ValidatingClientDisplayField( seedStorageAgencyDisplayFieldContainer, codesManager, "Seed Storage Agency", "Seed Storage Agency Location"); } public void initCodesListsAndCodeValidators(HttpServletRequest request) { CodesManager codesManager = CodesManager.get( request.getSession()); //Initiliaze drop downs seedlotStatusCodes = codesManager.getCodes("SEEDLOT_STATUS_ENTERABLE"); speciesCodes = codesManager.getCodes("VEGETATION"); geneticClassCodes = codesManager.getCodes("GENETIC_CLASS"); seedlotSourceCodes = codesManager.getCodes("SEEDLOT_SOURCE"); orgUnitCodes = codesManager.getCodes("ORG_UNIT"); provenanceCodes = codesManager.getCodes("PROVENANCE_ALL"); //unfiltered list for expiry code validation geoCodes = codesManager.getCodes("SEED_COAST_AREA"); collectionMethodCodes = codesManager.getCodes("CONE_COLLECTION_METHOD"); latCodes = codesManager.getCodes("COLLECTION_LATITUDE"); longCodes = codesManager.getCodes("COLLECTION_LONGITUDE"); numTreesCollectedFrom = codesManager.getCodes("NMBR_TREES_FROM"); spzACodes = codesManager.getCodes("SEED_PLAN_ZONEA"); spzBCodes = codesManager.getCodes("SEED_PLAN_ZONEB"); storageFaciltyTypeCodes = codesManager.getCodes("INTERM_FACILITY"); fundingSourceCodes = codesManager.getCodes("SPAR_FUND_SRCE_SHORTDESC"); paymentMethodCodes = codesManager.getCodes("METHOD_OF_PAYMENT_SHORT"); corpCaptureMethodCodes = codesManager.getCodes("CORP_CAPTURE_MTHD"); //Initialize illegal String[] seedlotStatusCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])seedlotStatusCodes); speciesCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])speciesCodes); geneticClassCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])geneticClassCodes); provenanceCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])provenanceCodes); seedlotSourceCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])seedlotSourceCodes); orgUnitCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])orgUnitCodes); geoCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])geoCodes); collectionMethodCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])collectionMethodCodes); latCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])latCodes); longCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])longCodes); numTreesCollectedFromIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])numTreesCollectedFrom); spzBCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])spzBCodes); spzACodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])spzACodes); storageFaciltyTypeCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])storageFaciltyTypeCodes); fundingSourceCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])fundingSourceCodes); paymentMethodCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])paymentMethodCodes); corpCaptureMethodCodesIllegalValues = CodeExpiryValidator.extractIllegalValues((SparCodeBean[])corpCaptureMethodCodes); //Initialize Code Validators seedlotStatusCodesValidator = new CodeExpiryValidator(this, "p_seedlot_status_code", "Status", seedlotStatusCodesIllegalValues); spzBCodesValidator = new CodeExpiryValidator(this, "p_seed_plan_zone_code", "Seed Planning Zone of Collection Area", spzBCodesIllegalValues); speciesCodesValidator = new CodeExpiryValidator(this, "p_vegetation_code", "Species", speciesCodesIllegalValues); geneticClassCodesValidator = new CodeExpiryValidator(this, "p_genetic_class_code", "Genetic Class", geneticClassCodesIllegalValues); provenanceCodesValidator = new CodeExpiryValidator(this, "p_provenance_id", "Collection Provenance", provenanceCodesIllegalValues); seedlotSourceCodesValidator = new CodeExpiryValidator(this, "p_seedlot_source_code", "Class A Source", seedlotSourceCodesIllegalValues); orgUnitCodesValidator = new CodeExpiryValidator(this, "p_org_unit_no", "Collection Org Unit", orgUnitCodesIllegalValues); geoCodesValidator = new CodeExpiryValidator(this, "p_seed_coast_area_code", "Geographic Area", geoCodesIllegalValues); collectionMethodCodesValidator = new CodeExpiryValidator(this, "p_cone_collection_method_code", "Collection Method", collectionMethodCodesIllegalValues); latCodesValidator = new CodeExpiryValidator(this, "p_collection_latitude_code", "Collection Latitude Code", latCodesIllegalValues); longCodesValidator = new CodeExpiryValidator(this, "p_collection_longitude_code", "Collection Latitude Code",longCodesIllegalValues); numTreesCollectedFromValidator = new CodeExpiryValidator(this, "p_nmbr_trees_from_code", "No. Trees Collected From", numTreesCollectedFromIllegalValues); storageFaciltyTypeCodesValidator = new CodeExpiryValidator(this, "p_interm_facility_code", "Storage Facility Type", storageFaciltyTypeCodesIllegalValues); corpCaptureMethodCodesValidator = new CodeExpiryValidator(this, "p_capture_method_code", "Capture Method", corpCaptureMethodCodesIllegalValues); } public void loadSaveValidators() { addValidator("Save", seedlotNumberEntryUpdateValidation); addValidator("Save", seedlotRequiredForExistingRecords); addValidator("Save", seedlotNumberNumeric); addValidator("Save", toBeRegisteredRequired); addValidator("Save", statusRequired); addValidator("Save", allowableStatusValues); addValidator("Save", speciesRequired); addValidator("Save", geneticCodeRequired); addValidator("Save", superiorProvenanceFormBRequired); addValidator("Save", classASourceFormARequired); addValidator("Save", bcSourceCFSStanadardRequired); addValidatorChain( "Save", new FieldValidator[]{applicantAgencyDisplayField, applicantClientNumberCFSStanadardRequired} ); addValidator("Save", applicantEmailValidation); addValidator("Save", applicantClientLocationCFSStanadardRequired); addValidator("Save", applicantClientLocnInteger); addValidator("Save", gw_gIntegerAndRangeValidator); addValidator("Save", gw_dIntegerAndRangeValidator); addValidator("Save", gw_rIntegerAndRangeValidator); addValidator("Save", gw_mIntegerAndRangeValidator); addValidator("Save", CFSMetRequired); addValidator("Save", collectionOrgUnitFormBValidate); addValidator("Save", effectivePopSizeFormAValidate); addValidator("Save", collectionProvenanceFormBValidate); addValidator("Save", collectionLocationFormBValidate); addValidator("Save", orchardRequired); addValidator("Save", orchardValid); addValidator("Save", seedPlanUnitRequired); //Elevation validation addValidator("Save", requiredElevationMeanValidator); addValidator("Save", numericElevationMeanValidator); addValidator("Save", rangeElevationMeanValidator); addValidator("Save", collectionElevMaxFormBRequired); addValidator("Save", collectionElevationMaxFormBValidate); addValidator("Save", collectionElevMinFormBRequired); addValidator("Save", collectionElevationMinFormBValidate); addValidator("Save", collectionElevationMinMeanFormBValidate); addValidator("Save", collectionElevationMaxMeanFormBValidate); addValidator("Save", collectionRadiusFormBValidate); addValidator("Save", collectionRadiusFloat); addValidator("Save", collectionRadiusRange); //Collection Lat addValidator("Save", latitudeValidatorRequired); addValidator("Save", numericLatitudeDegValidator); addValidator("Save", numericLatitudeMinValidator); addValidator("Save", numericLatitudeSecValidator); addValidator("Save", latitudeDegreesRangeValidation); addValidator("Save", rangeLatitudeMinValidator); addValidator("Save", rangeLatitudeSecValidator); addValidator("Save", collectionLatitudeCodeRequiredFormB); //Collection Long addValidator("Save", longitudeValidatorRequired); addValidator("Save", numericLongitudeDegValidator); addValidator("Save", numericLongitudeMinValidator); addValidator("Save", numericLongitudeSecValidator); addValidator("Save", longitudeDegreesRangeValidation); addValidator("Save", rangeLongitudeMinValidator); addValidator("Save", rangeLongitudeSecValidator); addValidator("Save", collectionLongitudeCodeRequiredFormB); addValidator("Save", longAndLatRequiredForCaptureMethod); addValidator("Save", collectionSpzAreaRequiredFormB); addValidator("Save", collectionAllFromSameSpzRequiredFormB); addValidator("Save", geographicAreaRequiredFormB); //BGC Zone, Sub Zone, Variant addValidator("Save", bgcZoneRequiredFormB); addValidator("Save", collectionAllFromSameBgcZoneRequiredFormB); addValidator("Save", becOverrideEntryRequiredValidation); //Collection Date Validators addValidator("Save",collectionStartDateRequired); addValidator("Save",collectionEndDateRequired); addValidator("Save",collectionStartDate); addValidator("Save",collectionStartlessTodayValidator); addValidator("Save",collectionEndlessTodayValidator); addValidator("Save",collectionStartLessEndDate); addValidator("Save",collectionStartANDEndStatusNotINC); addValidator("Save",collectionEndDate); //Collection Method addValidator("Save",collectionMethodRequired); addValidator("Save",collectionMethodDuplicateValidation); addValidator("Save",noTreesCollectedRequiredFormB); addValidator("Save",noContainersRequired); addValidator("Save",noContainersFloat); addValidator("Save",noContainersRange); addValidator("Save", volumeContainersRequired); addValidator("Save", volumeContainersFloat); addValidator("Save", volumeContainersRange); addValidator("Save", volumeConesRequired); addValidator("Save", volumeConesFloat); addValidator("Save", volumeConesRange); addValidator("Save", commentsValidate); addValidator("Save", commentsLength); addValidatorChain( "Save", new FieldValidator[]{coneCollectorAgencyDisplayField, coneCollectorAndLocationValidator, coneCollectorAgencyId} ); addValidator( "Save",coneCollectorAgencyLoc); /*Area of use */ addValidator("Save", spzDuplicateValidation); addValidator("Save", ownershipCommentsLength); //Elevation addValidator("Save", numericAreaofUseElevationMinValidator); addValidator("Save", numericAreaofUseElevationMaxValidator); addValidator("Save", areaofUseElevMinRange); addValidator("Save", areaofUseElevMaxRange); addValidator("Save", areaofUseMaxGreaterMin); //Latitude addValidator("Save", areaOfUseMinLatitudeValidator); addValidator("Save", numericAreaOfUseMinLatDegValidator); addValidator("Save", numericAreaOfUseMinLatMinValidator); addValidator("Save", numericAreaOfUseMinLatSecValidator); addValidator("Save", areaOfUseMinLatMinRange); addValidator("Save", areaOfUseMinLatSecRange); addValidator("Save", areaOfUseMinLatDegRange); addValidator("Save", areaOfUseMaxLatitudeValidator); addValidator("Save", numericAreaOfUseMaxLatDegValidator); addValidator("Save", numericAreaOfUseMaxLatMinValidator); addValidator("Save", numericAreaOfUseMaxLatSecValidator); addValidator("Save", areaOfUseMaxLatMinRange); addValidator("Save", areaOfUseMaxLatSecRange); addValidator("Save", areaOfUseMaxLatDegRange); addValidator("Save", areaOfUseMaxLatGreaterThenMinLatValidator); //Lonitude addValidator("Save", areaOfUseMinLongitudeValidator); addValidator("Save", numericAreaOfUseMinLongDegValidator); addValidator("Save", numericAreaOfUseMinLongMinValidator); addValidator("Save", numericAreaOfUseMinLongSecValidator); addValidator("Save", areaOfUseMinLongMinRange); addValidator("Save", areaOfUseMinLongSecRange); addValidator("Save", areaOfUseMinLongDegRange); addValidator("Save", areaOfUseMaxLongitudeValidator); addValidator("Save", numericAreaOfUseMaxLongDegValidator); addValidator("Save", numericAreaOfUseMaxLongMinValidator); addValidator("Save", numericAreaOfUseMaxLongSecValidator); addValidator("Save", areaOfUseMaxLongMinRange); addValidator("Save", areaOfUseMaxLongSecRange); addValidator("Save", areaOfUseMaxLongDegRange); addValidator("Save", areaOfUseMaxLongGreaterThenMinLongValidator); /*Interim*/ addValidatorChain( "Save", new FieldValidator[]{interimStorageAgencyDisplayField, interimAndLocationValidator, interimAgencyOrLocationRequired} ); addValidator("Save", interimLocationTypeRequiredPostCFS); addValidator("Save", interimFromDateRequiredPostCFS); addValidator("Save", interimToDateRequiredPostCFS); addValidator("Save", interimFromANDTo); addValidator("Save", interimFromDate); addValidator("Save", interimToDate); addValidator("Save", interimFromLessToDate); addValidator("Save", interimFromLessTodayValidator); addValidator("Save", interimToLessTodayValidator); /*Extraction AND Seed Storage*/ addValidatorChain( "Save", new FieldValidator[]{extractoryAgencyDisplayField, extractionAndLocationValidator} ); addValidator("Save", extractionFromANDTo); addValidator("Save", extractionFromDate); addValidator("Save", extractionToDate); addValidator("Save", extractionFromLessToDate); addValidatorChain( "Save", new FieldValidator[]{seedStorageAgencyDisplayField, seedStorageAndLocationValidator} ); //addValidator("Save", seedStorageFromANDTo); addValidator("Save", seedStorageFromDate); addValidator("Save", seedStorageToDate); addValidator("Save", seedStorageFromLessToDate); } /*RECALCULATION - Only validate data types and relational validation*/ public void loadRecalcValidators() { addValidator("Recalc", seedlotNumberEntryUpdateValidation); addValidator("Recalc", seedlotRequiredForExistingRecords); addValidator("Recalc", seedlotNumberNumeric); // addValidator("Recalc", speciesRequired); addValidator("Recalc", effectivePopSizeFormAValidate); addValidator("Recalc", gw_gIntegerAndRangeValidator); addValidator("Recalc", gw_dIntegerAndRangeValidator); addValidator("Recalc", gw_rIntegerAndRangeValidator); addValidator("Recalc", gw_mIntegerAndRangeValidator); addValidator("Recalc", numericElevationMeanValidator); addValidator("Recalc", rangeElevationMeanValidator); addValidator("Recalc", collectionElevationMaxFormBValidate); addValidator("Recalc", collectionElevationMinFormBValidate); addValidator("Recalc", collectionElevationMinMeanFormBValidate); addValidator("Recalc", collectionElevationMaxMeanFormBValidate); addValidator("Recalc", collectionRadiusFloat); addValidator("Recalc", collectionRadiusRange); // addValidator("Recalc", latitudeValidatorRequired); addValidator("Recalc", numericLatitudeDegValidator); addValidator("Recalc", numericLatitudeMinValidator); addValidator("Recalc", numericLatitudeSecValidator); addValidator("Recalc", latitudeDegreesRangeValidation); // addValidator("Recalc", longitudeValidatorRequired); addValidator("Recalc", rangeLatitudeMinValidator); addValidator("Recalc", rangeLatitudeSecValidator); addValidator("Recalc", numericLongitudeDegValidator); addValidator("Recalc", numericLongitudeMinValidator); addValidator("Recalc", numericLongitudeSecValidator); addValidator("Recalc", longitudeDegreesRangeValidation); addValidator("Recalc", rangeLongitudeMinValidator); addValidator("Recalc", rangeLongitudeSecValidator); addValidator("Recalc", collectionStartDate); addValidator("Recalc", collectionEndDate); addValidator("Recalc", noContainersFloat); addValidator("Recalc", noContainersRange); addValidator("Recalc", volumeContainersFloat); addValidator("Recalc", volumeContainersRange); addValidator("Recalc", volumeConesFloat); addValidator("Recalc", volumeConesRange); addValidator("Recalc", commentsValidate); addValidator("Recalc", commentsLength); addValidator("Recalc", numericAreaofUseElevationMinValidator); addValidator("Recalc", numericAreaofUseElevationMaxValidator); addValidator("Recalc", areaofUseElevMinRange); addValidator("Recalc", areaofUseElevMaxRange); addValidator("Recalc", numericAreaOfUseMinLatDegValidator); addValidator("Recalc", numericAreaOfUseMinLatMinValidator); addValidator("Recalc", numericAreaOfUseMinLatSecValidator); addValidator("Recalc", areaOfUseMinLatMinRange); addValidator("Recalc", areaOfUseMinLatSecRange); addValidator("Recalc", areaOfUseMinLatDegRange); addValidator("Recalc", numericAreaOfUseMaxLatDegValidator); addValidator("Recalc", numericAreaOfUseMaxLatMinValidator); addValidator("Recalc", numericAreaOfUseMaxLatSecValidator); addValidator("Recalc", areaOfUseMaxLatMinRange); addValidator("Recalc", areaOfUseMaxLatSecRange); addValidator("Recalc", areaOfUseMaxLatDegRange); addValidator("Recalc", numericAreaOfUseMinLongDegValidator); addValidator("Recalc", numericAreaOfUseMinLongMinValidator); addValidator("Recalc", numericAreaOfUseMinLongSecValidator); addValidator("Recalc", areaOfUseMinLongMinRange); addValidator("Recalc", areaOfUseMinLongSecRange); addValidator("Recalc", areaOfUseMinLongDegRange); addValidator("Recalc", numericAreaOfUseMaxLongDegValidator); addValidator("Recalc", numericAreaOfUseMaxLongMinValidator); addValidator("Recalc", numericAreaOfUseMaxLongSecValidator); addValidator("Recalc", areaOfUseMaxLongMinRange); addValidator("Recalc", areaOfUseMaxLongSecRange); addValidator("Recalc", areaOfUseMaxLongDegRange); addValidator("Recalc", interimFromDate); addValidator("Recalc", interimToDate); addValidator("Recalc", extractionFromDate); addValidator("Recalc", extractionToDate); addValidator("Recalc", seedStorageFromDate); addValidator("Recalc", seedStorageToDate); } public void loadSeedMapLinkValidators() { /* Map Collection Site validations */ addValidator("seedMapLinkCol", seedlotNumberEntryUpdateValidation); addValidator("seedMapLinkCol", seedlotRequiredForExistingRecords); //Collection Lat addValidator("seedMapLinkCol", collectionLatValidatorStatusNotInc); addValidator("seedMapLinkCol", numericLatitudeDegValidator); addValidator("seedMapLinkCol", numericLatitudeMinValidator); addValidator("seedMapLinkCol", numericLatitudeSecValidator); addValidator("seedMapLinkCol", latitudeDegreesRangeValidation); addValidator("seedMapLinkCol", rangeLatitudeMinValidator); addValidator("seedMapLinkCol", rangeLatitudeSecValidator); //Collection Long addValidator("seedMapLinkCol", collectionLongValidatorStatusNotInc); addValidator("seedMapLinkCol", numericLongitudeDegValidator); addValidator("seedMapLinkCol", numericLongitudeMinValidator); addValidator("seedMapLinkCol", numericLongitudeSecValidator); addValidator("seedMapLinkCol", longitudeDegreesRangeValidation); addValidator("seedMapLinkCol", rangeLongitudeMinValidator); addValidator("seedMapLinkCol", rangeLongitudeSecValidator); /* Map Area of Use validations */ addValidator("seedMapLinkAou", seedlotNumberEntryUpdateValidation); addValidator("seedMapLinkAou", seedlotRequiredForExistingRecords); /* Collection Area Polygon validations */ addValidator("seedMapLinkColArea", seedlotNumberEntryUpdateValidation); addValidator("seedMapLinkColArea", seedlotRequiredForExistingRecords); //Collection Lat addValidator("seedMapLinkColArea", collectionLatValidatorStatusNotInc); addValidator("seedMapLinkColArea", numericLatitudeDegValidator); addValidator("seedMapLinkColArea", numericLatitudeMinValidator); addValidator("seedMapLinkColArea", numericLatitudeSecValidator); addValidator("seedMapLinkColArea", latitudeDegreesRangeValidation); addValidator("seedMapLinkColArea", rangeLatitudeMinValidator); addValidator("seedMapLinkColArea", rangeLatitudeSecValidator); //Collection Long addValidator("seedMapLinkColArea", collectionLongValidatorStatusNotInc); addValidator("seedMapLinkColArea", numericLongitudeDegValidator); addValidator("seedMapLinkColArea", numericLongitudeMinValidator); addValidator("seedMapLinkColArea", numericLongitudeSecValidator); addValidator("seedMapLinkColArea", longitudeDegreesRangeValidation); addValidator("seedMapLinkColArea", rangeLongitudeMinValidator); addValidator("seedMapLinkColArea", rangeLongitudeSecValidator); } public void initFromRequest(HttpServletRequest request) { super.initFromRequest(request); if ( !validatorsInitialized ) { CodesManager codesManager = CodesManager.get( request.getSession() ); initCodesListsAndCodeValidators(request); initClientContainers(request); orchardValid = new DBFieldValidator(this, "p_orchard_id", "Orchard ID", "spar.lookup.orchard", codesManager, false); addValidator("Go", seedlotNumberRequired); addValidator("Go", seedlotNumberNumeric); addValidator("Cancel Lot", seedlotNumberEntryUpdateValidation); addValidator("Cancel Lot", seedlotNumberRequired); addValidator("Cancel Lot", seedlotNumberNumeric); addValidator("Copy Seedlot", seedlotNumberEntryUpdateValidation); addValidator("defaultSpzs", collectionLatValidatorStatusNotInc); addValidator("defaultSpzs", collectionLongValidatorStatusNotInc); loadSaveValidators(); loadRecalcValidators(); loadSeedMapLinkValidators(); //Set role based flags try { setRoleBasedPermissions(); } catch (Exception e) { e.printStackTrace(); } validatorsInitialized = true; } // clear-out the seedmap url for every refresh of the screen, or the seedMap screen will pop-up all the time. setSeedMapLink(""); setDisplaySeedmapWarning(false); } public void validateOwners(ActionErrors actionErrors) { int displayRowNumber = 0; float totalOwnerPortion = 0; // Flag to keep track of blank payment methods. This will be set to // true if any of the owner records. boolean hasBlankPaymentMethod = false; // Flag to keep track of blank funding sources. This will be set to // true if any of the owner records. boolean hasBlankFundingSource = false; //loop through and validate each item for (int i = 0; i < this.getDataBean().getItems().size(); i++) { Spr001SeedlotRegBean validateBean = (Spr001SeedlotRegBean) this.getDataBean().getItems().toArray()[i]; this.setItemBean(validateBean); displayRowNumber = i + 1; boolean portionisNumeric = true; boolean reservedIsNumeric = true; boolean surplusIsNumeric = true; //Only validate if there is data. //No data means the row is marked for deletion if(checkOwnerDataExists(validateBean)) { //We populate client id with either client number or client acronym but not both if(ownerClientNumberRequired.validate() != null && ownerClientAcronymRequired.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.field.missing.row", ""+displayRowNumber, "Owner Client Id"), actionErrors); } if(ownerClientLocnRequired.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.field.missing.row", ""+displayRowNumber, "Owner Client Location"), actionErrors); } if(ownerClientLocnInteger.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.numeric.float.type.row2", ""+displayRowNumber, "Owner Client Location"), actionErrors); } if(ownerPortionRequired.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.field.missing.row", ""+displayRowNumber, "Owner Client Portion"), actionErrors); } else if(ownerPortionFloat.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.numeric.float.type.row2", ""+displayRowNumber, "Owner Client Portion"), actionErrors); portionisNumeric = false; } else if(ownerPortionRange.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.field.range3.row", ""+displayRowNumber, "Owner Client Portion", "0 - 100"), actionErrors); } //owner reserved must be a valid float, and be within the alloted range if(ownerReservedRequired.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.field.missing.row", ""+displayRowNumber, "Owner Client Reserved"), actionErrors); reservedIsNumeric = false; } else if(ownerReservedFloat.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.numeric.float.type.row2", ""+displayRowNumber, "Owner Client Reserved"), actionErrors); reservedIsNumeric = false; } else if(ownerReservedRange.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.field.range3.row", ""+displayRowNumber, "Owner Client Reserved", "0 - 100"), actionErrors); } //owner surplus must be a valid float, and be within the alloted range if(ownerSurplusRequired.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.field.missing.row", ""+displayRowNumber, "Owner Client Surplus"), actionErrors); surplusIsNumeric = false; } if(ownerSurplusFloat.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.numeric.float.type.row2", ""+displayRowNumber, "Owner Client Surplus"), actionErrors); surplusIsNumeric = false; } else if(ownerSurplusRange.validate() != null) { checkForError(new ErrorMessage("spar.web.error.usr.field.range3.row", ""+displayRowNumber, "Owner Client Surplus", "0 - 100"), actionErrors); } // Update the flags if (!StringUtils.getInstance().hasAValue(validateBean.getMethod_of_payment_code())) { hasBlankFundingSource = true; } if (!StringUtils.getInstance().hasAValue(validateBean.getSpar_fund_srce_code())) { hasBlankPaymentMethod = true; } //reserve and surplus must add up to 100 if(reservedIsNumeric && surplusIsNumeric) { try { float pct_rsrvd = Float.parseFloat(validateBean.getOriginal_pct_rsrvd()); float pct_srpls = Float.parseFloat(validateBean.getOriginal_pct_srpls()); if((pct_rsrvd + pct_srpls) != 100.00) { checkForError(new ErrorMessage("spar.web.error.usr.reserve_surplus.total.error", ""+displayRowNumber), actionErrors); } } catch(NumberFormatException nfe) { //do nothing it is an empty value. Validators have already ensured //that it is not an alphNumeric number } } //total of all portions must equal 100 if(portionisNumeric) { try { totalOwnerPortion = totalOwnerPortion + Float.parseFloat(validateBean.getOriginal_pct_owned()); } catch(NumberFormatException nfe) { //do nothing it is an empty value. Validators have already ensured //that it is not an alphNumeric number } } //validate owner expired codes if(i < originalMethOfPayment.length) //existing record { if(! validateBean.getMethod_of_payment_code().equals(this.originalMethOfPayment[i])) { for(int j=0; j < paymentMethodCodesIllegalValues.length; j++) { if(validateBean.getMethod_of_payment_code().equals(paymentMethodCodesIllegalValues[j])) { /* boolean postApprovalDateExp = false; if(StringUtils.getInstance().hasAValue(dataBean.getP_approved_date())) { for(int k=0; k 0 && totalOwnerPortion != 100) { checkForError(new ErrorMessage("spar.web.error.usr.owner.portion.total.error"), actionErrors); } // Validate that there are no owner rows with a blank payment method or // funding source if the status is APP or COM. if (!this.isPreCFSStandardForm() && (dataBean.getP_seedlot_status_code().equals("APP") || dataBean.getP_seedlot_status_code().equals("COM")) && (hasBlankFundingSource || hasBlankPaymentMethod)) { checkForError(new ErrorMessage("spar.web.error.usr.owner.no_blank_fund_source_or_payment_method"), actionErrors); } } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) { SessionSnoop snoop = new SessionSnoop(request.getSession()); snoop.showRequest(request); //forceFormat before we validate forceFormats(); // Get the errors that were populated from the super-class ErrorHandler eh = HttpErrorHandler.get(request.getSession()); ActionErrors actionErrors = eh.getErrors(); if (userAction!= null && (userAction.equals("Save") || userAction.equals("Recalc")) && StringUtils.getInstance().hasAValue(dataBean.getP_revision_count())) { //Expired Code validation checkForError(seedlotStatusCodesValidator.validate(), actionErrors); checkForError(spzBCodesValidator.validate(), actionErrors); checkForError(speciesCodesValidator.validate(), actionErrors); checkForError(geneticClassCodesValidator.validate(), actionErrors); checkForError(seedlotSourceCodesValidator.validate(), actionErrors); checkForError(orgUnitCodesValidator.validate(), actionErrors); checkForError(geoCodesValidator.validate(), actionErrors); checkForError(collectionMethodCodesValidator.validate(), actionErrors); checkForError(longCodesValidator.validate(), actionErrors); checkForError(latCodesValidator.validate(), actionErrors); checkForError(numTreesCollectedFromValidator.validate(), actionErrors); checkForError(storageFaciltyTypeCodesValidator.validate(), actionErrors); checkForError(provenanceCodesValidator.validate(), actionErrors); checkForError(corpCaptureMethodCodesValidator.validate(), actionErrors); //spz code validation if(validateSpzValues()) { checkForError(new ErrorMessage("sil.web.error.usr.code-expired", "One or more of the newly selected SPZ codes"), actionErrors); } } // Save needs to validate result list for existing records if(userAction!= null && userAction.equals("Save") && StringUtils.getInstance().hasAValue(dataBean.getP_revision_count())) { /* DO NOT REMOVE THE SETTER OF THE CONTAINER HERE!! The order of the paramters in the request that struts is calling setters violates the rule that the variant must be set last. Therefore we are calling the setters here and reading the values from the request inorder for the container to work properly. Don't know why we have to do this as lotsearch works just fine. The reason the set to blank is done first is so that there are no old values around. This can cause wrong errors to come out of the container*/ becDisplayField.setZone(""); becDisplayField.setSubzone(""); becDisplayField.setVariant(""); becDisplayField.setZone(request.getParameter("becDisplayField.zone")); becDisplayField.setSubzone(request.getParameter("becDisplayField.subzone")); becDisplayField.setVariant(request.getParameter("becDisplayField.variant")); checkForError(becDisplayField.validate(), actionErrors); // populate result list from the request try { populateResultList(actionMapping, request); } catch(Exception ex) { ex.printStackTrace(); } validateOwners(actionErrors); }//end if save action // super.validate will populate the errors in the session super.validate(actionMapping, request); if (eh != null && eh.hasErrors()) { if(userAction.equalsIgnoreCase("Recalc")) { this.setOriginalValidationFields(true); this.setErrorsOnRecalc("Y"); } } else { //if this is the first time we are trying to save with SUB as the status //and we have no errors set the condition to prompt for the declared checkbox //to be checked if( userAction.equalsIgnoreCase("Save") && ! StringUtils.getInstance().hasAValue(dataBean.getP_declared_userid()) && dataBean.getP_seedlot_status_code().equalsIgnoreCase("SUB") && ! this.originalSeedlotStatus.equalsIgnoreCase("SUB")) { setDeclarationCheckBoxEnabled(true); } else { setDeclarationCheckBoxEnabled(false); } } //always reset the jspFocus this.setJspFocus(""); // Put the error handler back. try { HttpErrorHandler.put(request.getSession(), eh); } catch (SessionKeyInUseException e) { // Don't worry about it. } return actionErrors; } /** * Maps the values from the request back into our dataBean. * Needed because we need to validate the user values entered on the screen and * map those values back into our list in our bean. * * This method tests to see if the row has been blanked out and marked for deletion */ public void populateResultList(ActionMapping actionMapping, HttpServletRequest request) throws Exception { String[] clientId = null; String[] clientNumber = null; String[] clientAcronym = null; String[] clientLocnCode = null; String[] clientName = null; String[] originalPctOwned = null; String[] originalPctRsrvd = null; String[] originalPctSrpls = null; String[] sparFundSrceCode = null; String[] methodPaymentCode = null; //in case where there are no owner records try { clientId = request.getParameterValues("client_id"); clientNumber = request.getParameterValues("client_number"); clientAcronym = request.getParameterValues("client_acronym"); clientLocnCode = request.getParameterValues("client_locn_code"); clientName = request.getParameterValues("client_name"); originalPctOwned = request.getParameterValues("original_pct_owned"); originalPctRsrvd = request.getParameterValues("original_pct_rsrvd"); originalPctSrpls = request.getParameterValues("original_pct_srpls"); sparFundSrceCode = request.getParameterValues("spar_fund_srce_code"); methodPaymentCode = request.getParameterValues("method_of_payment_code"); } catch(NullPointerException npe) { //do nothing but catch a possible empty array } //Repopulate list with Data from Form if(clientId != null && clientId.length > 0) { for (int i = 0; i < clientId.length; i++) { itemBean = (Spr001SeedlotRegBean) this.getDataBean().getItems().toArray()[i]; //check to see if we are marking the record for deletion if(!StringUtils.getInstance().hasAValue(clientId[i]) && !StringUtils.getInstance().hasAValue(clientLocnCode[i]) && !StringUtils.getInstance().hasAValue(originalPctOwned[i]) && !StringUtils.getInstance().hasAValue(originalPctRsrvd[i]) && !StringUtils.getInstance().hasAValue(originalPctSrpls[i])) { itemBean.setClient_acronym(""); itemBean.setClient_number(""); itemBean.setClient_name(""); itemBean.setClient_locn_code(""); itemBean.setOriginal_pct_owned(""); itemBean.setOriginal_pct_rsrvd(""); itemBean.setOriginal_pct_srpls(""); itemBean.setSpar_fund_srce_code(""); // non-ministry users have default of ITC, do not clear-out. if(getUser().getUser_type().equals("M")) { itemBean.setMethod_of_payment_code(""); } } else { itemBean.setClient_locn_code(clientLocnCode[i]); itemBean.setClient_name(clientName[i]); itemBean.setOriginal_pct_owned(originalPctOwned[i]); if(!StringUtils.getInstance().hasAValue(originalPctRsrvd[i]) && StringUtils.getInstance().hasAValue(originalPctSrpls[i])) { itemBean.setOriginal_pct_rsrvd("0"); } else { itemBean.setOriginal_pct_rsrvd(originalPctRsrvd[i]); } if(!StringUtils.getInstance().hasAValue(originalPctSrpls[i]) && StringUtils.getInstance().hasAValue(originalPctRsrvd[i])) { itemBean.setOriginal_pct_srpls("0"); } else { itemBean.setOriginal_pct_srpls(originalPctSrpls[i]); } itemBean.setSpar_fund_srce_code(sparFundSrceCode[i]); itemBean.setMethod_of_payment_code(methodPaymentCode[i]); //if our client id is a number then set client_number //otherwise set it as the acronym try { int testClientId = Integer.parseInt(clientId[i]); itemBean.setClient_number(clientId[i]); itemBean.setClient_acronym(""); } catch ( NumberFormatException x ) { itemBean.setClient_acronym(clientId[i].toUpperCase()); itemBean.setClient_number(""); } } this.getDataBean().getItems().toArray()[i] = itemBean; } } } /** * This method populates the orignial owner code values on the JSP page * It is needed to verify that the user has not selected an expired code * */ public void populateOwnerCodeArrays() { originalFundingSource = new String[dataBean.getItems().size()]; originalMethOfPayment = new String[dataBean.getItems().size()]; for(int i = 0; i < dataBean.getItems().size(); i++) { Spr001SeedlotRegBean tempBean = (Spr001SeedlotRegBean) dataBean.getItems().toArray()[i]; originalFundingSource[i] = tempBean.getSpar_fund_srce_code(); originalMethOfPayment[i] = tempBean.getMethod_of_payment_code(); } } //getters and setters public ClientDisplayField getApplicantAgencyDisplayField() { return applicantAgencyDisplayField; } public ClientDisplayField getConeCollectorAgencyDisplayField() { return coneCollectorAgencyDisplayField; } public ClientDisplayField getInterimStorageAgencyDisplayField() { return interimStorageAgencyDisplayField; } public ClientDisplayField getExtractoryAgencyDisplayField() { return extractoryAgencyDisplayField; } public ClientDisplayField getSeedStorageAgencyDisplayField() { return seedStorageAgencyDisplayField; } public BECDisplayField getBecDisplayField(){return becDisplayField;} /** * Verifies if the owner record has info * * No info indicated the user wishes to delete the record. * */ public boolean checkOwnerDataExists(Spr001SeedlotRegBean bean){ if(StringUtils.getInstance().hasAValue(bean.getClient_locn_code()) || (StringUtils.getInstance().hasAValue(bean.getClient_number()) || StringUtils.getInstance().hasAValue(bean.getClient_acronym())) || StringUtils.getInstance().hasAValue(bean.getOriginal_pct_owned()) || StringUtils.getInstance().hasAValue(bean.getOriginal_pct_rsrvd()) || StringUtils.getInstance().hasAValue(bean.getOriginal_pct_srpls())) { return true; } return false; } /** * Populates local spz 0 through 9 varibles from the spz_list * returned in the bean * * Called in the handle get from the action class */ public void populateSpzCodeValues() { clearSpzCodes(); if(StringUtils.getInstance().hasAValue(dataBean.getP_spz_list())) { StringTokenizer deliminator = new StringTokenizer(dataBean.getP_spz_list(), ","); String spzValue = ""; int counter = 0; //for genetic class B there is no primary being returned so make the spz_0 blank if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { counter++; } while (deliminator.hasMoreTokens()) { spzValue = deliminator.nextToken(); switch(counter) { case 0: this.setSpz_code_0(spzValue);break; case 1: this.setSpz_code_1(spzValue);break; case 2: this.setSpz_code_2(spzValue);break; case 3: this.setSpz_code_3(spzValue);break; case 4: this.setSpz_code_4(spzValue);break; case 5: this.setSpz_code_5(spzValue);break; case 6: this.setSpz_code_6(spzValue);break; case 7: this.setSpz_code_7(spzValue);break; case 8: this.setSpz_code_8(spzValue);break; } counter++; } } } //populates values back into the comma delimated String so we have the value for the save. public String populateSpzListString() { int counter = 0; int numberOfLoops = 9; //hardcoded one for each spz_ field String spzList = ""; //Loop through for(int i = 0; i < numberOfLoops; i++) { switch(counter) { case 0: if(StringUtils.getInstance().hasAValue(this.getSpz_code_0())) { spzList = spzList + spz_code_0 + ","; }break; case 1: if(StringUtils.getInstance().hasAValue(this.getSpz_code_1())) { spzList = spzList + spz_code_1 + ","; }break; case 2: if(StringUtils.getInstance().hasAValue(this.getSpz_code_2())) { spzList = spzList + spz_code_2 + ","; }break; case 3: if(StringUtils.getInstance().hasAValue(this.getSpz_code_3())) { spzList = spzList + spz_code_3 + ","; }break; case 4: if(StringUtils.getInstance().hasAValue(this.getSpz_code_4())) { spzList = spzList + spz_code_4 + ","; }break; case 5: if(StringUtils.getInstance().hasAValue(this.getSpz_code_5())) { spzList = spzList + spz_code_5 + ","; }break; case 6: if(StringUtils.getInstance().hasAValue(this.getSpz_code_6())) { spzList = spzList + spz_code_6 + ","; }break; case 7: if(StringUtils.getInstance().hasAValue(this.getSpz_code_7())) { spzList = spzList + spz_code_7 + ","; }break; case 8: if(StringUtils.getInstance().hasAValue(this.getSpz_code_8())) { spzList = spzList + spz_code_8 + ","; }break; } counter++; } //trim the last comma if(StringUtils.getInstance().hasAValue(spzList)) { spzList = spzList.substring(0, spzList.length() - 1); } return spzList; } /** * Validates for exprird spz codes * Allowed - codes that were already selected and returned on the GET * Disallowed - Any expired codes selected by the user * * Note - The validation does not check for code selection based on position. As long * as the code used to exist in the list previously it will be accepted even if it is now associated * to a different spz_code droplist * */ private boolean validateSpzValues() { String [] illegalValues = null; //add a comma to the front so we can search on all values using the comma as the subset String originalSzpListForSearch = "," + originalSpzList; int counter = 0; final int spzNumber = 8; boolean foundError = false; //for genetic class B there is no primary being returned so make the spz_0 blank if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { illegalValues = spzBCodesIllegalValues; counter++; } else { illegalValues = spzACodesIllegalValues; } //existing record validation while (counter <= spzNumber && !foundError) { switch(counter) { case 0: //spzCode has a Value if(StringUtils.getInstance().hasAValue(this.getSpz_code_0())) { //spzCode is not in the original list check for illegal values if(originalSzpListForSearch.indexOf("," + this.getSpz_code_0()) < 0) { for(int i = 0; i < illegalValues.length; i++) { if(this.getSpz_code_0().equals(illegalValues[i])) { foundError = true; } } } }break; case 1: //spzCode has a Value if(StringUtils.getInstance().hasAValue(this.getSpz_code_1())) { //spzCode is not in the original list check for illegal values if(originalSzpListForSearch.indexOf("," + this.getSpz_code_1()) < 0) { for(int i = 0; i < illegalValues.length; i++) { if(this.getSpz_code_1().equals(illegalValues[i])) { foundError = true; } } } }break; case 2: //spzCode has a Value if(StringUtils.getInstance().hasAValue(this.getSpz_code_2())) { //spzCode is not in the original list check for illegal values if(originalSzpListForSearch.indexOf("," + this.getSpz_code_2()) < 0) { for(int i = 0; i < illegalValues.length; i++) { if(this.getSpz_code_2().equals(illegalValues[i])) { foundError = true; } } } }break; case 3: //spzCode has a Value if(StringUtils.getInstance().hasAValue(this.getSpz_code_3())) { //spzCode is not in the original list check for illegal values if(originalSzpListForSearch.indexOf("," + this.getSpz_code_3()) < 0) { for(int i = 0; i < illegalValues.length; i++) { if(this.getSpz_code_3().equals(illegalValues[i])) { foundError = true; } } } }break; case 4: //spzCode has a Value if(StringUtils.getInstance().hasAValue(this.getSpz_code_4())) { //spzCode is not in the original list check for illegal values if(originalSzpListForSearch.indexOf("," + this.getSpz_code_4()) < 0) { for(int i = 0; i < illegalValues.length; i++) { if(this.getSpz_code_4().equals(illegalValues[i])) { foundError = true; } } } }break; case 5: //spzCode has a Value if(StringUtils.getInstance().hasAValue(this.getSpz_code_5())) { //spzCode is not in the original list check for illegal values if(originalSzpListForSearch.indexOf("," + this.getSpz_code_5()) < 0) { for(int i = 0; i < illegalValues.length; i++) { if(this.getSpz_code_5().equals(illegalValues[i])) { foundError = true; } } } }break; case 6: //spzCode has a Value if(StringUtils.getInstance().hasAValue(this.getSpz_code_6())) { //spzCode is not in the original list check for illegal values if(originalSzpListForSearch.indexOf("," + this.getSpz_code_6()) < 0) { for(int i = 0; i < illegalValues.length; i++) { if(this.getSpz_code_6().equals(illegalValues[i])) { foundError = true; } } } }break; case 7: //spzCode has a Value if(StringUtils.getInstance().hasAValue(this.getSpz_code_7())) { //spzCode is not in the original list check for illegal values if(originalSzpListForSearch.indexOf("," + this.getSpz_code_7()) < 0) { for(int i = 0; i < illegalValues.length; i++) { if(this.getSpz_code_7().equals(illegalValues[i])) { foundError = true; } } } }break; case 8: //spzCode has a Value if(StringUtils.getInstance().hasAValue(this.getSpz_code_8())) { //spzCode is not in the original list check for illegal values if(originalSzpListForSearch.indexOf("," + this.getSpz_code_8()) < 0) { for(int i = 0; i < illegalValues.length; i++) { if(this.getSpz_code_8().equals(illegalValues[i])) { foundError = true; } } } }break; }//end switch counter++; } return foundError; } private boolean validateNoDuplicateSpzs() { String [] spzValues = new String [9]; boolean foundDuplicate = false; int counter = 0; //for genetic class B there is no primary being returned so make the spz_0 blank if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B")) { counter++; } for(int i = 0; i < spzValues.length; i++) { switch(counter) { case 0: spzValues[counter] = this.getSpz_code_0();break; case 1: spzValues[counter] = this.getSpz_code_1();break; case 2: spzValues[counter] = this.getSpz_code_2();break; case 3: spzValues[counter] = this.getSpz_code_3();break; case 4: spzValues[counter] = this.getSpz_code_4();break; case 5: spzValues[counter] = this.getSpz_code_5();break; case 6: spzValues[counter] = this.getSpz_code_6();break; case 7: spzValues[counter] = this.getSpz_code_7();break; case 8: spzValues[counter] = this.getSpz_code_8();break; } counter++; } //Check for dups for(int i = 0; i < spzValues.length; i++) { //find a dup value if(StringUtils.getInstance().hasAValue(spzValues[i]) && ! foundDuplicate) { String testSpz = spzValues[i]; for(int j = i+1; j < spzValues.length; j++) { if(testSpz.equalsIgnoreCase(spzValues[j])) { return true; } } } } return false; } //Sets applicantId and loc based on users org_unit_no private void setMinistryUserApplicationAgency(String user_org_unit_no, String userId) throws Exception { FunctionStore functionStore = null; CallableStatement callable = null; try { Parameter[] usdParms = { new Parameter("p_org_unit_no", DataAccessInt.NUMERIC, DataAccessInt.PARAM_IN,user_org_unit_no), new Parameter("p_client_number", DataAccessInt.VARCHAR, DataAccessInt.PARAM_OUT,""), new Parameter("p_client_locn_code", DataAccessInt.VARCHAR, DataAccessInt.PARAM_OUT, ""), }; functionStore = new ca.bc.gov.mof.spar.db.FunctionStore("ca.bc.gov.mof", "sil_get_org_cli_xref", usdParms, userId, "POPULATE_FORM"); callable = (CallableStatement)functionStore.execute(); //Place values into the form and container this.getApplicantAgencyDisplayField().setNumber(callable.getString(2)); this.getApplicantAgencyDisplayField().setId(callable.getString(2)); this.getApplicantAgencyDisplayField().setLocationCode(callable.getString(3)); } catch(Exception e) { e.printStackTrace(); } finally { try {//clearing the resultSet and closing the connection callable.clearParameters(); callable.close(); } catch(SQLException sqle) { sqle.printStackTrace(); } } } //Sets the roleBased permissions and the admin authority //Only SPR_TREE_SEED_CENTER_ADMIN has Admin authority private void setRoleBasedPermissions() throws Exception { String userRole = getUser().getUser_roles(); String [] userRoles = getUser().getRoleNames(); try { //set the hasOverride for(int i = 0; i< userRoles.length; i++ ) { if(userRoles[i].equals("SPR_TREE_SEED_CENTRE_ADMIN")) { userHasAdminAuthority = true; userHasTreeAdmin = true; } else if(userRoles[i].equals("SPR_TREE_IMPROVEMENT_HQ")){ userHasTreeAdmin = true; } } //set the DB related flags dataBean.setP_roles_string(userRole); dataBean.setP_action("SET_ROLE_BASED_IND"); SparStore store = new SparStore("ca.bc.gov.mof", getUser().getName(), "POPULATE_FORM"); dataBean.setPackageMapping(PackageMap.instance().getMapping("ca.bc.gov.mof.spar.data.beans.Spr001SeedlotRegBean")); dataBean = (Spr001SeedlotRegBean) store.get(dataBean); //set them on the form so we don't have to pass them to every other dataBase call if (! StringUtils.getInstance().hasAValue(dataBean.getP_error_message())) { this.setGeneticWorthEnabled(dataBean.getP_gw_enabled()); this.setAreaOfUseEnabled(dataBean.getP_area_of_use_enabled()); this.setCancelEnabled(dataBean.getP_cancel_enabled()); this.setApprovedEnabled(dataBean.getP_approve_enabled()); this.setSpecifiyLotNumberOnAdd(dataBean.getP_specify_lot_number_on_add()); } } catch(Exception e) { e.printStackTrace(); } } //Control flags getters public boolean getShowForm() { if(StringUtils.getInstance().hasAValue(dataBean.getP_seedlot_number()) && StringUtils.getInstance().hasAValue(dataBean.getP_revision_count())) { return true; } return false; } //Form A or new Forms public boolean getShowClassASource() { if(! StringUtils.getInstance().hasAValue(dataBean.getP_revision_count()) || ( StringUtils.getInstance().hasAValue(dataBean.getP_genetic_class_code()) && dataBean.getP_genetic_class_code().equalsIgnoreCase("A"))) { return true; } return false; } //Form B or new Forms public boolean getShowSupProvenance() { if(! StringUtils.getInstance().hasAValue(dataBean.getP_revision_count()) || ( StringUtils.getInstance().hasAValue(dataBean.getP_genetic_class_code()) && dataBean.getP_genetic_class_code().equalsIgnoreCase("B"))) { return true; } return false; } public boolean getShowStatusAsLabel() { if(dataBean.getP_seedlot_status_code().equalsIgnoreCase("COM") || dataBean.getP_seedlot_status_code().equalsIgnoreCase("CAN") || dataBean.getP_seedlot_status_code().equalsIgnoreCase("EXP")) { return true; } return false; } public String getStatusLabel() { if(originalSeedlotStatus.equalsIgnoreCase("COM")) { return "COMPLETE"; } if(originalSeedlotStatus.equalsIgnoreCase("CAN")) { return "CANCELLED"; } if(originalSeedlotStatus.equalsIgnoreCase("EXP")) { return "EXPIRED"; } return ""; } public String getShowFormAorB() { if(StringUtils.getInstance().hasAValue(dataBean.getP_genetic_class_code()) && dataBean.getP_genetic_class_code().startsWith("A")) { showFormAorB = "A"; } else if(StringUtils.getInstance().hasAValue(dataBean.getP_genetic_class_code()) && dataBean.getP_genetic_class_code().startsWith("B")) { showFormAorB = "B"; } return showFormAorB; } /** * @return Returns the showCancelButton. */ public String getShowCancelButton() { if(this.originalSeedlotStatus.equalsIgnoreCase("CAN")) { return "N"; } if(StringUtils.getInstance().hasAValue(dataBean.getP_revision_count()) && (cancelEnabled.equalsIgnoreCase("Y") || (this.originalSeedlotStatus.equalsIgnoreCase("INC") || this.originalSeedlotStatus.equalsIgnoreCase("PND")))) { return "Y"; } return "N"; } /** * @return Returns the showCopyButton. */ public String getShowCopyButton() { if(userHasAdminAuthority && StringUtils.getInstance().hasAValue(dataBean.getP_revision_count())) { return "Y"; } return "N"; } public void setBackForward(String backForward){ this.backForward = backForward; } /** * @return Returns the searchRowIndex. */ public String getSearchRowIndex() { return searchRowIndex; } /** * @param searchRowIndex The searchRowIndex to set. */ public void setSearchRowIndex(String searchRowIndex) { this.searchRowIndex = searchRowIndex; } /** * @return Returns the geneticWorthEnabled. */ public boolean isGeneticWorthEnabled() { if(geneticWorthEnabled.equals("Y")) { return true; } return false; } /** * @param geneticWorthEnabled The geneticWorthEnabled to set. */ public void setGeneticWorthEnabled(String geneticWorthEnabled) { this.geneticWorthEnabled = geneticWorthEnabled; } /** * @param specifiyLotNumberOnAdd The specifiyLotNumberOnAdd to set. */ public void setSpecifiyLotNumberOnAdd(String specifiyLotNumberOnAdd) { this.specifiyLotNumberOnAdd = specifiyLotNumberOnAdd; } /** * @param approvedEnabled The approvedEnabled to set. */ public void setApprovedEnabled(String approvedEnabled) { this.approvedEnabled = approvedEnabled; } /** * @param cancelEnabled The cancelEnabled to set. */ public void setCancelEnabled(String cancelEnabled) { this.cancelEnabled = cancelEnabled; } public String getCancelledEnabled() { return cancelEnabled; } /** * RULES * - Only SPR_TREE_SEED_CENTER_ADMIN may update these fields * - If bc source = N then area of use is disabled * @return Returns the isAreaOfUseEnabled. */ public boolean isAreaOfUseEnabled() { if (areaOfUseEnabled.equals("Y")) { return true; } return false; } /** * @param areaOfUseEnabled The areaOfUseEnabled to set. */ public void setAreaOfUseEnabled(String areaOfUseEnabled) { this.areaOfUseEnabled = areaOfUseEnabled; } /** * Rules * Tree Seed Center Admin can enter at any time. * Other user can only enter after clearing the screen from previous data * * @return Returns the isSeedlotNumberEnabled */ public boolean isSeedlotNumberEnabled() { if(userHasAdminAuthority || ! StringUtils.getInstance().hasAValue(dataBean.getP_revision_count())) { return true; } return false; } /** * Rules * * Status is not INC * * @return Returns the isgoToParentTreeEnabled */ public boolean isGoToParentTreeEnabled() { if(! this.getOriginalSeedlotStatus().equals("INC")) { return true; } return false; } /** * * Rules * Non Admin user can only save if status is INC or PND * Admin users can save for any status except CAN * * Note: if original status does not equal the form status it * means an error was generated when the user tried to change the status so don't lock * the save. */ public boolean isSaveEnabled() { if(! dataBean.getP_seedlot_status_code().equals(this.getOriginalSeedlotStatus())) { return true; } if(!userHasAdminAuthority) { if(!StringUtils.getInstance().hasAValue(dataBean.getP_revision_count())) { return true; } else { SparUser sparUser = (SparUser)getUser(); if(StringUtils.getInstance().hasAValue(dataBean.getP_applicant_client_number()) && StringUtils.getInstance().hasAValue(sparUser.getUser_client()) && !dataBean.getP_applicant_client_number().equals(sparUser.getUser_client())) { return false; } else if(StringUtils.getInstance().hasAValue(dataBean.getP_seedlot_status_code()) && ! (dataBean.getP_seedlot_status_code().equals("INC") || dataBean.getP_seedlot_status_code().equals("PND"))) { return false; } } } else { if(StringUtils.getInstance().hasAValue(dataBean.getP_seedlot_status_code()) && dataBean.getP_seedlot_status_code().equals("CAN")) { return false; } } return true; } public void setDeclarationCheckBoxEnabled(boolean value) { declarationCheckBoxEnabled = value; } public boolean isDeclarationCheckBoxEnabled() { return declarationCheckBoxEnabled; } /** * Rules * Disabled if Status = CAN * Disabled if new record * * NOTE: if originalSeedlotStatus does not equal the dataBean seedlot status value then * it means an error was generated so don't disable. * * only Admin can update seedlots that are not PND or INC * */ public boolean isStatusEnabled() { if(dataBean.getP_revision_count().equals("")) { return false; } if(StringUtils.getInstance().hasAValue(dataBean.getP_seedlot_status_code()) && originalSeedlotStatus.equals("CAN")) { return false; } return true; } /** * Rules * Locked if existing record * */ public boolean isGeneticClassEnabled() { if(StringUtils.getInstance().hasAValue(dataBean.getP_revision_count())) { return false; } return true; } /** * * Enabled if no revision count * or if status is INC or PND */ public boolean isSpeciesEnabled() { if(! StringUtils.getInstance().hasAValue(dataBean.getP_revision_count())|| (originalSeedlotStatus.equals("INC") || originalSeedlotStatus.equals("PND"))) { return true; } return false; } /** * Enabled if genetic class is B and BC source is Y OR bc source has no value */ public boolean isSupProvenanceEnabled() { //new records or no bc source picked if(! StringUtils.getInstance().hasAValue(dataBean.getP_revision_count()) || ! StringUtils.getInstance().hasAValue(dataBean.getP_bc_source_ind())) { return true; } if(dataBean.getP_genetic_class_code().equalsIgnoreCase("B") && dataBean.getP_bc_source_ind().equalsIgnoreCase("Y")) { return true; } return false; } public boolean isApplicantAgencyIdEnabled() { SparUser user = (SparUser)super.getUser(); if(StringUtils.getInstance().hasAValue(user.getUser_type()) && user.getUser_type().equals("M")) { return true; } return false; } public boolean isAdminUserEnabled() { return userHasAdminAuthority; } /* * Note: this is not the same as !isSupProveValueYesEnabled. */ public boolean isSupProveValueNo() { if (dataBean.getP_superior_prvnc_ind().equals("N")) { return true; } else { return false; } } public boolean isSupProveValueYesEnabled() { if(! StringUtils.getInstance().hasAValue(dataBean.getP_superior_prvnc_ind()) || dataBean.getP_superior_prvnc_ind().equals("Y")) { return true; } return false; } public boolean isOwnerFieldsEnabled() { if(StringUtils.getInstance().hasAValue(dataBean.getP_original_balance_seed_ind()) && dataBean.getP_original_balance_seed_ind().equals("Y")) { return false; } return true; } public boolean isMethodOfPaymentDropDownEnabled() { SparUser user = (SparUser)super.getUser(); if(!user.getUser_type().equals("M")) { return false; } return isOwnerFieldsDropDownsEnabled(); } public boolean isOwnerFieldsDropDownsEnabled() { if(StringUtils.getInstance().hasAValue(dataBean.getP_original_balance_seed_ind()) && dataBean.getP_original_balance_seed_ind().equals("Y")) { return false; } return true; } public boolean isAddMoreOwnersEnabled() { if(StringUtils.getInstance().hasAValue(dataBean.getP_original_balance_seed_ind()) && dataBean.getP_original_balance_seed_ind().equals("Y")) { return false; } if(StringUtils.getInstance().hasAValue(originalSeedlotStatus) && originalSeedlotStatus.equals("CAN")) { return false; } return true; } public boolean isBcSourceValueYesEnabled() { if(! StringUtils.getInstance().hasAValue(dataBean.getP_bc_source_ind()) || dataBean.getP_bc_source_ind().equals("Y")) { return true; } return false; } public boolean isBcSourceValueNoEnabled() { if(! StringUtils.getInstance().hasAValue(dataBean.getP_bc_source_ind()) || dataBean.getP_bc_source_ind().equals("N")) { return true; } return false; } public boolean isCollectionAreaCaptureEnabled() { if(isSaveEnabled()) { return true; } return false; } //droplist getters /** * @return Returns the geneticClassCodes. */ public OptionBean[] getGeneticClassCodes() { return geneticClassCodes; } /** * @return Returns the collectMethodCodes. */ public OptionBean[] getCollectionMethodCodes() { return collectionMethodCodes; } /** * @return Returns the geoCodes. */ public OptionBean[] getGeoCodes() { return geoCodes; } /** * @return Returns the latCodes. */ public OptionBean[] getLatCodes() { return latCodes; } /** * @return Returns the longCodes. */ public OptionBean[] getLongCodes() { return longCodes; } /** * @return Returns the numTreesCollectedFrom. */ public OptionBean[] getNumTreesCollectedFrom() { return numTreesCollectedFrom; } /** * @return Returns the orgUnitCodes. */ public OptionBean[] getOrgUnitCodes() { return orgUnitCodes; } /** * @return Returns the provenanceCodes. */ public OptionBean[] getProvenanceCodes() { return provenanceCodes; } public void setProvenanceCodes (OptionBean[] values) throws StoreException { this.provenanceCodes = values; } /** * @return Returns the seedlotSourceCodes. */ public OptionBean[] getSeedlotSourceCodes() { return seedlotSourceCodes; } /** * @return Returns the speciesCodes. */ public OptionBean[] getSpeciesCodes() { return speciesCodes; } /** * @return Returns the speciesStore. */ public CurrentSpeciesStore getSpeciesStore() { return speciesStore; } /** * @return Returns the spzACodes. */ public OptionBean[] getSpzACodes() { return spzACodes; } /** * @return Returns the spzBCodes. */ public OptionBean[] getSpzBCodes() { return spzBCodes; } /** * @return Returns the statusCodes. */ public OptionBean[] getSeedlotStatusCodes() { return seedlotStatusCodes; } /** * @return Returns the storageFaciltyTypeCodes. */ public OptionBean[] getStorageFaciltyTypeCodes() { return storageFaciltyTypeCodes; } /** * @return Returns the fundingSourceCodes. */ public OptionBean[] getFundingSourceCodes() { return fundingSourceCodes; } /** * @return Returns the paymentMethodCodes. */ public OptionBean[] getPaymentMethodCodes() { return paymentMethodCodes; } /** * @return Returns the corpCaptureMethodCodes. */ public OptionBean[] getCorpCaptureMethodCodes() { return corpCaptureMethodCodes; } /** * @return Returns the spz_code_0. */ public String getSpz_code_0() { return spz_code_0; } /** * @param spz_code_0 The spz_code_0 to set. */ public void setSpz_code_0(String spz_code_0) { this.spz_code_0 = spz_code_0; } /** * @return Returns the spz_code_1. */ public String getSpz_code_1() { return spz_code_1; } /** * @param spz_code_1 The spz_code_1 to set. */ public void setSpz_code_1(String spz_code_1) { this.spz_code_1= spz_code_1; } /** * @return Returns the spz_code_2. */ public String getSpz_code_2() { return spz_code_2; } /** * @param spz_code_2 The spz_code_2 to set. */ public void setSpz_code_2(String spz_code_2) { this.spz_code_2 = spz_code_2; } /** * @return Returns the spz_code_3. */ public String getSpz_code_3() { return spz_code_3; } /** * @param spz_code_3 The spz_code_3 to set. */ public void setSpz_code_3(String spz_code_3) { this.spz_code_3 = spz_code_3; } /** * @return Returns the spz_code_4. */ public String getSpz_code_4() { return spz_code_4; } /** * @param spz_code_4 The spz_code_4 to set. */ public void setSpz_code_4(String spz_code_4) { this.spz_code_4 = spz_code_4; } /** * @return Returns the spz_code_5. */ public String getSpz_code_5() { return spz_code_5; } /** * @param spz_code_5 The spz_code_5 to set. */ public void setSpz_code_5(String spz_code_5) { this.spz_code_5 = spz_code_5; } /** * @return Returns the spz_code_6. */ public String getSpz_code_6() { return spz_code_6; } /** * @param spz_code_6 The spz_code_6 to set. */ public void setSpz_code_6(String spz_code_6) { this.spz_code_6 = spz_code_6; } /** * @return Returns the spz_code_7. */ public String getSpz_code_7() { return spz_code_7; } /** * @param spz_code_7 The spz_code_7 to set. */ public void setSpz_code_7(String spz_code_7) { this.spz_code_7 = spz_code_7; } /** * @return Returns the spz_code_8. */ public String getSpz_code_8() { return spz_code_8; } /** * @param spz_code_8 The spz_code_8 to set. */ public void setSpz_code_8(String spz_code_8) { this.spz_code_8 = spz_code_8; } /** * @return Returns the jspFocus. */ public String getJspFocus() { return jspFocus; } /** * @param jspFocus The jspFocus to set. */ public void setJspFocus(String jspFocus) { this.jspFocus = jspFocus; } /** * @return Returns the originalSeedlotStatus. */ public String getOriginalSeedlotStatus() { return originalSeedlotStatus; } /** * @param originalSeedlotStatus The originalSeedlotStatus to set. */ public void setOriginalSeedlotStatus(String originalSeedlotStatus) { this.originalSeedlotStatus = originalSeedlotStatus; } /** * * @return Returns the declaredCheckBox. */ public String getDeclaredCheckBox() { return declaredCheckBox; } /** * If checked and Declared userId does not have a value then * set the userId into the bean. * * @param declaredCheckBox The declaredCheckBox to set. */ public void setDeclaredCheckBox(String declaredCheckBox) { this.declaredCheckBox = declaredCheckBox; } public String getDirtyFlg() { return dirtyFlg; } public void setDirtyFlg(String value) { this.dirtyFlg = value; } /** * @return Returns the preCFSForm. */ public boolean isPreCFSStandardForm() { return preCFSStandardForm; } //If the lot is split then relax cfs validations //Used in conjunction with isPreCFSStandardForm public boolean isLotSplit() { return dataBean.getP_is_lot_split_ind().equalsIgnoreCase("Y"); } //If the lot is not split AND the form //is not preCFS run the validation public boolean isLotSplitORPreCFSValidationRequired() { if (! isLotSplit() && !isPreCFSStandardForm()) { return true; } return false; } /** * * Convert the Y or N value sent in bean to boolean value * April 01 2005 or no value means set the boolean to true */ public void setPreCFSStandardForm() { preCFSStandardForm = Spr01SeedlotRegForm.dateIsPreCfsStandardDate(dataBean.getP_approved_date()); } /** * @return Returns the originalSeedlotNumber. */ public String getOriginalSeedlotNumber() { return originalSeedlotNumber; } /** * @param originalSeedlotNumber The originalSeedlotNumber to set. */ public void setOriginalSeedlotNumber(String originalSeedlotNumber) { this.originalSeedlotNumber = originalSeedlotNumber; } /** * @return Returns the originalBCSource. */ public String getOriginalBCSource() { return originalBCSource; } /** * @param originalBCSource The originalBCSource to set. */ public void setOriginalBCSource(String originalBCSource) { this.originalBCSource = originalBCSource; } /** * @return Returns the originalCollectionProvenance. */ public String getOriginalCollectionProvenance() { return originalCollectionProvenance; } /** * @param originalCollectionProvenance The originalCollectionProvenance to set. */ public void setOriginalCollectionProvenance( String originalCollectionProvenance) { this.originalCollectionProvenance = originalCollectionProvenance; } /** * @return Returns the originalSpecies. */ public String getOriginalSpecies() { return originalSpecies; } /** * @param originalSpecies The originalSpecies to set. */ public void setOriginalSpecies(String originalSpecies) { this.originalSpecies = originalSpecies; } /** * @return Returns the originalClassASource. */ public String getOriginalClassASource() { return originalClassASource; } /** * @param originalClassASource The originalClassASource to set. */ public void setOriginalClassASource(String originalClassASource) { this.originalClassASource = originalClassASource; } /** * @return Returns the originalSupProvenance. */ public String getOriginalSupProvenance() { return originalSupProvenance; } /** * @param originalSupProvenance The originalSupProvenance to set. */ public void setOriginalSupProvenance(String originalSupProvenance) { this.originalSupProvenance = originalSupProvenance; } /** * @param originalSpzList The originalSpzList to set. */ public void setOriginalSpzList(String originalSpzList) { this.originalSpzList = originalSpzList; } /** * @return Returns the originalClientId. */ public String getOriginalClientId() { return originalClientId; } /** * @return Returns the errorsonRecalc. */ public String getErrorsOnRecalc() { return errorsOnRecalc; } /** * @param errorsOnRecalc The errorsonRecalc to set. */ public void setErrorsOnRecalc(String errorsOnRecalc) { this.errorsOnRecalc = errorsOnRecalc; } public String getSeedMapLink() { return seedMapLink; } public void setSeedMapLink(String value) { seedMapLink = value; } public boolean displaySeedmap() { if(StringUtils.getInstance().hasAValue(seedMapLink)) { return true; } return false; } public void setDisplaySeedmapWarning(boolean value) { displaySeedmapWarning = value; } public String getDisplaySeedmapWarning() { return displaySeedmapWarning ? "Y" : "N"; } /** * @return Returns the originalSpzList. */ public String getOriginalSpzList() { return originalSpzList; } /** * @param originalClientId The originalClientId to set. */ public void setOriginalClientId(String originalClientId) { this.originalClientId = originalClientId; } /** * @return Returns the originalFundingSource. */ public String[] getOriginalFundingSource() { return originalFundingSource; } /** * @param originalFundingSource The originalFundingSource to set. */ public void setOriginalFundingSource(String[] originalFundingSource) { this.originalFundingSource = originalFundingSource; } public boolean isTreeAdminUserEnabled() { return userHasTreeAdmin; } public boolean rangeLimitExists() { if(!StringUtils.getInstance().hasAValue(dataBean.getP_latitude_deg_max()) || !StringUtils.getInstance().hasAValue(dataBean.getP_latitude_deg_min()) || !StringUtils.getInstance().hasAValue(dataBean.getP_longitude_deg_max()) || !StringUtils.getInstance().hasAValue(dataBean.getP_longitude_deg_min()) || !StringUtils.getInstance().hasAValue(dataBean.getP_latitude_min_max()) || !StringUtils.getInstance().hasAValue(dataBean.getP_latitude_min_min()) || !StringUtils.getInstance().hasAValue(dataBean.getP_longitude_min_max()) || !StringUtils.getInstance().hasAValue(dataBean.getP_longitude_min_min()) || !StringUtils.getInstance().hasAValue(dataBean.getP_latitude_sec_max()) || !StringUtils.getInstance().hasAValue(dataBean.getP_latitude_sec_min()) || !StringUtils.getInstance().hasAValue(dataBean.getP_longitude_sec_max()) || !StringUtils.getInstance().hasAValue(dataBean.getP_longitude_sec_min())) { return false; } else { boolean lat_match = true; boolean long_match = true; lat_match = lat_match && (dataBean.getP_latitude_deg_min().equals(dataBean.getP_latitude_deg_max())); lat_match = lat_match && (dataBean.getP_latitude_min_min().equals(dataBean.getP_latitude_min_max())); lat_match = lat_match && (dataBean.getP_latitude_sec_min().equals(dataBean.getP_latitude_sec_max())); long_match = long_match && (dataBean.getP_longitude_deg_min().equals(dataBean.getP_longitude_deg_max())); long_match = long_match && (dataBean.getP_longitude_min_min().equals(dataBean.getP_longitude_min_max())); long_match = long_match && (dataBean.getP_longitude_sec_min().equals(dataBean.getP_longitude_sec_max())); return !(lat_match && long_match); } } }