public Properties getProperties(TemplateResource templateResource) {
    Properties result = new Properties();
    String facilityKey = templateResource.getRequest().getParameter(QueryKeys.QUERY_KEY_FACILITY);
    boolean is_overview =
        this.getCalendarView(templateResource.getRequest()).equals(QueryKeys.OVERVIEW);
    Facility facility = RequestInterpreter.getFacility(templateResource.getRequest());
    if (facility == null) {
      // ↖ wrong url!
      RedirectResolver.redirectClient(
          RedirectTarget.SYSTEM_FACILITY_AVAILABILITY_OVERVIEW, templateResource);
    } else {
      result.put(
          "queue_based",
          facility.isBookable()
              && FacilityConfigDao.bookingRule(facilityKey).getBookingStrategy()
                  == BookingStrategy.QUEUE_BASED);
      result.put("facility_name", FacilityConfigDao.getInstance().getLabel(facilityKey));
      result.put("content", this.getCalendarHtml(templateResource, facilityKey));
      QueryString link_overview =
          QueryStringFactory.get(QueryKeys.QUERY_KEY_CALENDAR_VIEW, QueryKeys.OVERVIEW);
      link_overview.put(QueryKeys.QUERY_KEY_FACILITY, facilityKey);
      result.put("link_hidden_inputs", link_overview.getAsHtmlInputsTypeHidden());
      result.put("text_facilitykey", facilityKey);
      result.put("name_facilitykey", QueryKeys.QUERY_KEY_FACILITY);
      if (is_overview) {
        result.put("link_overview", link_overview.getAsHtmlLinkHref() + "#newrule");
        result.put("link_overview_text", "Add a new rule"); // INTLANG
        result.put("add_or_edit", "add");
      } else {
        result.put("link_overview", link_overview.getAsHtmlLinkHref());
        result.put("link_overview_text", "Edit availability rules"); // INTLANG
        result.put("add_or_edit", "edit");
      }
      link_overview.put(QueryKeys.QUERY_KEY_CALENDAR_VIEW, QueryKeys.WEEK);
      result.put("link_weekview", link_overview.getAsHtmlLinkHref());
      link_overview.put(QueryKeys.QUERY_KEY_CALENDAR_VIEW, QueryKeys.MONTH);
      result.put("link_monthview", link_overview.getAsHtmlLinkHref());
      // has many units
      boolean hasChildren = facility.hasChildren();
      int units = facility.isBookable() ? ((FacilityBookable) facility).getCapacityUnits() : 1;
      result.put("flag_hasmanyunits", units > 1);
      result.put("flag_haschildren", hasChildren);
      if (hasChildren) {
        result.put("number_children", facility.getChildren().size());
      } else {
        result.put("number_children", "");
      }
      if (units > 1) {
        result.put("string_nameofunits", FamText.capacityUnits((FacilityBookable) facility));
      } else {
        result.put("string_nameofunits", "");
      }

      // set edit form
      boolean suddenFailureIsActive = this.suddenFailureIsActive(facilityKey);
      if (is_overview && !suddenFailureIsActive) { // show "add a rule"
        result.put("show_edit", true);
        result.put("show_suddenFailureIsActive", false);
        result.put(
            "querystring",
            QueryStringBuilder.getBigCalendarQueryString(
                facilityKey,
                RequestInterpreter.getCalendar(templateResource.getRequest()),
                QueryKeys.OVERVIEW));

        // get current step
        int currentStep = 1;
        try {
          currentStep = Integer.parseInt(RequestInterpreter.getOf(templateResource.getRequest()));
        } catch (NumberFormatException e) {
        } // ← stay step 1

        QueryString hiddenInputs = null;
        // ↘ it is the final sending of add new rule
        if (currentStep >= 4) {
          hiddenInputs = new QueryString();
          hiddenInputs.put(QueryKeys.QUERY_KEY_FACILITY, facilityKey);
          hiddenInputs.put(QueryKeys.QUERY_KEY_CALENDAR_VIEW, QueryKeys.OVERVIEW);
          currentStep = 1;
        } else {
          hiddenInputs = QueryStringFactory.getInstance().get(templateResource.getRequest());
        }
        hiddenInputs.put(QueryKeys.QUERY_KEY_OF, currentStep + 1);
        // ↘ set flag: nothing shall be deleted when submit form
        hiddenInputs.put(QueryKeys.QUERY_KEY_DELETE, "-1");

        switch (currentStep) {
          case 1:
            // choose of availability
            result.put("name_available", QueryKeys.QUERY_KEY_AVAILABLILITY);
            result.put(
                "value_available_nomaintenance", FacilityAvailability.MAINTENANCE_NOT_AVAILABLE);
            result.put(
                "text_available_nomaintenance",
                FamText.facilityAvailability(FacilityAvailability.MAINTENANCE_NOT_AVAILABLE));
            result.put("value_available_noingeneral", FacilityAvailability.GENERAL_NOT_AVAILABLE);
            result.put(
                "text_available_noingeneral",
                FamText.facilityAvailability(FacilityAvailability.GENERAL_NOT_AVAILABLE));
            result.put(
                "value_available_mustnotstarthere",
                FacilityAvailability.BOOKING_MUST_NOT_START_HERE);
            result.put(
                "text_available_mustnotstarthere",
                FamText.facilityAvailability(FacilityAvailability.BOOKING_MUST_NOT_START_HERE));
            result.put("value_available_available", FacilityAvailability.COMPLETE_AVAILABLE);
            result.put(
                "text_available_available",
                FamText.facilityAvailability(FacilityAvailability.COMPLETE_AVAILABLE));

            // choose interval
            result.put("name_interval", QueryKeys.QUERY_KEY_ITERATION);
            result.put("value_interval_onetime", FacilityAvailability.ONE_TIME);
            result.put("value_interval_yearly", FacilityAvailability.EACH_YEAR);
            result.put("value_interval_monthly", FacilityAvailability.EACH_MONTH);
            result.put("value_interval_weekly", FacilityAvailability.EACH_WEEK);
            result.put("value_interval_daily", FacilityAvailability.EACH_DAY);
            break;
          case 2:
            result.put("text_info", this.getSummary(templateResource.getRequest()));
            result.put("select_time", this.getTimeInput(templateResource.getRequest()));
            result.put("name_notice", QueryKeys.QUERY_KEY_TEXT_NOTICE);
            break;
          case 3:
            result.put("text_info", this.getSummary(templateResource.getRequest()));
            break;
        }

        // set current step
        result.put("current_step", currentStep);

        result.put("hiddenInputs", hiddenInputs.getAsHtmlInputsTypeHidden());
      } else if (suddenFailureIsActive) {
        result.put("show_edit", false);
        result.put("show_suddenFailureIsActive", true);
        result.put("text_facilitykey", facilityKey);
        result.put("name_facilitykey", QueryKeys.QUERY_KEY_FACILITY);
        result.put("value_yes", QueryKeys.YES);
        result.put("name_yes", QueryKeys.QUERY_KEY_YES_NO);
        result.put(
            "querystring",
            QueryStringBuilder.getBigCalendarQueryString(
                facilityKey,
                RequestInterpreter.getCalendar(templateResource.getRequest()),
                QueryKeys.OVERVIEW));
      } else { // it is not the overview / editing view
        result.put("show_edit", false);
        result.put("show_suddenFailureIsActive", false);
      }
    }
    return result;
  }
  private HtmlElement getSummary(HttpServletRequest request) {
    HtmlElement result = HtmlFactory.get("ul").addClassName("asList");
    HtmlElement warningSpan = HtmlFactory.get("span").addClassName("warning");

    // summary availability
    Integer availability = RequestInterpreter.getAvailability(request);
    // is valid availability
    if (availability != null
        && (availability == COMPLETE_AVAILABLE
            || availability == GENERAL_NOT_AVAILABLE
            || availability == BOOKED_NOT_AVAILABLE
            || availability == MAINTENANCE_NOT_AVAILABLE
            || availability == BOOKING_MUST_NOT_START_HERE)) {
      result.add(
          HtmlFactory.get("li")
              .add(HtmlFactory.get("strong").add("Availability"))
              .add(": ")
              .add(FamText.facilityAvailability(availability))); // INTLANG;
    }

    // summary interval
    Integer interval = RequestInterpreter.getInterval(request);
    if (interval != null) {
      result.add(
          HtmlFactory.get("li")
              .add(HtmlFactory.get("strong").add("Interval"))
              .add(": ")
              .add(FamText.message("calendar.iteration." + interval))); // INTLANG;
    }

    // summary notice
    String notice = RequestInterpreter.getNotice(request);
    if (notice != null) {
      result.add(
          HtmlFactory.get("li")
              .add(HtmlFactory.get("strong").add("Notice"))
              .add(": ")
              .add(notice)); // INTLANG;
    }

    if (availability != null
        && availability.intValue() != FacilityAvailability.COMPLETE_AVAILABLE) {
      FacilityAvailability da =
          RequestInterpreter.getCompleteFacilityAvailabilityForInsertion(
              request, SessionAuth.user(request));
      if (da != null) {

        TimeFrame baseTimeFrame = da.getBasePeriodOfTime();
        if (baseTimeFrame != null) {
          String timeText =
              interval == FacilityAvailability.ONE_TIME
                  ? "Coming into effect"
                  : "First time coming into effect"; // INTLANG
          result.add(
              HtmlFactory.get("li")
                  .add(HtmlFactory.get("strong").add(timeText))
                  .add(": ")
                  .add(baseTimeFrame));

          // summarize bookings being canceled
          List<Facility> facilities = new ArrayList<Facility>();
          facilities.add(da.getFacility());
          List<Booking> bookings = FamDaoProxy.bookingDao().getAll(facilities);
          int negativeAnswers = 0;
          for (Booking booking : bookings) {
            if (!booking.isCanceled()
                && !booking.sessionAlreadyBegun()
                && booking.getIdBookedInBookingStrategy() != BookingStrategy.QUEUE_BASED
                && da.applicableTo(booking.getSessionTimeFrame())) {
              negativeAnswers++;
            }
          }

          result.add(
              HtmlFactory.get("li")
                  .add(
                      HtmlFactory.get("strong")
                          .add("Number of letters of refusal sent with this input"))
                  .add(": ")
                  .add(
                      negativeAnswers == 0
                          ? "no letter"
                          : warningSpan
                              .setContent(negativeAnswers + " letter(s)")
                              .toString())); // INTLANG;

          // warning on nothing set or left
          long durationOfBaseTime = baseTimeFrame.getDuration();
          long durationOfAnHour = 1000l * 60 * 60;
          boolean willBlockResource = false;
          boolean nothingSet = durationOfBaseTime <= 0;
          if (!nothingSet
              && interval != FacilityAvailability.ONE_TIME
              && availability != FacilityAvailability.COMPLETE_AVAILABLE) {
            if ((interval == FacilityAvailability.EACH_YEAR
                    && durationOfBaseTime >= durationOfAnHour * 24 * 365)
                || (interval == FacilityAvailability.EACH_MONTH
                    && durationOfBaseTime >= durationOfAnHour * 24 * 365 / 12)
                || (interval == FacilityAvailability.EACH_WEEK
                    && durationOfBaseTime >= durationOfAnHour * 24 * 7)
                || (interval == FacilityAvailability.EACH_DAY
                    && durationOfBaseTime >= durationOfAnHour * 24)
                || (interval == FacilityAvailability.EACH_HOUR
                    && durationOfBaseTime >= durationOfAnHour)) {
              willBlockResource = true;
            }
          }
          if (willBlockResource) {
            result.add(
                HtmlFactory.get("li")
                    .add(
                        warningSpan.setContent(
                            "If setting this, the facility will never ever be available!"))); // INTLANG;
          }
          if (nothingSet) {
            result.add(
                HtmlFactory.get("li")
                    .add(warningSpan.setContent("The duration of your setting is 0!"))); // INTLANG;
          }
        }
      }
    }
    return result;
  }