private void populateStateList(CountryEnterprise countryEnterprise) {

    cmbStateList.removeAllItems();

    for (Enterprise state :
        countryEnterprise.getCountryNetwork().getEnterpriseDirectory().getEnterpriseList()) {
      if (state.getClass() == StateEnterprise.class) cmbStateList.addItem((StateEnterprise) state);
    }
  }
  private void btnAddNewHospitalActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnAddNewHospitalActionPerformed
    // TODO add your handling code here:
    Address address = new Address();
    address.setCountry((CountryEnterprise) cmbCountryList.getSelectedItem());
    CityEnterprise cityEnterprise;
    StateEnterprise stateEnterprise;

    if (!(txtState.getText().equals(""))) {
      CountryEnterprise countryEnterprise = (CountryEnterprise) cmbCountryList.getSelectedItem();
      // countryEnterprise.getCountryNetwork().getEnterpriseDirectory().getEnterpriseList().add(new
      // StateEnterprise(txtState.getText()));
      stateEnterprise =
          (StateEnterprise)
              countryEnterprise
                  .getCountryNetwork()
                  .getEnterpriseDirectory()
                  .createAndAddEnterprise(
                      txtState.getText(),
                      Enterprise.EnterpriseType.State,
                      null,
                      null,
                      null,
                      null,
                      null);
      address.setState(stateEnterprise);
    } else {
      address.setState((StateEnterprise) cmbStateList.getSelectedItem());
    }

    if (!(txtCity.getText().equals(""))) {
      CountryEnterprise countryEnterprise = (CountryEnterprise) cmbCountryList.getSelectedItem();
      stateEnterprise = (StateEnterprise) cmbStateList.getSelectedItem();
      cityEnterprise =
          (CityEnterprise)
              stateEnterprise
                  .getStateNetwork()
                  .getEnterpriseDirectory()
                  .createAndAddEnterprise(
                      txtCity.getText(),
                      Enterprise.EnterpriseType.City,
                      null,
                      null,
                      null,
                      null,
                      null);
      address.setCity(cityEnterprise);
    } else {
      address.setCity((CityEnterprise) cmbCityList.getSelectedItem());
      cityEnterprise = (CityEnterprise) cmbCityList.getSelectedItem();
    }

    address.setStreet(txtStreetName.getText());
    address.setZipcode((txtZipcode.getText()));

    System.out.println("CityEnterprise" + cityEnterprise + " ");
    System.out.println(cityEnterprise.getCityNetwork());
    System.out.println(cityEnterprise.getCityNetwork().getEnterpriseDirectory());
    HospitalEnterprise hospitalEnterprise =
        (HospitalEnterprise)
            cityEnterprise
                .getCityNetwork()
                .getEnterpriseDirectory()
                .createAndAddEnterprise(
                    txtHospitalName.getText(),
                    Enterprise.EnterpriseType.Hospital,
                    txtUsername.getText(),
                    String.valueOf(txtPassword.getPassword()),
                    new AdminRole(),
                    "Active",
                    address);
    // hospitalEnterprise.setAddress(address);
    // hospitalEnterprise.getUserAccountDirectory().createUserAccount(txtUsername.getText(),
    // String.valueOf(txtPassword.getPassword()), new AdminRole(),"Active");
  } // GEN-LAST:event_btnAddNewHospitalActionPerformed