diff --git a/src/main/java/org/usf/trace/api/server/FilterCriteria.java b/src/main/java/org/usf/trace/api/server/FilterCriteria.java index 5d3416f..2e9af16 100644 --- a/src/main/java/org/usf/trace/api/server/FilterCriteria.java +++ b/src/main/java/org/usf/trace/api/server/FilterCriteria.java @@ -66,7 +66,7 @@ String toSql(Filters colname, Collection args, Collection argTy if(values.length == 1){ return " AND "+ sql; } - return " AND (" + sql + " " + colname + "IN(" + Utils.nArg(values.length) + "))";//error + return " AND (" + sql + " " + colname + " IN(" + Utils.nArg(values.length) + "))";//error } args.addAll(Arrays.asList(values)); argTypes.addAll(Collections.nCopies(values.length, colname.getType())); diff --git a/src/main/java/org/usf/trace/api/server/RequestDao.java b/src/main/java/org/usf/trace/api/server/RequestDao.java index 4ad2927..1c8e725 100644 --- a/src/main/java/org/usf/trace/api/server/RequestDao.java +++ b/src/main/java/org/usf/trace/api/server/RequestDao.java @@ -312,11 +312,11 @@ public Session getTreebyId(String id) { " select ''::varchar as prnt, ? as chld " + " union all " + " select recusive.chld, E_API_REQ.CD_API " + - " from E_API_REQ , recusive " + + " from E_API_REQ, recusive " + " where recusive.chld= E_API_REQ.CD_SES " + ") select distinct(chld) from recusive"; - List prntIds = template.query(query, (ResultSet rs, int rowNum) -> (rs.getString("chld")), id); + List prntIds = template.query(query, (ResultSet rs, int rowNum) -> (rs.getString("chld")), id).stream().filter(Objects::nonNull).collect(toList()); List prntIncList = getIncomingRequestById(true, Exchange::new,prntIds.toArray(String[]::new)); List sessionList = getMainRequestById(true, Exchange::new, id); if( sessionList != null && !sessionList.isEmpty()){ diff --git a/src/main/java/org/usf/trace/api/server/controller/ApiController.java b/src/main/java/org/usf/trace/api/server/controller/ApiController.java index 9930477..593300c 100644 --- a/src/main/java/org/usf/trace/api/server/controller/ApiController.java +++ b/src/main/java/org/usf/trace/api/server/controller/ApiController.java @@ -90,7 +90,7 @@ public ResponseEntity getMainRequestById(@PathVariable String id) { return ResponseEntity.ok().cacheControl(CacheControl.maxAge(1, TimeUnit.DAYS)).body(requireSingle(dao.getMainRequestById(true, ApiRequest::new, id))); } - @GetMapping("session/api/{id}/out") + @GetMapping("session/request/{id}/out") public ApiRequest getOutcomingRequestById(@PathVariable String id) { return dao.getOutcomingRequestById(id); } diff --git a/src/main/java/org/usf/trace/api/server/controller/PerformanceStatsController.java b/src/main/java/org/usf/trace/api/server/controller/PerformanceStatsController.java index b6597ec..20bc95b 100644 --- a/src/main/java/org/usf/trace/api/server/controller/PerformanceStatsController.java +++ b/src/main/java/org/usf/trace/api/server/controller/PerformanceStatsController.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.util.List; +import java.util.stream.Stream; import javax.servlet.http.HttpServletResponse; @@ -16,11 +17,13 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import org.usf.jquery.core.DynamicModel; -import org.usf.jquery.core.RequestQueryBuilder; +import org.usf.jquery.core.*; import org.usf.jquery.web.RequestQueryParam; import lombok.RequiredArgsConstructor; +import org.usf.trace.api.server.config.DataConstants; +import org.usf.trace.api.server.config.TraceApiColumn; +import org.usf.trace.api.server.config.TraceApiTable; @CrossOrigin @RestController @@ -31,17 +34,24 @@ public class PerformanceStatsController { private final JdbcTemplate template; @GetMapping(value="incoming/request", produces = APPLICATION_JSON_VALUE) - public List stats( + public List request( @RequestQueryParam(name = "request", defaultColumns = "count") RequestQueryBuilder query) { return usingSpringJdbc(query); } - + @GetMapping(value="session", produces = APPLICATION_JSON_VALUE) public List session( @RequestQueryParam(name = "session", defaultColumns = "count") RequestQueryBuilder query) { return usingSpringJdbc(query); } + @GetMapping(value="environment", produces = APPLICATION_JSON_VALUE) + public List environment( + @RequestQueryParam(name = "request", defaultColumns = "environement") RequestQueryBuilder query + ) { + return usingSpringJdbc(query.distinct()); + } + private List usingSpringJdbc(RequestQueryBuilder req) { var query = req.build(); return template.query(query.getQuery(), query.defaultMapper()::map, query.getParams());