Skip to content

Commit 4d4daa1

Browse files
authored
Merge pull request #86 from oneteme/develop
main session lazy
2 parents c1d3734 + 0faea13 commit 4d4daa1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/main/java/org/usf/inspect/server/service/RequestService.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public List<Session> getRestSessions(JqueryRequestSessionFilter jsf, boolean laz
368368

369369
public Session getMainSessionForTree(String id) throws SQLException {
370370
JqueryMainSessionFilter jsf = new JqueryMainSessionFilter(Collections.singletonList(id).toArray(String[]::new));
371-
Session session = requireSingle(getMainSessions(jsf));
371+
Session session = requireSingle(getMainSessions(jsf, true));
372372
if (session != null) {
373373
getRestRequests(session.getId(), Exchange::new).forEach(session::append);
374374
getDatabaseRequests(session.getId()).forEach(session::append);
@@ -381,7 +381,7 @@ public Session getMainSessionForTree(String id) throws SQLException {
381381

382382
public Session getMainSession(String id) throws SQLException{
383383
JqueryMainSessionFilter jsf = new JqueryMainSessionFilter(Collections.singletonList(id).toArray(String[]::new));
384-
return requireSingle(getMainSessions(jsf));
384+
return requireSingle(getMainSessions(jsf, false));
385385
}
386386

387387
@Deprecated
@@ -419,15 +419,17 @@ public List<Session> getMainSessionsForSearch(JqueryMainSessionFilter jsf) throw
419419
});
420420
}
421421

422-
public List<Session> getMainSessions(JqueryMainSessionFilter jsf) throws SQLException {
422+
public List<Session> getMainSessions(JqueryMainSessionFilter jsf, boolean lazy) throws SQLException {
423423
var v = new QueryBuilder()
424424
.columns(
425425
getColumns(
426426
MAIN_SESSION, ID, NAME, START, END, TYPE, LOCATION, THREAD,
427427
ERR_TYPE, ERR_MSG, MASK, USER, INSTANCE_ENV
428-
))
429-
.columns(getColumns(INSTANCE, APP_NAME, OS, RE, ADDRESS))
430-
.filters(MAIN_SESSION.column(INSTANCE_ENV).eq(INSTANCE.column(ID)));
428+
));
429+
if(lazy) {
430+
v.columns(getColumns(INSTANCE, APP_NAME, OS, RE, ADDRESS)).filters(MAIN_SESSION.column(INSTANCE_ENV).eq(INSTANCE.column(ID)));;
431+
}
432+
431433
if(jsf != null) {
432434
v.filters(jsf.filters(MAIN_SESSION).toArray(DBFilter[]::new));
433435
}
@@ -443,10 +445,12 @@ public List<Session> getMainSessions(JqueryMainSessionFilter jsf) throws SQLExce
443445
main.setLocation(rs.getString(LOCATION.reference()));
444446
main.setThreadName(rs.getString(THREAD.reference()));
445447
main.setException(getExceptionInfoIfNotNull(rs.getString(ERR_TYPE.reference()), rs.getString(ERR_MSG.reference())));
446-
main.setAppName(rs.getString(APP_NAME.reference()));
447-
main.setOs(rs.getString(OS.reference()));
448-
main.setRe(rs.getString(RE.reference()));
449-
main.setAddress(rs.getString(ADDRESS.reference()));
448+
if(lazy) {
449+
main.setAppName(rs.getString(APP_NAME.reference()));
450+
main.setOs(rs.getString(OS.reference()));
451+
main.setRe(rs.getString(RE.reference()));
452+
main.setAddress(rs.getString(ADDRESS.reference()));
453+
}
450454
main.setUser(rs.getString(USER.reference()));
451455
main.setInstanceId(rs.getString(INSTANCE_ENV.reference()));
452456
main.setRestRequests(new ArrayList<>());

0 commit comments

Comments
 (0)