Package org.openbravo.service.json
Class JSONWriterToCSV
- java.lang.Object
-
- org.openbravo.service.json.DefaultJsonDataService.QueryResultWriter
-
- org.openbravo.service.json.JSONWriterToCSV
-
public class JSONWriterToCSV extends DefaultJsonDataService.QueryResultWriter
Helper class to write JSON objects to generate a CSV file using the standard preferences. This class will be commonly used by first creating a new instance and that will write the header in the writer, then invoking the write method for each of the json objects that need to be written and then by invoking the writeCSVFooterNote method to write the fotter, if any.
-
-
Constructor Summary
Constructors Constructor Description JSONWriterToCSV(Writer printWriter, VariablesSecureApp vars, Map<String,String> parameters, Entity entity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
getFieldProperties()
Get selected properties those that will finally be exported.void
write(org.codehaus.jettison.json.JSONObject json)
Writes the JSON object as a record in CSV format based on the class parameters settings.void
writeCSVFooterNote(Map<String,String> parameters)
Writes the footer message of the CSV configured in the preference.
-
-
-
Constructor Detail
-
JSONWriterToCSV
public JSONWriterToCSV(Writer printWriter, VariablesSecureApp vars, Map<String,String> parameters, Entity entity)
- Parameters:
printWriter
- Writer that will be used to write the results of the export process.vars
- VariablseSecureApp with the session data.parameters
- It contains the parameters required to build properly the CSV file.entity
- Entity to load the properties.
-
-
Method Detail
-
getFieldProperties
public List<String> getFieldProperties()
Get selected properties those that will finally be exported.
-
write
public void write(org.codehaus.jettison.json.JSONObject json)
Writes the JSON object as a record in CSV format based on the class parameters settings.- Specified by:
write
in classDefaultJsonDataService.QueryResultWriter
- Parameters:
json
- JSON object to convert to CSV record.
-
writeCSVFooterNote
public void writeCSVFooterNote(Map<String,String> parameters) throws IOException, PropertyException
Writes the footer message of the CSV configured in the preference.- Parameters:
parameters
- It contains the parameters required to build properly the CSV file.- Throws:
IOException
PropertyException
-
-