Exemplo n.º 1
0
 /**
  * This method used to set Date values. to prepared statement
  *
  * @param stmt :TODO
  * @param index :
  * @param obj :
  * @throws SQLException : SQLException
  * @throws DAOException : DAOException
  */
 protected void setDateColumns(PreparedStatement stmt, int index, Object obj)
     throws SQLException, DAOException {
   if (obj != null && obj.toString().equals("##")) {
     java.util.Date date = null;
     try {
       date = Utility.parseDate("1-1-9999", "mm-dd-yyyy");
     } catch (ParseException exp) {
       // TODO have to replace this by parse key
       ErrorKey errorKey = ErrorKey.getErrorKey("db.operation.error");
       throw new DAOException(errorKey, exp, "HashedDataHandler.java :");
     }
     Date sqlDate = new Date(date.getTime());
     stmt.setDate(index, sqlDate);
   }
 }
Exemplo n.º 2
0
  /**
   * @see
   *     edu.common.dynamicextensions.validation.ValidatorRuleInterface#validate(edu.common.dynamicextensions.domaininterface.AttributeInterface,
   *     java.lang.Object, java.util.Map)
   * @throws DynamicExtensionsValidationException
   */
  public boolean validate(
      AttributeInterface attribute, Object valueObject, Map<String, String> parameterMap)
      throws DynamicExtensionsValidationException {
    boolean valid = false;
    String attributeName = attribute.getName();
    AttributeTypeInformationInterface attributeTypeInformation =
        attribute.getAttributeTypeInformation();

    if (((valueObject != null) && (!((String) valueObject).trim().equals("")))
        && ((attributeTypeInformation != null)
            && (attributeTypeInformation instanceof DateAttributeTypeInformation))) {
      DateAttributeTypeInformation dateAttributeTypeInformation =
          (DateAttributeTypeInformation) attributeTypeInformation;
      String dateFormat = dateAttributeTypeInformation.getFormat();
      String value = (String) valueObject;

      if (dateFormat.equals(ProcessorConstants.MONTH_YEAR_FORMAT)) {
        value = DynamicExtensionsUtility.formatMonthAndYearDate(value);
        value = value.substring(0, value.length() - 4);
      }
      if (dateFormat.equals(ProcessorConstants.YEAR_ONLY_FORMAT)) {
        value = DynamicExtensionsUtility.formatYearDate(value);
        value = value.substring(0, value.length() - 4);
      }

      try {
        Date date = null;
        date = Utility.parseDate(value, "MM-dd-yyyy");
        if (date != null) {
          valid = true;
        }
      } catch (ParseException parseException) {
        List<String> placeHolders = new ArrayList<String>();
        placeHolders.add(attributeName);
        placeHolders.add(dateFormat);
        throw new DynamicExtensionsValidationException(
            "Validation failed", null, "dynExtn.validation.Date", placeHolders);
      }
    }
    return valid;
  }
