From 959f6e9e039b0b7dd1cfe7566fc593976999bdfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Lindo?= Date: Thu, 3 Oct 2024 16:21:15 +0100 Subject: [PATCH] enabled db search, search all for users and on/off dbs in search all --- .github/workflows/CI.yml | 4 +- .../common/api/v1/DatabaseResource.java | 125 +++++++++++++---- .../common/client/ViewerConstants.java | 1 + .../common/lists/CrossDatabaseList.java | 82 ++++++++---- .../client/common/lists/DatabaseList.java | 5 +- .../client/common/search/SearchWrapper.java | 6 +- .../browse/DatabaseSearchPanel.java | 15 ++- .../PermissionsNavigationPanel.java | 30 ++++- .../databasePanel/admin/DatabaseManage.java | 71 +++++++++- .../databasePanel/admin/DatabaseManage.ui.xml | 2 + .../user/UserDatabaseListPanel.java | 126 +++++++++++++----- .../user/UserDatabaseListPanel.ui.xml | 27 +--- .../common/client/index/IndexResult.java | 3 + .../status/database/DatabaseStatus.java | 16 ++- .../models/structure/ViewerDatabase.java | 9 ++ .../client/services/DatabaseService.java | 5 + .../common/client/tools/HistoryManager.java | 4 + .../common/server/ConfigurationManager.java | 80 +++++++---- .../server/controller/SIARDController.java | 13 +- .../server/index/DatabaseRowsSolrManager.java | 26 +++- .../collections/DatabasesCollection.java | 4 + .../common/server/index/utils/SolrUtils.java | 8 +- .../desktop/client/main/MainPanelDesktop.java | 13 ++ .../server/client/main/MainPanel.java | 14 +- .../config/i18n/client/ClientMessages.java | 16 +++ .../common/public/main.css | 9 ++ .../resources/config/dbvtk-roles.properties | 1 + .../i18n/client/ClientMessages.properties | 10 +- 28 files changed, 562 insertions(+), 163 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 20bc97b27..630d26a91 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -16,10 +16,10 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Set up JDK 8 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: 8 + java-version: 21 distribution: 'adopt' - name: Cache uses: actions/cache@v3 diff --git a/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java b/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java index b492970fa..81f008c5b 100644 --- a/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java +++ b/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; import org.apache.solr.client.solrj.SolrServerException; import org.roda.core.data.exceptions.GenericException; @@ -34,6 +35,7 @@ import com.databasepreservation.common.client.index.facets.Facets; import com.databasepreservation.common.client.index.facets.SimpleFacetParameter; import com.databasepreservation.common.client.index.filter.AndFiltersParameters; +import com.databasepreservation.common.client.index.filter.BasicSearchFilterParameter; import com.databasepreservation.common.client.index.filter.Filter; import com.databasepreservation.common.client.index.filter.FilterParameter; import com.databasepreservation.common.client.index.filter.OrFiltersParameters; @@ -81,8 +83,9 @@ public IndexResult find(FindRequest findRequest, String localeSt fieldsToReturn.add(ViewerConstants.SOLR_DATABASES_METADATA); fieldsToReturn.add(ViewerConstants.SOLR_DATABASES_PERMISSIONS); - FindRequest userFindRequest = new FindRequest(findRequest.classToReturn, getDatabaseFilterForUser(user), - findRequest.sorter, findRequest.sublist, findRequest.facets, findRequest.exportFacets, fieldsToReturn); + FindRequest userFindRequest = new FindRequest(findRequest.classToReturn, + getDatabaseFindFilterForUser(user, findRequest.filter), findRequest.sorter, findRequest.sublist, + findRequest.facets, findRequest.exportFacets, fieldsToReturn); return getViewerDatabaseIndexResult(userFindRequest, fieldsToReturn, controllerAssistant, user, state); } } else { @@ -93,25 +96,14 @@ public IndexResult find(FindRequest findRequest, String localeSt @Override public IndexResult findAll(FindRequest findRequest, String localeString) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; - LogEntryState state = LogEntryState.SUCCESS; User user = controllerAssistant.checkRoles(request); - if (ViewerConfiguration.getInstance().getApplicationEnvironment().equals(ViewerConstants.APPLICATION_ENV_SERVER)) { if (user.isAdmin() || user.isWhiteList()) { - return getCrossViewerDatabaseIndexResult(findRequest, controllerAssistant, user, state); } else { - List fieldsToReturn = new ArrayList<>(); - fieldsToReturn.add(ViewerConstants.INDEX_ID); - fieldsToReturn.add(ViewerConstants.SOLR_DATABASES_STATUS); - fieldsToReturn.add(ViewerConstants.SOLR_DATABASES_METADATA); - fieldsToReturn.add(ViewerConstants.SOLR_DATABASES_PERMISSIONS); - - FindRequest userFindRequest = new FindRequest(findRequest.classToReturn, getDatabaseFilterForUser(user), - findRequest.sorter, findRequest.sublist, findRequest.facets, findRequest.exportFacets, fieldsToReturn); - return getCrossViewerDatabaseIndexResult(userFindRequest, controllerAssistant, user, state, - getDatabaseFilterForUser(user)); + return getCrossViewerDatabaseIndexResult(findRequest, controllerAssistant, user, state, + getDatabaseFindAllFilterForUser(user)); } } else { return getCrossViewerDatabaseIndexResult(findRequest, controllerAssistant, user, state); @@ -176,15 +168,27 @@ private IndexResult getViewerDatabaseIndexResult(FindRequest fin private IndexResult getCrossViewerDatabaseIndexResult(FindRequest findRequest, ControllerAssistant controllerAssistant, User user, LogEntryState state) { - return getCrossViewerDatabaseIndexResult(findRequest, controllerAssistant, user, state, new Filter()); + return getCrossViewerDatabaseIndexResult(findRequest, controllerAssistant, user, state, + new Filter(new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL, "true"))); } private IndexResult getCrossViewerDatabaseIndexResult(FindRequest findRequest, ControllerAssistant controllerAssistant, User user, LogEntryState state, Filter userFilter) { long count = 0; try { - IterableDatabaseResult databases = ViewerFactory.getSolrManager().findAll(ViewerDatabase.class, - userFilter, Sorter.NONE, findRequest.fieldsToReturn); + IterableDatabaseResult databases; + if (userFilter != null) { + List fieldsToReturn = new ArrayList<>(); + fieldsToReturn.add(ViewerConstants.INDEX_ID); + fieldsToReturn.add(ViewerConstants.SOLR_DATABASES_STATUS); + fieldsToReturn.add(ViewerConstants.SOLR_DATABASES_METADATA); + fieldsToReturn.add(ViewerConstants.SOLR_DATABASES_PERMISSIONS); + databases = ViewerFactory.getSolrManager().findAll(ViewerDatabase.class, userFilter, Sorter.NONE, + fieldsToReturn); + } else { + databases = ViewerFactory.getSolrManager().findAll(ViewerDatabase.class, new Filter(), Sorter.NONE, + findRequest.fieldsToReturn); + } if (databases.getTotalCount() == 0) { return new IndexResult<>(); @@ -196,14 +200,14 @@ private IndexResult getCrossViewerDatabaseIndexResult(FindReques for (ViewerDatabase database : databases) { databaseMap.put(database.getUuid(), database); // only add the available collections - if(database.getStatus().equals(ViewerDatabaseStatus.AVAILABLE)){ + if (database.getStatus().equals(ViewerDatabaseStatus.AVAILABLE)) { String collectionName = ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + database.getUuid(); collections.add(collectionName); } } - String collectionAlias = SolrUtils.crateSearchAllAlias(ViewerFactory.getSolrClient(), "alias-" + user.getUUID(), - collections); + String collectionAlias = SolrUtils.createSearchAllAlias(ViewerFactory.getSolrClient(), + "alias-" + UUID.randomUUID(), collections); SimpleFacetParameter simpleFacetParameter = new SimpleFacetParameter(ViewerConstants.SOLR_ROWS_DATABASE_UUID, FacetParameter.SORT.COUNT); @@ -213,11 +217,15 @@ private IndexResult getCrossViewerDatabaseIndexResult(FindReques final IndexResult facetsSearch = ViewerFactory.getSolrManager().findHits(ViewerDatabase.class, collectionAlias, findRequest.filter, findRequest.sorter, findRequest.sublist, new Facets(simpleFacetParameter)); + + SolrUtils.deleteSearchAllAlias(ViewerFactory.getSolrClient(), collectionAlias); + count = facetsSearch.getTotalCount(); FacetFieldResult facetResults = facetsSearch.getFacetResults().get(0); IndexResult searchHitsResult = new IndexResult<>(); - if(facetResults.getValues().size() < findRequest.sublist.getMaximumElementCount() && findRequest.sublist.getFirstElementIndex() == 0) { + if (facetResults.getValues().size() < findRequest.sublist.getMaximumElementCount() + && findRequest.sublist.getFirstElementIndex() == 0) { searchHitsResult.setTotalCount(facetResults.getValues().size()); } else { searchHitsResult.setTotalCount(-1); @@ -250,18 +258,64 @@ private IndexResult getCrossViewerDatabaseIndexResult(FindReques } } - private Filter getDatabaseFilterForUser(User user) { + private Filter getDatabaseFindAllFilterForUser(User user) { ArrayList permissionFilterParameters = new ArrayList<>(); - // Only retrieve databases with AVAILABLE status - SimpleFilterParameter statusFilter = new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_STATUS, + + // Only retrieve databases with AVAILABLE + SimpleFilterParameter statusFilter; + statusFilter = new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_STATUS, ViewerDatabaseStatus.AVAILABLE.name()); permissionFilterParameters.add(statusFilter); + permissionFilterParameters + .add(new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL, "true")); + // Add user permissions on filter ArrayList permissionsOrFilterParameters = new ArrayList<>(); for (String role : user.getAllRoles()) { permissionsOrFilterParameters.add(new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_PERMISSIONS, role)); } + + permissionFilterParameters.add(new OrFiltersParameters(permissionsOrFilterParameters)); + + return new Filter(new AndFiltersParameters(permissionFilterParameters)); + } + + private Filter getDatabaseFindFilterForUser(User user, Filter searchFilter) { + ArrayList permissionFilterParameters = new ArrayList<>(); + + // Only retrieve databases with AVAILABLE, this filter has to be default + SimpleFilterParameter statusFilter; + statusFilter = new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_STATUS, + ViewerDatabaseStatus.AVAILABLE.name()); + permissionFilterParameters.add(statusFilter); + + // Controlling the search filter + if (!searchFilter.getParameters().isEmpty()) { + for (FilterParameter filterParameter : searchFilter.getParameters()) { + if (filterParameter instanceof SimpleFilterParameter simpleFilterParameter) { + // If there is a status filter, remove the default and add the new one(s). + if (simpleFilterParameter.getName().equals(ViewerConstants.SOLR_DATABASES_STATUS)) { + permissionFilterParameters.remove(statusFilter); + permissionFilterParameters + .add(new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_STATUS, simpleFilterParameter.getValue())); + } else if (simpleFilterParameter.getName().equals(ViewerConstants.SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL)) { + permissionFilterParameters.add(new SimpleFilterParameter( + ViewerConstants.SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL, simpleFilterParameter.getValue())); + } + } else if (filterParameter instanceof BasicSearchFilterParameter searchFilterParameter) { + String searchValue = searchFilterParameter.getValue(); + permissionFilterParameters.add(new SimpleFilterParameter(ViewerConstants.INDEX_SEARCH, searchValue)); + } + } + } + + // Add user permissions on filter + ArrayList permissionsOrFilterParameters = new ArrayList<>(); + for (String role : user.getAllRoles()) { + permissionsOrFilterParameters.add(new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_PERMISSIONS, role)); + } + permissionFilterParameters.add(new OrFiltersParameters(permissionsOrFilterParameters)); return new Filter(new AndFiltersParameters(permissionFilterParameters)); @@ -345,4 +399,25 @@ public Set updateDatabasePermissions(String databaseUUID, Set pe databaseUUID); } } + + @Override + public boolean updateDatabaseSearchAllAvailability(String databaseUUID) { + ControllerAssistant controllerAssistant = new ControllerAssistant() {}; + + LogEntryState state = LogEntryState.SUCCESS; + User user = controllerAssistant.checkRoles(request); + + try { + return SIARDController.updateDatabaseSearchAllAvailability(databaseUUID); + } catch (GenericException | ViewerException | NotFoundException e) { + state = LogEntryState.FAILURE; + throw new RESTException(e); + } finally { + // register action + controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, + databaseUUID); + } + + } + } diff --git a/src/main/java/com/databasepreservation/common/client/ViewerConstants.java b/src/main/java/com/databasepreservation/common/client/ViewerConstants.java index a72d3103c..1379f9fb8 100644 --- a/src/main/java/com/databasepreservation/common/client/ViewerConstants.java +++ b/src/main/java/com/databasepreservation/common/client/ViewerConstants.java @@ -126,6 +126,7 @@ public class ViewerConstants { */ public static final String SOLR_DATABASES_STATUS = "status"; public static final String SOLR_DATABASES_BROWSE_LOAD_DATE = "browse_loaded_date"; + public static final String SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL = "available_to_search_all"; public static final String SOLR_DATABASES_METADATA = "metadata"; public static final String SOLR_DATABASES_SIARD_PATH = "siard_path"; public static final String SOLR_DATABASES_SIARD_SIZE = "siard_size"; diff --git a/src/main/java/com/databasepreservation/common/client/common/lists/CrossDatabaseList.java b/src/main/java/com/databasepreservation/common/client/common/lists/CrossDatabaseList.java index 6ea71e4bc..e284bd4ae 100644 --- a/src/main/java/com/databasepreservation/common/client/common/lists/CrossDatabaseList.java +++ b/src/main/java/com/databasepreservation/common/client/common/lists/CrossDatabaseList.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Map; +import com.databasepreservation.common.client.tools.HistoryManager; import org.fusesource.restygwt.client.MethodCallback; import org.roda.core.data.v2.index.sublist.Sublist; @@ -54,9 +55,11 @@ */ public class CrossDatabaseList extends BasicAsyncTableCell { private static final ClientMessages messages = GWT.create(ClientMessages.class); + private String searchValue; public CrossDatabaseList() { this(new Filter(), null, null, false, false); + this.searchValue=""; } public CrossDatabaseList(Filter filter, Facets facets, String summary, boolean selectable, boolean exportable) { @@ -67,10 +70,46 @@ public CrossDatabaseList(Filter filter, Facets facets, String summary, boolean s protected void configureDisplay(CellTable display) { display.setSelectionModel(display.getSelectionModel(), DefaultSelectionEventManager.createBlacklistManager(4, 10)); + display.addCellPreviewHandler(event -> { + if (event.getNativeEvent().getType().equals("click")) { + int columnIndex = event.getColumn(); + ViewerDatabase database = event.getValue(); + + UserLogin.getInstance().getAuthenticatedUser(new DefaultAsyncCallback() { + @Override + public void onSuccess(User user) { + if (database != null) { + if (user.isAdmin()) { + if (columnIndex == 7) { + HistoryManager.gotoDatabaseSearchWithValue(database.getUuid(), searchValue); + getSelectionModel().clear(); + } else { + HistoryManager.gotoSIARDInfo(database.getUuid()); + getSelectionModel().clear(); + } + } else { + if (columnIndex == 4) { + if (ApplicationType.getType().equals(ViewerConstants.APPLICATION_ENV_SERVER)) { + HistoryManager.gotoDatabaseSearchWithValue(database.getUuid(), searchValue); + } + getSelectionModel().clear(); + } else { + if (ApplicationType.getType().equals(ViewerConstants.APPLICATION_ENV_SERVER)) { + HistoryManager.gotoDatabase(database.getUuid()); + } + getSelectionModel().clear(); + } + } + } + } + }); + } + }); + Column nameColumn = new TooltipColumn() { @Override public SafeHtml getValue(ViewerDatabase database) { - return database != null && database.getMetadata() != null + return database != null && database.getMetadata() != null && database.getMetadata().getName() != null ? SafeHtmlUtils.fromString(database.getMetadata().getName()) : SafeHtmlUtils.fromString("unknown"); } @@ -79,7 +118,7 @@ public SafeHtml getValue(ViewerDatabase database) { Column description = new TooltipColumn() { @Override public SafeHtml getValue(ViewerDatabase database) { - return database != null && database.getMetadata() != null + return database != null && database.getMetadata() != null && database.getMetadata().getDescription() != null ? SafeHtmlUtils.fromString(database.getMetadata().getDescription()) : SafeHtmlUtils.fromString("unknown"); } @@ -88,7 +127,7 @@ public SafeHtml getValue(ViewerDatabase database) { Column dbmsColumn = new TooltipColumn() { @Override public SafeHtml getValue(ViewerDatabase database) { - return database != null && database.getMetadata() != null + return database != null && database.getMetadata() != null && database.getMetadata().getDatabaseProduct() != null ? SafeHtmlUtils.fromString(database.getMetadata().getDatabaseProduct()) : SafeHtmlUtils.fromString("unknown"); } @@ -97,7 +136,7 @@ public SafeHtml getValue(ViewerDatabase database) { Column dataOwnerColumn = new TooltipColumn() { @Override public SafeHtml getValue(ViewerDatabase database) { - return database != null && database.getMetadata() != null + return database != null && database.getMetadata() != null && database.getMetadata().getDataOwner() != null ? SafeHtmlUtils.fromString(database.getMetadata().getDataOwner()) : SafeHtmlUtils.fromString("unknown"); } @@ -106,7 +145,7 @@ public SafeHtml getValue(ViewerDatabase database) { Column archivalDateColumn = new TooltipColumn() { @Override public SafeHtml getValue(ViewerDatabase database) { - return database != null && database.getMetadata() != null + return database != null && database.getMetadata() != null && database.getMetadata().getArchivalDate() != null ? SafeHtmlUtils.fromString(database.getMetadata().getArchivalDate().substring(0, 10)) : null; } @@ -127,21 +166,6 @@ public String getValue(ViewerDatabase database) { } }); - Column sizeColumn = new TooltipColumn() { - @Override - public SafeHtml getValue(ViewerDatabase database) { - return database != null ? SafeHtmlUtils.fromString(Humanize.readableFileSize(database.getSize())) - : SafeHtmlUtils.fromString("unknown"); - } - }; - - Column versionColumn = new TooltipColumn() { - @Override - public SafeHtml getValue(ViewerDatabase database) { - return database != null ? SafeHtmlUtils.fromString(database.getVersion()) : SafeHtmlUtils.fromString("unknown"); - } - }; - Column validColumn = new Column(new SafeHtmlCell()) { @Override public SafeHtml getValue(ViewerDatabase database) { @@ -159,7 +183,11 @@ public SafeHtml getValue(ViewerDatabase database) { Column searchHitsColumn = new ButtonColumn() { @Override public String getValue(ViewerDatabase database) { - return database != null ? String.valueOf(database.getSearchHits()) : "unknown"; + if (searchValue != null && !searchValue.isEmpty()) { + return database != null ? String.valueOf(database.getSearchHits()) + " results" : "unknown"; + } else { + return database != null ? "" : "unknown"; + } } }; @@ -173,8 +201,6 @@ public void onSuccess(User user) { addColumn(archivalDateColumn, messages.managePageTableHeaderTextForArchivalDate(), true, TextAlign.NONE, 5); if (user.isAdmin()) { addColumn(dbmsColumn, messages.managePageTableHeaderTextForProductName(), true, TextAlign.NONE, 10); - addColumn(sizeColumn, messages.managePageTableHeaderTextForSIARDSize(), true, TextAlign.NONE, 4); - addColumn(versionColumn, messages.managePageTableHeaderTextForSIARDVersion(), true, TextAlign.NONE, 4); addColumn(validColumn, messages.managePageTableHeaderTextForSIARDValidationStatus(), true, TextAlign.NONE, 5); addColumn(statusColumn, messages.managePageTableHeaderTextForDatabaseStatus(), true, TextAlign.NONE, 5); @@ -189,8 +215,6 @@ public void onSuccess(User user) { addColumn(archivalDateColumn, messages.managePageTableHeaderTextForArchivalDate(), true, TextAlign.NONE, 5); addColumn(locationColumn, messages.managePageTableHeaderTextForSIARDLocation(), true, TextAlign.NONE, 8); addColumn(dbmsColumn, messages.managePageTableHeaderTextForProductName(), true, TextAlign.NONE, 10); - addColumn(sizeColumn, messages.managePageTableHeaderTextForSIARDSize(), true, TextAlign.NONE, 4); - addColumn(versionColumn, messages.managePageTableHeaderTextForSIARDVersion(), true, TextAlign.NONE, 4); addColumn(validColumn, messages.managePageTableHeaderTextForSIARDValidationStatus(), true, TextAlign.NONE, 5); addColumn(statusColumn, messages.managePageTableHeaderTextForDatabaseStatus(), true, TextAlign.NONE, 5); addColumn(searchHitsColumn, messages.managePageTableHeaderTextForSearchHits(), true, TextAlign.NONE, 5); @@ -213,6 +237,14 @@ protected void getData(Sublist sublist, ColumnSortList columnSortList, DatabaseService.Util.call(callback).findAll(findRequest, LocaleInfo.getCurrentLocale().getLocaleName()); } + public String getSearchValue() { + return searchValue; + } + + public void setSearchValue(String searchValue) { + this.searchValue = searchValue; + } + @Override public void exportClickHandler() { // do nothing diff --git a/src/main/java/com/databasepreservation/common/client/common/lists/DatabaseList.java b/src/main/java/com/databasepreservation/common/client/common/lists/DatabaseList.java index ee911f111..7ef5d800a 100644 --- a/src/main/java/com/databasepreservation/common/client/common/lists/DatabaseList.java +++ b/src/main/java/com/databasepreservation/common/client/common/lists/DatabaseList.java @@ -77,7 +77,7 @@ protected void configureDisplay(CellTable display) { Column nameColumn = new TooltipColumn() { @Override public SafeHtml getValue(ViewerDatabase database) { - return database != null && database.getMetadata() != null + return database != null && database.getMetadata() != null && database.getMetadata().getName() != null ? SafeHtmlUtils.fromString(database.getMetadata().getName()) : SafeHtmlUtils.fromString("unknown"); } @@ -95,7 +95,7 @@ public SafeHtml getValue(ViewerDatabase database) { Column dbmsColumn = new TooltipColumn() { @Override public SafeHtml getValue(ViewerDatabase database) { - return database != null && database.getMetadata() != null + return database != null && database.getMetadata() != null && database.getMetadata().getDatabaseProduct() != null ? SafeHtmlUtils.fromString(database.getMetadata().getDatabaseProduct()) : SafeHtmlUtils.fromString("unknown"); } @@ -114,6 +114,7 @@ public SafeHtml getValue(ViewerDatabase database) { @Override public SafeHtml getValue(ViewerDatabase database) { return database != null && database.getMetadata() != null + && database.getMetadata().getArchivalDate() != null ? SafeHtmlUtils.fromString(database.getMetadata().getArchivalDate().substring(0, 10)) : null; } diff --git a/src/main/java/com/databasepreservation/common/client/common/search/SearchWrapper.java b/src/main/java/com/databasepreservation/common/client/common/search/SearchWrapper.java index 861e78854..4dd8ccc89 100644 --- a/src/main/java/com/databasepreservation/common/client/common/search/SearchWrapper.java +++ b/src/main/java/com/databasepreservation/common/client/common/search/SearchWrapper.java @@ -129,12 +129,16 @@ private void attachComponents(String objectClassSimpleName } } + public Components getComponents() { + return components; + } + /** * Auxiliary manager for inner components (groups of one searchWrapper and one * BasicAsyncTableCell, at least for now) that is used to enforce type coherence */ @SuppressWarnings("unchecked") - private class Components { + public class Components { private final Map searchPanels = new LinkedHashMap<>(); private final Map> lists = new LinkedHashMap<>(); diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/browse/DatabaseSearchPanel.java b/src/main/java/com/databasepreservation/common/client/common/visualization/browse/DatabaseSearchPanel.java index 5f8a8801b..e35f76ff4 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/browse/DatabaseSearchPanel.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/browse/DatabaseSearchPanel.java @@ -59,7 +59,12 @@ public class DatabaseSearchPanel extends RightPanel implements ICollectionStatus private final CollectionStatus status; public static DatabaseSearchPanel getInstance(ViewerDatabase database, CollectionStatus status) { - return instances.computeIfAbsent(database.getUuid(), k -> new DatabaseSearchPanel(database, status)); + return DatabaseSearchPanel.getInstance(database, status, ""); + } + + public static DatabaseSearchPanel getInstance(ViewerDatabase database, CollectionStatus status, String search) { + String key = database.getUuid() + search; + return instances.computeIfAbsent(key, k -> new DatabaseSearchPanel(database, status, search)); } interface DatabaseSearchPanelUiBinder extends UiBinder { @@ -98,7 +103,7 @@ interface DatabaseSearchPanelUiBinder extends UiBinder(); noResults = new Alert(Alert.MessageAlertType.INFO, messages.noRecordsMatchTheSearchTerms()); this.status = status; @@ -150,13 +155,17 @@ public void onSuccess(TableSearchPanelContainer eventTriggered) { this.database = database; searchInputBox.getElement().setPropertyString("placeholder", messages.searchPlaceholder()); - + if (!search.isEmpty()) { + searchInputBox.setText(search); + doSearch(); + } searchInputBox.addKeyDownHandler(event -> { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { doSearch(); } }); + searchInputButton.addClickHandler(event -> doSearch()); } diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/PermissionsNavigationPanel.java b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/PermissionsNavigationPanel.java index 1ebd39434..f782dcc42 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/PermissionsNavigationPanel.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/PermissionsNavigationPanel.java @@ -21,11 +21,14 @@ import com.databasepreservation.common.client.common.lists.widgets.BasicTablePanel; import com.databasepreservation.common.client.common.utils.CommonClientUtils; import com.databasepreservation.common.client.common.utils.html.LabelUtils; +import com.databasepreservation.common.client.common.visualization.browse.configuration.handler.DataTransformationUtils; import com.databasepreservation.common.client.common.visualization.manager.SIARDPanel.SIARDManagerPage; import com.databasepreservation.common.client.models.authorization.AuthorizationGroup; import com.databasepreservation.common.client.models.structure.ViewerDatabase; +import com.databasepreservation.common.client.models.structure.ViewerDatabaseStatus; import com.databasepreservation.common.client.services.DatabaseService; import com.databasepreservation.common.client.widgets.Alert; +import com.databasepreservation.common.client.widgets.SwitchBtn; import com.databasepreservation.common.client.widgets.Toast; import com.google.gwt.cell.client.CheckboxCell; import com.google.gwt.core.client.GWT; @@ -54,6 +57,7 @@ public class PermissionsNavigationPanel { private FlowPanel body; private FlowPanel bottom; private Button btnEdit; + private SwitchBtn btnSwitch; private boolean overrideMissingGroups = false; @@ -85,6 +89,11 @@ public NavigationPanel build() { panel.addToInfoPanel(body); panel.addButton(bottom); + if (database.getStatus().equals(ViewerDatabaseStatus.AVAILABLE)) { + btnSwitch = new SwitchBtn(messages.SIARDHomePageTitleForPermissionsSwitchButton(), database.isAvailableToSearchAll()); + handleSwitchBottom(); + } + update(databasePermissions); return panel; @@ -139,7 +148,7 @@ private void updateBottom() { btnEdit.addClickHandler(clickEvent -> { overrideMissingGroups = false; Dialogs.showCustomConfirmationDialog(messages.SIARDHomePageDialogTitleForPermissionsList(), - messages.SIARDHomePageDialogDescriptionForPermissionsList(), "620px", getGroupsTable(), + messages.SIARDHomePageDialogDescriptionForPermissionsList(), "620px", getGroupsTables(), messages.basicActionCancel(), messages.basicActionConfirm(), new NoAsyncCallback() { @Override public void onSuccess(Boolean confirmation) { @@ -157,10 +166,24 @@ public void onSuccess(Boolean confirmation) { }); }); bottom.add(CommonClientUtils.wrapOnDiv("btn-item", btnEdit)); + if (database.getStatus().equals(ViewerDatabaseStatus.AVAILABLE)) { + bottom.add(CommonClientUtils.wrapOnDiv("btn-item", btnSwitch)); + } } } - private FlowPanel getGroupsTable() { + private void handleSwitchBottom() { + btnSwitch.setClickHandler(clickEvent -> { + btnSwitch.getButton().setValue(!btnSwitch.getButton().getValue(), true); + DatabaseService.Util.call((Boolean result) -> { + SIARDManagerPage.getInstance(database).refreshInstance(database.getUuid()); + Toast.showInfo(messages.SIARDHomePageDialogTitleForChangeAvailabilityToSearchAll(), + messages.SIARDHomePageDialogMessageForChangeAvailabilityToSearchAll()); + }).updateDatabaseSearchAllAvailability(database.getUuid()); + }); + } + + private FlowPanel getGroupsTables() { FlowPanel permissionListPanel = new FlowPanel(); permissionListPanel .add(new Alert(Alert.MessageAlertType.INFO, messages.SIARDHomePageDialogDetailsForPermissionsList())); @@ -234,7 +257,8 @@ public SafeHtml getValue(AuthorizationGroup group) { } }); Alert alert = new Alert(Alert.MessageAlertType.WARNING, - messages.SIARDHomePageDialogDetailsForUnknownPermissions(String.join(", ", missingGroups)), checkBoxOverrideMissingGroups); + messages.SIARDHomePageDialogDetailsForUnknownPermissions(String.join(", ", missingGroups)), + checkBoxOverrideMissingGroups); permissionListPanel.add(alert); diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/admin/DatabaseManage.java b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/admin/DatabaseManage.java index df2e9f2f6..8d8c979c4 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/admin/DatabaseManage.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/admin/DatabaseManage.java @@ -7,6 +7,7 @@ */ package com.databasepreservation.common.client.common.visualization.manager.databasePanel.admin; +import java.util.Collections; import java.util.List; import com.databasepreservation.common.client.ViewerConstants; @@ -22,11 +23,20 @@ import com.databasepreservation.common.client.common.search.SearchWrapper; import com.databasepreservation.common.client.common.utils.ApplicationType; import com.databasepreservation.common.client.common.utils.CommonClientUtils; +import com.databasepreservation.common.client.index.FindRequest; +import com.databasepreservation.common.client.index.IndexResult; +import com.databasepreservation.common.client.index.facets.Facets; +import com.databasepreservation.common.client.index.filter.Filter; +import com.databasepreservation.common.client.index.filter.SimpleFilterParameter; +import com.databasepreservation.common.client.index.sort.Sorter; import com.databasepreservation.common.client.models.structure.ViewerDatabase; +import com.databasepreservation.common.client.models.structure.ViewerDatabaseStatus; +import com.databasepreservation.common.client.services.DatabaseService; import com.databasepreservation.common.client.tools.BreadcrumbManager; import com.databasepreservation.common.client.tools.FontAwesomeIconManager; import com.databasepreservation.common.client.tools.HistoryManager; import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.LocaleInfo; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; @@ -36,6 +46,7 @@ import com.google.gwt.user.client.ui.Widget; import config.i18n.client.ClientMessages; +import org.roda.core.data.v2.index.sublist.Sublist; /** * @author Miguel Guimarães @@ -61,6 +72,12 @@ interface ManageUiBinder extends UiBinder { @UiField SimplePanel description; + @UiField + SimplePanel databasesNotLoadedInfo; + + @UiField + SimplePanel databasesNotSearchableInfo; + @UiField(provided = true) SearchWrapper search; @@ -83,6 +100,9 @@ private DatabaseManage() { ListBuilder databaseMetadataList = new ListBuilder<>(() -> { DatabaseList metadataDatabaseList = new DatabaseList(); metadataDatabaseList.getSelectionModel().addSelectionChangeHandler(event -> { + setNotLoadedDatabases(); + setNotSearchableDatabases(); + setDatabasesNotSearchableInfoVisibility(false); ViewerDatabase selected = metadataDatabaseList.getSelectionModel().getSelectedObject(); if (selected != null) { HistoryManager.gotoSIARDInfo(selected.getUuid()); @@ -95,11 +115,8 @@ private DatabaseManage() { ListBuilder databaseSearchAll = new ListBuilder<>(() -> { CrossDatabaseList allDatabaseList = new CrossDatabaseList(); allDatabaseList.getSelectionModel().addSelectionChangeHandler(event -> { - ViewerDatabase selected = allDatabaseList.getSelectionModel().getSelectedObject(); - if (selected != null) { - HistoryManager.gotoSIARDInfo(selected.getUuid()); - allDatabaseList.getSelectionModel().clear(); - } + setDatabasesNotSearchableInfoVisibility(true); + allDatabaseList.setSearchValue(search.getComponents().getSearchPanel("DatabaseList_all").getCurrentFilter()); }); return allDatabaseList; }, new AsyncTableCellOptions<>(ViewerDatabase.class, "DatabaseList_all")); @@ -135,6 +152,50 @@ private void initButtons() { } } + private void setNotLoadedDatabases() { + FindRequest notLoadedDatabasesRequest = new FindRequest(ViewerDatabase.class.getName(), + new Filter( + new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_STATUS, ViewerDatabaseStatus.METADATA_ONLY.name())), + Sorter.NONE, new Sublist(), Facets.NONE, false, Collections.singletonList(ViewerConstants.INDEX_ID)); + DatabaseService.Util.call((IndexResult result) -> { + MetadataField notLoadedInfoInstance; + if (result.getTotalCount() > 0) { + notLoadedInfoInstance = MetadataField + .createInstance(messages.manageDatabaseNotLoadedDescription(result.getTotalCount())); + } else { + notLoadedInfoInstance = MetadataField.createInstance(messages.manageDatabaseAllLoadedDescription()); + } + notLoadedInfoInstance.setCSS("siards-not-loaded-info", "font-size-description"); + databasesNotLoadedInfo.setWidget(notLoadedInfoInstance); + }).find(notLoadedDatabasesRequest, LocaleInfo.getCurrentLocale().getLocaleName()); + } + + private void setNotSearchableDatabases() { + FindRequest notSearchableDatabasesRequest = new FindRequest(ViewerDatabase.class.getName(), + new Filter(new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL, "false")), + Sorter.NONE, new Sublist(), Facets.NONE, false, Collections.singletonList(ViewerConstants.INDEX_ID)); + DatabaseService.Util.call((IndexResult result) -> { + MetadataField notSearchableInfoInstance; + if (result.getTotalCount() > 0) { + notSearchableInfoInstance = MetadataField + .createInstance(messages.manageDatabaseNotSearchableDescription(result.getTotalCount())); + } else { + notSearchableInfoInstance = MetadataField.createInstance(messages.manageDatabaseAllSearchableDescription()); + } + notSearchableInfoInstance.setCSS("font-size-description"); + databasesNotSearchableInfo.setWidget(notSearchableInfoInstance); + }).find(notSearchableDatabasesRequest, LocaleInfo.getCurrentLocale().getLocaleName()); + } + + private void setDatabasesNotSearchableInfoVisibility(boolean visible) { + databasesNotSearchableInfo.setVisible(visible); + if (!visible) { + databasesNotLoadedInfo.setStyleName("siards-not-loaded-info"); + } else { + databasesNotLoadedInfo.removeStyleName("siards-not-loaded-info"); + } + } + /** * This method is called immediately after a widget becomes attached to the * browser's document. diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/admin/DatabaseManage.ui.xml b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/admin/DatabaseManage.ui.xml index bc1a68c58..0d3795abc 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/admin/DatabaseManage.ui.xml +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/admin/DatabaseManage.ui.xml @@ -12,6 +12,8 @@ + + diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/user/UserDatabaseListPanel.java b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/user/UserDatabaseListPanel.java index 4367d72b7..1a1ceb685 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/user/UserDatabaseListPanel.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/user/UserDatabaseListPanel.java @@ -7,6 +7,7 @@ */ package com.databasepreservation.common.client.common.visualization.manager.databasePanel.user; +import java.util.Collections; import java.util.List; import com.databasepreservation.common.client.ViewerConstants; @@ -14,26 +15,34 @@ import com.databasepreservation.common.client.common.breadcrumb.BreadcrumbItem; import com.databasepreservation.common.client.common.breadcrumb.BreadcrumbPanel; import com.databasepreservation.common.client.common.fields.MetadataField; +import com.databasepreservation.common.client.common.lists.CrossDatabaseList; import com.databasepreservation.common.client.common.lists.DatabaseList; +import com.databasepreservation.common.client.common.lists.utils.AsyncTableCellOptions; +import com.databasepreservation.common.client.common.lists.utils.ListBuilder; +import com.databasepreservation.common.client.common.search.SearchWrapper; import com.databasepreservation.common.client.common.utils.ApplicationType; import com.databasepreservation.common.client.common.utils.CommonClientUtils; -import com.databasepreservation.common.client.index.filter.BasicSearchFilterParameter; +import com.databasepreservation.common.client.index.FindRequest; +import com.databasepreservation.common.client.index.IndexResult; +import com.databasepreservation.common.client.index.facets.Facets; import com.databasepreservation.common.client.index.filter.Filter; +import com.databasepreservation.common.client.index.filter.SimpleFilterParameter; +import com.databasepreservation.common.client.index.sort.Sorter; import com.databasepreservation.common.client.models.structure.ViewerDatabase; +import com.databasepreservation.common.client.models.structure.ViewerDatabaseStatus; +import com.databasepreservation.common.client.services.DatabaseService; import com.databasepreservation.common.client.tools.BreadcrumbManager; import com.databasepreservation.common.client.tools.FontAwesomeIconManager; import com.databasepreservation.common.client.tools.HistoryManager; -import com.databasepreservation.common.client.tools.ViewerStringUtils; -import com.databasepreservation.common.client.widgets.wcag.AccessibleFocusPanel; import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.i18n.client.LocaleInfo; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.SimplePanel; -import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.Widget; import config.i18n.client.ClientMessages; +import org.roda.core.data.v2.index.sublist.Sublist; /** * @author Miguel Guimarães @@ -54,19 +63,22 @@ interface ManageUiBinder extends UiBinder { private static ManageUiBinder binder = GWT.create(ManageUiBinder.class); @UiField - TextBox searchInputBox; + SimplePanel mainHeader; @UiField - AccessibleFocusPanel searchInputButton; + SimplePanel description; @UiField - SimplePanel mainHeader; + SimplePanel databasesNotLoadedInfo; @UiField - SimplePanel description; + SimplePanel databasesNotSearchableInfo; + + @UiField + SimplePanel adminInfo; @UiField(provided = true) - DatabaseList databaseList; + SearchWrapper search; private static UserDatabaseListPanel instance = null; @@ -78,7 +90,34 @@ public static UserDatabaseListPanel getInstance() { } private UserDatabaseListPanel() { - databaseList = new DatabaseList(); + + ListBuilder databaseMetadataList = new ListBuilder<>(() -> { + DatabaseList metadataDatabaseList = new DatabaseList(); + metadataDatabaseList.getSelectionModel().addSelectionChangeHandler(event -> { + setNotLoadedDatabases(); + setNotSearchableDatabases(); + setDatabasesNotSearchableInfoVisibility(false); + ViewerDatabase selected = metadataDatabaseList.getSelectionModel().getSelectedObject(); + if (selected != null) { + if (ApplicationType.getType().equals(ViewerConstants.APPLICATION_ENV_SERVER)) { + HistoryManager.gotoDatabase(selected.getUuid()); + } + metadataDatabaseList.getSelectionModel().clear(); + } + }); + return metadataDatabaseList; + }, new AsyncTableCellOptions<>(ViewerDatabase.class, "DatabaseList_metadata")); + ListBuilder databaseSearchAll = new ListBuilder<>(() -> { + CrossDatabaseList allDatabaseList = new CrossDatabaseList(); + allDatabaseList.getSelectionModel().addSelectionChangeHandler(event -> { + setDatabasesNotSearchableInfoVisibility(true); + allDatabaseList.setSearchValue(search.getComponents().getSearchPanel("DatabaseList_all").getCurrentFilter()); + }); + return allDatabaseList; + }, new AsyncTableCellOptions<>(ViewerDatabase.class, "DatabaseList_all")); + search = new SearchWrapper(true).createListAndSearchPanel(databaseMetadataList) + .createListAndSearchPanel(databaseSearchAll); + initWidget(binder.createAndBindUi(this)); mainHeader.setWidget(CommonClientUtils.getHeader(FontAwesomeIconManager.getTag(FontAwesomeIconManager.SERVER), @@ -89,38 +128,54 @@ private UserDatabaseListPanel() { description.setWidget(instance); - searchInputBox.getElement().setPropertyString("placeholder", messages.searchPlaceholder()); + MetadataField adminInfoInstance = MetadataField.createInstance(messages.manageDatabaseContactAdministratorDescription()); + adminInfoInstance.setCSS("siards-contact-admin-info", "font-size-description"); + adminInfo.setWidget(adminInfoInstance); - searchInputBox.addKeyDownHandler(event -> { - if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { - doSearch(); - } - }); + } - searchInputButton.addClickHandler(event -> doSearch()); + private void setNotLoadedDatabases() { + FindRequest notLoadedDatabasesRequest = new FindRequest(ViewerDatabase.class.getName(), + new Filter( + new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_STATUS, ViewerDatabaseStatus.METADATA_ONLY.name())), + Sorter.NONE, new Sublist(), Facets.NONE, false, Collections.singletonList(ViewerConstants.INDEX_ID)); + DatabaseService.Util.call((IndexResult result) -> { + MetadataField notLoadedInfoInstance; + if (result.getTotalCount() > 0) { + notLoadedInfoInstance = MetadataField + .createInstance(messages.manageDatabaseNotLoadedDescription(result.getTotalCount())); + } else { + notLoadedInfoInstance = MetadataField.createInstance(messages.manageDatabaseAllLoadedDescription()); + } + notLoadedInfoInstance.setCSS("siards-not-loaded-info", "font-size-description"); + databasesNotLoadedInfo.setWidget(notLoadedInfoInstance); + }).find(notLoadedDatabasesRequest, LocaleInfo.getCurrentLocale().getLocaleName()); + } - databaseList.getSelectionModel().addSelectionChangeHandler(event -> { - ViewerDatabase selected = databaseList.getSelectionModel().getSelectedObject(); - if (selected != null) { - if (ApplicationType.getType().equals(ViewerConstants.APPLICATION_ENV_SERVER)) { - HistoryManager.gotoDatabase(selected.getUuid()); - } - databaseList.getSelectionModel().clear(); + private void setNotSearchableDatabases() { + FindRequest notSearchableDatabasesRequest = new FindRequest(ViewerDatabase.class.getName(), + new Filter(new SimpleFilterParameter(ViewerConstants.SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL, "false")), + Sorter.NONE, new Sublist(), Facets.NONE, false, Collections.singletonList(ViewerConstants.INDEX_ID)); + DatabaseService.Util.call((IndexResult result) -> { + MetadataField notSearchableInfoInstance; + if (result.getTotalCount() > 0) { + notSearchableInfoInstance = MetadataField + .createInstance(messages.manageDatabaseNotSearchableDescription(result.getTotalCount())); + } else { + notSearchableInfoInstance = MetadataField.createInstance(messages.manageDatabaseAllSearchableDescription()); } - }); + notSearchableInfoInstance.setCSS("font-size-description"); + databasesNotSearchableInfo.setWidget(notSearchableInfoInstance); + }).find(notSearchableDatabasesRequest, LocaleInfo.getCurrentLocale().getLocaleName()); } - private void doSearch() { - // start searching - Filter filter; - String searchText = searchInputBox.getText(); - if (ViewerStringUtils.isBlank(searchText)) { - filter = ViewerConstants.DEFAULT_FILTER; + private void setDatabasesNotSearchableInfoVisibility(boolean visible) { + databasesNotSearchableInfo.setVisible(visible); + if (!visible) { + databasesNotLoadedInfo.setStyleName("siards-not-loaded-info"); } else { - filter = new Filter(new BasicSearchFilterParameter(ViewerConstants.INDEX_SEARCH, searchText)); + databasesNotLoadedInfo.removeStyleName("siards-not-loaded-info"); } - - databaseList.setFilter(filter); } /** @@ -130,6 +185,5 @@ private void doSearch() { @Override protected void onLoad() { super.onLoad(); - databaseList.getSelectionModel().clear(); } } \ No newline at end of file diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/user/UserDatabaseListPanel.ui.xml b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/user/UserDatabaseListPanel.ui.xml index d218ba6b0..d4c6fc083 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/user/UserDatabaseListPanel.ui.xml +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/databasePanel/user/UserDatabaseListPanel.ui.xml @@ -1,7 +1,6 @@ + xmlns:commonsearch="urn:import:com.databasepreservation.common.client.common.search"> @@ -10,26 +9,10 @@ - - - - - - - - - - - - - - - - - - - + + + + \ No newline at end of file diff --git a/src/main/java/com/databasepreservation/common/client/index/IndexResult.java b/src/main/java/com/databasepreservation/common/client/index/IndexResult.java index 1a3962d6b..274f4b818 100644 --- a/src/main/java/com/databasepreservation/common/client/index/IndexResult.java +++ b/src/main/java/com/databasepreservation/common/client/index/IndexResult.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -34,6 +35,8 @@ public class IndexResult implements Serializable { public IndexResult() { super(); + this.results = new ArrayList<>(); + this.facetResults = new ArrayList<>(); date = new Date(); } diff --git a/src/main/java/com/databasepreservation/common/client/models/status/database/DatabaseStatus.java b/src/main/java/com/databasepreservation/common/client/models/status/database/DatabaseStatus.java index 9f687a0c2..806232b86 100644 --- a/src/main/java/com/databasepreservation/common/client/models/status/database/DatabaseStatus.java +++ b/src/main/java/com/databasepreservation/common/client/models/status/database/DatabaseStatus.java @@ -20,7 +20,7 @@ /** * @author Miguel Guimarães */ -@JsonPropertyOrder({"version", "id", "siard", "validation", "collections"}) +@JsonPropertyOrder({"version", "id", "siard", "validation", "collections", "availableToSearchAll"}) public class DatabaseStatus implements Serializable { private String version = ViewerConstants.DATABASE_STATUS_VERSION; @@ -29,20 +29,23 @@ public class DatabaseStatus implements Serializable { private ValidationStatus validationStatus; private List collections; private Set permissions; + private boolean availableToSearchAll; public DatabaseStatus() { collections = new ArrayList<>(); permissions = new HashSet<>(); + availableToSearchAll = true; } public DatabaseStatus(String version, String id, SiardStatus siardStatus, ValidationStatus validationStatus, - List collections, Set permissions ) { + List collections, Set permissions, boolean availableToSearchAll) { this.version = version; this.id = id; this.siardStatus = siardStatus; this.validationStatus = validationStatus; this.collections = collections; this.permissions = permissions; + this.availableToSearchAll = availableToSearchAll; } public DatabaseStatus(DatabaseStatus status, Set permissions) { @@ -52,6 +55,7 @@ public DatabaseStatus(DatabaseStatus status, Set permissions) { this.validationStatus = status.getValidationStatus(); this.collections = status.getCollections(); this.permissions = status.getPermissions(); + this.availableToSearchAll = status.isAvailableToSearchAll(); } public String getVersion() { @@ -70,6 +74,14 @@ public void setId(String id) { this.id = id; } + public boolean isAvailableToSearchAll() { + return availableToSearchAll; + } + + public void setAvailableToSearchAll(boolean availableToSearchAll) { + this.availableToSearchAll = availableToSearchAll; + } + @JsonProperty("siard") public SiardStatus getSiardStatus() { return siardStatus; diff --git a/src/main/java/com/databasepreservation/common/client/models/structure/ViewerDatabase.java b/src/main/java/com/databasepreservation/common/client/models/structure/ViewerDatabase.java index 0d06ac649..10422e228 100644 --- a/src/main/java/com/databasepreservation/common/client/models/structure/ViewerDatabase.java +++ b/src/main/java/com/databasepreservation/common/client/models/structure/ViewerDatabase.java @@ -38,6 +38,7 @@ public class ViewerDatabase extends IsIndexed { private String validationWarnings; private String validationSkipped; private Set permissions; + private boolean isAvailableToSearchAll; private long searchHits = -1; @@ -135,6 +136,14 @@ public String getValidatedAt() { return validatedAt; } + public boolean isAvailableToSearchAll() { + return isAvailableToSearchAll; + } + + public void setAvailableToSearchAll(boolean availableToSearchAll) { + isAvailableToSearchAll = availableToSearchAll; + } + public void setValidatedAt(String validatedAt) { this.validatedAt = validatedAt; } diff --git a/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java b/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java index 068841268..864efe3c6 100644 --- a/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java +++ b/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java @@ -94,4 +94,9 @@ IndexResult findAll(@RequestBody FindRequest findRequest, @Operation(summary = "Updates database permissions") Set updateDatabasePermissions(@PathVariable(name = "databaseUUID") String databaseUUID, @Parameter(name = ViewerConstants.API_QUERY_PARAM_FILTER) @RequestBody Set permissions); + + @RequestMapping(path = "/{databaseUUID}/searchable", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Updates database permissions") + boolean updateDatabaseSearchAllAvailability(@PathVariable(name = "databaseUUID") String databaseUUID); + } diff --git a/src/main/java/com/databasepreservation/common/client/tools/HistoryManager.java b/src/main/java/com/databasepreservation/common/client/tools/HistoryManager.java index 04185fcca..dc9dac5ca 100644 --- a/src/main/java/com/databasepreservation/common/client/tools/HistoryManager.java +++ b/src/main/java/com/databasepreservation/common/client/tools/HistoryManager.java @@ -128,6 +128,10 @@ public static void gotoDatabaseSearch(String databaseUUID) { newHistory(Arrays.asList(ROUTE_DATABASE, databaseUUID, ROUTE_DATABASE_SEARCH)); } + public static void gotoDatabaseSearchWithValue(String databaseUUID, String search) { + newHistory(Arrays.asList(ROUTE_DATABASE, databaseUUID, ROUTE_DATABASE_SEARCH, search)); + } + public static void gotoDatabaseReport(String databaseUUID) { newHistory(Arrays.asList(ROUTE_DATABASE, databaseUUID, ROUTE_DATABASE_REPORT)); } diff --git a/src/main/java/com/databasepreservation/common/server/ConfigurationManager.java b/src/main/java/com/databasepreservation/common/server/ConfigurationManager.java index 13298bfca..091dd7857 100644 --- a/src/main/java/com/databasepreservation/common/server/ConfigurationManager.java +++ b/src/main/java/com/databasepreservation/common/server/ConfigurationManager.java @@ -56,12 +56,12 @@ public ConfigurationManager() { } public CollectionStatus getConfigurationCollection(String databaseUUID, String collectionUUID) - throws GenericException { + throws GenericException { return getConfigurationCollection(databaseUUID, collectionUUID, false); } public CollectionStatus getConfigurationCollection(String databaseUUID, String collectionUUID, boolean prefixed) - throws GenericException { + throws GenericException { Path databasesDirectoryPath = ViewerFactory.getViewerConfiguration().getDatabasesPath(); Path databaseDirectoryPath = databasesDirectoryPath.resolve(databaseUUID); Path collectionStatusFile; @@ -69,7 +69,7 @@ public CollectionStatus getConfigurationCollection(String databaseUUID, String c collectionStatusFile = databaseDirectoryPath.resolve(collectionUUID + ViewerConstants.JSON_EXTENSION); } else { collectionStatusFile = databaseDirectoryPath.resolve( - ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + collectionUUID + ViewerConstants.JSON_EXTENSION); + ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + collectionUUID + ViewerConstants.JSON_EXTENSION); } return JsonUtils.readObjectFromFile(collectionStatusFile, CollectionStatus.class); @@ -78,7 +78,7 @@ public CollectionStatus getConfigurationCollection(String databaseUUID, String c public void editSearch(String databaseUUID, String uuid, String name, String description) { try { final CollectionStatus collectionStatus = getCollectionStatus(databaseUUID, - ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + databaseUUID); + ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + databaseUUID); final SavedSearch savedSearch = collectionStatus.getSavedSearch(uuid); savedSearch.setName(name); @@ -94,7 +94,7 @@ public void editSearch(String databaseUUID, String uuid, String name, String des public void addSearch(SavedSearch savedSearch) { try { final CollectionStatus collectionStatus = getCollectionStatus(savedSearch.getDatabaseUUID(), - ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + savedSearch.getDatabaseUUID()); + ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + savedSearch.getDatabaseUUID()); collectionStatus.addSavedSearch(savedSearch); updateCollectionStatus(savedSearch.getDatabaseUUID(), collectionStatus); } catch (GenericException | ViewerException e) { @@ -150,8 +150,8 @@ public void removeDenormalization(String databaseUUID, String denormalizationUUI } public void addDenormalizationColumns(String databaseUUID, String tableUUID, ViewerColumn column, - NestedColumnStatus nestedId, String template, String originalType, String typeName, String nullable) - throws GenericException { + NestedColumnStatus nestedId, String template, String originalType, String typeName, String nullable) + throws GenericException { try { final DatabaseStatus databaseStatus = getDatabaseStatus(databaseUUID); if (!databaseStatus.getCollections().isEmpty()) { @@ -197,9 +197,9 @@ public void removeDenormalizationColumns(String databaseUUID, String tableUUID) } public void addCollection(String databaseUUID, String databaseName, String databaseDescription, - String solrCollectionName) { + String solrCollectionName) { final CollectionStatus collectionStatus = StatusUtils.getCollectionStatus(databaseUUID, databaseName, - databaseDescription, solrCollectionName); + databaseDescription, solrCollectionName); try { final DatabaseStatus databaseStatus = getDatabaseStatus(databaseUUID); @@ -262,12 +262,12 @@ public void updateIndicators(String id, String passed, String failed, String war final Path databaseDirectoryPath = databasesDirectoryPath.resolve(id); Path databaseFile = databaseDirectoryPath - .resolve(ViewerConstants.DATABASE_STATUS_PREFIX + id + ViewerConstants.JSON_EXTENSION); + .resolve(ViewerConstants.DATABASE_STATUS_PREFIX + id + ViewerConstants.JSON_EXTENSION); // verify if file exists if (FSUtils.exists(databaseFile)) { final DatabaseStatus databaseStatus = JsonUtils.readObjectFromFile(databaseFile, DatabaseStatus.class); databaseStatus.getValidationStatus() - .setIndicators(StatusUtils.getIndicators(passed, failed, warnings, skipped)); + .setIndicators(StatusUtils.getIndicators(passed, failed, warnings, skipped)); // update database file JsonTransformer.writeObjectToFile(databaseStatus, databaseFile); @@ -278,14 +278,15 @@ public void updateIndicators(String id, String passed, String failed, String war } } - public void updateDatabasePermissions(String databaseId, Set permissions) throws GenericException, ViewerException { + public void updateDatabasePermissions(String databaseId, Set permissions) + throws GenericException, ViewerException { synchronized (databaseStatusFileLock) { try { final Path databasesDirectoryPath = ViewerFactory.getViewerConfiguration().getDatabasesPath(); final Path databaseDirectoryPath = databasesDirectoryPath.resolve(databaseId); Path databaseFile = databaseDirectoryPath - .resolve(ViewerConstants.DATABASE_STATUS_PREFIX + databaseId + ViewerConstants.JSON_EXTENSION); + .resolve(ViewerConstants.DATABASE_STATUS_PREFIX + databaseId + ViewerConstants.JSON_EXTENSION); // verify if file exists if (FSUtils.exists(databaseFile)) { @@ -302,6 +303,31 @@ public void updateDatabasePermissions(String databaseId, Set permissions } } + public void updateDatabaseSearchAllAvailability(String databaseId, boolean isAvailableToSearchAll) + throws GenericException, ViewerException { + synchronized (databaseStatusFileLock) { + try { + final Path databasesDirectoryPath = ViewerFactory.getViewerConfiguration().getDatabasesPath(); + final Path databaseDirectoryPath = databasesDirectoryPath.resolve(databaseId); + + Path databaseFile = databaseDirectoryPath + .resolve(ViewerConstants.DATABASE_STATUS_PREFIX + databaseId + ViewerConstants.JSON_EXTENSION); + + // verify if file exists + if (FSUtils.exists(databaseFile)) { + final DatabaseStatus databaseStatus = JsonUtils.readObjectFromFile(databaseFile, DatabaseStatus.class); + databaseStatus.setAvailableToSearchAll(isAvailableToSearchAll); + + // update database file + JsonTransformer.writeObjectToFile(databaseStatus, databaseFile); + } + } catch (GenericException | ViewerException e) { + LOGGER.debug(e.getMessage(), e); + throw e; + } + } + } + public void updateDatabaseStatus(DatabaseStatus status) throws ViewerException { synchronized (databaseStatusFileLock) { Path statusFile = getDatabaseStatusPath(status.getId()); @@ -317,11 +343,11 @@ public void updateCollectionStatus(String databaseUUID, CollectionStatus status) } public void updateCollectionStatus(String databaseUUID, ViewerMetadata metadata, boolean updateOnModel) - throws GenericException, ViewerException { + throws GenericException, ViewerException { List list = StatusUtils.getTableStatusFromList(metadata); CollectionStatus collectionStatus = getCollectionStatus(databaseUUID, - ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + databaseUUID); + ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + databaseUUID); if (updateOnModel) { collectionStatus.setName(metadata.getName()); @@ -335,10 +361,10 @@ public void updateCollectionStatus(String databaseUUID, ViewerMetadata metadata, } for (ColumnStatus column : table.getColumns()) { collectionStatus.getColumnByTableIdAndColumn(table.getId(), column.getId()) - .setDescription(column.getDescription()); + .setDescription(column.getDescription()); if (updateOnModel) { collectionStatus.getColumnByTableIdAndColumn(table.getId(), column.getId()) - .setCustomDescription(column.getDescription()); + .setCustomDescription(column.getDescription()); } } } @@ -347,20 +373,20 @@ public void updateCollectionStatus(String databaseUUID, ViewerMetadata metadata, } public void updateValidationStatus(String id, ViewerDatabaseValidationStatus status, String date, - String validationReportPath, String dbptkVersion) { + String validationReportPath, String dbptkVersion) { synchronized (databaseStatusFileLock) { try { final Path databasesDirectoryPath = ViewerFactory.getViewerConfiguration().getDatabasesPath(); final Path databaseDirectoryPath = databasesDirectoryPath.resolve(id); Path databaseFile = databaseDirectoryPath - .resolve(ViewerConstants.DATABASE_STATUS_PREFIX + id + ViewerConstants.JSON_EXTENSION); + .resolve(ViewerConstants.DATABASE_STATUS_PREFIX + id + ViewerConstants.JSON_EXTENSION); // verify if file exists if (FSUtils.exists(databaseFile)) { final DatabaseStatus databaseStatus = JsonUtils.readObjectFromFile(databaseFile, DatabaseStatus.class); databaseStatus.setValidationStatus(StatusUtils.getValidationStatus(status, date, validationReportPath, - dbptkVersion, databaseStatus.getValidationStatus().getIndicators())); + dbptkVersion, databaseStatus.getValidationStatus().getIndicators())); JsonTransformer.writeObjectToFile(databaseStatus, databaseFile); } @@ -383,7 +409,7 @@ public void addDatabase(ViewerDatabase database) throws GenericException { JsonUtils.writeObjectToFile(StatusUtils.getDatabaseStatus(database), databaseStatusPath); addCollection(database.getUuid(), database.getMetadata().getName(), database.getMetadata().getDescription(), - ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + database.getUuid()); + ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX + database.getUuid()); addTable(database); } catch (FileAlreadyExistsException e) { // do nothing (just caused due to concurrency) @@ -402,7 +428,7 @@ public void deleteDatabaseFolder(String databaseUUID) throws GenericException { LOGGER.info("Database folder removed from system ({})", databaseDirectoryPath.toAbsolutePath()); } catch (IOException e) { throw new GenericException("Could not delete the database folder for uuid: " + databaseUUID + " from the system", - e); + e); } } @@ -416,24 +442,24 @@ public void deleteCollection(String databaseUUID, String collectionUUID) throws Files.deleteIfExists(denormalizationFilePath); } catch (IOException e) { throw new GenericException( - "Could not delete the collection file " + collectionUUID + ViewerConstants.JSON_EXTENSION + " from the system", - e); + "Could not delete the collection file " + collectionUUID + ViewerConstants.JSON_EXTENSION + " from the system", + e); } } public void deleteDenormalizationFromCollection(String databaseUUID, String denormalizationUUID) - throws GenericException { + throws GenericException { final Path databasesDirectoryPath = ViewerFactory.getViewerConfiguration().getDatabasesPath(); final Path databaseDirectoryPath = databasesDirectoryPath.resolve(databaseUUID); final Path denormalizationFilePath = databaseDirectoryPath - .resolve(denormalizationUUID + ViewerConstants.JSON_EXTENSION); + .resolve(denormalizationUUID + ViewerConstants.JSON_EXTENSION); try { Files.deleteIfExists(denormalizationFilePath); } catch (IOException e) { throw new GenericException("Could not delete the denormalization file " + denormalizationUUID - + ViewerConstants.JSON_EXTENSION + " from the system", e); + + ViewerConstants.JSON_EXTENSION + " from the system", e); } } diff --git a/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java b/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java index 20f05f550..631f0f16b 100644 --- a/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java +++ b/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java @@ -7,9 +7,6 @@ */ package com.databasepreservation.common.server.controller; -import static com.databasepreservation.common.client.ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX; -import static com.databasepreservation.common.client.ViewerConstants.SOLR_SEARCHES_DATABASE_UUID; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -36,6 +33,8 @@ import com.databasepreservation.SIARDEdition; import com.databasepreservation.SIARDValidation; import com.databasepreservation.common.client.ViewerConstants; +import static com.databasepreservation.common.client.ViewerConstants.SOLR_INDEX_ROW_COLLECTION_NAME_PREFIX; +import static com.databasepreservation.common.client.ViewerConstants.SOLR_SEARCHES_DATABASE_UUID; import com.databasepreservation.common.client.common.search.SavedSearch; import com.databasepreservation.common.client.index.filter.Filter; import com.databasepreservation.common.client.index.filter.SimpleFilterParameter; @@ -620,6 +619,7 @@ private static void convertSIARDMetadataToSolr(Path siardPath, String databaseUU viewerDatabase.setPath(siardPath.toAbsolutePath().toString()); viewerDatabase.setSize(siardPath.toFile().length()); viewerDatabase.setVersion(siardEdition.getSIARDVersion()); + viewerDatabase.setAvailableToSearchAll(true); viewerDatabase.setValidationStatus(ViewerDatabaseValidationStatus.NOT_VALIDATED); Set authorizationDefault = ViewerConfiguration.getInstance().getCollectionsAuthorizationDefault(); @@ -840,6 +840,13 @@ public static Set updateDatabasePermissions(String databaseUUID, Set IndexResult find(Class classToReturn, Filter } public IndexResult findHits(Class classToReturn, String alias, Filter filter, - Sorter sorter, Sublist sublist, Facets facets) - throws GenericException, RequestNotValidException { - return SolrUtils.findHits(client, SolrDefaultCollectionRegistry.get(classToReturn), alias, filter, sorter, - sublist, facets); + Sorter sorter, Sublist sublist, Facets facets) throws GenericException, RequestNotValidException { + return SolrUtils.findHits(client, SolrDefaultCollectionRegistry.get(classToReturn), alias, filter, sorter, sublist, + facets); } public IndexResult find(Class classToReturn, Filter filter, Sorter sorter, @@ -531,6 +530,25 @@ public void updateDatabasePermissions(String databaseUUID, Set permissio LOGGER.debug("Finish updating database metadata ({})", databaseUUID); } + public boolean updateDatabaseSearchAllAvailability(String databaseUUID, boolean isAvailableToSearchAll) + throws GenericException, ViewerException { + LOGGER.debug("Starting to update database search all availability ({})", databaseUUID); + // create document to update this DB + SolrInputDocument doc = new SolrInputDocument(); + doc.addField(ViewerConstants.INDEX_ID, databaseUUID); + + try { + doc.addField(ViewerConstants.SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL, SolrUtils.asValueUpdate(isAvailableToSearchAll)); + insertDocument(ViewerConstants.SOLR_INDEX_DATABASES_COLLECTION_NAME, doc); + } catch (ViewerException e) { + LOGGER.error("Could not update database metadata ({})", databaseUUID, e); + } + + ViewerFactory.getConfigurationManager().updateDatabaseSearchAllAvailability(databaseUUID, isAvailableToSearchAll); + LOGGER.debug("Finish updating database metadata ({})", databaseUUID); + return true; + } + public void updateDatabaseMetadata(String databaseUUID, ViewerMetadata metadata) { LOGGER.debug("Starting to update database metadata ({})", databaseUUID); diff --git a/src/main/java/com/databasepreservation/common/server/index/schema/collections/DatabasesCollection.java b/src/main/java/com/databasepreservation/common/server/index/schema/collections/DatabasesCollection.java index 0adb681b8..361c63e15 100644 --- a/src/main/java/com/databasepreservation/common/server/index/schema/collections/DatabasesCollection.java +++ b/src/main/java/com/databasepreservation/common/server/index/schema/collections/DatabasesCollection.java @@ -7,6 +7,7 @@ */ package com.databasepreservation.common.server.index.schema.collections; +import static com.databasepreservation.common.client.ViewerConstants.SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL; import static com.databasepreservation.common.client.ViewerConstants.SOLR_DATABASES_BROWSE_LOAD_DATE; import static com.databasepreservation.common.client.ViewerConstants.SOLR_DATABASES_METADATA; import static com.databasepreservation.common.client.ViewerConstants.SOLR_DATABASES_PERMISSIONS; @@ -90,6 +91,7 @@ public List getFields() { fields.add(newIndexedStoredNotRequiredField(SOLR_DATABASES_VALIDATION_WARNINGS, Field.TYPE_STRING)); fields.add(newIndexedStoredNotRequiredField(SOLR_DATABASES_VALIDATION_SKIPPED, Field.TYPE_STRING)); fields.add(newIndexedStoredNotRequiredField(SOLR_DATABASES_BROWSE_LOAD_DATE, Field.TYPE_STRING)); + fields.add(newIndexedStoredNotRequiredField(SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL, Field.TYPE_BOOLEAN)); fields.add(new Field(SOLR_DATABASES_PERMISSIONS, Field.TYPE_STRING).setIndexed(true).setMultiValued(true)); return fields; @@ -111,6 +113,7 @@ public SolrInputDocument toSolrDocument(ViewerDatabase object) throws ViewerExce doc.addField(SOLR_DATABASES_SIARD_PATH, object.getPath()); doc.addField(SOLR_DATABASES_SIARD_SIZE, object.getSize()); doc.addField(SOLR_DATABASES_SIARD_VERSION, object.getVersion()); + doc.addField(SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL, object.isAvailableToSearchAll()); doc.addField(SOLR_DATABASES_VALIDATED_AT, object.getValidatedAt()); doc.addField(SOLR_DATABASES_VALIDATOR_REPORT_PATH, object.getValidatorReportPath()); @@ -143,6 +146,7 @@ public ViewerDatabase fromSolrDocument(SolrDocument doc) throws ViewerException viewerDatabase.setPath(SolrUtils.objectToString(doc.get(SOLR_DATABASES_SIARD_PATH), "")); viewerDatabase.setSize(SolrUtils.objectToLong(doc.get(SOLR_DATABASES_SIARD_SIZE), 0L)); viewerDatabase.setVersion(SolrUtils.objectToString(doc.get(SOLR_DATABASES_SIARD_VERSION), "2.1")); + viewerDatabase.setAvailableToSearchAll(SolrUtils.objectToBoolean(doc.get(SOLR_DATABASES_AVAILABLE_TO_SEARCH_ALL), true)); viewerDatabase.setValidatedAt(SolrUtils.objectToString(doc.get(SOLR_DATABASES_VALIDATED_AT), "")); viewerDatabase.setValidatorReportPath(SolrUtils.objectToString(doc.get(SOLR_DATABASES_VALIDATOR_REPORT_PATH), "")); diff --git a/src/main/java/com/databasepreservation/common/server/index/utils/SolrUtils.java b/src/main/java/com/databasepreservation/common/server/index/utils/SolrUtils.java index dd8d1b785..de5d22166 100644 --- a/src/main/java/com/databasepreservation/common/server/index/utils/SolrUtils.java +++ b/src/main/java/com/databasepreservation/common/server/index/utils/SolrUtils.java @@ -1301,7 +1301,7 @@ public static > E objectToEnum(Object object, Class enumera return ret; } - public static String crateSearchAllAlias(SolrClient index, String aliasName, List collections) + public static String createSearchAllAlias(SolrClient index, String aliasName, List collections) throws SolrServerException, IOException { if (!collections.isEmpty()) { CollectionAdminRequest.CreateAlias request = CollectionAdminRequest.createAlias(aliasName, @@ -1311,4 +1311,10 @@ public static String crateSearchAllAlias(SolrClient index, String aliasName, Lis } return aliasName; } + + public static void deleteSearchAllAlias(SolrClient index, String aliasName) throws SolrServerException, IOException { + CollectionAdminRequest.DeleteAlias request = CollectionAdminRequest.deleteAlias(aliasName); + request.setMethod(SolrRequest.METHOD.POST); + index.request(request); + } } diff --git a/src/main/java/com/databasepreservation/desktop/client/main/MainPanelDesktop.java b/src/main/java/com/databasepreservation/desktop/client/main/MainPanelDesktop.java index cfbd8f5f6..7850e51c6 100644 --- a/src/main/java/com/databasepreservation/desktop/client/main/MainPanelDesktop.java +++ b/src/main/java/com/databasepreservation/desktop/client/main/MainPanelDesktop.java @@ -157,6 +157,19 @@ public RightPanel load(ViewerDatabase database, CollectionStatus status) { return DatabaseSearchPanel.getInstance(database, status); } }); + } else if (currentHistoryPath.size() == 4 + && currentHistoryPath.get(2).equals(HistoryManager.ROUTE_DATABASE_SEARCH)) { + // #database//search/ + String databaseUUID = currentHistoryPath.get(1); + String searchValue = currentHistoryPath.get(3); + setContent(databaseUUID, HistoryManager.ROUTE_DATABASE, currentHistoryPath.get(2), + new RightPanelLoader() { + @Override + public RightPanel load(ViewerDatabase database, CollectionStatus status) { + return DatabaseSearchPanel.getInstance(database, status, searchValue); + } + }); + } else if (currentHistoryPath.size() == 3 && currentHistoryPath.get(2).equals(HistoryManager.ROUTE_SCHEMA_ROUTINES)) { // #database//routines diff --git a/src/main/java/com/databasepreservation/server/client/main/MainPanel.java b/src/main/java/com/databasepreservation/server/client/main/MainPanel.java index 6764bca35..81e0d660e 100644 --- a/src/main/java/com/databasepreservation/server/client/main/MainPanel.java +++ b/src/main/java/com/databasepreservation/server/client/main/MainPanel.java @@ -408,7 +408,7 @@ public RightPanel load(ViewerDatabase database, CollectionStatus status) { } else if (currentHistoryPath.size() == 3 && currentHistoryPath.get(2).equals(HistoryManager.ROUTE_DATABASE_SEARCH)) { - // #database//search + // #database//search/ String databaseUUID = currentHistoryPath.get(1); setContent(databaseUUID, HistoryManager.ROUTE_DATABASE, currentHistoryPath.get(2), new RightPanelLoader() { @@ -417,6 +417,18 @@ public RightPanel load(ViewerDatabase database, CollectionStatus status) { return DatabaseSearchPanel.getInstance(database, status); } }); + } else if (currentHistoryPath.size() == 4 + && currentHistoryPath.get(2).equals(HistoryManager.ROUTE_DATABASE_SEARCH)) { + // #database//search/ + String databaseUUID = currentHistoryPath.get(1); + String searchValue = currentHistoryPath.get(3); + setContent(databaseUUID, HistoryManager.ROUTE_DATABASE, currentHistoryPath.get(2), + new RightPanelLoader() { + @Override + public RightPanel load(ViewerDatabase database, CollectionStatus status) { + return DatabaseSearchPanel.getInstance(database, status, searchValue); + } + }); } else if (currentHistoryPath.size() == 3 && currentHistoryPath.get(2).equals(HistoryManager.ROUTE_SCHEMA_ROUTINES)) { diff --git a/src/main/java/config/i18n/client/ClientMessages.java b/src/main/java/config/i18n/client/ClientMessages.java index 8b27b3911..2a58a46c9 100644 --- a/src/main/java/config/i18n/client/ClientMessages.java +++ b/src/main/java/config/i18n/client/ClientMessages.java @@ -708,6 +708,16 @@ public interface ClientMessages extends Messages { String manageDatabasePageDescription(); + String manageDatabaseNotLoadedDescription(long number); + + String manageDatabaseNotSearchableDescription(long number); + + String manageDatabaseAllLoadedDescription(); + + String manageDatabaseAllSearchableDescription(); + + String manageDatabaseContactAdministratorDescription(); + /******************************************** * SIARD Home Page ********************************************/ @@ -859,18 +869,24 @@ public interface ClientMessages extends Messages { String SIARDHomePageDialogTitleForPermissionsList(); + String SIARDHomePageDialogTitleForChangeAvailabilityToSearchAll(); + SafeHtml SIARDHomePageDialogDescriptionForPermissionsList(); String SIARDHomePageDialogDetailsForPermissionsList(); String SIARDHomePageDialogMessageForPermissionsList(); + String SIARDHomePageDialogMessageForChangeAvailabilityToSearchAll(); + String SIARDHomePageDialogDetailsForUnknownPermission(); String SIARDHomePageDialogDetailsForUnknownPermissions(String permissions); String SIARDHomePageDialogActionForOverridePermissions(); + String SIARDHomePageTitleForPermissionsSwitchButton(); + /******************************************** * Edit Metadata ********************************************/ diff --git a/src/main/resources/com/databasepreservation/common/public/main.css b/src/main/resources/com/databasepreservation/common/public/main.css index 46f60cbe2..f76b8b39d 100644 --- a/src/main/resources/com/databasepreservation/common/public/main.css +++ b/src/main/resources/com/databasepreservation/common/public/main.css @@ -1069,6 +1069,14 @@ p[data-value]:after { margin-bottom: 10px; } +.siards-not-loaded-info { + margin-top: -30px; +} + +.siards-contact-admin-info { + margin-bottom: 5px; +} + .btn-pull-right { padding-right: 0 !important; } @@ -1444,6 +1452,7 @@ html, body { } .button-group-panel-btn .btn { + margin-top: 5px; width: 100%; padding: 8px; text-align: center; diff --git a/src/main/resources/config/dbvtk-roles.properties b/src/main/resources/config/dbvtk-roles.properties index 1b8934744..865a0c786 100644 --- a/src/main/resources/config/dbvtk-roles.properties +++ b/src/main/resources/config/dbvtk-roles.properties @@ -64,6 +64,7 @@ roles.com.databasepreservation.common.api.v1.DatabaseResource.retrieve=users roles.com.databasepreservation.common.api.v1.DatabaseResource.delete=administrators roles.com.databasepreservation.common.api.v1.DatabaseResource.getDatabasePermissions=administrators roles.com.databasepreservation.common.api.v1.DatabaseResource.updateDatabasePermissions=administrators +roles.com.databasepreservation.common.api.v1.DatabaseResource.updateDatabaseSearchAllAvailability=administrators ################################################ # File Resource # ################################################ diff --git a/src/main/resources/config/i18n/client/ClientMessages.properties b/src/main/resources/config/i18n/client/ClientMessages.properties index e32772c8d..707d58241 100644 --- a/src/main/resources/config/i18n/client/ClientMessages.properties +++ b/src/main/resources/config/i18n/client/ClientMessages.properties @@ -254,9 +254,14 @@ managePageTableHeaderTextForSIARDSize=Size managePageTableHeaderTextForSIARDVersion=Version managePageTableHeaderTextForSIARDValidationStatus=Valid managePageTableHeaderTextForActions=Actions -managePageTableHeaderTextForSearchHits=Hits +managePageTableHeaderTextForSearchHits=Search managePageTableHeaderTextForDatabaseStatus=Status manageDatabasePageDescription=Databases available on the application +manageDatabaseNotLoadedDescription=Search results only include loaded databases, which excludes {0} databases that you have access to. +manageDatabaseNotSearchableDescription=Excluding {0} databases that you have access to from results because of their privacy settings. +manageDatabaseAllLoadedDescription=Search results include all available databases. +manageDatabaseAllSearchableDescription=Search results do not exclude any database due to their privacy settings. +manageDatabaseContactAdministratorDescription=Please contact the administrator to request databases to be loaded or made searchable. ############################################################################# # SIARD Home Page # ############################################################################# @@ -342,12 +347,15 @@ SIARDHomePageLabelForPermissionsTableGroupAttributeName=Attribute SIARDHomePageLabelForPermissionsTableGroupAttributeOperator=Operator SIARDHomePageLabelForPermissionsTableGroupAttributeValue=Value SIARDHomePageDialogTitleForPermissionsList=Permission list +SIARDHomePageDialogTitleForChangeAvailabilityToSearchAll=Availability for search all SIARDHomePageDialogDescriptionForPermissionsList=Select the required permissions to access this database. Admin users have full access to the database. SIARDHomePageDialogDetailsForPermissionsList=The list of groups is defined on the system configuration. SIARDHomePageDialogMessageForPermissionsList=Permissions updated successfully +SIARDHomePageDialogMessageForChangeAvailabilityToSearchAll=Availability for search all updated successfully SIARDHomePageDialogDetailsForUnknownPermission=Unknown permission SIARDHomePageDialogDetailsForUnknownPermissions=Could not find any groups associated with the following permissions: {0} SIARDHomePageDialogActionForOverridePermissions=Override all permissions +SIARDHomePageTitleForPermissionsSwitchButton=Available for search all SIARD=SIARD dialogReimportSIARDTitle=SIARD File Found dialogReimportSIARD=Do you want to reimport?