diff --git a/publish-custom-image.sh b/publish-custom-image.sh new file mode 100755 index 0000000..18885ad --- /dev/null +++ b/publish-custom-image.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +set -e + +dir=${PWD##*/} + +gradle assemble + +# Get the current Git branch +branch=$(git rev-parse --abbrev-ref HEAD) + +# Replace any slashes (e.g., in 'feature/' or 'release/') with a hyphen +cleaned_branch=$(echo "$branch" | sed 's/\//_/g') + +# Get the short commit hash (first 5 characters) +commit_hash=$(git rev-parse --short=5 HEAD) + +# Combine branch and commit hash +buildName="${USER}-${cleaned_branch}-${commit_hash}" + +gradle bootBuildImage --publishImage -PbuildbootDockerHostNetwork=true -Pversion=${buildName} + +newImageName="nexus.knecon.com:5001/red/${dir}-server-v1:${buildName}" + +echo "full image name:" +echo ${newImageName} +echo "" + +if [ -z "$1" ]; then + exit 0 +fi + +namespace=${1} +deployment_name="redaction-report-service-v1" + +echo "deploying to ${namespace}" + +oldImageName=$(rancher kubectl -n ${namespace} get deployment ${deployment_name} -o=jsonpath='{.spec.template.spec.containers[*].image}') + +if [ "${newImageName}" = "${oldImageName}" ]; then + echo "Image tag did not change, redeploying..." + rancher kubectl rollout restart deployment ${deployment_name} -n ${namespace} +else + echo "upgrading the image tag..." + rancher kubectl set image deployment/${deployment_name} ${deployment_name}=${newImageName} -n ${namespace} +fi +rancher kubectl rollout status deployment ${deployment_name} -n ${namespace} +echo "Built ${deployment_name}:${buildName} and deployed to ${namespace}" diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelModelFactory.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelModelFactory.java index a1ba01b..716e1b0 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelModelFactory.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelModelFactory.java @@ -163,6 +163,7 @@ public class ExcelModelFactory { lastCellIndex += 1; col += 1; sheet.shiftColumns(col, lastCellIndex, 1); + actualRow = sheet.getRow(row); } } diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ScmReportService.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ScmReportService.java index 29f697c..a1ec1db 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ScmReportService.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ScmReportService.java @@ -52,14 +52,8 @@ public class ScmReportService { componentLog.getComponentLogEntries() .forEach(componentLogEntry -> { - - if (componentLogEntry.getComponentValues().isEmpty()) { - return; - } - // Process each ComponentLogEntryValue addOtherCells(sheet, excelModel, rowIndexCounter, componentIndexMap, componentLogEntry, fileModel); - }); autosizeColumns(sheet, rowIndexCounter); @@ -93,47 +87,75 @@ public class ScmReportService { String componentValue = componentLogEntry.getName().replaceAll("_", " "); - int componentIndex = componentIndexMap.getOrDefault(componentValue, 0); - List fileAttributeModels = excelModel.getFileAttributeColumns(); - + if (componentLogEntry.getComponentValues().isEmpty()) { + writeRow(sheet, excelModel, rowIndexCounter, fileModel, "", componentValue, componentIndexMap, fileAttributeModels); + return; + } for (ComponentLogEntryValue componentLogEntryValue : componentLogEntry.getComponentValues()) { - componentIndex++; - componentIndexMap.put(componentValue, componentIndex); - List textChunks = cellTextChunkingService.process(componentLogEntryValue.getValue()); for (String chunk : textChunks) { - int currentRowIdx = rowIndexCounter.getAndIncrement(); - Row row = sheet.createRow(currentRowIdx); - excelModel.getWrittenRows().add(currentRowIdx); - - Cell fileNameCell = row.createCell(0); - fileNameCell.setCellValue(fileModel.getFilename() == null ? "" : fileModel.getFilename()); - CellUtil.setVerticalAlignment(fileNameCell, VerticalAlignment.TOP); - - Cell componentNameCell = row.createCell(excelModel.getComponentReport().getComponentNameColumn()); - componentNameCell.setCellValue(componentValue); - if (excelModel.getComponentReport().writeComponentValueIndices()) { - Cell indexCell = row.createCell(excelModel.getComponentReport().getComponentValueIndexColumn()); - indexCell.setCellValue(componentIndex); - CellUtil.setAlignment(indexCell, HorizontalAlignment.CENTER); - CellUtil.setVerticalAlignment(indexCell, VerticalAlignment.TOP); - } - - Cell textCell = row.createCell(excelModel.getComponentReport().getComponentValueColumn()); - textCell.setCellValue(chunk); - CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); - cellStyle.setWrapText(true); - textCell.setCellStyle(cellStyle); - - addFileAttribute(row, fileModel, fileAttributeModels); + writeRow(sheet, excelModel, rowIndexCounter, fileModel, chunk, componentValue, componentIndexMap, fileAttributeModels); } } } + private void writeRow(Sheet sheet, + ExcelModel excelModel, + AtomicInteger rowIndexCounter, + FileModel fileModel, + String chunk, + String componentValue, + Map componentIndexMap, + List fileAttributeModels) { + + int componentIndex = incrementAndGet(componentValue, componentIndexMap); + int currentRowIdx = rowIndexCounter.getAndIncrement(); + Row row = sheet.createRow(currentRowIdx); + excelModel.getWrittenRows().add(currentRowIdx); + + Cell fileNameCell = row.createCell(0); + fileNameCell.setCellValue(fileModel.getFilename() == null ? "" : fileModel.getFilename()); + CellUtil.setVerticalAlignment(fileNameCell, VerticalAlignment.TOP); + + Cell componentNameCell = row.createCell(excelModel.getComponentReport().getComponentNameColumn()); + componentNameCell.setCellValue(componentValue); + if (excelModel.getComponentReport().writeComponentValueIndices()) { + Cell indexCell = row.createCell(excelModel.getComponentReport().getComponentValueIndexColumn()); + indexCell.setCellValue(componentIndex); + CellUtil.setAlignment(indexCell, HorizontalAlignment.CENTER); + CellUtil.setVerticalAlignment(indexCell, VerticalAlignment.TOP); + } + + Cell textCell = row.createCell(excelModel.getComponentReport().getComponentValueColumn()); + textCell.setCellValue(chunk); + CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); + cellStyle.setWrapText(true); + textCell.setCellStyle(cellStyle); + + addFileAttribute(row, fileModel, fileAttributeModels); + } + + + private static int incrementAndGet(String componentValue, Map componentIndexMap) { + + int componentIndex = componentIndexMap.getOrDefault(componentValue, 0); + componentIndex++; + componentIndexMap.put(componentValue, componentIndex); + return componentIndex; + } + + + private static int increment(Map componentIndexMap, int componentIndex, String componentValue) { + + + return componentIndex; + } + + private void addFileAttribute(Row row, FileModel fileModel, List fileAttributeModels) { for (FileAttributeModel fileAttributeModel : fileAttributeModels) {