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 ); } } }
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() ); }
@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 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 ); } } } ); }
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; }