@@ -422,18 +422,30 @@ private boolean isInfrastructureClass(Class<?> clazz) {
422422 return clazz == RegionReferenceDto .class || clazz == DistrictReferenceDto .class || clazz == CommunityReferenceDto .class || clazz == FacilityReferenceDto .class || clazz == PointOfEntryReferenceDto .class ;
423423 }
424424
425- @ LocalBean
426- @ Stateless
427- public static class ImportFacadeEjbLocal extends ImportFacadeEjb {
428-
429- }
430-
425+ /**
426+ * Writes the given line as a comment line
427+ * @param csvWriter file writer
428+ * @param line line to write
429+ */
431430 private void writeCommentLine (CSVWriter csvWriter , String [] line ) {
432431 String [] commentedLine = Arrays .copyOf (line , line .length );
433432 commentedLine [0 ] = CSVCommentLineValidator .DEFAULT_COMMENT_LINE_PREFIX + commentedLine [0 ];
434433 csvWriter .writeNext (commentedLine );
435434 }
436435
436+ /**
437+ * Writes template files with the following lines:
438+ * <ul>
439+ * <li><code>entityNames</code> - only if <code>includeEntityNames</code> is <code>true</code></li>
440+ * <li><code>columnNames</code> - represent the DTO properties that can be filled</li>
441+ * <li><code>captions</code> - (commented) internationalized caption for each field</li>
442+ * <li><code>dataDescription</code> - (commented) data examples or description for each field</li>
443+ * </ul>
444+ * @param templatePath path to write the template to
445+ * @param importColumns details about each CSV column
446+ * @param includeEntityNames weather to include the <code>entityNames</code> or not
447+ * @throws IOException
448+ */
437449 private void writeTemplate (Path templatePath , List <ImportColumn > importColumns , boolean includeEntityNames ) throws IOException {
438450 try (CSVWriter writer = CSVUtils .createCSVWriter (new FileWriter (templatePath .toString ()), configFacade .getCsvSeparator ())) {
439451 if (includeEntityNames ) {
@@ -453,6 +465,13 @@ public String getImportTemplateContent(String templateFilePath) throws IOExcepti
453465 return resolvePlaceholders (content );
454466 }
455467
468+ /**
469+ * Replaces placeholders in the given file content.
470+ * The placeholders are resolved using dynamic data. For any static data extend {@link ImportColumn}.
471+ * @param content file content.
472+ * @return
473+ * @see ImportFacade#ACTIVE_DISEASES_PLACEHOLDER
474+ */
456475 private String resolvePlaceholders (String content ) {
457476 Map <String , Provider <String >> placeholderResolvers = new HashMap <>();
458477 placeholderResolvers .put (ImportFacade .ACTIVE_DISEASES_PLACEHOLDER ,
@@ -465,4 +484,10 @@ private String resolvePlaceholders(String content) {
465484
466485 return content ;
467486 }
487+
488+ @ LocalBean
489+ @ Stateless
490+ public static class ImportFacadeEjbLocal extends ImportFacadeEjb {
491+
492+ }
468493}
0 commit comments