Exemplo n.º 1
0
  /**
   * Overrides the validate method of ActionForm.
   *
   * @return error ActionErrors instance
   * @param mapping Actionmapping instance
   * @param request HttpServletRequest instance
   */
  @Override
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    final ActionErrors errors = super.validate(mapping, request);
    final Validator validator = new Validator();

    try {
      // checks the neoplasticCellularityPercentage
      if (!Validator.isEmpty(this.neoplasticCellularityPercentage)
          && !validator.isDouble(this.neoplasticCellularityPercentage, false)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.format",
                ApplicationProperties.getValue(
                    "cellspecimenreviewparameters.neoplasticcellularitypercentage")));
      }
      // checks the viableCellPercentage
      if (!Validator.isEmpty(this.viableCellPercentage)
          && !validator.isDouble(this.viableCellPercentage, false)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.format",
                ApplicationProperties.getValue(
                    "cellspecimenreviewparameters.viablecellpercentage")));
      }
    } catch (final Exception excp) {
      CellSpecimenReviewParametersForm.logger.error(excp.getMessage(), excp);
      excp.printStackTrace();
    }
    return errors;
  }
Exemplo n.º 2
0
  /* (non-Javadoc)
   * @see edu.wustl.common.actionForm.AbstractActionForm#setAllValues(edu.wustl.common.domain.AbstractDomainObject)
   */
  @Override
  // public void setAllValues(AbstractDomainObject arg0)
  // {
  // TODO Auto-generated method stub

  // }

  /**
   * Overrides the validate method of ActionForm.
   *
   * @param mapping ActionMapping mapping
   * @param request HttpServletRequest request
   * @return ActionErrors ActionErrors
   */
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    Validator validator = new Validator();

    if (createGroupAs != null
        && createGroupAs.equals(ProcessorConstants.GROUP_CREATEAS_NEW)
        && (groupNameText == null || validator.isEmpty(String.valueOf(groupNameText)))) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              "errors.item.required", ApplicationProperties.getValue("eav.att.GroupTitle")));
    } else if (createGroupAs != null
        && createGroupAs.equals(ProcessorConstants.GROUP_CREATEFROM_EXISTING)
        && (groupName == null || validator.isEmpty(String.valueOf(groupName)))) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              "errors.item.required", ApplicationProperties.getValue("eav.att.GroupTitle")));
    } else if (createGroupAs == null) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              "errors.item.required", ApplicationProperties.getValue("eav.att.NewGroup")));
    }

    if ((groupDescription != null)
        && (groupDescription.length() > ProcessorConstants.MAX_LENGTH_DESCRIPTION)) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              "errors.maxlength.exceeded",
              ApplicationProperties.getValue("eav.att.Description"),
              ProcessorConstants.MAX_LENGTH_DESCRIPTION));
    }

    if ((groupNameText != null) && (groupNameText.length() > ProcessorConstants.MAX_LENGTH_NAME)) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              "errors.maxlength.exceeded",
              ApplicationProperties.getValue("eav.att.GroupTitle"),
              ProcessorConstants.MAX_LENGTH_NAME));
    }
    return errors;
  }
 /**
  * This method validate timestamptime value.
  *
  * @param enteredValue entered Value.
  * @param errors errors.
  * @return conditionError boolean value.
  */
 public boolean validate(String enteredValue, ActionErrors errors) {
   Validator validator = new Validator();
   boolean conditionError = false;
   if (!(validator.isValidTime(
       enteredValue, CommonServiceLocator.getInstance().getTimePattern()))) {
     errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("simpleQuery.time.format"));
     conditionError = true;
   }
   return conditionError;
 }
