/**
   * Creates a hash map view to all the object's form fields and their values, including their
   * referenced objects resolved to keys and values.<br>
   * This method is safe to never return null values.
   *
   * @param identifier or NULL
   * @return A HashMap<key,value/>
   */
  public synchronized Map<String, Object> getFormattedFormFields(final String identifier) {
    Map<String, Object> map = getFormFields();
    TreeMap<String, Object> maps = new TreeMap<String, Object>();

    for (Iterator<String> it = map.keySet().iterator(); it.hasNext(); ) {
      String key = it.next();
      Object o = map.get(key);

      String skey = null;
      if (identifier == null) {
        skey = obj.getType() + "." + key;
      } else {
        skey = identifier + "." + key;
      }

      if (o == null || String.valueOf(o).equals("null")) {
        maps.put(skey, "");
      } else if (o instanceof DatabaseObject && !(o instanceof Group)) {
        maps.putAll(
            new FormFieldsHandler((DatabaseObject) o)
                .getFormattedFormFields(obj.getType() + "." + key));
      } else if (o instanceof Boolean) {
        maps.put(skey, TypeConversion.booleanToString((Boolean) o));
      } else if (o instanceof Double || o.getClass() == double.class) {
        maps.put(skey, FormatNumber.formatDezimal((Double) o));
      } else if (o instanceof Date) {
        maps.put(skey, DateConverter.getDefDateString((Date) o));
      } else {
        maps.put(skey, o);
      }
    }
    List<String[]> mapi =
        User.getCurrentUser().getProperties().getProperties("companyinfo.").getList();
    for (int i = 0; i < mapi.size(); i++) {
      String[] strings = mapi.get(i);
      if (strings[1] != null) {
        maps.put(
            "companyinfo." + strings[0],
            strings[1].contains("[") ? VariablesHandler.parse(strings[1], obj) : strings[1]);
      }
    }

    return maps;
  }
Example #2
0
 /** @return */
 public static synchronized String getDayMonthAndYear() {
   return DateConverter.getDefDateString(new Date());
 }