/** * List all HTML Forms */ @RequestMapping("/module/htmlformentry/htmlForms") public void manageHtmlForms(Model model) { model.addAttribute("forms", HtmlFormEntryUtil.getService().getAllHtmlForms()); }
@Override protected Object formBackingObject(HttpServletRequest request) throws Exception { return HtmlFormEntryUtil.getService().getAllHtmlForms(); }
private <C extends Collection<Form>> C addAllHtmlForms(C collection) { boolean showUnpublished = Context.getAuthenticatedUser().hasPrivilege(PrivilegeConstants.VIEW_UNPUBLISHED_FORMS); Set<Form> ret = new LinkedHashSet<Form>(); for (HtmlForm form : HtmlFormEntryUtil.getService().getAllHtmlForms()) { if (showUnpublished || form.getForm().getPublished()) ret.add(form.getForm()); } collection.addAll(ret); return collection; }
/** * Handles submission for splitting html forms that share an underlying form * @param request * @return */ @RequestMapping(method=RequestMethod.POST, params="migration=duplicateForms") public String splitDuplicateForms(WebRequest request) { HtmlFormEntryService service = HtmlFormEntryUtil.getService(); Map<Integer, List<HtmlForm>> duplicates = getDuplicateForms(service.getAllHtmlForms()); for (Map.Entry<Integer, List<HtmlForm>> e : duplicates.entrySet()) { Integer id = e.getKey(); List<HtmlForm> htmlForms = e.getValue(); String choice = request.getParameter("group." + id); try { Integer keepHtmlFormId = Integer.valueOf(choice); for (HtmlForm htmlForm : htmlForms) { if (!htmlForm.getId().equals(keepHtmlFormId)) { splitUnderlyingForm(htmlForm); } } } catch (NumberFormatException ex) { } } return "redirect:migrateNamesAndDescriptions.form"; }
/** * Clears deprecated names and descriptions (because they exactly matched the underlying form * @param request * @return */ @RequestMapping(method=RequestMethod.POST, params="migration=clearNamesAndDescriptions") public String clearNamesAndDescriptionsThatMatch(@RequestParam(value="clearName", required=false) List<Integer> clearNames, @RequestParam(value="clearDescription", required=false) List<Integer> clearDescriptions) { HtmlFormEntryService service = HtmlFormEntryUtil.getService(); for (HtmlForm form : service.getAllHtmlForms()) { boolean needToSave = false; if (clearNames != null && clearNames.contains(form.getId())) { form.setDeprecatedName(null); needToSave = true; } if (clearDescriptions != null && clearDescriptions.contains(form.getId())) { form.setDeprecatedDescription(null); needToSave = true; } if (needToSave) service.saveHtmlForm(form); } return "redirect:migrateNamesAndDescriptions.form"; }
public String showMigrationsNeeded(Model model) { HtmlFormEntryService service = HtmlFormEntryUtil.getService(); List<HtmlForm> allForms = service.getAllHtmlForms();
/** * @see {@link HtmlFormEntryService#getAllHtmlForms()} */ @Test @Verifies(value = "should return all html forms", method = "getAllHtmlForms()") public void getAllHtmlForms_shouldReturnAllHtmlForms() throws Exception { Assert.assertEquals(2, service.getAllHtmlForms().size()); }
HtmlFormEntryService service = HtmlFormEntryUtil.getService(); for (HtmlForm htmlForm : service.getAllHtmlForms()) { boolean modified = false;