Skip to content

Commit

Permalink
Get responses from form
Browse files Browse the repository at this point in the history
  • Loading branch information
TimotheeHrl committed Nov 27, 2023
1 parent b0314c4 commit fc7d2a5
Showing 1 changed file with 21 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
package fr.paris.lutece.plugins.forms.export.pdf;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Entities.EscapeMode;

import fr.paris.lutece.plugins.forms.business.CompositeDisplayType;
import fr.paris.lutece.plugins.forms.business.FormDisplay;
import fr.paris.lutece.plugins.forms.business.FormDisplayHome;
import fr.paris.lutece.plugins.forms.business.FormQuestionResponse;
import fr.paris.lutece.plugins.forms.business.FormResponse;
import fr.paris.lutece.plugins.forms.business.FormResponseStep;
import fr.paris.lutece.plugins.forms.business.Group;
import fr.paris.lutece.plugins.forms.business.GroupHome;
import fr.paris.lutece.plugins.forms.business.MultiviewConfig;
import fr.paris.lutece.plugins.forms.business.Question;
import fr.paris.lutece.plugins.forms.business.Step;
import fr.paris.lutece.plugins.forms.business.*;
import fr.paris.lutece.plugins.forms.business.form.FormItemSortConfig;
import fr.paris.lutece.plugins.forms.business.form.column.IFormColumn;
import fr.paris.lutece.plugins.forms.business.form.filter.FormFilter;
Expand Down Expand Up @@ -58,6 +29,20 @@
import fr.paris.lutece.portal.service.util.AppLogService;
import fr.paris.lutece.portal.service.util.AppPropertiesService;
import fr.paris.lutece.util.html.HtmlTemplate;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Entities.EscapeMode;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

public abstract class AbstractPdfFileGenerator extends AbstractFileGenerator {

Expand Down Expand Up @@ -281,16 +266,20 @@ private PdfCell createPdfCell( FormResponseStep formResponseStep, FormDisplay fo
.filter( fqr -> fqr.getQuestion( ).getEntry( ).isExportablePdf( ) )
.filter( fqr -> fqr.getQuestion( ).getId( ) == formDisplay.getCompositeId( ) )
.filter( fqr -> fqr.getQuestion( ).getIterationNumber( ) == iterationNumber ).findFirst( ).orElse( null );

System.out.println("formQuestionResponse: " + formQuestionResponse);
if ( formQuestionResponse != null )
{
String key = formQuestionResponse.getQuestion( ).getTitle( );
System.out.println("key: " + key);
List<String> listResponseValue = getResponseValue( formQuestionResponse, iterationNumber );

if ( CollectionUtils.isNotEmpty( listResponseValue ) )
{
PdfCell cell = new PdfCell( );
cell.setTitle( key );
cell.setValue( listResponseValue.stream( ).filter( StringUtils::isNotEmpty ).collect( Collectors.joining( ";" ) ) );
System.out.println("cell val: " + cell.getValue());

return cell;
}
}
Expand All @@ -308,6 +297,7 @@ private PdfCell createPdfCell( FormResponseStep formResponseStep, FormDisplay fo
*/
private List<String> getResponseValue( FormQuestionResponse formQuestionResponse, int iteration )
{
System.out.println("formQuestionResponse: " + formQuestionResponse);
Entry entry = formQuestionResponse.getQuestion( ).getEntry( );

IEntryTypeService entryTypeService = EntryTypeServiceManager.getEntryTypeService( entry );
Expand Down

0 comments on commit fc7d2a5

Please sign in to comment.