use of com.axelor.text.GroovyTemplates in project axelor-open-suite by axelor.
the class AppLoaderExportServiceImpl method addAppDataFile.
protected void addAppDataFile(AppLoader appLoader, File exportDir) throws IOException {
Map<String, InputStream> inputStreams = getExportTemplateResources();
GroovyTemplates templates = new GroovyTemplates();
for (String xmlFileName : inputStreams.keySet()) {
log.debug("Exporting file: {}", xmlFileName);
File file = new File(exportDir, xmlFileName);
FileWriter writer = new FileWriter(file);
Map<String, Object> ctx = getExportContext(appLoader);
templates.from(new InputStreamReader(inputStreams.get(xmlFileName))).make(ctx).render(writer);
writer.close();
if (file.length() == 0) {
file.delete();
} else {
long lines = java.nio.file.Files.lines(file.toPath()).count();
if (lines == 1) {
file.delete();
}
}
}
}
Aggregations