diff --git a/qqq-middleware-api/src/main/java/com/kingsrook/qqq/api/model/metadata/processes/ApiProcessSummaryListOutput.java b/qqq-middleware-api/src/main/java/com/kingsrook/qqq/api/model/metadata/processes/ApiProcessSummaryListOutput.java index 0fcb94a2..5be52fdf 100644 --- a/qqq-middleware-api/src/main/java/com/kingsrook/qqq/api/model/metadata/processes/ApiProcessSummaryListOutput.java +++ b/qqq-middleware-api/src/main/java/com/kingsrook/qqq/api/model/metadata/processes/ApiProcessSummaryListOutput.java @@ -48,7 +48,9 @@ import org.eclipse.jetty.http.HttpStatus; /******************************************************************************* - ** + ** For a process that puts "processResults" in its output (as a list of + ** ProcessSummaryLineInterface objects) - this class converts such an object + ** to a suitable ApiProcessOutput. *******************************************************************************/ public class ApiProcessSummaryListOutput implements ApiProcessOutputInterface { @@ -143,22 +145,31 @@ public class ApiProcessSummaryListOutput implements ApiProcessOutputInterface { if(processSummaryLineInterface instanceof ProcessSummaryLine processSummaryLine) { - processSummaryLine.setCount(1); - processSummaryLine.pickMessage(true); - List primaryKeys = processSummaryLine.getPrimaryKeys(); if(CollectionUtils.nullSafeHasContents(primaryKeys)) { + //////////////////////////////////////////////////////////////////////////// + // if there are primary keys in the line, then we'll loop over those, and // + // output an object in the API output for each one - and we'll make the // + // line appear to be a singular-past-tense line about that individual key // + //////////////////////////////////////////////////////////////////////////// + processSummaryLine.setCount(1); + processSummaryLine.pickMessage(true); + for(Serializable primaryKey : primaryKeys) { - HashMap map = toMap(processSummaryLine); + HashMap map = toMap(processSummaryLine, false); map.put("id", primaryKey); apiOutput.add(map); } } else { - apiOutput.add(toMap(processSummaryLine)); + ////////////////////////////////////////////////////////////////////////// + // otherwise, handle a line without pkeys as a single output map/object // + ////////////////////////////////////////////////////////////////////////// + HashMap map = toMap(processSummaryLine, true); + apiOutput.add(map); } } else if(processSummaryLineInterface instanceof ProcessSummaryRecordLink processSummaryRecordLink) @@ -219,12 +230,19 @@ public class ApiProcessSummaryListOutput implements ApiProcessOutputInterface /******************************************************************************* ** *******************************************************************************/ - private static HashMap toMap(ProcessSummaryLine processSummaryLine) + private static HashMap toMap(ProcessSummaryLine processSummaryLine, boolean tryToIncludeCount) { HashMap map = initResultMapForProcessSummaryLine(processSummaryLine); String messagePrefix = getResultMapMessagePrefix(processSummaryLine); - map.put("message", messagePrefix + processSummaryLine.getMessage()); + + String messageSuffix = processSummaryLine.getMessage(); + if(tryToIncludeCount && processSummaryLine.getCount() != null) + { + messageSuffix = processSummaryLine.getCount() + " " + messageSuffix; + } + + map.put("message", messagePrefix + messageSuffix); return (map); }