Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.ikasan.dashboard.ui.general.component.SearchResults Maven / Gradle / Ivy
package org.ikasan.dashboard.ui.general.component;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vaadin.flow.component.*;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.checkbox.Checkbox;
import com.vaadin.flow.component.grid.HeaderRow;
import com.vaadin.flow.component.grid.ItemDoubleClickEvent;
import com.vaadin.flow.component.html.Anchor;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.html.Label;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.data.provider.Query;
import com.vaadin.flow.data.renderer.ComponentRenderer;
import com.vaadin.flow.data.renderer.TemplateRenderer;
import com.vaadin.flow.router.RouteConfiguration;
import com.vaadin.flow.server.StreamResource;
import com.vaadin.flow.shared.Registration;
import org.ikasan.dashboard.ui.search.SearchConstants;
import org.ikasan.dashboard.ui.search.component.SolrSearchFilteringGrid;
import org.ikasan.dashboard.ui.search.component.filter.SearchFilter;
import org.ikasan.dashboard.ui.search.listener.IgnoreHospitalEventSubmissionListener;
import org.ikasan.dashboard.ui.search.listener.ReplayEventSubmissionListener;
import org.ikasan.dashboard.ui.search.listener.ResubmitHospitalEventSubmissionListener;
import org.ikasan.dashboard.ui.util.ComponentSecurityVisibility;
import org.ikasan.dashboard.ui.util.DateFormatter;
import org.ikasan.dashboard.ui.util.IkasanDocumentToCsvConverter;
import org.ikasan.dashboard.ui.util.SecurityConstants;
import org.ikasan.security.service.authentication.IkasanAuthentication;
import org.ikasan.solr.model.IkasanSolrDocument;
import org.ikasan.solr.model.IkasanSolrDocumentSearchResults;
import org.ikasan.spec.hospital.service.HospitalAuditService;
import org.ikasan.spec.metadata.ModuleMetaDataService;
import org.ikasan.spec.module.client.ReplayService;
import org.ikasan.spec.module.client.ResubmissionService;
import org.ikasan.spec.persistence.BatchInsert;
import org.ikasan.spec.solr.SolrGeneralService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.context.SecurityContextHolder;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class SearchResults extends Div {
private static Logger logger = LoggerFactory.getLogger(SearchResults.class);
private SolrSearchFilteringGrid searchResultsGrid;
private Label resultsLabel = new Label();
private SolrGeneralService solrGeneralService;
private HorizontalLayout buttonLayout = new HorizontalLayout();
private Registration replayEventRegistration;
private ReplayEventSubmissionListener replayEventSubmissionListener;
private Registration resubmitHospitalEventRegistration;
private ResubmitHospitalEventSubmissionListener resubmitHospitalEventSubmissionListener;
private Registration ignoreHospitalEventRegistration;
private IgnoreHospitalEventSubmissionListener ignoreHospitalEventSubmissionListener;
private Button selectAllButton;
private Button replayButton;
private Button resubmitButton;
private Button ignoreButton;
private LazyDownloadButton csvExportButton;
private LazyDownloadButton downloadButton;
private HospitalAuditService hospitalAuditService;
private ResubmissionService resubmissionRestService;
private ReplayService replayRestService;
private ModuleMetaDataService moduleMetadataService;
private BatchInsert replayAuditService;
private HashMap selectionBoxes = new HashMap<>();
private HashMap selectionItems = new HashMap<>();
private Boolean selected = Boolean.FALSE;
private String translatedEventActionMessage;
private List searchTypes;
private SearchFilter searchFilter = new SearchFilter();
private DateFormatter dateFormatter;
private int maxDownloadBytes;
private IkasanAuthentication ikasanAuthentication;
public SearchResults(SolrGeneralService solrGeneralService,
HospitalAuditService hospitalAuditService, ResubmissionService resubmissionRestService,
ReplayService replayRestService, ModuleMetaDataService moduleMetadataService, BatchInsert replayAuditService,
DateFormatter dateFormatter, int maxDownloadBytes){
this.solrGeneralService = solrGeneralService;
if(this.solrGeneralService == null) {
throw new IllegalArgumentException("solrGeneralService cannot be null!!");
}
this.hospitalAuditService = hospitalAuditService;
if(this.hospitalAuditService == null) {
throw new IllegalArgumentException("hospitalAuditService cannot be null!!");
}
this.resubmissionRestService = resubmissionRestService;
if(this.resubmissionRestService == null) {
throw new IllegalArgumentException("resubmissionRestService cannot be null!!");
}
this.replayRestService = replayRestService;
if(this.replayRestService == null) {
throw new IllegalArgumentException("replayRestService cannot be null!!");
}
this.moduleMetadataService = moduleMetadataService;
if(this.moduleMetadataService == null) {
throw new IllegalArgumentException("moduleMetadataService cannot be null!!");
}
this.replayAuditService = replayAuditService;
if(this.replayAuditService == null) {
throw new IllegalArgumentException("replayAuditService cannot be null!!");
}
this.dateFormatter = dateFormatter;
if(this.dateFormatter == null) {
throw new IllegalArgumentException("dateFormatter cannot be null!!");
}
this.maxDownloadBytes = maxDownloadBytes;
this.createSearchResultsGrid();
createSearchResultGridLayout();
this.setSizeFull();
translatedEventActionMessage = getTranslation("message.resubmission-event-action"
, UI.getCurrent().getLocale());
this.ikasanAuthentication = (IkasanAuthentication) SecurityContextHolder.getContext().getAuthentication();
}
/**
* Create the results grid layout.
*/
protected void createSearchResultGridLayout()
{
createSearchResultsGrid();
this.resultsLabel.setVisible(false);
Image selectAllImage = new Image("/frontend/images/all-small-off-icon.png", "");
selectAllImage.setHeight("30px");
selectAllButton = new Button(selectAllImage);
selectAllButton.getElement().setAttribute("title", getTranslation("tooltip.select-all", UI.getCurrent().getLocale()));
selectAllButton.setHeight("35px");
selectAllButton.setWidth("35px");
selectAllButton.setId("selectAllButton");
Image replayImage = new Image("/frontend/images/replay-service.png", "");
replayImage.setHeight("30px");
replayButton = new Button(replayImage);
replayButton.getElement().setAttribute("title", getTranslation("tooltip.bulk-replay", UI.getCurrent().getLocale()));
replayButton.setHeight("35px");
replayButton.setWidth("35px");
Image resubmitImage = new Image("/frontend/images/resubmit-icon.png", "");
resubmitImage.setHeight("30px");
resubmitButton = new Button(resubmitImage);
resubmitButton.getElement().setAttribute("title", getTranslation("tooltip.bulk-resubmit", UI.getCurrent().getLocale()));
resubmitButton.setHeight("35px");
resubmitButton.setWidth("35px");
Image ignoreImage = new Image("/frontend/images/ignore-icon.png", "");
ignoreImage.setHeight("30px");
ignoreButton = new Button(ignoreImage);
ignoreButton.getElement().setAttribute("title", getTranslation("tooltip.bulk-ignore", UI.getCurrent().getLocale()));
ignoreButton.setHeight("35px");
ignoreButton.setWidth("30px");
this.createCsvDownloadButton();
this.createDownloadZipButton();
selectAllButton.addClickListener((ComponentEventListener>) buttonClickEvent -> toggleSelected());
buttonLayout.setWidth("70px");
HorizontalLayout buttonLayoutWrapper = new HorizontalLayout();
buttonLayoutWrapper.setWidthFull();
buttonLayoutWrapper.add(this.resultsLabel, buttonLayout);
buttonLayoutWrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.END);
buttonLayoutWrapper.setVerticalComponentAlignment(FlexComponent.Alignment.END, buttonLayout);
HorizontalLayout resultsLayout = new HorizontalLayout();
resultsLayout.setWidthFull();
resultsLayout.add(resultsLabel);
HorizontalLayout controlLayout = new HorizontalLayout();
controlLayout.setWidthFull();
controlLayout.setSpacing(false);
controlLayout.setMargin(false);
controlLayout.getStyle().set("background", "white");
controlLayout.getStyle().set("color", "black");
controlLayout.add(resultsLayout, buttonLayoutWrapper);
this.add(controlLayout, searchResultsGrid);
}
private void createCsvDownloadButton() {
Image excelImage = new Image("/frontend/images/excel.png", "");
excelImage.setHeight("30px");
Optional optionalUI = UI.getCurrent().getUI();
this.csvExportButton = new LazyDownloadButton(excelImage,
() -> "search-results-"+System.currentTimeMillis()+".csv",
() -> {
IkasanDocumentToCsvConverter csvConverter = new IkasanDocumentToCsvConverter();
for (int i = 0; i < searchResultsGrid.getResultSize(); i += 100) {
List docs = (List) searchResultsGrid.getDataProvider().fetch
(new Query<>(i, 100, Collections.EMPTY_LIST, null, null)).collect(Collectors.toList());
for (IkasanSolrDocument document : docs) {
csvConverter.addDocument(document);
}
if(csvConverter.getCvsContents().getBytes().length > this.maxDownloadBytes) {
optionalUI.ifPresent(ui -> {
if(ui.isAttached()) {
ui.access(() ->
NotificationHelper.showUserNotification(String.format(getTranslation("notification.download-size-exceeded"
, UI.getCurrent().getLocale()), this.maxDownloadBytes))
);
}
});
break;
}
}
return new ByteArrayInputStream(csvConverter.getCvsContents().getBytes());
}
);
csvExportButton.getElement().setAttribute("title"
, getTranslation("tooltip.export-to-csv", UI.getCurrent().getLocale()));
csvExportButton.setHeight("35px");
csvExportButton.setWidth("30px");
csvExportButton.setDisableOnClick(true);
csvExportButton.addClickListener(event -> {
if(this.searchResultsGrid.getResultSize() == 0) {
NotificationHelper.showUserNotification(getTranslation("notification.no-records-to-download"
, UI.getCurrent().getLocale()));
csvExportButton.reset();
csvExportButton.setEnabled(true);
}
else {
NotificationHelper.showUserNotification(getTranslation("notification.preparing-download"
, UI.getCurrent().getLocale()));
}
});
csvExportButton.addDownloadStartsListener(event -> {
event.getSource().setEnabled(true);
csvExportButton.reset();
});
}
private void createDownloadZipButton() {
Image zipImage = new Image("/frontend/images/zip.png", "");
zipImage.setHeight("30px");
Optional optionalUI = UI.getCurrent().getUI();
downloadButton = new LazyDownloadButton(zipImage,
() -> "search-results-" + System.currentTimeMillis() + ".zip",
() -> {
ObjectMapper objectMapper = new ObjectMapper();
try (final var baos = new ByteArrayOutputStream();
final var zos = new ZipOutputStream(baos)) {
for (int i = 0; i < searchResultsGrid.getResultSize(); i += 100) {
List docs = (List) searchResultsGrid.getDataProvider().fetch
(new Query<>(i, 100, Collections.EMPTY_LIST, null, null)).collect(Collectors.toList());
for (IkasanSolrDocument document : docs) {
String documentAsString = objectMapper.writerWithDefaultPrettyPrinter()
.writeValueAsString(document);
ZipEntry entry = new ZipEntry(document.getModuleName() + "_" +
document.getFlowName() + "_" +
(document.getComponentName() != null ? document.getComponentName() + "_" : "") +
document.getType() + "_" +
document.getEventId() + "_" +
+ document.getTimestamp() + ".json");
entry.setSize(documentAsString.getBytes().length);
zos.putNextEntry(entry);
zos.write(documentAsString.getBytes());
zos.closeEntry();
}
if(baos.toByteArray().length > this.maxDownloadBytes) {
optionalUI.ifPresent(ui -> {
if(ui.isAttached()) {
ui.access(() ->
NotificationHelper.showUserNotification(String.format(getTranslation("notification.download-size-exceeded"
, UI.getCurrent().getLocale()), this.maxDownloadBytes))
);
}
});
break;
}
}
zos.finish();
zos.flush();
zos.close();
return new ByteArrayInputStream(baos.toByteArray());
} catch (Exception e) {
e.printStackTrace();
optionalUI.ifPresent(ui -> {
if(ui.isAttached()) {
ui.access(() ->
NotificationHelper.showUserNotification(getTranslation("error.download"
, UI.getCurrent().getLocale()))
);
}
});
return new ByteArrayInputStream(new byte[0]);
}
}
);
downloadButton.getElement().setAttribute("title", getTranslation("tooltip.download-grid-items", UI.getCurrent().getLocale()));
downloadButton.setHeight("35px");
downloadButton.setWidth("35px");
downloadButton.setDisableOnClick(true);
downloadButton.addClickListener(event -> {
if(this.searchResultsGrid.getResultSize() == 0) {
NotificationHelper.showUserNotification(getTranslation("notification.no-records-to-download"
, UI.getCurrent().getLocale()));
downloadButton.reset();
downloadButton.setEnabled(true);
}
else {
NotificationHelper.showUserNotification(getTranslation("notification.preparing-download"
, UI.getCurrent().getLocale()));
}
});
downloadButton.addDownloadStartsListener(event -> {
LazyDownloadButton button = event.getSource();
button.setEnabled(true);
downloadButton.reset();
});
}
/**
* Create the grid that the search results appear.
*/
private void createSearchResultsGrid()
{
this.searchResultsGrid = new SolrSearchFilteringGrid(this.solrGeneralService, searchFilter, this.resultsLabel);
// Add the icon column to the grid
this.searchResultsGrid.addColumn(new ComponentRenderer<>(ikasanSolrDocument ->
{
HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setWidth("100%");
horizontalLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
if(ikasanSolrDocument.getType().equalsIgnoreCase(SearchConstants.WIRETAP))
{
Image wiretapImage = new Image("frontend/images/wiretap-service.png", "");
wiretapImage.setHeight("30px");
horizontalLayout.add(wiretapImage);
horizontalLayout.setId("frontend/images/wiretap-service.png");
}
else if(ikasanSolrDocument.getType().equalsIgnoreCase(SearchConstants.ERROR))
{
Image errorImage = new Image("frontend/images/error-service.png", "");
errorImage.setHeight("30px");
horizontalLayout.add(errorImage);
horizontalLayout.setId("frontend/images/error-service.png");
}
else if(ikasanSolrDocument.getType().equalsIgnoreCase(SearchConstants.EXCLUSION))
{
Image hospitalImage = new Image("frontend/images/hospital-service.png", "");
hospitalImage.setHeight("30px");
horizontalLayout.add(hospitalImage);
horizontalLayout.setId("frontend/images/hospital-service.png");
}
else if(ikasanSolrDocument.getType().equalsIgnoreCase(SearchConstants.REPLAY)) {
Image replayImage = new Image("frontend/images/replay-service.png", "");
replayImage.setHeight("30px");
horizontalLayout.add(replayImage);
horizontalLayout.setId("frontend/images/replay-service.png");
}
return horizontalLayout;
})).setWidth("40px").setKey("entityImage");
// Add the module name column to the grid
this.searchResultsGrid.addColumn(IkasanSolrDocument::getModuleName)
.setKey("moduleName")
.setHeader(getTranslation("table-header.module-name", UI.getCurrent().getLocale()))
.setSortable(true)
.setFlexGrow(4)
.setResizable(true);
// Add the flow name column to the grid
this.searchResultsGrid.addColumn(IkasanSolrDocument::getFlowName).setKey("flowName")
.setHeader(getTranslation("table-header.flow-name", UI.getCurrent().getLocale()))
.setSortable(true)
.setFlexGrow(6)
.setResizable(true);
// Add the component name column to the grid
this.searchResultsGrid.addColumn(TemplateRenderer.of(
"[[item.componentName]]
")
.withProperty("componentName",
ikasanSolrDocument -> Optional.ofNullable(ikasanSolrDocument.getComponentName()).orElse(getTranslation("label.not-applicable", UI.getCurrent().getLocale()))))
.setKey("componentName")
.setHeader(getTranslation("table-header.component-name", UI.getCurrent().getLocale()))
.setSortable(true)
.setFlexGrow(6)
.setResizable(true);
// Add the event identifier column to the grid
this.searchResultsGrid.addColumn(new ComponentRenderer<>(ikasanSolrDocument -> {
HorizontalLayout horizontalLayout = new HorizontalLayout();
if(ikasanSolrDocument.getType().equals("wiretap")) {
String route = RouteConfiguration.forSessionScope()
.getUrl(EventLifeIdDeepLinkView.class, ikasanSolrDocument.getEventId());
Anchor link = new Anchor(route, ikasanSolrDocument.getEventId());
link.setTarget("_blank");
add(link);
horizontalLayout.add(link);
link.getStyle().set("color", "blue");
}
else if(ikasanSolrDocument.getType().equals("error") || ikasanSolrDocument.getType().equals("exclusion")) {
Div div = new Div();
String identifier = new String();
if(ikasanSolrDocument.getEventId() != null && !ikasanSolrDocument.getEventId().isBlank()) {
identifier = ikasanSolrDocument.getEventId() + " / ";
}
div.add(identifier + ikasanSolrDocument.getErrorUri());
horizontalLayout.add(div);
}
else {
Div div = new Div();
div.add(ikasanSolrDocument.getEventId());
horizontalLayout.add(div);
}
return horizontalLayout;
}))
.setKey("event")
.setHeader(getTranslation("table-header.event-id", UI.getCurrent().getLocale()))
.setSortable(true)
.setFlexGrow(8)
.setResizable(true);
// Add the timestamp column to the grid
this.searchResultsGrid.addColumn(TemplateRenderer.of(
"[[item.date]]
")
.withProperty("date",
ikasanSolrDocument -> this.dateFormatter.getFormattedDate(ikasanSolrDocument.getTimeStamp()))).setHeader(getTranslation("table-header.timestamp", UI.getCurrent().getLocale()))
.setSortable(true)
.setKey("timestamp")
.setFlexGrow(6)
.setResizable(true);
// Add the select column to the grid
this.searchResultsGrid.addColumn(new ComponentRenderer<>(ikasanSolrDocument ->
{
HorizontalLayout horizontalLayout = new HorizontalLayout();
if(searchTypes.size() == 1 && (searchTypes.get(0).equals("replay")
|| searchTypes.get(0).equals("exclusion"))) {
Checkbox checkbox = new Checkbox();
checkbox.setId(ikasanSolrDocument.getId());
horizontalLayout.add(checkbox);
checkbox.addValueChangeListener((HasValue.ValueChangeListener>) checkboxBooleanComponentValueChangeEvent ->
{
if (checkboxBooleanComponentValueChangeEvent.getValue()) {
this.selectionItems.put(ikasanSolrDocument.getId(), ikasanSolrDocument);
} else {
this.selectionItems.remove(ikasanSolrDocument.getId());
}
});
if (!this.selectionBoxes.containsKey(ikasanSolrDocument.getId())) {
checkbox.setValue(selected);
this.selectionBoxes.put(ikasanSolrDocument.getId(), checkbox);
} else {
checkbox.setValue(selectionBoxes.get(ikasanSolrDocument.getId()).getValue());
this.selectionItems.put(ikasanSolrDocument.getId(), ikasanSolrDocument);
this.selectionBoxes.put(ikasanSolrDocument.getId(), checkbox);
}
}
return horizontalLayout;
})).setWidth("20px");
// Add the double click replayEventSubmissionListener to the grid so that the relevant dialog can be opened.
this.searchResultsGrid.addItemDoubleClickListener((ComponentEventListener>)
ikasanSolrDocumentItemDoubleClickEvent ->
{
if(ikasanSolrDocumentItemDoubleClickEvent.getItem().getType().equalsIgnoreCase(SearchConstants.WIRETAP))
{
WiretapDialog wiretapDialog = new WiretapDialog(this.dateFormatter);
wiretapDialog.populate(ikasanSolrDocumentItemDoubleClickEvent.getItem());
}
else if(ikasanSolrDocumentItemDoubleClickEvent.getItem().getType().equalsIgnoreCase(SearchConstants.ERROR))
{
ErrorDialog errorDialog = new ErrorDialog(this.dateFormatter);
errorDialog.populate(ikasanSolrDocumentItemDoubleClickEvent.getItem());
}
else if(ikasanSolrDocumentItemDoubleClickEvent.getItem().getType().equalsIgnoreCase(SearchConstants.REPLAY))
{
ReplayDialog replayDialog = new ReplayDialog(this.replayRestService, this.replayAuditService, this.dateFormatter);
replayDialog.populate(ikasanSolrDocumentItemDoubleClickEvent.getItem());
}
else if(ikasanSolrDocumentItemDoubleClickEvent.getItem().getType().equalsIgnoreCase(SearchConstants.EXCLUSION))
{
HospitalDialog hospitalDialog = new HospitalDialog(this.solrGeneralService, this.hospitalAuditService
, this.resubmissionRestService, this.moduleMetadataService, this.searchResultsGrid, this.dateFormatter);
hospitalDialog.populate(ikasanSolrDocumentItemDoubleClickEvent.getItem());
}
});
// Add filtering to the relevant columns.
HeaderRow hr = searchResultsGrid.appendHeaderRow();
this.searchResultsGrid.addGridFiltering(hr, searchFilter::setModuleNameFilter, "moduleName");
this.searchResultsGrid.addGridFiltering(hr, searchFilter::setFlowNameFilter, "flowName");
this.searchResultsGrid.addGridFiltering(hr, searchFilter::setComponentNameFilter, "componentName");
this.searchResultsGrid.addGridFiltering(hr, searchFilter::setEventIdFilter, "event");
this.searchResultsGrid.setSizeFull();
}
/**
* Helper method to toggle the selected check box.
*/
public void toggleSelected()
{
if(this.selected)
{
selectionBoxes.keySet().forEach(key -> selectionBoxes.get(key).setValue(false));
Image selectedImage = new Image("/frontend/images/all-small-off-icon.png", "");
selectedImage.setHeight("30px");
this.selectAllButton = new Button(selectedImage);
selectAllButton.setHeight("35px");
selectAllButton.setWidth("35px");
this.selectionItems.clear();
this.selected = Boolean.FALSE;
this.replayEventSubmissionListener.setSelected(Boolean.FALSE);
this.resubmitHospitalEventSubmissionListener.setSelected(Boolean.FALSE);
this.ignoreHospitalEventSubmissionListener.setSelected(Boolean.FALSE);
}
else
{
this.selectionBoxes.keySet().forEach(key -> selectionBoxes.get(key).setValue(true));
Image deSelectedImage = new Image("/frontend/images/all-small-on-icon.png", "");
deSelectedImage.setHeight("30px");
this.selectAllButton = new Button(deSelectedImage);
selectAllButton.setHeight("35px");
selectAllButton.setWidth("35px");
this.selected = Boolean.TRUE;
this.replayEventSubmissionListener.setSelected(Boolean.TRUE);
this.resubmitHospitalEventSubmissionListener.setSelected(Boolean.TRUE);
this.ignoreHospitalEventSubmissionListener.setSelected(Boolean.TRUE);
}
selectAllButton.addClickListener((ComponentEventListener>) buttonClickEvent -> toggleSelected());
this.functionalGroupSetup(this.searchTypes);
}
/**
* Add the event listener for replay events.
*/
private void addReplayButtonEventListener()
{
if(this.replayEventRegistration != null)
{
this.replayEventRegistration.remove();
}
this.replayEventSubmissionListener = new ReplayEventSubmissionListener(this.replayRestService, this.replayAuditService
, this.moduleMetadataService, this.searchResultsGrid, this.selectionBoxes, this.selectionItems);
this.replayEventRegistration = this.replayButton.addClickListener(this.replayEventSubmissionListener);
}
/**
* Add the event listener for the resubmission of hospital events.
*/
private void addHospitalResubmitButtonEventListener()
{
if(this.resubmitHospitalEventRegistration != null)
{
this.resubmitHospitalEventRegistration.remove();
}
IkasanAuthentication authentication = (IkasanAuthentication) SecurityContextHolder.getContext().getAuthentication();
this.resubmitHospitalEventSubmissionListener = new ResubmitHospitalEventSubmissionListener(this.hospitalAuditService, this.resubmissionRestService
, this.moduleMetadataService, this.solrGeneralService, translatedEventActionMessage, this.searchResultsGrid, this.selectionBoxes
, this.selectionItems, authentication, this.dateFormatter, this);
this.resubmitHospitalEventRegistration = this.resubmitButton.addClickListener(this.resubmitHospitalEventSubmissionListener);
}
/**
* Add the event listener to deal with ignoring hospital events.
*/
private void addIgnoreButtonEventListener()
{
if(this.ignoreHospitalEventRegistration != null)
{
this.ignoreHospitalEventRegistration.remove();
}
IkasanAuthentication authentication = (IkasanAuthentication) SecurityContextHolder.getContext().getAuthentication();
this.ignoreHospitalEventSubmissionListener = new IgnoreHospitalEventSubmissionListener(this.hospitalAuditService, this.resubmissionRestService
, this.moduleMetadataService, this.solrGeneralService, translatedEventActionMessage, this.searchResultsGrid, this.selectionBoxes
, this.selectionItems, authentication, this.dateFormatter, this);
this.ignoreHospitalEventRegistration = this.ignoreButton.addClickListener(ignoreHospitalEventSubmissionListener);
}
/**
* Set up the functional group.
*/
private void functionalGroupSetup(List types)
{
buttonLayout.removeAll();
if(types.size() != 1) {
buttonLayout.add(this.csvExportButton, this.downloadButton);
buttonLayout.setWidth("82px");
return;
}
String type = types.get(0);
if(type.equals("replay"))
{
buttonLayout.add(this.replayButton, this.selectAllButton, this.csvExportButton, this.downloadButton);
ComponentSecurityVisibility.applySecurity(this.ikasanAuthentication, replayButton
, SecurityConstants.REPLAY_WRITE
, SecurityConstants.REPLAY_ADMIN
, SecurityConstants.REPLAY_ALL_MODULES_WRITE
, SecurityConstants.REPLAY_ALL_MODULES_ADMIN
, SecurityConstants.ALL_AUTHORITY);
ComponentSecurityVisibility.applySecurity(this.ikasanAuthentication, selectAllButton
, SecurityConstants.REPLAY_WRITE
, SecurityConstants.REPLAY_ADMIN
, SecurityConstants.REPLAY_ALL_MODULES_WRITE
, SecurityConstants.REPLAY_ALL_MODULES_ADMIN
, SecurityConstants.ALL_AUTHORITY);
buttonLayout.setWidth("184px");
}
else if(type.equals("exclusion"))
{
buttonLayout.add(this.resubmitButton, this.ignoreButton, this.selectAllButton, this.csvExportButton, downloadButton);
ComponentSecurityVisibility.applySecurity(this.ikasanAuthentication, resubmitButton
, SecurityConstants.EXCLUSION_WRITE
, SecurityConstants.EXCLUSION_ADMIN
, SecurityConstants.EXCLUSION_ALL_MODULES_WRITE
, SecurityConstants.EXCLUSION_ALL_MODULES_ADMIN
, SecurityConstants.ALL_AUTHORITY);
ComponentSecurityVisibility.applySecurity(this.ikasanAuthentication, ignoreButton
, SecurityConstants.EXCLUSION_WRITE
, SecurityConstants.EXCLUSION_ADMIN
, SecurityConstants.EXCLUSION_ALL_MODULES_WRITE
, SecurityConstants.EXCLUSION_ALL_MODULES_ADMIN
, SecurityConstants.ALL_AUTHORITY);
ComponentSecurityVisibility.applySecurity(this.ikasanAuthentication, selectAllButton
, SecurityConstants.EXCLUSION_WRITE
, SecurityConstants.EXCLUSION_ADMIN
, SecurityConstants.EXCLUSION_ALL_MODULES_WRITE
, SecurityConstants.EXCLUSION_ALL_MODULES_ADMIN
, SecurityConstants.ALL_AUTHORITY);
buttonLayout.setWidth("230px");
}
else {
buttonLayout.add(this.csvExportButton, this.downloadButton);
buttonLayout.setWidth("82px");
}
}
public void search(long startTime, long endTime, String searchTerm, List types, boolean negateQuery, List moduleNames, List flowNames) {
this.searchTypes = types;
this.selected = false;
searchFilter.setModuleNamesFilterList(moduleNames);
searchFilter.setFlowNamesFilterList(flowNames);
if(searchTerm != null && !searchTerm.isEmpty() && !searchTerm.startsWith("\"") && !searchTerm.endsWith("\"")){
searchTerm = "\""+searchTerm+"\"";
}
this.searchResultsGrid.init(startTime, endTime, searchTerm, types, negateQuery, null);
this.resultsLabel.setVisible(true);
this.functionalGroupSetup(types);
this.addReplayButtonEventListener();
this.addHospitalResubmitButtonEventListener();
this.addIgnoreButtonEventListener();
}
}