Exemplo n.º 1
0
 /**
  * @see
  *     edu.wustl.catissuecore.actionForm.AbstractActionForm#setAllValues(edu.wustl.catissuecore.domain.AbstractDomainObject)
  * @param abstractDomain An object of Specimen class.
  */
 @Override
 public void setAllValues(AbstractDomainObject abstractDomain) {
   super.setAllValues(abstractDomain);
   final CellSpecimenReviewParameters cellSpecimenReviewParametersObject =
       (CellSpecimenReviewParameters) abstractDomain;
   this.neoplasticCellularityPercentage =
       CommonUtilities.toString(
           cellSpecimenReviewParametersObject.getNeoplasticCellularityPercentage());
   this.viableCellPercentage =
       CommonUtilities.toString(cellSpecimenReviewParametersObject.getViableCellPercentage());
 }
  /**
   * Populates all the fields from the domain object to the form bean.
   *
   * @param abstractDomain An AbstractDomain Object
   */
  @Override
  public void setAllValues(AbstractDomainObject abstractDomain) {
    super.setAllValues(abstractDomain);
    final TissueSpecimenReviewEventParameters tissueSpecimenReviewParametersObject =
        (TissueSpecimenReviewEventParameters) abstractDomain;

    this.neoplasticCellularityPercentage =
        CommonUtilities.toString(
            tissueSpecimenReviewParametersObject.getNeoplasticCellularityPercentage());
    this.necrosisPercentage =
        CommonUtilities.toString(tissueSpecimenReviewParametersObject.getNecrosisPercentage());
    this.lymphocyticPercentage =
        CommonUtilities.toString(tissueSpecimenReviewParametersObject.getLymphocyticPercentage());
    this.totalCellularityPercentage =
        CommonUtilities.toString(
            tissueSpecimenReviewParametersObject.getTotalCellularityPercentage());
    this.histologicalQuality =
        CommonUtilities.toString(tissueSpecimenReviewParametersObject.getHistologicalQuality());
    logger.debug("this.neoplasticCellularityPercentage : " + this.neoplasticCellularityPercentage);
    logger.debug("this.necrosisPercentage : " + this.necrosisPercentage);
    logger.debug("this.lymphocyticPercentage : " + this.lymphocyticPercentage);
    logger.debug("this.totalCellularityPercentage : " + this.totalCellularityPercentage);
  }
 /**
  * @param uiRepOfDomain EventParametersForm.
  * @throws AssignDataException AssignDataException.
  */
 private void setDateTimeFromCalender(D domainObject, EventParametersForm uiRepOfDomain) {
   final Calendar calendar = Calendar.getInstance();
   Date date;
   try {
     date =
         CommonUtilities.parseDate(
             uiRepOfDomain.getDateOfEvent(),
             CommonUtilities.datePattern(uiRepOfDomain.getDateOfEvent()));
     calendar.setTime(date);
     domainObject.setTimestamp(calendar.getTime());
     calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(uiRepOfDomain.getTimeInHours()));
     calendar.set(Calendar.MINUTE, Integer.parseInt(uiRepOfDomain.getTimeInMinutes()));
     domainObject.setTimestamp(calendar.getTime());
   } catch (final ParseException excp) {
     // TODO
     // SpecimenEventParameters.logger.error(excp.getMessage(), excp);
     excp.printStackTrace();
     // final ErrorKey errorKey =
     // ErrorKey.getErrorKey("assign.data.error");
     // throw new AssignDataException(errorKey, null,
     // "SpecimenEventParameters.java :");
   }
 }
  /**
   * Overrides the executeSecureAction method of SecureAction class.
   *
   * @param mapping object of ActionMapping
   * @param form : actionForm
   * @param request object of HttpServletRequest
   * @param response object of HttpServletResponse
   * @throws Exception generic exception
   * @return ActionForward : ActionForward
   */
  @Override
  public ActionForward executeSecureAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    DAO dao = null;
    String pageOf = null;
    try {
      final SessionDataBean sessionDataBean =
          (SessionDataBean) request.getSession().getAttribute(Constants.SESSION_DATA);
      dao = AppUtility.openDAOSession(sessionDataBean);
      final SpecimenArrayAliquotForm specimenArrayAliquotForm = (SpecimenArrayAliquotForm) form;
      pageOf = request.getParameter(Constants.PAGE_OF);
      final StorageContainerForSpArrayBizLogic bizLogic = new StorageContainerForSpArrayBizLogic();
      final SessionDataBean sessionData =
          (SessionDataBean) request.getSession().getAttribute(Constants.SESSION_DATA);
      final List<NameValueBean> storagePositionListForSpecimenArrayAliquot =
          AppUtility.getStoragePositionTypeListForTransferEvent();
      request.setAttribute(
          "storagePositionListForSpecimenArrayAliquot", storagePositionListForSpecimenArrayAliquot);
      final String exceedingMaxLimit = "false";
      if (specimenArrayAliquotForm.getButtonClicked().equalsIgnoreCase("submit")) {
        final Map tempAliquotMap = new HashMap();
        if (specimenArrayAliquotForm.getCheckedButton().equals("1")) {
          tempAliquotMap.put("label", specimenArrayAliquotForm.getParentSpecimenArrayLabel());
        } else {
          tempAliquotMap.put("barcode", specimenArrayAliquotForm.getBarcode());
        }
        tempAliquotMap.put("aliquotcount", specimenArrayAliquotForm.getAliquotCount());
        request.getSession().setAttribute("tempAliquotMap", tempAliquotMap);
      } else if (specimenArrayAliquotForm.getButtonClicked().equalsIgnoreCase("create")) {
        boolean arePropertiesChanged = false;
        final Map tempAliquotMap = (HashMap) request.getSession().getAttribute("tempAliquotMap");
        final String label = (String) tempAliquotMap.get("label");
        final String barcode = (String) tempAliquotMap.get("barcode");
        if (specimenArrayAliquotForm.getCheckedButton().equals("1")) {
          if (label == null
              || !label
                  .trim()
                  .equalsIgnoreCase(
                      specimenArrayAliquotForm.getParentSpecimenArrayLabel().trim())) {
            arePropertiesChanged = true;
          }
        } else {
          if (barcode == null
              || !barcode.trim().equalsIgnoreCase(specimenArrayAliquotForm.getBarcode().trim())) {
            arePropertiesChanged = true;
          }
        }
        final String aliquotcount = (String) tempAliquotMap.get("aliquotcount");
        if (!aliquotcount
            .trim()
            .equalsIgnoreCase(specimenArrayAliquotForm.getAliquotCount().trim())) {
          arePropertiesChanged = true;
        }

        /**
         * Repopulate the form with storage container locations in case user has changed any of
         * label/barcode, aliquot count, quantity per aliquot.
         */
        if (arePropertiesChanged == true) {
          specimenArrayAliquotForm.setParentSpecimenArrayLabel(label);
          specimenArrayAliquotForm.setAliquotCount(aliquotcount);
          specimenArrayAliquotForm.setBarcode(barcode);

          ActionErrors errors = this.getActionErrors(request);

          if (errors == null) {
            errors = new ActionErrors();
          }
          if (arePropertiesChanged == true) {
            errors.add(
                ActionErrors.GLOBAL_ERROR,
                new ActionError("errors.specimenArrayAliquots.reSubmit"));
          }

          TreeMap containerMap = new TreeMap();
          this.checkForSpecimenArray(request, specimenArrayAliquotForm, dao);
          // int aliquotCount =
          // Integer.parseInt(specimenArrayAliquotForm.getAliquotCount());
          final Long id = (Long) request.getAttribute(Constants.STORAGE_TYPE_ID);
          containerMap =
              bizLogic.getAllocatedContainerMapForSpecimenArray(id.longValue(), sessionData, dao);
          this.populateAliquotsStorageLocations(specimenArrayAliquotForm, containerMap);
          request.setAttribute(Constants.AVAILABLE_CONTAINER_MAP, containerMap);
          request.setAttribute(Constants.PAGE_OF, Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT);
          this.saveErrors(request, errors);
          return mapping.findForward(Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT);

        } else {
          // TODO
          specimenArrayAliquotForm.setButtonClicked("none");
          return mapping.findForward(Constants.COMMON_ADD_EDIT);
        }
      }

      if (Constants.PAGE_OF_SPECIMEN_ARRAY_ALIQUOT_SUMMARY.equals(pageOf)) {
        final Map map = (Map) request.getAttribute("forwardToHashMap");

        if (map != null) {
          // TODO
          specimenArrayAliquotForm.setSpecimenClass(
              CommonUtilities.toString(map.get(Constants.ALIQUOT_SPECIMEN_CLASS)));
          specimenArrayAliquotForm.setSpecimenArrayType(
              CommonUtilities.toString(map.get(Constants.ALIQUOT_SPECIMEN_ARRAY_TYPE)));
          specimenArrayAliquotForm.setAliquotCount(
              CommonUtilities.toString(map.get(Constants.ALIQUOT_ALIQUOT_COUNTS)));
          final Collection specimenTypesCollection =
              (Collection) map.get(Constants.ALIQUOT_SPECIMEN_TYPES);
          final List specimenTypeList =
              this.setSpecimenTypes(specimenTypesCollection, specimenArrayAliquotForm);
          request.setAttribute(Constants.SPECIMEN_TYPE_LIST, specimenTypeList);
          String containerNameKey = "";
          String posDim1Key = "";
          String posDim2Key = "";
          /** This code is added to set storage positions in case of manual mode. bug 15085 */
          for (int iCount = 1;
              iCount <= Integer.parseInt(specimenArrayAliquotForm.getAliquotCount());
              iCount++) {
            if (map.get("radio_" + iCount) != null && map.get("radio_" + iCount).equals("2")) {
              containerNameKey = "SpecimenArray:" + iCount + "_StorageContainer_name";
              posDim1Key = "SpecimenArray:" + iCount + "_positionDimensionOne";
              posDim2Key = "SpecimenArray:" + iCount + "_positionDimensionTwo";
              map.put(containerNameKey, map.get(containerNameKey + "_fromMap"));
              if (!map.get(posDim1Key + "_fromMap").equals("")) {
                map.put(posDim1Key, map.get(posDim1Key + "_fromMap"));
              }
              if (!map.get(posDim2Key + "_fromMap").equals("")) {
                map.put(posDim2Key, map.get(posDim2Key + "_fromMap"));
              }
            }
          }
          specimenArrayAliquotForm.setSpecimenArrayAliquotMap(map);
        }

        final ActionErrors errors = this.getActionErrors(request);

        if (errors == null || errors.size() == 0) {
          final ActionMessages messages = new ActionMessages();
          messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("aliquots.success"));
          this.saveMessages(request, messages);
        }
        return mapping.findForward(pageOf);
      }

      Map containerMap = new HashMap();
      if (Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT.equals(
          request.getParameter(Constants.PAGE_OF))) {
        pageOf = this.validate(request, specimenArrayAliquotForm);

        if (Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT.equals(pageOf)) {
          pageOf = this.checkForSpecimenArray(request, specimenArrayAliquotForm, dao);

          if (Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT.equals(pageOf)) {
            final int aliquotCount = Integer.parseInt(specimenArrayAliquotForm.getAliquotCount());
            final Long id = (Long) request.getAttribute(Constants.STORAGE_TYPE_ID);
            containerMap =
                bizLogic.getAllocatedContainerMapForSpecimenArray(id.longValue(), sessionData, dao);
            pageOf = this.checkForSufficientAvailablePositions(request, containerMap, aliquotCount);

            if (Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT.equals(pageOf)) {
              final ActionErrors errors = (ActionErrors) request.getAttribute(Globals.ERROR_KEY);
              if (errors == null || errors.size() == 0) {
                this.populateAliquotsStorageLocations(specimenArrayAliquotForm, containerMap);
              }
            }
          }
        }
      }
      request.setAttribute(Constants.EXCEEDS_MAX_LIMIT, exceedingMaxLimit);
      request.setAttribute(Constants.AVAILABLE_CONTAINER_MAP, containerMap);
      request.setAttribute(Constants.PAGE_OF, pageOf);
    } finally {
      dao.closeSession();
    }
    return mapping.findForward(pageOf);
  }