/**
   * Searches for units by the criterias specified in the provided form.
   *
   * @param theForm The form with the search criterias.
   * @return A list of matching units.
   * @throws KivException If no units were found with the provided criterias or if no connection to
   *     the LDAP server could be made.
   */
  public SikSearchResultList<Unit> doSearch(UnitSearchSimpleForm theForm) throws KivException {
    LOGGER.debug(CLASS_NAME + ".doSearch()");

    SikSearchResultList<Unit> list = new SikSearchResultList<Unit>();
    try {
      TimeMeasurement overAllTime = new TimeMeasurement();

      // start measurement
      overAllTime.start();
      if (!theForm.isEmpty()) {
        SearchUnitCriterions u = this.mapSearchCriterias(theForm);
        int currentMaxSearchResult = this.maxSearchResult;
        if ("true".equals(theForm.getShowAll())) {
          currentMaxSearchResult = Integer.MAX_VALUE;
        }
        list = this.getSearchService().searchUnits(u, currentMaxSearchResult);

        // stop measurement
        overAllTime.stop();

        if (list == null) {
          list = new SikSearchResultList<Unit>();
        }
        LogUtils.printSikSearchResultListToLog(this, "doSearch", overAllTime, LOGGER, list);
        if (list.size() == 0) {
          throw new KivNoDataFoundException();
        } else {
          Collections.sort(list, new UnitNameComparator());
        }
      }
    } catch (KivNoDataFoundException e) {
      throw e;
    } catch (KivException e) {
      LOGGER.error(e);
      list = new SikSearchResultList<Unit>();
    }
    return list;
  }
  private SearchUnitCriterions mapSearchCriterias(UnitSearchSimpleForm theForm) {
    SearchUnitCriterions searchUnitCriterions = new SearchUnitCriterions();

    searchUnitCriterions.setUnitName(theForm.getUnitName());
    searchUnitCriterions.setLocation(theForm.getLocation());
    searchUnitCriterions.setAdministrationName(theForm.getAdministrationName());
    searchUnitCriterions.setLiableCode(theForm.getLiableCode());
    searchUnitCriterions.setBusinessClassificationName(theForm.getBusinessClassificationName());
    searchUnitCriterions.setCareTypeName(theForm.getCareTypeName());
    return searchUnitCriterions;
  }
 /**
  * Cleans the search form.
  *
  * @param theForm The form to clean.
  */
 public void cleanSearchSimpleForm(UnitSearchSimpleForm theForm) {
   LOGGER.debug(CLASS_NAME + ".cleanSearchSimpleForm()");
   theForm.setLocation("");
   theForm.setUnitName("");
 }