SEBSERV-478 review and optimizations
This commit is contained in:
parent
a43042ce2f
commit
7ddbb218e6
4 changed files with 30 additions and 42 deletions
|
@ -493,14 +493,21 @@ public class MonitoringRunningExam implements TemplateComposer {
|
|||
final ActionDefinition showActionDef,
|
||||
final ActionDefinition hideActionDef) {
|
||||
|
||||
|
||||
final int numOfConnections = filter.getNumOfConnections(connectionIssueStatus);
|
||||
final PageAction action = actionBuilder.newAction(hideActionDef)
|
||||
.withExec(hideIssueViewAction(filter, clientTable, connectionIssueStatus))
|
||||
final PageAction action = actionBuilder.newAction(filter.isIssueHidden(connectionIssueStatus)
|
||||
? showActionDef
|
||||
: hideActionDef)
|
||||
.withExec(filter.isIssueHidden(connectionIssueStatus)
|
||||
? showIssueViewAction(filter, clientTable, connectionIssueStatus)
|
||||
: hideIssueViewAction(filter, clientTable, connectionIssueStatus))
|
||||
.noEventPropagation()
|
||||
.withSwitchAction(
|
||||
actionBuilder.newAction(showActionDef)
|
||||
.withExec(showIssueViewAction(filter, clientTable, connectionIssueStatus))
|
||||
actionBuilder.newAction(filter.isIssueHidden(connectionIssueStatus)
|
||||
? hideActionDef
|
||||
: showActionDef)
|
||||
.withExec(filter.isIssueHidden(connectionIssueStatus)
|
||||
? hideIssueViewAction(filter, clientTable, connectionIssueStatus)
|
||||
: showIssueViewAction(filter, clientTable, connectionIssueStatus))
|
||||
.noEventPropagation()
|
||||
.withNameAttributes(numOfConnections)
|
||||
.create())
|
||||
|
|
|
@ -206,6 +206,11 @@ public class FullPageMonitoringUpdate implements MonitoringFilter {
|
|||
saveFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIssueHidden(final ConnectionIssueStatus connectionIssueStatus) {
|
||||
return this.issueFilter.contains(connectionIssueStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideIssue(final ConnectionIssueStatus connectionIssueStatus) {
|
||||
this.issueFilter.add(connectionIssueStatus);
|
||||
|
@ -359,7 +364,7 @@ public class FullPageMonitoringUpdate implements MonitoringFilter {
|
|||
}
|
||||
|
||||
} catch (final Exception e) {
|
||||
log.warn("Failed to load status filter to user session");
|
||||
log.warn("Failed to load issue filter to user session");
|
||||
this.issueFilter.clear();
|
||||
} finally {
|
||||
this.issueFilterParam = StringUtils.join(this.issueFilter, Constants.LIST_SEPARATOR);
|
||||
|
|
|
@ -53,6 +53,8 @@ public interface MonitoringFilter {
|
|||
|
||||
void showClientGroup(Long clientGroupId);
|
||||
|
||||
boolean isIssueHidden(ConnectionIssueStatus connectionIssueStatus);
|
||||
|
||||
void hideIssue(ConnectionIssueStatus connectionIssueStatus);
|
||||
|
||||
void showIssue(ConnectionIssueStatus connectionIssueStatus);
|
||||
|
|
|
@ -547,17 +547,11 @@ public class ExamMonitoringController {
|
|||
}
|
||||
|
||||
private Predicate<ClientConnectionData> activeIssueFilterSebVersion(final EnumSet<ConnectionIssueStatus> filterStates) {
|
||||
if(!filterStates.contains(ConnectionIssueStatus.SEB_VERSION_GRANTED)){
|
||||
return null;
|
||||
}
|
||||
return conn -> conn != null && BooleanUtils.isFalse(conn.clientConnection.clientVersionGranted);
|
||||
return conn -> BooleanUtils.isFalse(conn.clientConnection.clientVersionGranted);
|
||||
}
|
||||
|
||||
private Predicate<ClientConnectionData> activeIssueFilterAsk(final EnumSet<ConnectionIssueStatus> filterStates) {
|
||||
if(!filterStates.contains(ConnectionIssueStatus.ASK_GRANTED)){
|
||||
return null;
|
||||
}
|
||||
return conn -> conn != null && BooleanUtils.isFalse(conn.clientConnection.securityCheckGranted);
|
||||
return conn -> BooleanUtils.isFalse(conn.clientConnection.securityCheckGranted);
|
||||
}
|
||||
|
||||
/** If we have a filter criteria for ACTIVE connection, we shall filter only the active connections
|
||||
|
@ -592,7 +586,7 @@ public class ExamMonitoringController {
|
|||
filterStates.remove(ConnectionStatus.ACTIVE);
|
||||
}
|
||||
|
||||
final Predicate<ClientConnectionData> stateFilter = filterStates.isEmpty()
|
||||
Predicate<ClientConnectionData> filter = filterStates.isEmpty()
|
||||
? Objects::nonNull
|
||||
: active
|
||||
? withActiveFilter(filterStates)
|
||||
|
@ -606,16 +600,12 @@ public class ExamMonitoringController {
|
|||
}
|
||||
}
|
||||
|
||||
final Predicate<ClientConnectionData> issueFilterSebVersion =
|
||||
filterIssues.isEmpty()
|
||||
? null
|
||||
: activeIssueFilterSebVersion(filterIssues);
|
||||
|
||||
final Predicate<ClientConnectionData> issueFilterAsk =
|
||||
filterIssues.isEmpty()
|
||||
? null
|
||||
: activeIssueFilterAsk(filterIssues);
|
||||
|
||||
if (filterIssues.contains(ConnectionIssueStatus.SEB_VERSION_GRANTED)) {
|
||||
filter = filter.and(activeIssueFilterSebVersion(filterIssues));
|
||||
}
|
||||
if (filterIssues.contains(ConnectionIssueStatus.ASK_GRANTED)) {
|
||||
filter = filter.and(activeIssueFilterAsk(filterIssues));
|
||||
}
|
||||
|
||||
Set<Long> filterClientGroups = null;
|
||||
if (StringUtils.isNotBlank(hiddenClientGroups)) {
|
||||
|
@ -627,23 +617,7 @@ public class ExamMonitoringController {
|
|||
}
|
||||
|
||||
final Set<Long> _filterClientGroups = filterClientGroups;
|
||||
return ccd -> {
|
||||
if (ccd == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean result = stateFilter.test(ccd) && ccd.filter(_filterClientGroups);
|
||||
|
||||
if (issueFilterSebVersion != null) {
|
||||
result = result && issueFilterSebVersion.test(ccd);
|
||||
}
|
||||
|
||||
if (issueFilterAsk != null) {
|
||||
result = result && issueFilterAsk.test(ccd);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
return filter.and(ccd -> ccd.filter(_filterClientGroups));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue