@Override public void configure(FormManagerService formManagerService) { setFormManagerService(formManagerService); }
@Override public void configure( FormManagerService formManagerService ) { setFormManagerService( formManagerService ); }
protected void parseFormContent( String formId, Map<String, Object> contextForms, Collection<String> availableForms ) { if ( !StringUtils.isEmpty( formId ) && !contextForms.containsKey( formId )) { JsonObject jsonForm = findForm( formId, availableForms ); if ( jsonForm != null ) { parseFormContent( jsonForm, contextForms, availableForms ); } } }
PurchaseOrder purchaseOrder = new PurchaseOrder(); purchaseOrder.setDescription("test description"); purchaseOrder.setRequiresCFOApproval(true); purchaseOrder.setTotal(100.0); PurchaseOrderHeader header = new PurchaseOrderHeader(); header.setCreationDate(new Date()); header.setCustomer("john"); header.setProject("test project"); purchaseOrder.setHeader(header); PurchaseOrderLine orderLine1 = new PurchaseOrderLine(); orderLine1.setDescription("first line"); orderLine1.setTotal(10.0); orderLine1.setAmount(2.0); orderLine1.setUnitPrice(25.0); PurchaseOrderLine orderLine2 = new PurchaseOrderLine(); orderLine2.setDescription("second line"); orderLine2.setTotal(20.0); orderLine2.setAmount(4.0); orderLine2.setUnitPrice(25.0); purchaseOrder.setLines(orderLines); PurchaseOrder purchaseOrderOut = new PurchaseOrder(); purchaseOrderOut.setDescription("output description"); purchaseOrderOut.setRequiresCFOApproval(true);
String defaultSubForm = findPropertyValue(node, "defaultSubform"); if (defaultSubForm != null) { String currentNodeInputBinding = findPropertyValue(node, "inputBinding"); currentNodeInputBinding = currentNodeInputBinding.replaceAll("/", String currentNodeOutputBinding = findPropertyValue(node, "outputBinding"); currentNodeOutputBinding = currentNodeOutputBinding.replaceAll("/", String inputBindingSubForm = findPropertyValue(firstFieldNode, "inputBinding"); inputBindingSubForm = inputBindingSubForm.split("/")[0]; String outputBindingSubForm = findPropertyValue(firstFieldNode, "outputBinding"); outputBindingSubForm = outputBindingSubForm.split("/")[0]; String filtered = filterXML(subFormContent, lang, deploymentId, String defaultSubForm = findPropertyValue(node, "defaultSubform"); if (defaultSubForm != null) { String inputBinding = findPropertyValue(node,
if (templateString == null) { templateString = formManagerService.getFormByKey(process.getDeploymentId(), process.getId() + getFormSuffix()); templateString = filterXML(templateString, lang, process.getDeploymentId(), null); } else { templateString = attachSubForms(templateString, process.getDeploymentId());
String lookupName = getTaskFormName(task); templateString = filterXML(templateString, lang, task.getTaskData().getDeploymentId(), outputs); } else { templateString = attachSubForms(templateString, task.getTaskData().getDeploymentId());
@Test public void testAddSubForm() throws Exception { String allForms = formProvider.attachSubForms(createOrderFormContent, "test"); validateFormXML(allForms); }
@Override public String render( String name, ProcessDefinition process, Map<String, Object> renderContext ) { if (!(process instanceof ProcessAssetDesc )) { return null; } return render( process.getId() + getFormSuffix(), process.getDeploymentId() ); }
@Override public String render( String name, Task task, ProcessDefinition process, Map<String, Object> renderContext ) { String lookupName = getTaskFormName( task ); if ( lookupName == null || lookupName.isEmpty()) return null; return render( lookupName, task.getTaskData().getDeploymentId() ); }
protected String generateRenderingContextString( String formContent, Map<String, String> availableForms ) { Map<String, Object> contextForms = new HashMap<>(); Collection<String> result = availableForms.entrySet().stream().filter( entry -> entry.getKey().endsWith( getFormExtension() ) ).collect( Collectors.toMap( p -> p.getKey(), p -> p.getValue()) ).values(); parseFormContent( parser.parse( formContent ).getAsJsonObject(), contextForms, result ); return gson.toJson( contextForms.values() ); }
if (SUB_FORM_TYPE.equals(fieldType) || MULTI_SUB_FORM_TYPE.equals(fieldType)) { String defaultSubForm = findPropertyValue(node, "defaultSubform"); if (defaultSubForm != null) { document = asString(doc); } catch (Exception ex) { logger.error("Error when attaching subform",
@Before public void setup() throws IOException { formManagerService = new FormManagerServiceImpl(); createOrderFormContent = IOUtils.toString(this.getClass().getResourceAsStream("/test-forms/CreateOrder.form"), "UTF-8"); headerFormContent = IOUtils.toString(this.getClass().getResourceAsStream("/test-forms/PurchaseHeader.form"), "UTF-8"); orderLineFormContent = IOUtils.toString(this.getClass().getResourceAsStream("/test-forms/PurchaseLine.form"), "UTF-8"); formManagerService.registerForm("test", "CreateOrder.form", createOrderFormContent); formManagerService.registerForm("test", "PurchaseHeader.form", headerFormContent); formManagerService.registerForm("test", "PurchaseLine.form", orderLineFormContent); formProvider = new RemoteFormModellerFormProvider(); formProvider.configure(formManagerService); }
private void filterProperty(Node property, String lang, String value) { String label = getLabel(lang, value); property.getAttributes().getNamedItem(ATTR_VALUE).setNodeValue(label); }
protected String render( String formName, String deploymentId ) { String formContent = formManagerService.getFormByKey( deploymentId, formName); if ( !StringUtils.isEmpty( formContent ) ) { return generateRenderingContextString( formContent, formManagerService.getAllFormsByDeployment( deploymentId ) ); } return null; }
protected void parseFormContent( JsonObject jsonForm, Map<String, Object> contextForms, Collection<String> availableForms ) { String id = jsonForm.get( "id" ).getAsString(); if ( !contextForms.containsKey( id ) ) { contextForms.put( id, jsonForm ); } JsonArray fields = jsonForm.get( "fields" ).getAsJsonArray(); fields.forEach( jsonElement -> { JsonObject object = jsonElement.getAsJsonObject(); if ( object != null ) { String code = object.get( "code" ).getAsString(); if( SUBFORM.equals( code ) ) { String id1 = object.get( SUBFORM_FORM_PROPERTY ).getAsString(); parseFormContent( id1, contextForms, availableForms ); } else if ( MULTIPLE_SUBFORM.equals( code ) ) { String id1 = object.get( MULTIPLE_SUBFORM_CREATION_FORM_PROPERTY ).getAsString(); parseFormContent( id1, contextForms, availableForms ); id1 = object.get( MULTIPLE_SUBFORM_EDITION_FORM_PROPERTY ).getAsString(); parseFormContent( id1, contextForms, availableForms ); } } } ); }