if (!FormType.ANY.getName().equals(formType) && !provider.getType().equals(formType)) { logger.debug("Provider {} does not support {} form type", provider, formType); continue;
public String getFormDisplayProcess(String containerId, String processId, String lang, boolean filterContent, String formType) { containerId = registry.getContainerId(containerId, ContainerLocatorProvider.get().getLocator()); ProcessDefinition processDesc = definitionService.getProcessDefinition(containerId, processId); if (processDesc == null) { throw new IllegalStateException("Process definition " + containerId + " : " + processId + " not found"); } Map<String, String> processData = definitionService.getProcessVariables(containerId, processId); if (processData == null) { processData = new HashMap<>(); } Map<String, Object> renderContext = new HashMap<>(); renderContext.put("process", processDesc); renderContext.put("outputs", processData); renderContext.put("lang", lang); renderContext.put("filterForm", filterContent); for (UIFormProvider provider : providers) { // if there's no formType or formType is ANY the first provider able to generate the formContent wins if (!FormType.ANY.getName().equals(formType) && !provider.getType().equals(formType)) { logger.debug("Provider {} does not support {} form type", provider, formType); continue; } String template = provider.render(processDesc.getName(), processDesc, renderContext); if (!StringUtils.isEmpty(template)) { return template; } } logger.warn("Unable to find form to render for process '{}'", processDesc.getName()); throw new IllegalStateException("No form for process with id " + processDesc.getName() + " found"); }
protected String marshallFormContent( String formContent, String formType, Variant variant ) throws Exception { if ( StringUtils.isEmpty( formContent ) ) { return formContent; } FormServiceBase.FormType actualFormType = FormServiceBase.FormType.fromName(formType); String actualContentType = actualFormType.getContentType(); if ( actualContentType == null ) { actualContentType = getMediaTypeForFormContent( formContent ); } if (variant.getMediaType().equals(MediaType.APPLICATION_JSON_TYPE) && !MediaType.APPLICATION_JSON_TYPE.getSubtype().equals( actualContentType )) { JSONObject json = XML.toJSONObject(formContent); formatJSONResponse(json); formContent = json.toString(PRETTY_PRINT_INDENT_FACTOR); } else if (variant.getMediaType().equals(MediaType.APPLICATION_XML_TYPE) && !MediaType.APPLICATION_XML_TYPE.getSubtype().equals( actualContentType )) { Object json = parseToJSON(formContent); formContent = XML.toString(json); } return formContent; }
public static FormType fromName(String name) { if (FORM_MODELLER_TYPE.getName().equals(name)) { return FORM_MODELLER_TYPE; } else if (FORM_TYPE.getName().equals(name)) { return FORM_TYPE; } else if (FREE_MARKER_TYPE.getName().equals(name)) { return FREE_MARKER_TYPE; } else if (ANY.getName().equals(name)) { return ANY; } else { throw new IllegalArgumentException("No FormType enum value for " + name); } } }
@Override public String getType() { return FormServiceBase.FormType.FORM_TYPE.getName(); }
@Override public String getType() { return FormServiceBase.FormType.FREE_MARKER_TYPE.getName(); } }
@Override public String getType() { return FormServiceBase.FormType.FORM_MODELLER_TYPE.getName(); } }