I wanted to edit the contents of the output CSV while using the standard CSV download function.
Since it was not on the support page, I will describe what I checked.
8.2.0
--I don't want to output the CSV header line. --I want to modify (format) the contents of each output column.
It seems that it is not recommended to do it on the application created by Wagby. If you can process it separately using an ETL tool, that may be easier.
It is necessary to create a class that inherits Java that is automatically generated and change the contents of the CSV output method.
Class to inherit: Download model name ProcessBean
DownloadTestProcessBean.java
public Object outputAllData(DbDownloadProcessor out, Map paramMap, boolean getallmodelitem) {
...
// Output header line
Collection<String> targetitems =
(Collection<String>) getParameter("targetitems");
String[] _data = ((jp.jasminesoft.wagby.app.test.TestPCSVHelper)p.appctx.getBean("TestPCSVHelper")).toCsvDataHeader(null, colMap, (ActionParameter)p, getallmodelitem, targetitems);
out.write(_data);
...
}
You can create a CSV without a header by creating a method that overrides the above method and deletes the header output process described.
This process may change when the Wagby version is upgraded, so it is better to check if the inheritance source process has changed when the version is upgraded.
Since it is not introduced on the support page, it seems that it is not a standard custom point, but there is javascript called at the timing of reading and outputting each line, and it is possible to edit the contents there.
javascript name: model name + Helper_beforeShowInDownload.js
TestHelper_beforeShowInDownload.js
/**
*Methods called from Java
*/
function process() {
//The contents of the store model can be rewritten
test.id = "hoge";
}
At this time, not only the column output to CSV but also the store model stores all one record of the model.
Recommended Posts