コード例 #1
0
  /**
   * @param request HttpServletRequest
   * @param form SpecimenArrayAliquotForm
   * @return String : String
   * @throws BizLogicException : BizLogicException
   * @throws Exception : Exception
   */
  private String checkForSpecimenArray(
      HttpServletRequest request, SpecimenArrayAliquotForm form, DAO dao)
      throws BizLogicException, Exception {
    List specimenArrayList = new ArrayList();
    String errorString = "";
    final String specimenArrayLabel = form.getParentSpecimenArrayLabel();
    final int aliquotCount = Integer.parseInt(form.getAliquotCount());
    if (form.getCheckedButton().equals("1")) {

      specimenArrayList =
          dao.retrieve(SpecimenArray.class.getName(), Constants.SYSTEM_NAME, specimenArrayLabel);
      errorString = Constants.SYSTEM_LABEL;
    } else {
      final String barcode = form.getBarcode().trim();
      specimenArrayList =
          dao.retrieve(SpecimenArray.class.getName(), Constants.SYSTEM_BARCODE, barcode);
      errorString = Constants.SYSTEM_BARCODE;
    }

    if (specimenArrayList.isEmpty()) {
      final ActionErrors errors = this.getActionErrors(request);
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError("errors.specimenArrayAliquots.notExists", errorString));
      this.saveErrors(request, errors);
      return Constants.PAGE_OF_SPECIMEN_ARRAY_ALIQUOT;
    } else {
      final SpecimenArray specimenArray = (SpecimenArray) specimenArrayList.get(0);
      /**
       * Name : Virender Reviewer: Prafull Retriving specimenArrayTypeObject replaced
       * SpecimenArrayType arrayType = specimenArray.getSpecimenArrayType();
       */
      if (Status.ACTIVITY_STATUS_DISABLED.toString().equals(specimenArray.getActivityStatus())) {
        final ActionErrors errors = this.getActionErrors(request);
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError("errors.specimenArrayAliquots.disabled", "Parent Specimen Array"));
        this.saveErrors(request, errors);
        return Constants.PAGE_OF_SPECIMEN_ARRAY_ALIQUOT;
        // throw BizLogicException(
        // "Fail to create Aliquots, Parent SpecimenArray" + " " +
        // ApplicationProperties.getValue("error.object.disabled"));
      }
      final List arrayTypeList =
          dao.retrieveAttribute(
              SpecimenArray.class, "id", specimenArray.getId(), "specimenArrayType");
      if ((arrayTypeList != null) && (arrayTypeList.size() > 0)) {
        final SpecimenArrayType arrayType = (SpecimenArrayType) arrayTypeList.get(0);
        form.setSpecimenArrayType(arrayType.getName());
        form.setSpecimenClass(arrayType.getSpecimenClass());

        /**
         * Name: Virender Mehta Reviewer: Prafull Retrive Child Specimen Collection from parent
         * Specimen String[] specimenTypeArr = new
         * String[arrayType.getSpecimenTypeCollection().size()];
         */
        final Collection specimenTypeCollection =
            dao.retrieveAttribute(
                SpecimenArrayType.class,
                "id",
                arrayType.getId(),
                "elements(specimenTypeCollection)");
        // String[] specimenTypeArr = new
        // String[specimenTypeCollection.size()];

        final List specimenTypeList = this.setSpecimenTypes(specimenTypeCollection, form);
        request.setAttribute(Constants.SPECIMEN_TYPE_LIST, specimenTypeList);

        request.setAttribute(Constants.STORAGE_TYPE_ID, arrayType.getId());

        final Map aliquotMap = form.getSpecimenArrayAliquotMap();

        final SpecimenArrayAliquotsBizLogic aliquotBizLogic =
            (SpecimenArrayAliquotsBizLogic)
                AbstractFactoryConfig.getInstance()
                    .getBizLogicFactory()
                    .getBizLogic(Constants.SPECIMEN_ARRAY_ALIQUOT_FORM_ID);
        final long nextAvailablenumber =
            aliquotBizLogic.getNextAvailableNumber("CATISSUE_SPECIMEN_ARRAY");

        /** Putting the default label values in the AliquotMap */
        for (int i = 1; i <= aliquotCount; i++) {

          final String labelKey = "SpecimenArray:" + i + "_label";
          final String aliquotLabel = specimenArrayLabel + "_" + (nextAvailablenumber + i - 1);
          aliquotMap.put(labelKey, aliquotLabel);
        }

        form.setSpecimenArrayAliquotMap(aliquotMap);
        form.setSpecimenArrayId("" + specimenArray.getId());
      }
    }

    return Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT;
  }
