From 324e39e395ffe515ad4254fa473c5aa66bcf309b Mon Sep 17 00:00:00 2001 From: Guus Wilmink Date: Wed, 31 Jul 2024 12:26:03 +0200 Subject: [PATCH] fix Word generator --- .../ETLWordDocumentGenerator.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/rabbitinahat/src/main/java/org/ohdsi/rabbitInAHat/ETLWordDocumentGenerator.java b/rabbitinahat/src/main/java/org/ohdsi/rabbitInAHat/ETLWordDocumentGenerator.java index e7193aa6..d7d23be0 100644 --- a/rabbitinahat/src/main/java/org/ohdsi/rabbitInAHat/ETLWordDocumentGenerator.java +++ b/rabbitinahat/src/main/java/org/ohdsi/rabbitInAHat/ETLWordDocumentGenerator.java @@ -149,7 +149,15 @@ private static void addTargetTableSection(CustomXWPFDocument document, ETL etl, int rowNr = 1; for (MappableItem targetField : fieldtoFieldMapping.getTargetItems()) { XWPFTableRow row = table.getRow(rowNr++); - row.getCell(0).setText(targetField.getName()); + + // Check if the field is non-nullable and prepend an asterisk if true + String fieldName = targetField.getName(); + for (Field field : targetTable.getFields()) { + if (field.getName().equals(fieldName) && !field.isNullable()) { + fieldName = "*" + fieldName; + break; + } + } StringBuilder source = new StringBuilder(); StringBuilder logic = new StringBuilder(); @@ -177,6 +185,15 @@ private static void addTargetTableSection(CustomXWPFDocument document, ETL etl, comment.append(field.getComment().trim()); } } + + // Grey out the font if source field, logic, and comment are all empty + if (source.toString().trim().isEmpty() && logic.toString().trim().isEmpty() && comment.toString().trim().isEmpty()) { + XWPFRun runGrey = row.getCell(0).getParagraphs().get(0).createRun(); + runGrey.setColor("999999"); + runGrey.setText(fieldName); + } else { + row.getCell(0).setText(fieldName); + } createCellParagraph(row.getCell(1), source.toString()); createCellParagraph(row.getCell(2), logic.toString());