RM-226 && All-Components: add publish script, fix missing column labels, write empty component values

This commit is contained in:
Kilian Schüttler 2025-01-21 14:54:20 +01:00
parent 808814911c
commit 3eee0726d4
3 changed files with 107 additions and 36 deletions

48
publish-custom-image.sh Executable file
View File

@ -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}"

View File

@ -163,6 +163,7 @@ public class ExcelModelFactory {
lastCellIndex += 1;
col += 1;
sheet.shiftColumns(col, lastCellIndex, 1);
actualRow = sheet.getRow(row);
}
}

View File

@ -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<FileAttributeModel> 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<String> 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<String, Integer> componentIndexMap,
List<FileAttributeModel> 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<String, Integer> componentIndexMap) {
int componentIndex = componentIndexMap.getOrDefault(componentValue, 0);
componentIndex++;
componentIndexMap.put(componentValue, componentIndex);
return componentIndex;
}
private static int increment(Map<String, Integer> componentIndexMap, int componentIndex, String componentValue) {
return componentIndex;
}
private void addFileAttribute(Row row, FileModel fileModel, List<FileAttributeModel> fileAttributeModels) {
for (FileAttributeModel fileAttributeModel : fileAttributeModels) {