コード例 #2
0
  /**
   * Overrides the execute method of Action class.
   *
   * @param mapping : mapping
   * @param form : form
   * @param request : request
   * @param response : response
   * @throws IOException : IOException
   * @throws ServletException : ServletException
   * @throws BizLogicException : BizLogicException
   * @return ActionForward : ActionForward
   */
  @Override
  public ActionForward executeSecureAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException, BizLogicException {

    final CreateSpecimenForm createForm = (CreateSpecimenForm) form;
    final String pageOf = request.getParameter(Constants.PAGE_OF);

    final String sourceObjectName = Specimen.class.getName();
    // String[] selectColumnName = {Constants.SYSTEM_IDENTIFIER};

    final String[] whereColumnName = new String[1];
    final Object[] whereColumnValue = new Object[1];

    // checks whether label or barcode is selected
    if (createForm.getRadioButton().equals("1")) {
      whereColumnName[0] = Constants.SYSTEM_LABEL;
      whereColumnValue[0] = createForm.getParentSpecimenLabel().trim();
    } else {
      whereColumnName[0] = Constants.SYSTEM_BARCODE;
      whereColumnValue[0] = createForm.getParentSpecimenBarcode().trim();
    }

    // String[] whereColumnCondition = {"="};

    final IFactory factory = AbstractFactoryConfig.getInstance().getBizLogicFactory();
    final IBizLogic bizLogic = factory.getBizLogic(Constants.DEFAULT_BIZ_LOGIC);
    final List list = bizLogic.retrieve(sourceObjectName, whereColumnName[0], whereColumnValue[0]);

    /**
     * If list is not empty, set the Parent specimen Id and forward to success. If list is null or
     * empty, forward to failure.
     */
    if (list != null && !list.isEmpty()) {
      final Specimen objSpecimen = (Specimen) list.get(0);

      if (objSpecimen.getActivityStatus().equals(Status.ACTIVITY_STATUS_DISABLED.toString())) {
        /**
         * Name : Falguni Sachde Reviewer Name : Sachin Lale Bug ID: 4919 Description: Added new
         * error message and check for pageOf flow, if user clicks directly derived link and
         * specimen status is disabled
         */
        final ActionErrors errors = this.getActionErrors(request);
        errors.add(
            ActionErrors.GLOBAL_ERROR, new ActionError("error.parentobject.disabled", "Specimen"));
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.derived", "Derived Specimen"));
        this.saveErrors(request, errors);
        return mapping.findForward(Constants.FAILURE);
      } else if (objSpecimen.getActivityStatus().equals(Status.ACTIVITY_STATUS_CLOSED.toString())) {
        /**
         * Name : Falguni Sachde Reviewer Name : Sachin Lale Bug ID: 4919 Description: Added new
         * error message and check for pageOf flow, if user clicks directly derived link and
         * specimen status is disabled
         */
        final ActionErrors errors = this.getActionErrors(request);
        errors.add(
            ActionErrors.GLOBAL_ERROR, new ActionError("error.parentobject.closed", "Specimen"));
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.derived", "Derived Specimen"));
        this.saveErrors(request, errors);
        return mapping.findForward(Constants.FAILURE);
      }

      final Long specimen = objSpecimen.getId();
      createForm.setParentSpecimenId("" + specimen.longValue());
      createForm.setReset(false); // Will not reset the parameters
      if (pageOf != null && pageOf.equals(Constants.PAGE_OF_CREATE_SPECIMEN_CP_QUERY)) {
        return mapping.findForward(Constants.PAGE_OF_CREATE_SPECIMEN_CP_QUERY);
      }
      return mapping.findForward(Constants.SUCCESS);
    } else {
      return mapping.findForward(Constants.FAILURE);
    }
  }