コード例 #1
0
 public static LabelValueChoiceRenderer<Long> getDatumChoiceRenderer(final int lastNDays) {
   final LabelValueChoiceRenderer<Long> datumChoiceRenderer = new LabelValueChoiceRenderer<Long>();
   for (int i = 0; i > -lastNDays; i--) {
     final DayHolder day = new DayHolder();
     day.add(Calendar.DAY_OF_YEAR, i);
     datumChoiceRenderer.addValue(
         day.getSQLDate().getTime(),
         DateTimeFormatter.instance()
             .getFormattedDate(
                 day.getSQLDate(), DateFormats.getFormatString(DateFormatType.DATE)));
   }
   return datumChoiceRenderer;
 }
コード例 #2
0
 private void callNow() {
   if (StringUtils.isBlank(ConfigXml.getInstance().getTelephoneSystemUrl()) == true) {
     log.error("Telephone system url not configured. Phone calls not supported.");
     return;
   }
   log.info(
       "User initiates direct call from phone with id '"
           + form.getMyCurrentPhoneId()
           + "' to destination numer: "
           + StringHelper.hideStringEnding(form.getPhoneNumber(), 'x', 3));
   result = null;
   final StringBuffer buf = new StringBuffer();
   buf.append(form.getPhoneNumber()).append(SEPARATOR);
   final AddressDO address = form.getAddress();
   if (address != null
       && StringHelper.isIn(
               form.getPhoneNumber(),
               extractPhonenumber(address.getBusinessPhone()),
               extractPhonenumber(address.getMobilePhone()),
               extractPhonenumber(address.getPrivatePhone()),
               extractPhonenumber(address.getPrivateMobilePhone()))
           == true) {
     buf.append(address.getFirstName()).append(" ").append(address.getName());
     if (form.getPhoneNumber().equals(extractPhonenumber(address.getMobilePhone())) == true) {
       buf.append(", ").append(getString("address.phoneType.mobile"));
     } else if (form.getPhoneNumber().equals(extractPhonenumber(address.getPrivatePhone()))
         == true) {
       buf.append(", ").append(getString("address.phoneType.private"));
     }
     buf.append(" #").append(address.getId());
   } else {
     buf.append("???");
   }
   final HttpClient client = new HttpClient();
   String url = ConfigXml.getInstance().getTelephoneSystemUrl();
   url = StringUtils.replaceOnce(url, "#source", form.getMyCurrentPhoneId());
   url = StringUtils.replaceOnce(url, "#target", form.getPhoneNumber());
   final String urlProtected = StringHelper.hideStringEnding(url, 'x', 3);
   final GetMethod method = new GetMethod(url);
   String errorKey = null;
   try {
     form.lastSuccessfulPhoneCall = new Date();
     client.executeMethod(method);
     final String resultStatus = method.getResponseBodyAsString();
     if ("0".equals(resultStatus) == true) {
       result =
           DateTimeFormatter.instance().getFormattedDateTime(new Date())
               + ": "
               + getString("address.phoneCall.result.successful");
       form.getRecentSearchTermsQueue().append(buf.toString());
     } else if ("2".equals(resultStatus) == true) {
       errorKey = "address.phoneCall.result.wrongSourceNumber";
     } else if ("3".equals(resultStatus) == true) {
       errorKey = "address.phoneCall.result.wrongDestinationNumber";
     } else {
       errorKey = "address.phoneCall.result.callingError";
     }
   } catch (final HttpException ex) {
     result = "Call failed. Please contact administrator.";
     log.fatal(result + ": " + urlProtected);
     throw new RuntimeException(ex);
   } catch (final IOException ex) {
     result = "Call failed. Please contact administrator.";
     log.fatal(result + ": " + urlProtected);
     throw new RuntimeException(ex);
   }
   if (errorKey != null) {
     form.addError(errorKey);
   }
 }