@Override @SuppressWarnings("unchecked") public void setDataMap(Map<String, Object> dataMap) throws FormEncodingException { FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); this.mimeType = (String) dataMap.get("mimeType"); this.name = (String) dataMap.get("name"); this.value = (String) dataMap.get("value"); this.formatter = (Formatter) decoder .decode((Map<String, Object>) dataMap.get("formatter")); }
@Override public String encode(FormItemRepresentation item) throws FormEncodingException { if (item == null) { return "null"; } return jsonFromMap(item.getDataMap()); }
@Override public String saveForm(FormRepresentation form) throws FormBuilderServiceException { String encode = null; try { encode = FormEncodingServerFactory.getEncoder().encode(form); } catch (FormEncodingException ex) { logger.error("Error while saving form", ex); } return encode; }
@Override public Map<String, List<MenuItemDescription>> listMenuItems() throws MenuServiceException { Map<String, List<MenuItemDescription>> retval = null; try { FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); URL url = asURL("/menuItems.json"); String json = readURL(url); retval = decoder.decodeMenuItemsMap(json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem parsing menu items json file", e); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu items json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu items json file found", e); } catch (IOException e) { throw new MenuServiceException("Problem reading menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } return retval; }
private void writeMenuItems(Map<String, List<MenuItemDescription>> items) throws MenuServiceException { try { FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder(); String json = encoder.encodeMenuItemsMap(items); URL url = asURL("/menuItems.json"); writeToURL(url, json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem transforming menu items to json", e); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu items json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu items json file found", e); } catch (IOException e) { throw new MenuServiceException("Problem writing menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } }
public FormRepresentation loadForm(String json) { try { return FormEncodingServerFactory.getDecoder().decode(json); } catch (FormEncodingException ex) { logger.error("Error while loading form", ex); } return null; } }
@Before public void setUp() throws Exception { FormEncodingFactory.register(FormEncodingServerFactory.getEncoder(), FormEncodingServerFactory.getDecoder()); }
@Override @SuppressWarnings("unchecked") public void setDataMap(Map<String, Object> dataMap) throws FormEncodingException { FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); this.mimeType = (String) dataMap.get("mimeType"); this.name = (String) dataMap.get("name"); this.value = (String) dataMap.get("value"); this.formatter = (Formatter) decoder .decode((Map<String, Object>) dataMap.get("formatter")); }
@Override public Map<String, List<MenuItemDescription>> listMenuItems() throws MenuServiceException { Map<String, List<MenuItemDescription>> retval = null; try { FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); URL url = asURL("/menuItems.json"); String json = readURL(url); retval = decoder.decodeMenuItemsMap(json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem parsing menu items json file", e); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu items json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu items json file found", e); } catch (IOException e) { throw new MenuServiceException("Problem reading menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } return retval; }
private void writeMenuItems(Map<String, List<MenuItemDescription>> items) throws MenuServiceException { try { FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder(); String json = encoder.encodeMenuItemsMap(items); URL url = asURL("/menuItems.json"); writeToURL(url, json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem transforming menu items to json", e); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu items json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu items json file found", e); } catch (IOException e) { throw new MenuServiceException("Problem writing menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } }
@Override public String encode(FormItemRepresentation item) throws FormEncodingException { if (item == null) { return "null"; } return jsonFromMap(item.getDataMap()); }
@Override @SuppressWarnings("unchecked") public void setDataMap(Map<String, Object> data) throws FormEncodingException { super.setDataMap(data); this.condition = (String) data.get("condition"); FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); this.ifBlock = (FormItemRepresentation) decoder.decode((Map<String, Object>) data.get("ifBlock")); this.elseBlock = (FormItemRepresentation) decoder.decode((Map<String, Object>) data.get("elseBlock")); }
private String toJson(Mappable obj) { StringBuilder builder = new StringBuilder(); if (obj == null) { builder.append("null"); } else { Map<String, Object> data = obj.getDataMap(); if (data != null) { builder.append(jsonFromMap(data)); } } return builder.toString(); }
@Override @SuppressWarnings("unchecked") public void setDataMap(Map<String, Object> data) throws FormEncodingException { super.setDataMap(data); this.condition = (String) data.get("condition"); FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); this.ifBlock = (FormItemRepresentation) decoder.decode((Map<String, Object>) data.get("ifBlock")); this.elseBlock = (FormItemRepresentation) decoder.decode((Map<String, Object>) data.get("elseBlock")); }
private String toJson(Mappable obj) { StringBuilder builder = new StringBuilder(); if (obj == null) { builder.append("null"); } else { Map<String, Object> data = obj.getDataMap(); if (data != null) { builder.append(jsonFromMap(data)); } } return builder.toString(); }
@Override @SuppressWarnings("unchecked") public void setDataMap(Map<String, Object> data) throws FormEncodingException { super.setDataMap(data); this.inputName = (String) data.get("inputName"); this.variableName = (String) data.get("variableName"); this.loopBlock = (FormItemRepresentation) FormEncodingFactory.getDecoder().decode((Map<String, Object>) data.get("loopBlock")); }
@Override @SuppressWarnings("unchecked") public void setDataMap(Map<String, Object> data) throws FormEncodingException { super.setDataMap(data); this.inputName = (String) data.get("inputName"); this.variableName = (String) data.get("variableName"); this.loopBlock = (FormItemRepresentation) FormEncodingFactory.getDecoder().decode((Map<String, Object>) data.get("loopBlock")); }
@Override @SuppressWarnings("unchecked") public void setDataMap(Map<String, Object> data) throws FormEncodingException { super.setDataMap(data); this.cssClassName = (String) data.get("cssClassName"); this.id = (String) data.get("id"); this.cssStylesheetUrl = (String) data.get("cssStylesheetUrl"); this.items.clear(); List<Object> mapItems = (List<Object>) data.get("items"); FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); if (mapItems != null) { for (Object obj : mapItems) { Map<String, Object> itemMap = (Map<String, Object>) obj; FormItemRepresentation item = (FormItemRepresentation) decoder.decode(itemMap); this.items.add(item); } } }
@Override @SuppressWarnings("unchecked") public void setDataMap(Map<String, Object> data) throws FormEncodingException { super.setDataMap(data); this.text = (String) data.get("text"); this.name = (String) data.get("name"); this.id = (String) data.get("id"); Map<String, String> i18nMap = (Map<String, String>) data.get("i18n"); if (i18nMap != null) { this.i18n = new HashMap<String, String>(); this.i18n.putAll(i18nMap); } this.format = (String) data.get("format"); FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); this.onClickScript = (ScriptRepresentation) decoder.decode((Map<String, Object>) data.get("onClickScript")); }
@Override @SuppressWarnings("unchecked") public void setDataMap(Map<String, Object> data) throws FormEncodingException { super.setDataMap(data); this.text = (String) data.get("text"); this.name = (String) data.get("name"); this.id = (String) data.get("id"); Map<String, String> i18nMap = (Map<String, String>) data.get("i18n"); if (i18nMap != null) { this.i18n = new HashMap<String, String>(); this.i18n.putAll(i18nMap); } this.format = (String) data.get("format"); FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); this.onClickScript = (ScriptRepresentation) decoder.decode((Map<String, Object>) data.get("onClickScript")); }