Exemplo n.º 4
0
 /**
  * Checks the validity of numeric value of the component and adds an ActionError object in the
  * ActionErrors object.
  *
  * @param componentName Component which is to be checked.
  * @param labelName Label of the component on the jsp page which is checked.
  * @param errors ActionErrors Object.
  */
 protected void checkValidNumber(
     String componentName, String labelName, ActionErrors errors, Validator validator) {
   if (validator.isEmpty(componentName)) {
     errors.add(
         ActionErrors.GLOBAL_ERROR,
         new ActionError("errors.item.required", ApplicationProperties.getValue(labelName)));
   } else {
     if (!validator.isNumeric(componentName)) {
       errors.add(
           ActionErrors.GLOBAL_ERROR,
           new ActionError("errors.item.format", ApplicationProperties.getValue(labelName)));
     }
   }
 }
  /**
   * Overrides the validate method of ActionForm.
   *
   * @return error ActionErrors instance
   * @param mapping Actionmapping instance
   * @param request HttpServletRequest instance
   */
  @Override
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    final ActionErrors errors = super.validate(mapping, request);
    final Validator validator = new Validator();

    try {

      //         	// checks the neoplasticCellularityPercentage
      if (!Validator.isEmpty(this.neoplasticCellularityPercentage)
          && !validator.isDouble(this.neoplasticCellularityPercentage, false)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.format",
                ApplicationProperties.getValue(
                    "tissuespecimenrevieweventparameters.neoplasticcellularitypercentage")));
      }
      //

      //         	// checks the necrosisPercentage
      if (!Validator.isEmpty(this.necrosisPercentage)
          && !validator.isDouble(this.necrosisPercentage, false)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.format",
                ApplicationProperties.getValue(
                    "tissuespecimenrevieweventparameters.necrosispercentage")));
      }
      //

      //         	// checks the lymphocyticPercentage
      if (!Validator.isEmpty(this.lymphocyticPercentage)
          && !validator.isDouble(this.lymphocyticPercentage, false)) {

        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.format",
                ApplicationProperties.getValue(
                    "tissuespecimenrevieweventparameters.lymphocyticpercentage")));
      }
      //

      //         	// checks the totalCellularityPercentage
      if (!Validator.isEmpty(this.totalCellularityPercentage)
          && !validator.isDouble(this.totalCellularityPercentage, false)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.format",
                ApplicationProperties.getValue(
                    "tissuespecimenrevieweventparameters.totalcellularitypercentage")));
      }
      //

      //         	// checks the histologicalQuality
      //           	if (!validator.isValidOption(histologicalQuality) )
      //            {
      //           		errors.add(ActionErrors.GLOBAL_ERROR, new
      // ActionError("errors.item.required",ApplicationProperties.getValue("tissuespecimenrevieweventparameters.histologicalquality")));
      //            }
      //
    } catch (final Exception excp) {
      TissueSpecimenReviewEventParametersForm.logger.error(excp.getMessage(), excp);
      excp.printStackTrace();
    }
    return errors;
  }
