diff --git a/src/main/java/nl/nn/testtool/filter/View.java b/src/main/java/nl/nn/testtool/filter/View.java index e4ec561d..98b2a460 100644 --- a/src/main/java/nl/nn/testtool/filter/View.java +++ b/src/main/java/nl/nn/testtool/filter/View.java @@ -15,9 +15,13 @@ */ package nl.nn.testtool.filter; +import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.HashMap; +import nl.nn.testtool.MetadataExtractor; +import nl.nn.testtool.storage.CrudStorage; import org.springframework.beans.factory.annotation.Autowired; import jakarta.enterprise.context.Dependent; @@ -44,6 +48,7 @@ public class View implements BeanParent { private List checkpointMatchers; private BeanParent beanParent; private Echo2Application echo2Application; + private @Inject @Autowired MetadataExtractor metadataExtractor; protected enum NodeLinkStrategy { PATH, @@ -118,4 +123,30 @@ public String toString() { return getName(); } + public Map toMap(boolean isDefaultView) { + Map metadataTypes = new HashMap<>(); + for (String metadataName : getMetadataNames()) { + metadataTypes.put(metadataName, metadataExtractor.getType(metadataName)); + } + + return new HashMap() {{ + put("storageName", debugStorage.getName()); + put("defaultView", isDefaultView); + put("metadataNames", metadataNames); + put("metadataLabels", getMetadataLabels()); + put("crudStorage", debugStorage instanceof CrudStorage); + put("nodeLinkStrategy", nodeLinkStrategy); + put("name", getName()); + put("metadataTypes", metadataTypes); + }}; + } + + public List getMetadataLabels() { + List metadataLabels = new ArrayList<>(); + for (String metadataName : getMetadataNames()) { + metadataLabels.add(metadataExtractor.getLabel(metadataName)); + } + + return metadataLabels; + } } diff --git a/src/main/java/nl/nn/testtool/web/api/TestToolApi.java b/src/main/java/nl/nn/testtool/web/api/TestToolApi.java index c692cad8..0a94282e 100644 --- a/src/main/java/nl/nn/testtool/web/api/TestToolApi.java +++ b/src/main/java/nl/nn/testtool/web/api/TestToolApi.java @@ -167,17 +167,17 @@ public Response deleteReportInProgress(@PathParam("index") int index) { } } - /** - * Gets the report in progress warning threshold time - * - * @return Response containing the time it will take before ladybug shows a warning that a report is still in progress - * */ - @GET - @Path("/in-progress/threshold-time") - @Produces(MediaType.APPLICATION_JSON) - public Response getReportsInProgressWarningThreshold(){ - return Response.ok(testTool.getReportsInProgressThreshold()).build(); - } + /** + * Gets the report in progress warning threshold time + * + * @return Response containing the time it will take before ladybug shows a warning that a report is still in progress + */ + @GET + @Path("/in-progress/threshold-time") + @Produces(MediaType.APPLICATION_JSON) + public Response getReportsInProgressWarningThreshold() { + return Response.ok(testTool.getReportsInProgressThreshold()).build(); + } /** * Change the default transformation. @@ -231,39 +231,18 @@ public Response getViewsResponse() { // Starting from CXF 3.2.0 the setViews() will not be called by Spring when the name of this method is // getViews() instead of getViewsResponse() (with CXF 3.1.18 this was not the case) (maybe Spring's // ExtendedBeanInfo isn't used anymore with newer CXF versions) - Map> response = new LinkedHashMap>(); + Map> response = new LinkedHashMap<>(); for (View view : views) { - Map map = new HashMap(); - map.put("storageName", view.getDebugStorage().getName()); - map.put("defaultView", view == views.getDefaultView()); - map.put("metadataNames", view.getMetadataNames()); - map.put("metadataLabels", getMetadataLabels(view.getMetadataNames())); - map.put("crudStorage", view.getDebugStorage() instanceof CrudStorage); - map.put("nodeLinkStrategy", view.getNodeLinkStrategy()); - Map metadataTypes = new HashMap<>(); - for(String metadataName : view.getMetadataNames()) { - metadataTypes.put(metadataName, metadataExtractor.getType(metadataName)); - } - map.put("metadataTypes", metadataTypes); - response.put(view.getName(), map); + response.put(view.getName(), view.toMap(view == views.getDefaultView())); } return Response.ok(response).build(); } - public List getMetadataLabels(List metadataNames) { - List metadataLabels = new ArrayList<>(); - for (String metadataName : metadataNames) { - metadataLabels.add(metadataExtractor.getLabel(metadataName)); - } - - return metadataLabels; - } - @PUT @Path("/node-link-strategy") @Consumes(MediaType.APPLICATION_JSON) public Response changeNodeLinkStrategy(@QueryParam("nodeLinkStrategy") String nodeLinkStrategy, @QueryParam("viewName") String viewName) { - for (View view: views) { + for (View view : views) { if (viewName.equals(view.getName())) { setSessionAttr(view.getName() + ".NodeLinkStrategy", nodeLinkStrategy); break;