/** * @(#)Spr001aParentTreeContribForm * Copyright (c) 2005, B.C. Ministry of Forests * All rights reserved. */ package ca.bc.gov.mof.spar.web.form; /******************************************************** Form Class: Spr001aParentTreeContribForm Purpose: Revision History Person Date Comments ----------------- --------- ----------------------- Pangaea June 22 2005 Created *******************************************************/ import java.sql.SQLException; import java.util.Iterator; 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.DecimalPlacesValidator; 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.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.validators.StringNotEqualValidator; import ca.bc.gov.mof.sil.common.web.frame.SilUser; import ca.bc.gov.mof.sil.http.HttpErrorHandler; import ca.bc.gov.mof.spar.common.GeneticWorthFormat; import ca.bc.gov.mof.spar.data.beans.Spr001aParentTreeContribBean; import ca.bc.gov.mof.spar.data.beans.Spr001aParentTreeContribResultArrayElement; import ca.bc.gov.mof.spar.data.validators.WrappedValidator; import ca.bc.gov.mof.spar.db.PrimarySPUStore; import ca.bc.gov.mof.spar.db.SPUCodeListStore; import ca.bc.gov.mof.spar.db.SPUStore; import ca.bc.gov.mof.spar.db.SparExtStore; 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.CodesManager; import ca.bc.gov.mof.sil.webade.db.DataBean; 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.util.StringUtils; 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.Trace; import ca.bc.gov.mof.sil.webade.db.validators.FieldValidator; import ca.bc.gov.mof.sil.webade.db.validators.ValidatingForm; public class Spr001aParentTreeContribForm extends SparForm implements ValidatingForm { private static final Trace trace = new Trace( Spr001aParentTreeContribForm.class ); // Member variables private Spr001aParentTreeContribBean dataBean = new Spr001aParentTreeContribBean(); /** * Validates that a field is entered if the lot has not been split and the * approval date is before the CFS Standard Date. */ private class RequiredIfLotSplitOrPostCfsStandardDateFieldValidator extends RequiredFieldValidator { public RequiredIfLotSplitOrPostCfsStandardDateFieldValidator(ValidatingForm form, String fieldname, String fieldLabel) { super(form, fieldname, fieldLabel); } public ErrorMessage validate() { Spr001aParentTreeContribBean bean = (Spr001aParentTreeContribBean)form.getBean(); if (! bean.getP_is_lot_split_ind().equalsIgnoreCase("Y") && ! Spr01SeedlotRegForm.dateIsPreCfsStandardDate(bean.getP_approved_date())) { return super.validate(); } else { return null; } } } // Comment may not exceed 2000 chars private final FieldValidator commentLengthValidator = new FieldValidator() { public ErrorMessage validate() { if(!"".equals(dataBean.getP_orchard_comment()) && dataBean.getP_orchard_comment().length() >= 2000) { return new ErrorMessage( "sil.error.usr.field.char.length", "Comments", "2000"); } return null; } }; private RequiredFieldValidator primarySpuRequired = new RequiredFieldValidator(this, "p_seed_plan_unit_id", "Primary SPU"); //If the class A source is custom or tested the primary spu is mandatory private final FieldValidator primarySpuMandatoryClassASource = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_seedlot_source_code().equalsIgnoreCase("TPT") || dataBean.getP_seedlot_source_code().equalsIgnoreCase("CUS")) { return primarySpuRequired.validate(); } return null; } }; // Pollen Contamination percent is mandatory if "Was pollen contamination present in the seed orchard?" is 'Yes' // this should really be a EnsureTextEntry!!! private final FieldValidator pollenContaminationPctMandatory = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_pollen_contamination_ind().equals("Y")) { return pollenContaminationPctRequired.validate(); } else if(dataBean.getP_pollen_contamination_ind().equals("N") && StringUtils.getInstance().hasAValue(dataBean.getP_pollen_contamination_pct())) // throw error if value provided. { return new ErrorMessage( "spar.web.error.usr.must_be_empty", "Proportion of contaminant pollen", "Was pollen contamination present in the seed orchard?", "No"); } return null; } }; // Pollen Contamination Method Code is mandatory if "Was pollen contamination present in the seed orchard?" is 'Yes' private final FieldValidator pollenContaminationMthdMandatory = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_pollen_contamination_ind().equals("Y")) { return pollenContaminationMthdRequired.validate(); } else if(dataBean.getP_pollen_contamination_ind().equals("N") && StringUtils.getInstance().hasAValue(dataBean.getP_pollen_contam_mthd_code())) // throw error if value provided. { return new ErrorMessage( "spar.web.error.usr.must_be_empty", "Methodology used to determine the proportion of contaminant pollen", "Was pollen contamination present in the seed orchard?", "No"); } return null; } }; // Pollen Contamination BV is mandatory if "Was pollen contamination present in the seed orchard?" is 'Yes' private final FieldValidator pollenContaminationBvMandatory = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_pollen_contamination_ind().equals("Y")) { return pollenContaminationBvRequired.validate(); } else if(dataBean.getP_pollen_contamination_ind().equals("N") && StringUtils.getInstance().hasAValue(dataBean.getP_contaminant_pollen_bv())) // throw error if value provided. { return new ErrorMessage( "spar.web.error.usr.must_be_empty", "Contaminant pollen BV", "Was pollen contamination present in the seed orchard?", "No"); } return null; } }; //Used for Client Display Field Implementation(s) private SilUser user() { return super.getUser(); } // Declarations for Expired Code List drop downs private CodesManager codesManager; private OptionBean[] spuCodes = null; private OptionBean[] maleGameticMthdCodes = null; private OptionBean[] femaleGameticMthdCodes = null; private OptionBean[] pollenContaminationMthdCodes = null; //Orchard ID Validator DBFieldValidator orchardValid; DBFieldValidator secOrchardValid; private RequiredFieldValidator orchardIdRequired = new RequiredFieldValidator(this, "p_orchard_id", "Orchard ID"); private StringNotEqualValidator orchardIdNotEqual = new StringNotEqualValidator(this, "p_orchard_id", "Orchard ID", "p_secondary_orchard_id", "Additional Orchard ID", "spar.web.error.usr.not.same"); private RequiredFieldValidator maleGameticMthdCodeRequired = new RequiredIfLotSplitOrPostCfsStandardDateFieldValidator(this, "p_male_gametic_mthd_code", "Methodology used to determine female gametic contribution of each PT"); private RequiredFieldValidator femaleGameticMthdCodeRequired = new RequiredIfLotSplitOrPostCfsStandardDateFieldValidator(this, "p_female_gametic_mthd_code", "Methodology used to determine male gametic contribution of each PT"); private RequiredFieldValidator pollenContaminationIndRequired = new RequiredIfLotSplitOrPostCfsStandardDateFieldValidator(this, "p_pollen_contamination_ind", "Was pollen contamination present in the seed orchard"); private RequiredFieldValidator pollenContaminationPctRequired = new RequiredFieldValidator(this, "p_pollen_contamination_pct", "Proportion of contaminant pollen"); private RequiredFieldValidator pollenContaminationMthdRequired = new RequiredFieldValidator(this, "p_pollen_contam_mthd_code", "Methodology used to determine the proportion of contaminant pollen"); private RequiredFieldValidator controlledCrossIndRequired = new RequiredIfLotSplitOrPostCfsStandardDateFieldValidator(this, "p_controlled_cross_ind", "Was the lot produced through controlled crosses"); private RequiredFieldValidator biotechProcessesIndRequired = new RequiredIfLotSplitOrPostCfsStandardDateFieldValidator(this, "p_biotech_processes_ind", "Have biotechnological processes been used to produce this lot"); private RequiredFieldValidator pollenContaminationBvRequired = new RequiredFieldValidator(this, "p_contaminant_pollen_bv", "Contaminant pollen BV"); private IntegerFieldValidator pollenContaminationPctNumeric = new IntegerFieldValidator(this, "p_pollen_contamination_pct", "Proportion of contaminant pollen", false); private IntegerLimitsValidator pollenContaminationPctRange = new IntegerLimitsValidator(this, "p_pollen_contamination_pct", "Proportion of contaminant pollen", 1, 100, false); private FloatFieldValidator contaminantPollenBvNumeric = new FloatFieldValidator(this, "p_contaminant_pollen_bv", "Contaminant pollen BV", false); private FloatRangeValidator contaminantContaminationPctRange = new FloatRangeValidator(this, "p_contaminant_pollen_bv", "Contaminant pollen BV", 0.0, 999.9, false); private IntegerFieldValidator smpParentsOutsideNumeric = new IntegerFieldValidator(this, "p_smp_parents_outside", "# of SMP Parents from Outside", false); private IntegerLimitsValidator smpParentsOutsideRange = new IntegerLimitsValidator(this, "p_smp_parents_outside", "# of SMP Parents from Outside", 0, 99999, false); private FloatFieldValidator coancestryNumeric = new FloatFieldValidator(this, "p_coancestry", "Coancestry (Sum PiPj * Cij)", false); private FloatRangeValidator coancestryRange = new FloatRangeValidator(this, "p_coancestry", "Coancestry (Sum PiPj * Cij)", 0, 9999999999.9999999999, false) { // TODO: Roll this validator into sil FloatRangeValidator. The validator // in sil should use a DecimalFormat to format the numbers instead of // concatenating with a blank string. public ErrorMessage validate() { ErrorMessage validationResult = super.validate(); if (validationResult != null) { return new ErrorMessage(validationResult.getKey(), "Coancestry", "0", "999999999.999999999"); } return null; } }; 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 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); private DecimalPlacesValidator effectivePopSizeDecimal = new DecimalPlacesValidator(this, "p_effective_pop_size", "Effective Population Size", "ca.bc.gov.mof.sil.webade.db.error.decimal-places2", 1, false); /** * Contains the forward to use when returning using the back button. * This is populated with the searchRequest.requestor in the action class. */ private String backForward = ""; /** * Gets the forward to go to when invoking a back action * @return the forward to go to when invoking a back action */ public String getBackForward() { return backForward; } /** * Sets the forward to go to when invoking a back action * @param backForward the forward to use to go back */ public void setBackForward(String backForward) { if (backForward == null) { this.backForward = ""; } else { this.backForward = backForward.trim(); } } /** * Keeps track of the seed plan unit id from the last get. Used by logic in the jsp * to check to see if a message should be displayed */ private String old_seed_plan_unit_id = ""; public String getOld_seed_plan_unit_id() { return old_seed_plan_unit_id; } public void setOld_seed_plan_unit_id(String seed_plan_unit_id) { if (seed_plan_unit_id == null) { this.old_seed_plan_unit_id = ""; } else { this.old_seed_plan_unit_id = seed_plan_unit_id; } } /** * Keeps track of the orchard id from the last get. Used by logic in the jsp * to check to see if a message should be displayed */ private String old_orchard_id = ""; public String getOld_orchard_id() { return old_orchard_id; } public void setOld_orchard_id(String orchard_id) { if (orchard_id == null) { this.old_orchard_id = ""; } else { this.old_orchard_id = orchard_id; } } /** * Keeps track of the secondary orchard id from the last get. Used by logic in the jsp * to check to see if a message should be displayed */ private String old_secondary_orchard_id = ""; public String getOld_secondary_orchard_id() { return old_secondary_orchard_id; } public void setOld_secondary_orchard_id(String secondary_orchard_id) { if (secondary_orchard_id == null) { this.old_secondary_orchard_id = ""; } else { this.old_secondary_orchard_id = secondary_orchard_id; } } /** * These values will be used by the Copy SMP line. */ private String smp_success_pct = ""; public String getSmp_success_pct() { return smp_success_pct; } public void setSmp_success_pct(String value) { if (value == null) { this.smp_success_pct = ""; } else { this.smp_success_pct = value; } } private String smp_mix_bv_g = ""; public String getSmp_mix_bv_g() { return smp_mix_bv_g; } public void setSmp_mix_bv_g(String value) { if (value == null) { this.smp_mix_bv_g = ""; } else { this.smp_mix_bv_g = value; } } private String smp_mix_bv_d = ""; public String getSmp_mix_bv_d() { return smp_mix_bv_d; } public void setSmp_mix_bv_d(String value) { if (value == null) { this.smp_mix_bv_d = ""; } else { this.smp_mix_bv_d = value; } } private String smp_mix_bv_r = ""; public String getSmp_mix_bv_r() { return smp_mix_bv_r; } public void setSmp_mix_bv_r(String value) { if (value == null) { this.smp_mix_bv_r = ""; } else { this.smp_mix_bv_r = value; } } private String smp_mix_bv_m = ""; public String getSmp_mix_bv_m() { return smp_mix_bv_m; } public void setSmp_mix_bv_m(String value) { if (value == null) { this.smp_mix_bv_m = ""; } else { this.smp_mix_bv_m = value; } } private String smp_mix_latitude_degrees = ""; public String getSmp_mix_latitude_degrees() { return smp_mix_latitude_degrees; } public void setSmp_mix_latitude_degrees(String value) { if (value == null) { this.smp_mix_latitude_degrees = ""; } else { this.smp_mix_latitude_degrees = value; } } private String smp_mix_latitude_minutes = ""; public String getSmp_mix_latitude_minutes() { return smp_mix_latitude_minutes; } public void setSmp_mix_latitude_minutes(String value) { if (value == null) { this.smp_mix_latitude_minutes = ""; } else { this.smp_mix_latitude_minutes = value; } } private String smp_mix_longitude_degrees = ""; public String getSmp_mix_longitude_degrees() { return smp_mix_longitude_degrees; } public void setSmp_mix_longitude_degrees(String value) { if (value == null) { this.smp_mix_longitude_degrees = ""; } else { this.smp_mix_longitude_degrees = value; } } private String smp_mix_longitude_minutes = ""; public String getSmp_mix_longitude_minutes() { return smp_mix_longitude_minutes; } public void setSmp_mix_longitude_minutes(String value) { if (value == null) { this.smp_mix_longitude_minutes = ""; } else { this.smp_mix_longitude_minutes = value; } } private String smp_mix_elevation = ""; public String getSmp_mix_elevation() { return smp_mix_elevation; } public void setSmp_mix_elevation(String value) { if (value == null) { this.smp_mix_elevation = ""; } else { this.smp_mix_elevation = value; } } /** * Holds a cached copy of gw_enabled. Populated from initFromRequest */ private boolean gwEnabled = false; public boolean getGwEnabled() { return gwEnabled; } public void setGwEnabled(boolean gwEnabled) { this.gwEnabled = gwEnabled; } /** * Holds a cached copy of gw_enabled. Populated from initFromRequest */ private boolean areaOfUseEnabled = false; public boolean getAreaOfUseEnabled() { return areaOfUseEnabled; } public void setAreaOfUseEnabled(boolean areaOfUseEnabled) { this.areaOfUseEnabled = areaOfUseEnabled; } /** * Contains the name of the field that is to be populated by the search response. This is required * because there are two orchard id fields on the this screen. */ private String searchField = ""; /** * Gets the field currently being searched. * @return the field currently being searched */ public String getSearchField() { return searchField; } /** * Sets the field currently being searched. */ public void setSearchField(String searchField) { if (searchField == null) { this.searchField = ""; } else { this.searchField = searchField.trim(); } } boolean validatorsInitialized = false; // Constructor public Spr001aParentTreeContribForm () {} public void initFromRequest(HttpServletRequest request) { super.initFromRequest(request); if(!userAction.equalsIgnoreCase("BackToPT") && !userAction.equalsIgnoreCase("SaveBackToPT") && !userAction.equalsIgnoreCase("Save") && !userAction.startsWith("Recalc")) { clearCopySmp(); } codesManager = CodesManager.get(request.getSession()); // Declare filtered code lists here, so they're refreshed on every request. maleGameticMthdCodes = codesManager.getCodes("MALE_GAMETIC_MTHD"); femaleGameticMthdCodes = codesManager.getCodes("FEMALE_GAMETIC_MTHD"); pollenContaminationMthdCodes = codesManager.getCodes("POLLEN_CONTAMINATION_MTHD"); // Read the array parameters from the screen accumulateParentTreeInformation(request); try { // Get screen security try { Spr001aParentTreeContribBean securityBean = new Spr001aParentTreeContribBean(); securityBean.setP_action("SET_ROLE_BASED_IND"); securityBean.setP_update_userid(getUser().getName()); securityBean.setP_roles_string(((SparUser)getUser()).getUser_roles()); securityBean.setP_user_org_unit_no(((SparUser)getUser()).getUser_org_unit()); securityBean.setP_user_type(((SparUser)getUser()).getUser_type()); securityBean.setP_user_client_number(((SparUser)getUser()).getUser_client()); securityBean.setP_user_client_locn_code(((SparUser)getUser()).getUser_client_locn()); SparExtStore store = new SparExtStore("ca.bc.gov.mof", getUser().getName(), "POPULATE_FORM"); securityBean.setPackageMapping(PackageMap.instance().getMapping("ca.bc.gov.mof.spar.data.beans.Spr001aParentTreeContribBean")); securityBean = (Spr001aParentTreeContribBean) store.put(securityBean); if (securityBean.getP_error_message().equals("")) { this.setGwEnabled( securityBean.getP_gw_enabled().equals("Y") ? true : false ); this.setAreaOfUseEnabled( securityBean.getP_area_of_use_enabled().equals("Y") ? true : false ); } else { throw new Exception("Error when loading security. " + securityBean.getP_error_message()); } store.rollback(); } catch (Exception e) { e.printStackTrace(); this.setGwEnabled(false); this.setAreaOfUseEnabled(false); } if (!validatorsInitialized) { orchardValid = new DBFieldValidator(this, "p_orchard_id", "Orchard ID", "spar.lookup.orchard", codesManager, false); secOrchardValid = new DBFieldValidator(this, "p_secondary_orchard_id", "Additional orchard id contributing parent trees", "spar.lookup.orchard", codesManager, false); // Add validators addValidatorChain("Save", new FieldValidator[]{orchardIdRequired, orchardIdNotEqual}); addValidator("Save", commentLengthValidator); addValidator("Save", orchardValid); addValidator("Save", secOrchardValid); addValidator("Save", primarySpuMandatoryClassASource); addValidator("Save", pollenContaminationIndRequired); addValidator("Save", maleGameticMthdCodeRequired); addValidator("Save", femaleGameticMthdCodeRequired); addValidator("Save", pollenContaminationPctMandatory); addValidator("Save", pollenContaminationPctNumeric); addValidator("Save", pollenContaminationPctRange); addValidator("Save", pollenContaminationMthdMandatory); addValidator("Save", pollenContaminationBvMandatory); addValidator("Save", controlledCrossIndRequired); addValidator("Save", biotechProcessesIndRequired); addValidator("Save", contaminantPollenBvNumeric); addValidator("Save", contaminantContaminationPctRange); addValidator("Save", smpParentsOutsideNumeric); addValidator("Save", smpParentsOutsideRange); addValidator("Save", coancestryNumeric); addValidator("Save", coancestryRange); addValidator("Save", gw_gIntegerAndRangeValidator); addValidator("Save", gw_dIntegerAndRangeValidator); addValidator("Save", gw_rIntegerAndRangeValidator); addValidator("Save", gw_mIntegerAndRangeValidator); addValidator("Save", floatEffectivePopSizeValidator); addValidator("Save", floatEffectivePopSizeRange); addValidator("Save", effectivePopSizeDecimal); addValidator("Recalc", pollenContaminationPctNumeric); addValidator("Recalc", pollenContaminationPctRange); addValidator("Recalc", contaminantPollenBvNumeric); addValidator("Recalc", contaminantContaminationPctRange); addValidator("Recalc", smpParentsOutsideNumeric); addValidator("Recalc", smpParentsOutsideRange); addValidator("Recalc", coancestryNumeric); addValidator("Recalc", coancestryRange); addValidator("Recalc", gw_gIntegerAndRangeValidator); addValidator("Recalc", gw_dIntegerAndRangeValidator); addValidator("Recalc", gw_rIntegerAndRangeValidator); addValidator("Recalc", gw_mIntegerAndRangeValidator); addValidator("Recalc", floatEffectivePopSizeValidator); addValidator("Recalc", floatEffectivePopSizeRange); addValidator("Recalc", effectivePopSizeDecimal); addValidator("RecalcBV", pollenContaminationPctNumeric); addValidator("RecalcBV", pollenContaminationPctRange); addValidator("RecalcBV", contaminantPollenBvNumeric); addValidator("RecalcBV", contaminantContaminationPctRange); addValidator("RecalcBV", smpParentsOutsideNumeric); addValidator("RecalcBV", smpParentsOutsideRange); addValidator("RecalcBV", coancestryNumeric); addValidator("RecalcBV", coancestryRange); addValidator("RecalcBV", gw_gIntegerAndRangeValidator); addValidator("RecalcBV", gw_dIntegerAndRangeValidator); addValidator("RecalcBV", gw_rIntegerAndRangeValidator); addValidator("RecalcBV", gw_mIntegerAndRangeValidator); addValidator("RecalcBV", floatEffectivePopSizeValidator); addValidator("RecalcBV", floatEffectivePopSizeRange); addValidator("RecalcBV", effectivePopSizeDecimal); validatorsInitialized = true; } } catch (Exception e) { e.printStackTrace(); } } public DataBean getBean() { return dataBean; } public void setBean( DataBean bean ) { dataBean = (Spr001aParentTreeContribBean)bean; } /** * Implemented from ValidatingForm interface. */ public DataBean getFormBean() { return dataBean; } /** * Gets/Sets the instance of the bean for the page */ public Spr001aParentTreeContribBean getDataBean() { return dataBean; } public void setDataBean(Spr001aParentTreeContribBean dataBean) { this.dataBean = dataBean; } /* Getters for drop down lists */ public OptionBean[] getSpuCodes () throws StoreException { return spuCodes; } public void setSpuCodes (OptionBean[] values) throws StoreException { this.spuCodes = values; } public OptionBean[] getMaleGameticMthdCodes () throws StoreException { return maleGameticMthdCodes; } public void setMaleGameticMthdCodes (OptionBean[] values) throws StoreException { this.maleGameticMthdCodes = values; } public OptionBean[] getFemaleGameticMthdCodes () throws StoreException { return femaleGameticMthdCodes; } public void setFemaleGameticMthdCodes (OptionBean[] values) throws StoreException { this.femaleGameticMthdCodes = values; } public OptionBean[] getPollenContaminationMthdCodes() throws StoreException { return pollenContaminationMthdCodes; } public void setPollenContaminationMthdCodes (OptionBean[] values) throws StoreException { this.pollenContaminationMthdCodes = values; } /** * Clear form member variables. */ public void clear () { this.dataBean = new Spr001aParentTreeContribBean(); this.setOld_seed_plan_unit_id(""); this.setOld_orchard_id(""); this.setOld_secondary_orchard_id(""); } /** * Clear copy smp variables. */ public void clearCopySmp () { this.setSmp_success_pct(""); this.setSmp_mix_bv_g(""); this.setSmp_mix_bv_d(""); this.setSmp_mix_bv_r(""); this.setSmp_mix_bv_m(""); this.setSmp_mix_elevation(""); this.setSmp_mix_latitude_degrees(""); this.setSmp_mix_latitude_minutes(""); this.setSmp_mix_longitude_degrees(""); this.setSmp_mix_longitude_minutes(""); } public void clearDataBean () { this.clear(); } /** * Performs the validation on the form. */ public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) { // Call the form's validators and validate the parent tree information super.validate(actionMapping, request); this.validateParentTreeInformation(actionMapping, request); // Get the errors from the session and return them ErrorHandler eh = HttpErrorHandler.get(request.getSession()); return eh.getErrors(); } /** * Force formatting on data entry fields. */ public void forceFormats() { if (!dataBean.getP_orchard_comment().trim().equals("")) { dataBean.setP_orchard_comment(dataBean.getP_orchard_comment().toUpperCase()); } 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())); } /* Parent Tree Information related methods (Validation and Accumulation) */ /** * Wraps the messages coming from the validators to display the parent tree number */ private class Spr001aWrappedValidator extends WrappedValidator { private String fieldName = null; private ValidatingForm form = null; public Spr001aWrappedValidator(ValidatingForm form, FieldValidator validator) { super(form, validator, "spar.web.error.usr.spr001a.parentTreeInformationValidationWrapper", new String[]{""}); // Needed for the validate. this.form = form; this.fieldName = "parent_tree_number"; } public ErrorMessage validate() { // Set the message parameter getParameters()[0] = this.getPropertyValue(form.getBean(), fieldName); return super.validate(); } } /** * Form used for the parent tree validators */ private class ParentTreeInformationForm extends SparForm implements ValidatingForm { // Field validators private FieldValidator pollenCountAndConeCountAreZero = new FieldValidator() { public ErrorMessage validate() { try { float coneCount = Float.parseFloat(bean.getCone_count()); float pollenCount = Float.parseFloat(bean.getPollen_count()); if ((coneCount == 0.0) && (pollenCount == 0.0)) { return new ErrorMessage("spar.web.error.usr.spr001a.coneCountPollenCountEqual0"); } } catch (NumberFormatException e) { // Do nothing, this will be handled by the numeric validators } return null; } }; private RequiredFieldValidator coneCountRequired = new RequiredFieldValidator(this, "pollen_count", "Pollen Count"); private RequiredFieldValidator pollenCountRequired = new RequiredFieldValidator(this, "cone_count", "Cone Count"); private FloatFieldValidator coneCountNumeric = new FloatFieldValidator(this, "cone_count", "Cone Count", false); private FloatRangeValidator coneCountRange = new FloatRangeValidator(this, "cone_count", "Cone Count", 0.0, 9999999999.9999999999, false) { // TODO: Roll this validator into sil FloatRangeValidator. The validator // in sil should use a DecimalFormat to format the numbers instead of // concatenating with a blank string. public ErrorMessage validate() { ErrorMessage validationResult = super.validate(); if (validationResult != null) { return new ErrorMessage(validationResult.getKey(), "Cone Count", "0", "999999999.999999999"); } return null; } }; private FloatFieldValidator pollenCountNumeric = new FloatFieldValidator(this, "pollen_count", "Pollen Count", false); private FloatRangeValidator pollenCountRange = new FloatRangeValidator(this, "pollen_count", "Pollen Count", 0.0, 9999999999.9999999999, false) { // TODO: Roll this validator into sil FloatRangeValidator. The validator // in sil should use a DecimalFormat to format the numbers instead of // concatenating with a blank string. public ErrorMessage validate() { ErrorMessage validationResult = super.validate(); if (validationResult != null) { return new ErrorMessage(validationResult.getKey(), "Pollen Count", "0", "999999999.999999999"); } return null; } }; private IntegerFieldValidator smpSuccessPctNumeric = new IntegerFieldValidator(this, "smp_success_pct", "SMP Success on parent", false); private IntegerLimitsValidator smpSuccessPctRange = new IntegerLimitsValidator(this, "smp_success_pct", "SMP Success on parent", 0, 25, false); private IntegerLimitsValidator smpSuccessPctRangePW = new IntegerLimitsValidator(this, "smp_success_pct", "SMP Success on parent", 0, 100, false); // For Western White Pine (PW), the smp success pct can go up to 100 private final FieldValidator smpSuccessPctRangeValidator = new FieldValidator() { public ErrorMessage validate() { if(dataBean.getP_vegetation_code().equals("PW")) { return smpSuccessPctRangePW.validate(); } else { return smpSuccessPctRange.validate(); } } }; private FloatFieldValidator smpMixBvGNumeric = new FloatFieldValidator(this, "smp_mix_bv_g", "BV-G of SMP mix used on parent", false); private FloatRangeValidator smpMixBvGRange = new FloatRangeValidator(this, "smp_mix_bv_g", "BV-G of SMP mix used on parent", -99.9, 999.9, false, true); private DecimalPlacesValidator smpMixBvGDecimalPlaces = new DecimalPlacesValidator(this, "smp_mix_bv_g", "BV-G of SMP mix used on parent", "ca.bc.gov.mof.sil.webade.db.error.decimal-places", 1, false); private FloatFieldValidator smpMixBvDNumeric = new FloatFieldValidator(this, "smp_mix_bv_d", "BV-D of SMP mix used on parent", false); private FloatRangeValidator smpMixBvDRange = new FloatRangeValidator(this, "smp_mix_bv_d", "BV-D of SMP mix used on parent", -99.9, 999.9, false, true); private DecimalPlacesValidator smpMixBvDDecimalPlaces = new DecimalPlacesValidator(this, "smp_mix_bv_d", "BV-D of SMP mix used on parent", "ca.bc.gov.mof.sil.webade.db.error.decimal-places", 1, false); private FloatFieldValidator smpMixBvRNumeric = new FloatFieldValidator(this, "smp_mix_bv_r", "BV-R of SMP mix used on parent", false); private FloatRangeValidator smpMixBvRRange = new FloatRangeValidator(this, "smp_mix_bv_r", "BV-R of SMP mix used on parent", -99.9, 999.9, false, true); private DecimalPlacesValidator smpMixBvRDecimalPlaces = new DecimalPlacesValidator(this, "smp_mix_bv_r", "BV-R of SMP mix used on parent", "ca.bc.gov.mof.sil.webade.db.error.decimal-places", 1, false); private FloatFieldValidator smpMixBvMNumeric = new FloatFieldValidator(this, "smp_mix_bv_m", "BV-M of SMP mix used on parent", false); private FloatRangeValidator smpMixBvMRange = new FloatRangeValidator(this, "smp_mix_bv_m", "BV-M of SMP mix used on parent", -99.9, 999.9, false, true); private DecimalPlacesValidator smpMixBvMDecimalPlaces = new DecimalPlacesValidator(this, "smp_mix_bv_m", "BV-M of SMP mix used on parent", "ca.bc.gov.mof.sil.webade.db.error.decimal-places", 1, false); private IntegerFieldValidator smpMixLatitudeDegreesNumeric = new IntegerFieldValidator(this, "smp_mix_latitude_degrees", "Mean degrees lat. of SMP mix used on parent", false); private IntegerLimitsValidator smpMixLatitudeDegreesRange = new IntegerLimitsValidator(this, "smp_mix_latitude_degrees", "Mean degrees lat. of SMP mix used on parent", 0, 90, false); private IntegerFieldValidator smpMixLatitudeMinutesNumeric = new IntegerFieldValidator(this, "smp_mix_latitude_minutes", "Mean minutes lat. of SMP mix used on parent", false); private IntegerLimitsValidator smpMixLatitudeMinutesRange = new IntegerLimitsValidator(this, "smp_mix_latitude_minutes", "Mean minutes lat. of SMP mix used on parent", 0, 59, false); private IntegerFieldValidator smpMixLongitudeDegreesNumeric = new IntegerFieldValidator(this, "smp_mix_longitude_degrees", "Mean degrees long. of SMP mix used on parent", false); private IntegerLimitsValidator smpMixLongitudeDegreesRange = new IntegerLimitsValidator(this, "smp_mix_longitude_degrees", "Mean degrees long. of SMP mix used on parent", 0, 180, false); private IntegerFieldValidator smpMixLongitudeMinutesNumeric = new IntegerFieldValidator(this, "smp_mix_longitude_minutes", "Mean minutes long. of SMP mix used on parent", false); private IntegerLimitsValidator smpMixLongitudeMinutesRange = new IntegerLimitsValidator(this, "smp_mix_longitude_minutes", "Mean minutes long. of SMP mix used on parent", 0, 59, false); private IntegerFieldValidator smpMixElevationNumeric = new IntegerFieldValidator(this, "smp_mix_elevation", "Mean elev. of SMP mix used on parent", false); private IntegerLimitsValidator smpMixElevationRange = new IntegerLimitsValidator(this, "smp_mix_elevation", "Mean elev. of SMP mix used on parent", 0, 99999, false); private IntegerFieldValidator nonOrchardPollenContamPctNumeric = new IntegerFieldValidator(this, "non_orchard_pollen_contam_pct", "Non-orchard pollen contam", false); private IntegerLimitsValidator nonOrchardPollenContamPctRange = new IntegerLimitsValidator(this, "non_orchard_pollen_contam_pct", "Non-orchard pollen contam", 0, 999, false); public ParentTreeInformationForm() { // Initialize the validators addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, coneCountRequired), new Spr001aWrappedValidator(this, coneCountNumeric), new Spr001aWrappedValidator(this, coneCountRange)}); addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, pollenCountRequired), new Spr001aWrappedValidator(this, pollenCountNumeric), new Spr001aWrappedValidator(this, pollenCountRange)}); addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, smpSuccessPctNumeric), new Spr001aWrappedValidator(this, smpSuccessPctRangeValidator)}); addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, smpMixBvGNumeric), new Spr001aWrappedValidator(this, smpMixBvGRange), new Spr001aWrappedValidator(this, smpMixBvGDecimalPlaces)}); addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, smpMixBvDNumeric), new Spr001aWrappedValidator(this, smpMixBvDRange), new Spr001aWrappedValidator(this, smpMixBvDDecimalPlaces)}); addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, smpMixBvRNumeric), new Spr001aWrappedValidator(this, smpMixBvRRange), new Spr001aWrappedValidator(this, smpMixBvRDecimalPlaces)}); addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, smpMixBvMNumeric), new Spr001aWrappedValidator(this, smpMixBvMRange), new Spr001aWrappedValidator(this, smpMixBvMDecimalPlaces)}); addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, smpMixLatitudeDegreesNumeric), new Spr001aWrappedValidator(this, smpMixLatitudeDegreesRange), new Spr001aWrappedValidator(this, smpMixLatitudeMinutesNumeric), new Spr001aWrappedValidator(this, smpMixLatitudeMinutesRange)}); addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, smpMixLongitudeDegreesNumeric), new Spr001aWrappedValidator(this, smpMixLongitudeDegreesRange), new Spr001aWrappedValidator(this, smpMixLongitudeMinutesNumeric), new Spr001aWrappedValidator(this, smpMixLongitudeMinutesRange)}); addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, smpMixElevationNumeric), new Spr001aWrappedValidator(this, smpMixElevationRange)}); addValidatorChain("Save", new FieldValidator[]{new Spr001aWrappedValidator(this, nonOrchardPollenContamPctNumeric), new Spr001aWrappedValidator(this, nonOrchardPollenContamPctRange)}); addValidator("Save", new Spr001aWrappedValidator(this, pollenCountAndConeCountAreZero)); } private Spr001aParentTreeContribResultArrayElement bean = null; private String userAction = ""; public DataBean getBean() { return bean; } public void setUserAction(String userAction) { this.userAction = userAction; } public String getUserAction() { return userAction; } public void clear() { // Do Nothing } public void setBean(DataBean bean) { this.bean = (Spr001aParentTreeContribResultArrayElement) bean; } }; private ParentTreeInformationForm parentTreeInformationForm = new ParentTreeInformationForm(); /** * Validates the parent tree information contained within the bean and adds * any failures to the passed errors. * */ private void validateParentTreeInformation(ActionMapping mapping, HttpServletRequest request) { Spr001aParentTreeContribResultArrayElement element = null; parentTreeInformationForm.setUserAction(userAction); // Validate each of the beans Iterator iterator = dataBean.getP_result().iterator(); while (iterator.hasNext()) { element = (Spr001aParentTreeContribResultArrayElement) iterator.next(); parentTreeInformationForm.setBean(element); // If the item should be saved, validate it if (!Spr001aParentTreeContribForm.parentTreeInformationIsBlank(element)) { parentTreeInformationForm.validate(mapping, request); } } } /** * Accumulates parent tree information into p_results. * * @param request */ private void accumulateParentTreeInformation(HttpServletRequest request) { int index = 0; // Each item in the result set will have a p_results_N.p_parent_tree_id // field on the screen while (request.getParameter("p_result_" + index + ".parent_tree_id") != null) { Spr001aParentTreeContribResultArrayElement element = new Spr001aParentTreeContribResultArrayElement(); // Populate the element element.setParent_tree_id(request.getParameter("p_result_" + index + ".parent_tree_id")); element.setParent_tree_number(request.getParameter("p_result_" + index + ".parent_tree_number")); element.setG_estimated_ind(request.getParameter("p_result_" + index + ".g_estimated_ind")); element.setD_estimated_ind(request.getParameter("p_result_" + index + ".d_estimated_ind")); element.setR_estimated_ind(request.getParameter("p_result_" + index + ".r_estimated_ind")); element.setM_estimated_ind(request.getParameter("p_result_" + index + ".m_estimated_ind")); element.setUntested_ind(request.getParameter("p_result_" + index + ".untested_ind")); element.setBv_g(request.getParameter("p_result_" + index + ".bv_g")); element.setBv_d(request.getParameter("p_result_" + index + ".bv_d")); element.setBv_r(request.getParameter("p_result_" + index + ".bv_r")); element.setBv_m(request.getParameter("p_result_" + index + ".bv_m")); element.setCv_g(request.getParameter("p_result_" + index + ".cv_g")); element.setCv_d(request.getParameter("p_result_" + index + ".cv_d")); element.setCv_r(request.getParameter("p_result_" + index + ".cv_r")); element.setCv_m(request.getParameter("p_result_" + index + ".cv_m")); element.setCone_count(request.getParameter("p_result_" + index + ".cone_count")); element.setPollen_count(request.getParameter("p_result_" + index + ".pollen_count")); element.setSmp_success_pct(request.getParameter("p_result_" + index + ".smp_success_pct")); element.setSmp_mix_latitude_degrees(request.getParameter("p_result_" + index + ".smp_mix_latitude_degrees")); element.setSmp_mix_latitude_minutes(request.getParameter("p_result_" + index + ".smp_mix_latitude_minutes")); element.setSmp_mix_longitude_degrees(request.getParameter("p_result_" + index + ".smp_mix_longitude_degrees")); element.setSmp_mix_longitude_minutes(request.getParameter("p_result_" + index + ".smp_mix_longitude_minutes")); element.setSmp_mix_elevation(request.getParameter("p_result_" + index + ".smp_mix_elevation")); element.setSmp_mix_bv_g(request.getParameter("p_result_" + index + ".smp_mix_bv_g")); element.setSmp_mix_bv_d(request.getParameter("p_result_" + index + ".smp_mix_bv_d")); element.setSmp_mix_bv_r(request.getParameter("p_result_" + index + ".smp_mix_bv_r")); element.setSmp_mix_bv_m(request.getParameter("p_result_" + index + ".smp_mix_bv_m")); element.setNon_orchard_pollen_contam_pct(request.getParameter("p_result_" + index + ".non_orchard_pollen_contam_pct")); element.setTotal_genetic_worth_contrib(request.getParameter("p_result_" + index + ".total_genetic_worth_contrib")); element.setGeography_error_ind(request.getParameter("p_result_" + index + ".geography_error_ind")); element.setRevision_count(request.getParameter("p_result_" + index + ".revision_count")); dataBean.getP_result().set(index, element); index++; } } /** * Returns true if the passed parent tree information element contains all blanks * @param element Element to checked * @return True if the element should be saved, false if not */ public static boolean parentTreeInformationIsBlank(Spr001aParentTreeContribResultArrayElement element) { boolean blank = element.getCone_count().equals("") && element.getPollen_count().equals("") && element.getSmp_success_pct().equals("") && element.getSmp_mix_bv_g().equals("") && element.getSmp_mix_bv_d().equals("") && element.getSmp_mix_bv_r().equals("") && element.getSmp_mix_bv_m().equals("") && element.getSmp_mix_latitude_degrees().equals("") && element.getSmp_mix_latitude_minutes().equals("") && element.getSmp_mix_longitude_degrees().equals("") && element.getSmp_mix_longitude_minutes().equals("") && element.getSmp_mix_elevation().equals("") && element.getNon_orchard_pollen_contam_pct().equals(""); return blank; } /** * Returns true if the passed parent tree information element should be saved * @param element Element to checked * @return True if the element should be saved, false if not */ public static boolean parentTreeInformationSavable(Spr001aParentTreeContribResultArrayElement element) { boolean saveable = (!element.getCone_count().equals("") && !element.getPollen_count().equals("")) || !element.getRevision_count().equals(""); return saveable; } /* Security Methods */ /** * Determines if the user is allowed to save. */ public boolean getSaveEnabled() { SparUser sparUser = (SparUser) user(); // If the record is pending, anybody can save if (dataBean.getP_seedlot_status_code().equals("PND")) { return true; } // If the seedlot is cancelled, or incomplete it is not updateable else if (dataBean.getP_seedlot_status_code().equals("CAN") || dataBean.getP_seedlot_status_code().equals("INC")) { return false; } // If the seedlot is approved, complete, submitted, or expired only users who are SPR_TREE_CENTRE_ADMIN can update it else if (dataBean.getP_seedlot_status_code().equals("EXP") || dataBean.getP_seedlot_status_code().equals("APP") || dataBean.getP_seedlot_status_code().equals("COM") || dataBean.getP_seedlot_status_code().equals("SUB")) { if (sparUser.getIsTreeSeedCentreAdmin()) { return true; } else { return false; } } // Assume the user is allowed to save return true; } /** * Determines if the user is allowed to enter data for the passed parent tree * information record. * * @return true if the user can edit the record, false if not. */ public boolean parentTreeInformationEditable(Spr001aParentTreeContribResultArrayElement element) { if (!StringUtils.getInstance().hasAValue(element.getBv_g()) && !StringUtils.getInstance().hasAValue(element.getCv_g())) { return false; } return true; } /** * Returns true if bv_* are to be displayed instead of cv_*. * * @return true if bv_* are to be displayed instead of cv_*. */ public boolean getDisplayBv() { if (dataBean.getP_result().size() > 0) { Spr001aParentTreeContribResultArrayElement element = (Spr001aParentTreeContribResultArrayElement) dataBean.getP_result().get(0); // If any of the Bv_ fields have a value then bv will be displayed. if (!element.getBv_d().equals("") || !element.getBv_g().equals("") || !element.getBv_r().equals("") || !element.getBv_m().equals("")) { return true; } else { return false; } } else { // Assume that BV are displayed return true; } } /** * Returns true if calculation of smp is available. * * @return true if calculation of smp is available. */ public boolean getDisplaySmp() { if (StringUtils.getInstance().hasAValue(this.getOld_orchard_id()) && StringUtils.getInstance().hasAValue(this.getOld_seed_plan_unit_id())) { return true; } else { // Assume that BV are displayed return false; } } /** * Refreshes the SPU codes */ public void refreshSpuCodes() { try { SPUCodeListStore spuStore = null; // Tested Parent Trees should only display primary SPUs if (dataBean.getP_seedlot_source_code().equals("TPT")) { spuStore = new PrimarySPUStore("ca.bc.gov.mof", "PKG_SPR_CODE_LISTS.GET_PRIMARY_SPU", new Parameter[1], getUser().getName(), "POPULATE_FORM"); } else { spuStore = new SPUStore("ca.bc.gov.mof", "PKG_SPR_CODE_LISTS.GET_SPU", new Parameter[1], getUser().getName(), "POPULATE_FORM"); } // Only select codes if there is a selected class A source. if (spuStore != null) { OptionBean[] spuCodes = spuStore.getSpuCodeListWithId(getDataBean().getP_vegetation_code()); setSpuCodes(spuCodes); } } catch (StoreException x) { x.printStackTrace(); } catch (SQLException x) { x.printStackTrace(); } } }