Exemplo n.º 6
0
 public void setRedirectValue(Validator validator) {
   String cf = getRedirectTo();
   if (validator.isEmpty(cf)) cf = "";
   setRedirectTo(cf);
 }
  /* (non-Javadoc)
   * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
   */
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    final ActionErrors errors = new ActionErrors();
    final Validator validator = new Validator();
    double aliquotQuantity = 0;
    double initialQuantity = 0;
    try {
      if (validator.isEmpty(this.className)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.required", ApplicationProperties.getValue("specimen.type")));
      }
      //			if(this.labelGenType.equals("2") && validator.isEmpty(this.labelFormat))
      //			{
      //				errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
      //						"collectionProtocol.labelformat", ApplicationProperties
      //						.getValue("collectionProtocol.labelformat")));
      //			}
      if (validator.isEmpty(this.type)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.required", ApplicationProperties.getValue("specimen.subType")));
      }
      final List specimenClassList =
          CDEManager.getCDEManager()
              .getPermissibleValueList(Constants.CDE_NAME_SPECIMEN_CLASS, null);
      if (!Validator.isEnumeratedValue(specimenClassList, this.className)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.invalid", ApplicationProperties.getValue("specimen.type")));
      }

      if (!Validator.isEnumeratedValue(AppUtility.getSpecimenTypes(this.className), this.type)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.invalid", ApplicationProperties.getValue("specimen.subType")));
      }

      if (!validator.isEmpty(this.quantity)) {
        try {
          this.quantity = new BigDecimal(this.quantity).toPlainString();
          if (AppUtility.isQuantityDouble(this.className, this.type)) {
            if (!validator.isDouble(this.quantity, true)) {
              errors.add(
                  ActionErrors.GLOBAL_ERROR,
                  new ActionError(
                      "errors.item.required", ApplicationProperties.getValue("specimen.quantity")));
            }
          } else {
            if (!validator.isNumeric(this.quantity, 0)) {
              errors.add(
                  ActionErrors.GLOBAL_ERROR,
                  new ActionError(
                      "errors.item.format", ApplicationProperties.getValue("specimen.quantity")));
            }
          }
        } catch (final NumberFormatException exp) {
          CreateSpecimenTemplateForm.logger.info(exp.getMessage(), exp);
          exp.printStackTrace();
          errors.add(
              ActionErrors.GLOBAL_ERROR,
              new ActionError(
                  "errors.item.format", ApplicationProperties.getValue("specimen.quantity")));
        }

      } else {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.format", ApplicationProperties.getValue("specimen.quantity")));
      }

      if (!this.quantityPerAliquot.equals("")) {
        if (this.quantityPerAliquot != null && this.quantityPerAliquot.trim().length() != 0) {
          try {
            this.quantityPerAliquot = new BigDecimal(this.quantityPerAliquot).toPlainString();
            if (AppUtility.isQuantityDouble(this.className, this.type)) {
              if (!validator.isDouble(this.quantityPerAliquot.trim())) {
                errors.add(
                    ActionErrors.GLOBAL_ERROR,
                    new ActionError(
                        "errors.item.format",
                        ApplicationProperties.getValue("aliquots.qtyPerAliquot")));
              }
            } else {
              if (!validator.isPositiveNumeric(this.quantityPerAliquot.trim(), 1)) {
                errors.add(
                    ActionErrors.GLOBAL_ERROR,
                    new ActionError(
                        "errors.item.format",
                        ApplicationProperties.getValue("aliquots.qtyPerAliquot")));
              }
            }
          } catch (final NumberFormatException exp) {
            CreateSpecimenTemplateForm.logger.error(exp.getMessage(), exp);
            exp.printStackTrace();
            errors.add(
                ActionErrors.GLOBAL_ERROR,
                new ActionError(
                    "errors.item.format",
                    ApplicationProperties.getValue("aliquots.qtyPerAliquot")));
          }
        }
      }

      if (!this.noOfAliquots.equals("")) {
        this.noOfAliquots = AppUtility.isValidCount(this.noOfAliquots, errors);

        if (!validator.isNumeric(this.noOfAliquots, 1)) {
          errors.add(
              ActionErrors.GLOBAL_ERROR,
              new ActionError(
                  "errors.item.format",
                  ApplicationProperties.getValue("specimenArrayAliquots.noOfAliquots")));
        } else {
          try {
            if (this.quantityPerAliquot.equals("")) {
              if (this.quantity.equals("0") || this.quantity.equals("0")) {
                errors.add(
                    ActionErrors.GLOBAL_ERROR,
                    new ActionError(
                        "errors.invalid", ApplicationProperties.getValue("specimen.quantity")));
              } else {
                aliquotQuantity =
                    Double.parseDouble(this.quantity) / Double.parseDouble(this.noOfAliquots);
                initialQuantity =
                    Double.parseDouble(this.quantity)
                        - (aliquotQuantity * Double.parseDouble(this.noOfAliquots));
              }
            } else {
              aliquotQuantity = Double.parseDouble(this.quantityPerAliquot);
              initialQuantity = Double.parseDouble(this.quantity);
              initialQuantity =
                  initialQuantity - (aliquotQuantity * Double.parseDouble(this.noOfAliquots));
            }
            if (initialQuantity < 0) {
              errors.add(
                  ActionErrors.GLOBAL_ERROR,
                  new ActionError(
                      "errors.invalid",
                      ApplicationProperties.getValue("cpbasedentry.quantityperaliquot")));
            }
            //						if(this.labelGenTypeForAliquot.equals("2") &&
            // validator.isEmpty(this.labelFormatForAliquot))
            //						{
            //							errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
            //									"sp.req.aliquot.labelformat", ApplicationProperties
            //									.getValue("sp.req.aliquot.labelformat")));
            //						}
          } catch (final NumberFormatException exp) {
            CreateSpecimenTemplateForm.logger.error(exp.getMessage(), exp);
            errors.add(
                ActionErrors.GLOBAL_ERROR,
                new ActionError(
                    "errors.item.format", ApplicationProperties.getValue("specimen.quantity")));
          }
        }
      }

      if (this.tissueSite.equals("")) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.required", ApplicationProperties.getValue("specimen.tissueSite")));
      }

      if (this.tissueSide.equals("")) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.required", ApplicationProperties.getValue("specimen.tissueSide")));
      }

      if (this.noOfAliquots != null && !this.noOfAliquots.equals("")) {
        if (!this.storageLocationForAliquotSpecimen.equals("Auto")
            && !this.storageLocationForAliquotSpecimen.equals("Manual")
            && !this.storageLocationForAliquotSpecimen.equals("Virtual")) {
          errors.add(
              ActionErrors.GLOBAL_ERROR,
              new ActionError(
                  "errors.item.required",
                  ApplicationProperties.getValue("cpbasedentry.aliquotstoragelocation")));
        }
      }
      if (!this.storageLocationForSpecimen.equals("Auto")
          && !this.storageLocationForSpecimen.equals("Manual")
          && !this.storageLocationForSpecimen.equals("Virtual")) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.required",
                ApplicationProperties.getValue("cpbasedentry.specimenstoragelocation")));
      }
      if (this.pathologicalStatus.equals("")) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.required",
                ApplicationProperties.getValue("specimen.pathologicalStatus")));
      }
      final List tissueSiteList =
          CDEManager.getCDEManager().getPermissibleValueList(Constants.CDE_NAME_TISSUE_SITE, null);
      if (!Validator.isEnumeratedValue(tissueSiteList, this.tissueSite)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.invalid", ApplicationProperties.getValue("specimen.tissueSite")));
      }

      final List tissueSideList =
          CDEManager.getCDEManager().getPermissibleValueList(Constants.CDE_NAME_TISSUE_SIDE, null);
      if (!Validator.isEnumeratedValue(tissueSideList, this.tissueSide)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.invalid", ApplicationProperties.getValue("specimen.tissueSide")));
      }

      final List pathologicalStatusList =
          CDEManager.getCDEManager()
              .getPermissibleValueList(Constants.CDE_NAME_PATHOLOGICAL_STATUS, null);

      if (!Validator.isEnumeratedValue(pathologicalStatusList, this.pathologicalStatus)) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                "errors.item.invalid",
                ApplicationProperties.getValue("specimen.pathologicalStatus")));
      }

      if ((this.collectionEventUserId) == 0L) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError("errors.item.required", "Collection Event's user"));
      }

      // checks the collectionProcedure
      if (!validator.isValidOption(this.getCollectionEventCollectionProcedure())) {
        final String message =
            ApplicationProperties.getValue("collectioneventparameters.collectionprocedure");
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.item.required", message));
      }

      final List procedureList =
          CDEManager.getCDEManager()
              .getPermissibleValueList(Constants.CDE_NAME_COLLECTION_PROCEDURE, null);
      if (!Validator.isEnumeratedValue(
          procedureList, this.getCollectionEventCollectionProcedure())) {
        final String message = ApplicationProperties.getValue("cpbasedentry.collectionprocedure");
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.invalid", message));
      }
      // Container validation
      if (!validator.isValidOption(this.getCollectionEventContainer())) {
        final String message =
            ApplicationProperties.getValue("collectioneventparameters.container");
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.item.required", message));
      }
      final List containerList =
          CDEManager.getCDEManager().getPermissibleValueList(Constants.CDE_NAME_CONTAINER, null);
      if (!Validator.isEnumeratedValue(containerList, this.getCollectionEventContainer())) {
        final String message =
            ApplicationProperties.getValue("collectioneventparameters.container");
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.invalid", message));
      }
      if ((this.receivedEventUserId) == 0L) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError("errors.item.required", "Received Event's user"));
      }
      final List qualityList =
          CDEManager.getCDEManager()
              .getPermissibleValueList(Constants.CDE_NAME_RECEIVED_QUALITY, null);
      if (!Validator.isEnumeratedValue(qualityList, this.receivedEventReceivedQuality)) {
        final String message = ApplicationProperties.getValue("cpbasedentry.receivedquality");
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.invalid", message));
      }

      if (this.className.equals(Constants.MOLECULAR)) {
        if (!validator.isDouble(this.concentration, true)) {
          errors.add(
              ActionErrors.GLOBAL_ERROR,
              new ActionError(
                  "errors.item.format", ApplicationProperties.getValue("specimen.concentration")));
        }
      }

      if (this.noOfDeriveSpecimen >= 1) {
        boolean bSpecimenClass = false;
        boolean bSpecimenType = false;
        //				boolean validateLabel = false;
        //				boolean labelGenType = false;
        //				boolean labelFormat = false;
        final Map deriveSpecimenMap = this.deriveSpecimenMap();
        final Iterator it = deriveSpecimenMap.keySet().iterator();
        while (it.hasNext()) {
          final String key = (String) it.next();
          String mapValue = (String) deriveSpecimenMap.get(key);
          if (!bSpecimenClass) {
            if (key.indexOf("specimenClass") != -1 && !validator.isValidOption(mapValue)) {
              errors.add(
                  ActionErrors.GLOBAL_ERROR,
                  new ActionError(
                      "errors.item.selected",
                      ApplicationProperties.getValue("collectionprotocol.specimenclass")));
              bSpecimenClass = true;
            }
          }
          //					if(!labelGenType)
          //					{
          //						if ((key.indexOf("_labelGenType")) != -1 && mapValue != null)
          //						{
          //							if (mapValue.equals("2"))
          //							{
          //								validateLabel=true;
          //								labelGenType = true;
          //							}
          //						}
          //
          //					}
          //					if(!labelFormat && labelGenType)
          //					{
          //						if(validateLabel && (key.indexOf("_labelFormat")) != -1 &&
          // validator.isEmpty(mapValue))
          //						{
          //							labelFormat = true;
          //							errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
          //									"sp.req.derivative.labelformat", ApplicationProperties
          //									.getValue("sp.req.derivative.labelformat")));
          //						}
          //					}
          if ((key.indexOf("_concentration")) != -1 && mapValue != null) {
            mapValue = new BigDecimal(mapValue).toPlainString();
            if (!validator.isDouble(mapValue, true)) {
              errors.add(
                  ActionErrors.GLOBAL_ERROR,
                  new ActionError(
                      "errors.item.format",
                      ApplicationProperties.getValue("specimen.concentration")));
            }
          }

          if (!bSpecimenType) {
            if (key.indexOf("specimenType") != -1 && !validator.isValidOption(mapValue)) {
              errors.add(
                  ActionErrors.GLOBAL_ERROR,
                  new ActionError(
                      "errors.item.selected",
                      ApplicationProperties.getValue("collectionprotocol.specimetype")));
              bSpecimenType = true;
            }
          }

          if ((key.indexOf("_quantity")) != -1) {
            if (!validator.isEmpty(mapValue)) {
              try {
                mapValue = new BigDecimal(mapValue).toPlainString();
                if (AppUtility.isQuantityDouble(this.className, this.type)) {
                  if (!validator.isDouble(mapValue, true)) {
                    errors.add(
                        ActionErrors.GLOBAL_ERROR,
                        new ActionError(
                            "errors.item.required",
                            ApplicationProperties.getValue("specimen.quantity")));
                  }
                } else {
                  if (!validator.isNumeric(mapValue, 0)) {
                    errors.add(
                        ActionErrors.GLOBAL_ERROR,
                        new ActionError(
                            "errors.item.format",
                            ApplicationProperties.getValue(
                                "cpbasedentry.derivedspecimen.quantity")));
                  }
                }
              } catch (final NumberFormatException exp) {
                CreateSpecimenTemplateForm.logger.error(exp.getMessage(), exp);
                errors.add(
                    ActionErrors.GLOBAL_ERROR,
                    new ActionError(
                        "errors.item.format",
                        ApplicationProperties.getValue("cpbasedentry.derivedspecimen.quantity")));
              }
            } else {
              errors.add(
                  ActionErrors.GLOBAL_ERROR,
                  new ActionError(
                      "errors.item.format",
                      ApplicationProperties.getValue("cpbasedentry.derivedspecimen.quantity")));
            }
          }
        }
      }
    } catch (final Exception excp) {
      CreateSpecimenTemplateForm.logger.error(excp.getMessage(), excp);
      excp.printStackTrace();
    }
    return errors;
  }