Exemplo n.º 3
0
  private void createSCGUnderCPHavingScientistAsPI() {
    try {
      CollectionProtocol cp = new CollectionProtocol();
      cp.setId(new Long(BizTestCaseUtility.CP_WITH_SCIENTIST_AS_PI));
      Participant participant = BaseTestCaseUtility.initParticipant();
      participant.setSocialSecurityNumber("111-22-3233");
      try {
        participant.setBirthDate(
            Utility.parseDate("05-02-1984", CommonServiceLocator.getInstance().getDatePattern()));
      } catch (ParseException e) {
        Logger.out.debug("" + e);
      }
      System.out.println("Participant" + participant);
      SessionDataBean bean = (SessionDataBean) getSession().getAttribute("sessionData");
      try {
        participant = (Participant) appService.createObject(participant);
      } catch (Exception e) {
        e.printStackTrace();
        assertFalse(e.getMessage(), true);
      }
      BizTestCaseUtility.setNameObjectMap("ParticipantWithScientistAsPI", participant);
      CollectionProtocolRegistration collectionProtocolRegistration =
          new CollectionProtocolRegistration();

      collectionProtocolRegistration.setCollectionProtocol(cp);
      collectionProtocolRegistration.setParticipant(participant);
      collectionProtocolRegistration.setProtocolParticipantIdentifier("");
      collectionProtocolRegistration.setActivityStatus("Active");

      try {
        collectionProtocolRegistration.setRegistrationDate(
            Utility.parseDate("08/15/2006", Utility.datePattern("08/15/2006")));

        collectionProtocolRegistration.setConsentSignatureDate(
            Utility.parseDate("11/23/2006", Utility.datePattern("11/23/2006")));
        System.out.println("Creating CPR");
      } catch (ParseException e) {
        e.printStackTrace();
      }

      collectionProtocolRegistration.setSignedConsentDocumentURL("F:/doc/consentDoc.doc");

      User user = new User();
      user.setId(new Long(1));

      collectionProtocolRegistration.setConsentWitness(user);

      //				Collection consentTierResponseCollection = new LinkedHashSet();
      //				Collection consentTierCollection = new LinkedHashSet();
      //
      //				consentTierCollection = cp.getConsentTierCollection();
      //				System.out.println("Creating CPR");
      //				Iterator consentTierItr = consentTierCollection.iterator();
      //				System.out.println("Creating CPR");
      //				 while(consentTierItr.hasNext())
      //				 {
      //					 ConsentTier consent= (ConsentTier) consentTierItr.next();
      //					 ConsentTierResponse response= new ConsentTierResponse();
      //					 response.setResponse("Yes");
      //					 response.setConsentTier(consent);
      //					 consentTierResponseCollection.add(response);
      //				 }
      //
      //
      //	collectionProtocolRegistration.setConsentTierResponseCollection(consentTierResponseCollection);
      try {
        collectionProtocolRegistration =
            (CollectionProtocolRegistration)
                appService.createObject(collectionProtocolRegistration);
      } catch (Exception e) {
        Logger.out.error(e.getMessage(), e);
        e.printStackTrace();
        assertFalse(e.getMessage(), true);
      }
      BizTestCaseUtility.setNameObjectMap("CPRWithScientistAsPI", collectionProtocolRegistration);

      SpecimenCollectionGroup scg = new SpecimenCollectionGroup();

      scg = (SpecimenCollectionGroup) BaseTestCaseUtility.createSCG(collectionProtocolRegistration);
      Site site = new Site();
      site.setId(new Long(BizTestCaseUtility.CP_WITH_ALLOW_READ_PRIV));
      scg.setSpecimenCollectionSite(site);
      scg.setName("New SCG" + UniqueKeyGeneratorUtil.getUniqueKey());
      scg = (SpecimenCollectionGroup) BaseTestCaseUtility.setEventParameters(scg);
      scg.setSurgicalPathologyNumber("SPN" + UniqueKeyGeneratorUtil.getUniqueKey());
      System.out.println("Creating SCG");

      try {
        scg = (SpecimenCollectionGroup) appService.createObject(scg);
        System.out.println("SCG::" + scg.getName());
      } catch (Exception e) {
        Logger.out.error(e.getMessage(), e);
        e.printStackTrace();
        assertFalse(e.getMessage(), true);
      }

      IdentifiedSurgicalPathologyReport identifiedSurgicalPathologyReport =
          new IdentifiedSurgicalPathologyReport();
      identifiedSurgicalPathologyReport.setActivityStatus(Status.ACTIVITY_STATUS_ACTIVE.toString());
      identifiedSurgicalPathologyReport.setCollectionDateTime(new Date());
      identifiedSurgicalPathologyReport.setIsFlagForReview(new Boolean(false));
      identifiedSurgicalPathologyReport.setReportStatus(CaTIESConstants.PENDING_FOR_DEID);
      identifiedSurgicalPathologyReport.setReportSource(site);
      TextContent textContent = new TextContent();
      String data =
          "[FINAL DIAGNOSIS]\n"
              + "This is the Final Diagnosis Text"
              + "\n\n[GROSS DESCRIPTION]"
              + "The specimen is received unfixed labeled hernia sac and consists of a soft, pink to yellow segment of fibrous and fatty tissue measuring 7.5cm in length x 3.2 x 0.9cm with a partly defined lumen.  Representative tissue submitted labeled 1A.";

      textContent.setData(data);
      textContent.setSurgicalPathologyReport(identifiedSurgicalPathologyReport);
      Set reportSectionCollection = new HashSet();
      ReportSection reportSection1 = new ReportSection();
      reportSection1.setName("GDT");
      reportSection1.setDocumentFragment(
          "The specimen is received unfixed labeled hernia sac and consists of a soft, pink to yellow segment of fibrous and fatty tissue measuring 7.5cm in length x 3.2 x 0.9cm with a partly defined lumen.  Representative tissue submitted labeled 1A.");
      reportSection1.setTextContent(textContent);

      ReportSection reportSection2 = new ReportSection();
      reportSection2.setName("FIN");
      reportSection2.setDocumentFragment("This is the Final Diagnosis Text");
      reportSection2.setTextContent(textContent);

      reportSectionCollection.add(reportSection1);
      reportSectionCollection.add(reportSection2);

      textContent.setReportSectionCollection(reportSectionCollection);

      identifiedSurgicalPathologyReport.setTextContent(textContent);
      identifiedSurgicalPathologyReport.setSpecimenCollectionGroup(scg);
      scg.setSurgicalPathologyNumber("SPN" + UniqueKeyGeneratorUtil.getUniqueKey());

      try {
        identifiedSurgicalPathologyReport =
            (IdentifiedSurgicalPathologyReport)
                appService.createObject(identifiedSurgicalPathologyReport);
      } catch (Exception e) {
        Logger.out.error(e.getMessage(), e);
        e.printStackTrace();
        assertFalse(e.getMessage(), true);
      }
      BizTestCaseUtility.setObjectMap(
          identifiedSurgicalPathologyReport, IdentifiedSurgicalPathologyReport.class);

      BizTestCaseUtility.setNameObjectMap("SCGWithScientistAsPI", scg);
      //				TissueSpecimen specimenObj = (TissueSpecimen) BaseTestCaseUtility.initTissueSpecimen();
      //				specimenObj.setSpecimenCollectionGroup(scg);
      //				StorageContainer sc = new StorageContainer();
      //				sc.setId(new Long(1));
      //				specimenObj.setStorageContainer(sc);
      //				specimenObj.setPositionDimensionOne(new Integer(3));
      //				specimenObj.setPositionDimensionTwo(new Integer(1));
      //				try{
      //					specimenObj =  (TissueSpecimen) appService.createObject(specimenObj);
      //					System.out.println("Mol Specimen:"+ specimenObj.getLabel());
      //				}
      //				catch(Exception e){
      //					Logger.out.error(e.getMessage(),e);
      //		           	e.printStackTrace();
      //		           	assertFalse("Failed to register participant", true);
      //				}
    } catch (Exception e) {
      Logger.out.error(e.getMessage(), e);
      e.printStackTrace();
      assertFalse(e.getMessage(), true);
    }
  }