コード例 #1
0
  /**
   * Adds the new user. Event is logged.
   *
   * @param p bean containing the information for the new user
   * @return MID of the new user.
   * @throws FormValidationException
   * @throws iTrustException
   */
  public long add(PersonnelBean p) throws FormValidationException, iTrustException {
    new AddPersonnelValidator().validate(p);
    long newMID = personnelDAO.addEmptyPersonnel(Role.ER);
    p.setMID(newMID);
    personnelDAO.editPersonnel(p);
    String pwd = authDAO.addUser(newMID, Role.ER, RandomPassword.getRandomPassword());
    p.setPassword(pwd);

    return newMID;
  }
コード例 #2
0
  /**
   * Creates the patients and adds them to the DB
   *
   * @throws DBException
   * @throws AddPatientFileExceptionTest
   */
  private void createPatients() throws DBException, AddPatientFileException {
    for (int i = 0; i < CSVData.size(); i++) {
      PatientBean temp = new PatientBean();

      temp.setFirstName(
          CSVData.get(i)
              .get(requiredFieldsMapping[Arrays.asList(requiredFields).indexOf("firstName")]));
      temp.setLastName(
          CSVData.get(i)
              .get(requiredFieldsMapping[Arrays.asList(requiredFields).indexOf("lastName")]));
      temp.setEmail(
          CSVData.get(i)
              .get(requiredFieldsMapping[Arrays.asList(requiredFields).indexOf("email")]));

      try {
        temp.setStreetAddress1(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("streetAddress1")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setStreetAddress2(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("streetAddress2")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setCity(
            CSVData.get(i).get(validFieldsMapping[Arrays.asList(validFields).indexOf("city")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setState(
            CSVData.get(i).get(validFieldsMapping[Arrays.asList(validFields).indexOf("state")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setZip(
            CSVData.get(i).get(validFieldsMapping[Arrays.asList(validFields).indexOf("zip")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setPhone(
            CSVData.get(i).get(validFieldsMapping[Arrays.asList(validFields).indexOf("phone")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setMotherMID(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("motherMID")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setFatherMID(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("fatherMID")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setCreditCardType(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("creditCardType")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setCreditCardNumber(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("creditCardNumber")]));
      } catch (NullPointerException e) {
      }

      try {
        new AddPatientValidator().validate(temp);
        new PatientValidator().validate(temp);
        if (patientDAO != null) {
          long newMID = patientDAO.addEmptyPatient();
          temp.setMID(newMID);
          String pwd = authDAO.addUser(newMID, Role.PATIENT, RandomPassword.getRandomPassword());
          temp.setPassword(pwd);
          patientDAO.editPatient(temp, loggedInMID);
        }
        patients.add(temp);
      } catch (FormValidationException e) {
        for (int j = 0; j < e.getErrorList().size(); j++) {
          System.out.println(e.getErrorList().get(j));
        }
        errors.addIfNotNull(
            "Input validation failed for patient \""
                + temp.getFirstName()
                + " "
                + temp.getLastName()
                + "\"!");
      }
    }
  }