diff --git a/stroom-app/src/test/java/stroom/app/docs/GenerateDocumentReferenceDoc.java b/stroom-app/src/test/java/stroom/app/docs/GenerateDocumentReferenceDoc.java index b4ee120f5a4..a84d79bf591 100644 --- a/stroom-app/src/test/java/stroom/app/docs/GenerateDocumentReferenceDoc.java +++ b/stroom-app/src/test/java/stroom/app/docs/GenerateDocumentReferenceDoc.java @@ -96,7 +96,7 @@ void generateDocumentsReference(final ScanResult scanResult) { .filter(Objects::nonNull) .filter(docInfo -> DocumentTypeGroup.SYSTEM != docInfo.group - && DocumentTypeGroup.STRUCTURE != docInfo.group) + && DocumentTypeGroup.STRUCTURE != docInfo.group) .sequential() .collect(Collectors.groupingBy(DocInfo::group)) .entrySet() diff --git a/stroom-app/src/test/java/stroom/explorer/TestExplorerTree.java b/stroom-app/src/test/java/stroom/explorer/TestExplorerTree.java index b5a6b55c334..b5d4c1af06f 100644 --- a/stroom-app/src/test/java/stroom/explorer/TestExplorerTree.java +++ b/stroom-app/src/test/java/stroom/explorer/TestExplorerTree.java @@ -44,7 +44,7 @@ void testCreateTree() { explorerTreeDao.addChild(c1, newTreePojo("C11")); // Check create model. - explorerTreeDao.createModel(type -> null, 0, System.currentTimeMillis()); + explorerTreeDao.createModel(0, System.currentTimeMillis()); } private ExplorerTreeNode newTreePojo(final String name) { diff --git a/stroom-app/src/test/java/stroom/explorer/TestExplorerTreePerformance.java b/stroom-app/src/test/java/stroom/explorer/TestExplorerTreePerformance.java index 73ddde2e004..ba04c2e2716 100644 --- a/stroom-app/src/test/java/stroom/explorer/TestExplorerTreePerformance.java +++ b/stroom-app/src/test/java/stroom/explorer/TestExplorerTreePerformance.java @@ -114,7 +114,6 @@ void testLargeTreePerformance() { LOGGER.logDurationIfInfoEnabled(() -> { // Check create model. explorerTreeDao.createModel( - this::getIcon, 0, System.currentTimeMillis()); }, "Create model"); @@ -215,14 +214,6 @@ private void addChildren(final ExplorerTreeNode parent, final int depth, final i } } - private ExplorerTreeNode newSystemNode() { - final ExplorerTreeNode explorerTreeNode = new ExplorerTreeNode(); - explorerTreeNode.setName(ExplorerConstants.SYSTEM); - explorerTreeNode.setType(ExplorerConstants.SYSTEM_DOC_REF.getType()); - explorerTreeNode.setUuid(ExplorerConstants.SYSTEM_DOC_REF.getUuid()); - return explorerTreeNode; - } - private ExplorerTreeNode newTreeNode(final String name) { final ExplorerTreeNode explorerTreeNode = new ExplorerTreeNode(); explorerTreeNode.setName(name); @@ -230,13 +221,4 @@ private ExplorerTreeNode newTreeNode(final String name) { explorerTreeNode.setUuid(UUID.randomUUID().toString()); return explorerTreeNode; } - - private SvgImage getIcon(final String type) { - return typeToIconMap.computeIfAbsent(type, k -> - explorerActionHandlers.stream() - .filter(handler -> handler.getDocumentType().getType().equals(k)) - .map(handler -> handler.getDocumentType().getIcon()) - .findFirst() - .orElse(SvgImage.OK)); - } } diff --git a/stroom-core-client/src/main/java/stroom/analytics/client/AnalyticsPlugin.java b/stroom-core-client/src/main/java/stroom/analytics/client/AnalyticsPlugin.java index 1c1b1c3b121..0bb0ffd6476 100644 --- a/stroom-core-client/src/main/java/stroom/analytics/client/AnalyticsPlugin.java +++ b/stroom-core-client/src/main/java/stroom/analytics/client/AnalyticsPlugin.java @@ -52,6 +52,11 @@ public class AnalyticsPlugin extends DocumentPlugin { AnalyticRuleDoc.DOCUMENT_TYPE, "Analytic Rule", SvgImage.DOCUMENT_ANALYTIC_RULE); + public static final ClientDocumentType ANALYTIC_DOCUMENT_TYPE = new ClientDocumentType( + DocumentTypeGroup.SEARCH, + "Analytics", + "Analytics", + SvgImage.DOCUMENT_SEARCHABLE); private final Provider editorProvider; private final RestFactory restFactory; @@ -68,6 +73,7 @@ public AnalyticsPlugin(final EventBus eventBus, this.restFactory = restFactory; ClientDocumentTypeRegistry.put(DOCUMENT_TYPE); + ClientDocumentTypeRegistry.put(ANALYTIC_DOCUMENT_TYPE); } @Override diff --git a/stroom-core-client/src/main/java/stroom/document/client/ClientDocumentTypeRegistry.java b/stroom-core-client/src/main/java/stroom/document/client/ClientDocumentTypeRegistry.java index 5f96c9ce85c..9dc36a98569 100644 --- a/stroom-core-client/src/main/java/stroom/document/client/ClientDocumentTypeRegistry.java +++ b/stroom-core-client/src/main/java/stroom/document/client/ClientDocumentTypeRegistry.java @@ -2,7 +2,9 @@ import stroom.svg.shared.SvgImage; +import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; public class ClientDocumentTypeRegistry { @@ -20,8 +22,12 @@ public static ClientDocumentType get(final String type) { public static SvgImage getIcon(final String type) { final ClientDocumentType documentType = MAP.get(type); if (documentType == null) { - return null; + return SvgImage.DOCUMENT_SEARCHABLE; } return documentType.getIcon(); } + + public static Collection getTypes() { + return MAP.values(); + } } diff --git a/stroom-core-client/src/main/java/stroom/document/client/DocumentPluginEventManager.java b/stroom-core-client/src/main/java/stroom/document/client/DocumentPluginEventManager.java index 8459fb9ba6d..d3e39f602d1 100644 --- a/stroom-core-client/src/main/java/stroom/document/client/DocumentPluginEventManager.java +++ b/stroom-core-client/src/main/java/stroom/document/client/DocumentPluginEventManager.java @@ -463,11 +463,10 @@ protected void onBind() { final ExplorerNodePermissions permissions = documentPermissions.get(explorerNode); final String type = event.getDocumentType(); if (permissions.hasCreatePermission(type)) { - documentTypeCache.fetch(documentTypes -> { - GwtNullSafe.consume(documentTypes.getDocumentType(type), documentType -> { + final ClientDocumentType documentType = ClientDocumentTypeRegistry.get(type); + if (documentType != null) { fireShowCreateDocumentDialogEvent(documentType, explorerNode); - }); - }, explorerListener); + } } }, explorerListener); } @@ -1016,7 +1015,7 @@ private List createNewMenuItems(final ExplorerNode explorerNode, return children; } - private void fireShowCreateDocumentDialogEvent(final DocumentType documentType, + private void fireShowCreateDocumentDialogEvent(final ClientDocumentType documentType, final ExplorerNode explorerNode) { final Consumer newDocumentConsumer = newDocNode -> { final DocRef docRef = newDocNode.getDocRef(); @@ -1040,14 +1039,14 @@ private void fireShowCreateDocumentDialogEvent(final DocumentType documentType, private IconMenuItem createIconMenuItemFromDocumentType( final DocumentType documentType, final ExplorerNode explorerNode) { - + final ClientDocumentType clientDocumentType = ClientDocumentTypeRegistry.get(documentType.getType()); return new IconMenuItem.Builder() .priority(1) - .icon(documentType.getIcon()) - .text(documentType.getDisplayType()) + .icon(clientDocumentType.getIcon()) + .text(clientDocumentType.getDisplayType()) .command(() -> - fireShowCreateDocumentDialogEvent(documentType, explorerNode)) - .action(KeyBinding.getCreateActionByType(documentType.getType()).orElse(null)) + fireShowCreateDocumentDialogEvent(clientDocumentType, explorerNode)) + .action(KeyBinding.getCreateActionByType(clientDocumentType.getType()).orElse(null)) .build(); } diff --git a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/DocumentTypeCell.java b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/DocumentTypeCell.java index f3964bd6de4..e2b9d6fa126 100644 --- a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/DocumentTypeCell.java +++ b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/DocumentTypeCell.java @@ -1,7 +1,7 @@ package stroom.explorer.client.presenter; import stroom.cell.tickbox.client.TickBoxCell; -import stroom.explorer.shared.DocumentType; +import stroom.document.client.ClientDocumentType; import stroom.widget.util.client.SvgImageUtil; import com.google.gwt.cell.client.AbstractCell; @@ -11,7 +11,7 @@ import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.safehtml.shared.SafeHtmlUtils; -public class DocumentTypeCell extends AbstractCell { +public class DocumentTypeCell extends AbstractCell { private static Template template; @@ -50,7 +50,7 @@ public DocumentTypeCell(final DocumentTypeSelectionModel selectionModel) { // } @Override - public void render(final Context context, final DocumentType item, final SafeHtmlBuilder sb) { + public void render(final Context context, final ClientDocumentType item, final SafeHtmlBuilder sb) { if (item != null) { final SafeHtml iconHtml = SvgImageUtil.toSafeHtml(item.getIcon(), "explorerCell-icon"); diff --git a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/DocumentTypeSelectionModel.java b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/DocumentTypeSelectionModel.java index 174689ecfba..1075f23f3b2 100644 --- a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/DocumentTypeSelectionModel.java +++ b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/DocumentTypeSelectionModel.java @@ -1,8 +1,9 @@ package stroom.explorer.client.presenter; import stroom.cell.tickbox.shared.TickBoxState; -import stroom.explorer.shared.DocumentType; +import stroom.document.client.ClientDocumentType; public interface DocumentTypeSelectionModel { - TickBoxState getState(DocumentType type); + + TickBoxState getState(ClientDocumentType type); } diff --git a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindInContentResultCell.java b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindInContentResultCell.java index ebb72f063c2..9b7a1b32daa 100644 --- a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindInContentResultCell.java +++ b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindInContentResultCell.java @@ -17,6 +17,8 @@ package stroom.explorer.client.presenter; import stroom.docref.DocContentMatch; +import stroom.document.client.ClientDocumentType; +import stroom.document.client.ClientDocumentTypeRegistry; import stroom.explorer.shared.FindInContentResult; import stroom.widget.util.client.SafeHtmlUtil; import stroom.widget.util.client.SvgImageUtil; @@ -50,10 +52,12 @@ public void render(final Context context, final FindInContentResult value, final final SafeHtmlBuilder sub = new SafeHtmlBuilder(); // Add icon - if (value.getIcon() != null) { + final ClientDocumentType documentType = ClientDocumentTypeRegistry.get( + value.getDocContentMatch().getDocRef().getType()); + if (documentType != null && documentType.getIcon() != null) { main.append(SvgImageUtil.toSafeHtml( match.getDocRef().getType(), - value.getIcon(), + documentType.getIcon(), getCellClassName() + "-icon", "svgIcon")); } diff --git a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindResultCell.java b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindResultCell.java index b5603ccb515..f675c3e2693 100644 --- a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindResultCell.java +++ b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindResultCell.java @@ -17,6 +17,8 @@ package stroom.explorer.client.presenter; import stroom.docref.DocRef; +import stroom.document.client.ClientDocumentType; +import stroom.document.client.ClientDocumentTypeRegistry; import stroom.explorer.shared.FindResult; import stroom.widget.util.client.SafeHtmlUtil; import stroom.widget.util.client.SvgImageUtil; @@ -50,10 +52,11 @@ public void render(final Context context, final FindResult value, final SafeHtml final SafeHtmlBuilder sub = new SafeHtmlBuilder(); // Add icon - if (value.getIcon() != null) { + final ClientDocumentType documentType = ClientDocumentTypeRegistry.get(docRef.getType()); + if (documentType != null && documentType.getIcon() != null) { main.append(SvgImageUtil.toSafeHtml( docRef.getType(), - value.getIcon(), + documentType.getIcon(), getCellClassName() + "-icon", "svgIcon")); } diff --git a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindResultWithPermissionsCell.java b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindResultWithPermissionsCell.java index 9570388e988..b536d9df04e 100644 --- a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindResultWithPermissionsCell.java +++ b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/FindResultWithPermissionsCell.java @@ -17,6 +17,8 @@ package stroom.explorer.client.presenter; import stroom.docref.DocRef; +import stroom.document.client.ClientDocumentType; +import stroom.document.client.ClientDocumentTypeRegistry; import stroom.explorer.shared.FindResult; import stroom.explorer.shared.FindResultWithPermissions; import stroom.security.shared.DocumentUserPermissions; @@ -58,10 +60,11 @@ public void render(final Context context, final FindResultWithPermissions v, fin final SafeHtmlBuilder sub = new SafeHtmlBuilder(); // Add icon - if (value.getIcon() != null) { + final ClientDocumentType documentType = ClientDocumentTypeRegistry.get(docRef.getType()); + if (documentType != null && documentType.getIcon() != null) { main.append(SvgImageUtil.toSafeHtml( docRef.getType(), - value.getIcon(), + documentType.getIcon(), getCellClassName() + "-icon", "svgIcon")); } diff --git a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/TypeFilterPresenter.java b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/TypeFilterPresenter.java index 35a1cdbd12c..e100085663d 100644 --- a/stroom-core-client/src/main/java/stroom/explorer/client/presenter/TypeFilterPresenter.java +++ b/stroom-core-client/src/main/java/stroom/explorer/client/presenter/TypeFilterPresenter.java @@ -22,8 +22,9 @@ import stroom.data.client.event.HasDataSelectionHandlers; import stroom.data.grid.client.MyDataGrid; import stroom.data.table.client.MyCellTable; +import stroom.document.client.ClientDocumentType; +import stroom.document.client.ClientDocumentTypeRegistry; import stroom.explorer.client.presenter.TypeFilterPresenter.TypeFilterView; -import stroom.explorer.shared.DocumentType; import stroom.explorer.shared.DocumentTypeGroup; import stroom.explorer.shared.DocumentTypes; import stroom.svg.shared.SvgImage; @@ -54,6 +55,7 @@ import java.util.Comparator; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.function.Consumer; @@ -64,16 +66,16 @@ public class TypeFilterPresenter extends MyPresenterWidget DocumentTypeSelectionModel { private final Set selected = new HashSet<>(); - private List visibleTypes; + private List visibleTypes; private static final String SELECT_ALL_OR_NONE_TEXT = "All / None"; - static final DocumentType SELECT_ALL_OR_NONE_DOCUMENT_TYPE = new DocumentType( + static final ClientDocumentType SELECT_ALL_OR_NONE_DOCUMENT_TYPE = new ClientDocumentType( DocumentTypeGroup.SYSTEM, SELECT_ALL_OR_NONE_TEXT, SELECT_ALL_OR_NONE_TEXT, SvgImage.DOCUMENT_SELECT_ALL_OR_NONE); - private final CellTable cellTable; + private final CellTable cellTable; private final TypeFilterSelectionEventManager typeFilterSelectionEventManager; private Consumer filterStateConsumer = null; @@ -95,7 +97,7 @@ public TypeFilterPresenter(final EventBus eventBus, final TypeFilterView view) { cellTable.addColumn(getTickBoxColumn()); cellTable.setSkipRowHoverCheck(true); - MySingleSelectionModel selectionModel = new MySingleSelectionModel<>(); + MySingleSelectionModel selectionModel = new MySingleSelectionModel<>(); typeFilterSelectionEventManager = new TypeFilterSelectionEventManager(cellTable); cellTable.setSelectionModel(selectionModel, typeFilterSelectionEventManager); @@ -131,13 +133,13 @@ private void hideSelf() { .fire(); } - public void execute(final DocumentType documentType) { + public void execute(final ClientDocumentType documentType) { if (documentType != null) { toggle(documentType); } } - public void setData(final List items) { + public void setData(final List items) { cellTable.setRowData(0, items); cellTable.setRowCount(items.size()); } @@ -153,7 +155,9 @@ public void focus() { public void setDocumentTypes(final DocumentTypes documentTypes) { visibleTypes = documentTypes.getVisibleTypes() .stream() - .sorted(Comparator.comparing(DocumentType::getDisplayType)) + .map(documentType -> ClientDocumentTypeRegistry.get(documentType.getType())) + .filter(Objects::nonNull) + .sorted(Comparator.comparing(ClientDocumentType::getDisplayType)) .collect(Collectors.toList()); selectAll(); refreshView(); @@ -165,7 +169,7 @@ public void setDocumentTypes(final DocumentTypes documentTypes) { public Optional> getIncludedTypes() { if (visibleTypes != null) { final Set visibleTypeNames = visibleTypes.stream() - .map(DocumentType::getType) + .map(ClientDocumentType::getType) .collect(Collectors.toSet()); if (selected.containsAll(visibleTypeNames)) { // All selected so return null to save the back end pointlessly filtering on them. @@ -190,7 +194,7 @@ public HandlerRegistration addDataSelectionHandler(final DataSelectionHandler selectableTypes = new ArrayList<>(visibleTypes); + List selectableTypes = new ArrayList<>(visibleTypes); selectableTypes.add(0, SELECT_ALL_OR_NONE_DOCUMENT_TYPE); // To refresh the view we need to set the row data again. @@ -217,7 +221,7 @@ private void toggleSelectAll() { } } - private void toggle(final DocumentType type) { + private void toggle(final ClientDocumentType type) { if (type.equals(SELECT_ALL_OR_NONE_DOCUMENT_TYPE)) { toggleSelectAll(); } else { @@ -240,7 +244,7 @@ private void toggle(final DocumentType type) { } @Override - public TickBoxState getState(final DocumentType type) { + public TickBoxState getState(final ClientDocumentType type) { if (type.equals(SELECT_ALL_OR_NONE_DOCUMENT_TYPE)) { if (selected.size() == 0) { return TickBoxState.UNTICK; @@ -255,10 +259,10 @@ public TickBoxState getState(final DocumentType type) { return TickBoxState.UNTICK; } - private Column getTickBoxColumn() { - return new Column(new DocumentTypeCell(this)) { + private Column getTickBoxColumn() { + return new Column(new DocumentTypeCell(this)) { @Override - public DocumentType getValue(final DocumentType documentType) { + public ClientDocumentType getValue(final ClientDocumentType documentType) { return documentType; } }; @@ -277,24 +281,24 @@ public interface TypeFilterView extends View { // -------------------------------------------------------------------------------- - private class TypeFilterSelectionEventManager extends CheckListSelectionEventManager { + private class TypeFilterSelectionEventManager extends CheckListSelectionEventManager { - public TypeFilterSelectionEventManager(final AbstractHasData cellTable) { + public TypeFilterSelectionEventManager(final AbstractHasData cellTable) { super(cellTable); } @Override - protected void onToggle(final DocumentType item) { + protected void onToggle(final ClientDocumentType item) { execute(item); } @Override - protected void onClose(final CellPreviewEvent e) { + protected void onClose(final CellPreviewEvent e) { escape(); } @Override - protected void onSelectAll(final CellPreviewEvent e) { + protected void onSelectAll(final CellPreviewEvent e) { toggleSelectAll(); refreshView(); DataSelectionEvent.fire( diff --git a/stroom-core-client/src/main/java/stroom/explorer/client/view/ExplorerCell.java b/stroom-core-client/src/main/java/stroom/explorer/client/view/ExplorerCell.java index 6f884399165..80dc3f16ea2 100644 --- a/stroom-core-client/src/main/java/stroom/explorer/client/view/ExplorerCell.java +++ b/stroom-core-client/src/main/java/stroom/explorer/client/view/ExplorerCell.java @@ -2,6 +2,8 @@ import stroom.cell.tickbox.client.TickBoxCell; import stroom.cell.tickbox.shared.TickBoxState; +import stroom.document.client.ClientDocumentType; +import stroom.document.client.ClientDocumentTypeRegistry; import stroom.explorer.client.presenter.TickBoxSelectionModel; import stroom.explorer.shared.ExplorerConstants; import stroom.explorer.shared.ExplorerNode; @@ -103,11 +105,12 @@ public void render(final Context context, final ExplorerNode node, final SafeHtm content.append(tickBoxHtml); } - if (node.getIcon() != null) { + final ClientDocumentType documentType = ClientDocumentTypeRegistry.get(node.getType()); + if (documentType != null && documentType.getIcon() != null) { // Add icon final SafeHtml iconSafeHtml = SvgImageUtil.toSafeHtml( - node.getType(), - node.getIcon(), + documentType.getDisplayType(), + documentType.getIcon(), getCellClassName() + "-icon"); final SafeHtmlBuilder builder = new SafeHtmlBuilder().append(iconSafeHtml); diff --git a/stroom-core-client/src/main/java/stroom/importexport/client/presenter/DependenciesPresenter.java b/stroom-core-client/src/main/java/stroom/importexport/client/presenter/DependenciesPresenter.java index f1d32f451b0..72484b287db 100644 --- a/stroom-core-client/src/main/java/stroom/importexport/client/presenter/DependenciesPresenter.java +++ b/stroom-core-client/src/main/java/stroom/importexport/client/presenter/DependenciesPresenter.java @@ -26,6 +26,7 @@ import stroom.dispatch.client.RestErrorHandler; import stroom.dispatch.client.RestFactory; import stroom.docref.DocRef; +import stroom.document.client.ClientDocumentTypeRegistry; import stroom.document.client.event.DeleteDocumentEvent; import stroom.document.client.event.OpenDocumentEvent; import stroom.explorer.client.event.LocateDocEvent; @@ -86,8 +87,6 @@ public class DependenciesPresenter private final MyDataGrid dataGrid; private final MenuPresenter menuPresenter; - // Holds all the doc type icons - private Map typeToSvgMap = new HashMap<>(); private Set openableTypes = new HashSet<>(); @Inject @@ -287,26 +286,6 @@ private void refreshDocTypeIcons() { .stream() .map(DocumentType::getType) .collect(Collectors.toSet()); - - typeToSvgMap = documentTypes - .getTypes() - .stream() - .collect(Collectors.toMap( - DocumentType::getType, - DocumentType::getIcon)); - - // Special case for Searchable as it is not a normal doc type - // Not ideal defining it here but adding it fetchDocumentTypes causes problems - // with the explorer context menus. - typeToSvgMap.putIfAbsent( - "Searchable", - SvgImage.DOCUMENT_SEARCHABLE); - typeToSvgMap.putIfAbsent( - "Analytics", - SvgImage.DOCUMENT_SEARCHABLE); - typeToSvgMap.putIfAbsent( - "ProcessorFilter", - SvgImage.FILTER); }) .taskMonitorFactory(this) .exec(); @@ -346,9 +325,9 @@ private String getValue(final Dependency row, private Preset getDocTypeIcon(final DocRef docRef) { if (docRef != null && docRef.getType() != null && !docRef.getType().isEmpty()) { - final SvgImage svgPreset = typeToSvgMap.get(docRef.getType()); - if (svgPreset != null) { - return new Preset(svgPreset, docRef.getType(), true); + final SvgImage icon = ClientDocumentTypeRegistry.getIcon(docRef.getType()); + if (icon != null) { + return new Preset(icon, docRef.getType(), true); } else { return SvgPresets.ALERT.title("Unknown Document Type"); } diff --git a/stroom-core-client/src/main/java/stroom/pipeline/client/PipelinePlugin.java b/stroom-core-client/src/main/java/stroom/pipeline/client/PipelinePlugin.java index 2a5e33fb70f..6c3eb901345 100644 --- a/stroom-core-client/src/main/java/stroom/pipeline/client/PipelinePlugin.java +++ b/stroom-core-client/src/main/java/stroom/pipeline/client/PipelinePlugin.java @@ -56,6 +56,18 @@ public class PipelinePlugin extends DocumentPlugin { PipelineDoc.DOCUMENT_TYPE, SvgImage.DOCUMENT_PIPELINE); + public static final ClientDocumentType PROCESSOR_DOCUMENT_TYPE = new ClientDocumentType( + DocumentTypeGroup.DATA_PROCESSING, + "Processor", + "Processor", + SvgImage.DOCUMENT_PIPELINE); + + public static final ClientDocumentType PROCESSOR_FILTER_DOCUMENT_TYPE = new ClientDocumentType( + DocumentTypeGroup.DATA_PROCESSING, + "ProcessorFilter", + "Processor Filter", + SvgImage.FILTER); + private final Provider editorProvider; private final RestFactory restFactory; @@ -71,6 +83,8 @@ public PipelinePlugin(final EventBus eventBus, this.restFactory = restFactory; ClientDocumentTypeRegistry.put(DOCUMENT_TYPE); + ClientDocumentTypeRegistry.put(PROCESSOR_DOCUMENT_TYPE); + ClientDocumentTypeRegistry.put(PROCESSOR_FILTER_DOCUMENT_TYPE); } @Override diff --git a/stroom-core-client/src/main/java/stroom/query/client/presenter/QueryHelpSelectionItem.java b/stroom-core-client/src/main/java/stroom/query/client/presenter/QueryHelpSelectionItem.java index 5af0e3acaa2..0e5fb5ea837 100644 --- a/stroom-core-client/src/main/java/stroom/query/client/presenter/QueryHelpSelectionItem.java +++ b/stroom-core-client/src/main/java/stroom/query/client/presenter/QueryHelpSelectionItem.java @@ -16,6 +16,8 @@ package stroom.query.client.presenter; +import stroom.document.client.ClientDocumentType; +import stroom.document.client.ClientDocumentTypeRegistry; import stroom.item.client.SelectionItem; import stroom.query.shared.QueryHelpRow; import stroom.svg.shared.SvgImage; @@ -37,7 +39,7 @@ public String getLabel() { @Override public SvgImage getIcon() { - return queryHelpRow.getIcon(); + return ClientDocumentTypeRegistry.getIcon(queryHelpRow.getDocumentType()); } @Override @@ -74,7 +76,7 @@ public int hashCode() { @Override public String toString() { return "QueryHelpSelectionItem{" + - "fieldInfo=" + queryHelpRow + - '}'; + "fieldInfo=" + queryHelpRow + + '}'; } } diff --git a/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentCreatePermissionsListPresenter.java b/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentCreatePermissionsListPresenter.java index 90851dfeba4..7931af2dd50 100644 --- a/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentCreatePermissionsListPresenter.java +++ b/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentCreatePermissionsListPresenter.java @@ -21,6 +21,8 @@ import stroom.data.client.presenter.ColumnSizeConstants; import stroom.data.grid.client.DataGridSelectionEventManager; import stroom.data.grid.client.MyDataGrid; +import stroom.document.client.ClientDocumentType; +import stroom.document.client.ClientDocumentTypeRegistry; import stroom.explorer.client.presenter.DocumentTypeCache; import stroom.explorer.shared.DocumentType; import stroom.explorer.shared.DocumentTypes; @@ -319,10 +321,12 @@ public Set getExplicitCreatePermissions() { private Preset getDocTypeIcon(final DocumentType documentType) { if (documentType != null) { - return new Preset(documentType.getIcon(), documentType.getDisplayType(), true); - } else { - return null; + final ClientDocumentType clientDocumentType = ClientDocumentTypeRegistry.get(documentType.getType()); + if (clientDocumentType != null) { + return new Preset(clientDocumentType.getIcon(), clientDocumentType.getDisplayType(), true); + } } + return null; } public interface DocumentCreatePermissionsListView extends View { diff --git a/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentUserPermissionsListPresenter.java b/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentUserPermissionsListPresenter.java index 897d4019b20..97a5dc92d09 100644 --- a/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentUserPermissionsListPresenter.java +++ b/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentUserPermissionsListPresenter.java @@ -25,6 +25,8 @@ import stroom.dispatch.client.RestErrorHandler; import stroom.dispatch.client.RestFactory; import stroom.docref.DocRef; +import stroom.document.client.ClientDocumentType; +import stroom.document.client.ClientDocumentTypeRegistry; import stroom.explorer.client.presenter.DocumentTypeCache; import stroom.explorer.shared.DocumentType; import stroom.explorer.shared.DocumentTypes; @@ -265,7 +267,7 @@ private void setupColumns(final DocumentTypes documentTypes) { // Explicit doc create types dataGrid.addResizableColumn( DataGridUtil.safeHtmlColumn((DocumentUserPermissions row) -> - permissionsToExplicitTypeIcons(row, documentTypes, docTypeCount)), + permissionsToExplicitTypeIcons(row, docTypeCount)), DataGridUtil.headingBuilder("Explicit Create Document Types") .withToolTip("The document types that this user/group has explicit permission to create. " + "Ignores inherited permissions. 'ALL' will be displayed if the user/group " + @@ -276,7 +278,7 @@ private void setupColumns(final DocumentTypes documentTypes) { // Effective doc create types dataGrid.addResizableColumn( DataGridUtil.safeHtmlColumn((DocumentUserPermissions row) -> - permissionsToEffectiveTypeIcons(row, documentTypes, docTypeCount)), + permissionsToEffectiveTypeIcons(row, docTypeCount)), DataGridUtil.headingBuilder("Effective Create Document Types") .withToolTip("The document types that this user/group has permission to create. " + "Includes both explicit and inherited permissions. 'ALL' will be " + @@ -291,35 +293,32 @@ private void setupColumns(final DocumentTypes documentTypes) { } public SafeHtml permissionsToExplicitTypeIcons(final DocumentUserPermissions row, - final DocumentTypes documentTypes, final int docTypeCount) { final Set explicit = row .getDocumentCreatePermissions(); - return permissionsToTypeIcons(explicit, documentTypes, docTypeCount); + return permissionsToTypeIcons(explicit, docTypeCount); } public SafeHtml permissionsToEffectiveTypeIcons(final DocumentUserPermissions row, - final DocumentTypes documentTypes, final int docTypeCount) { final Set effective = new HashSet<>(GwtNullSafe.set(row .getDocumentCreatePermissions())); effective.addAll(GwtNullSafe.set(row.getInheritedDocumentCreatePermissions())); - return permissionsToTypeIcons(effective, documentTypes, docTypeCount); + return permissionsToTypeIcons(effective, docTypeCount); } public SafeHtml permissionsToTypeIcons(final Set createTypes, - final DocumentTypes documentTypes, final int docTypeCount) { if ((GwtNullSafe.hasItems(createTypes))) { if (GwtNullSafe.size(createTypes) == docTypeCount) { return SafeHtmlUtils.fromTrustedString("ALL"); } else { //noinspection SimplifyStreamApiCallChains // Cos GWT - final List typeIcons = documentTypes.getTypes() + final List typeIcons = ClientDocumentTypeRegistry.getTypes() .stream() .filter(docType -> createTypes.contains(docType.getType())) - .sorted(Comparator.comparing(DocumentType::getType)) + .sorted(Comparator.comparing(ClientDocumentType::getType)) .collect(Collectors.toList()); return HtmlBuilder.builder() diff --git a/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentUserPermissionsPresenter.java b/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentUserPermissionsPresenter.java index eebaa91e3f0..a61d14bace4 100644 --- a/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentUserPermissionsPresenter.java +++ b/stroom-core-client/src/main/java/stroom/security/client/presenter/DocumentUserPermissionsPresenter.java @@ -19,9 +19,9 @@ import stroom.content.client.presenter.ContentTabPresenter; import stroom.docref.DocRef; +import stroom.document.client.ClientDocumentType; +import stroom.document.client.ClientDocumentTypeRegistry; import stroom.explorer.client.presenter.DocumentTypeCache; -import stroom.explorer.shared.DocumentType; -import stroom.explorer.shared.DocumentTypes; import stroom.item.client.SelectionBox; import stroom.security.client.presenter.DocumentUserPermissionsPresenter.DocumentUserPermissionsView; import stroom.security.shared.DocumentPermission; @@ -161,11 +161,9 @@ private void updateDetails() { // Fetch detailed permissions report. if (selection != null) { docPermissionClient.getDocUserPermissionsReport(docRef, selection.getUserRef(), response -> { - documentTypeCache.fetch(documentTypes -> { - final SafeHtml details = getDetails(documentTypes, response); - getView().setUserRef(selection.getUserRef()); - getView().setDetails(details); - }, this); + final SafeHtml details = getDetails(response); + getView().setUserRef(selection.getUserRef()); + getView().setDetails(details); }, this); } else { getView().setUserRef(null); @@ -173,8 +171,7 @@ private void updateDetails() { } } - private SafeHtml getDetails(final DocumentTypes documentTypes, - final DocumentUserPermissionsReport permissions) { + private SafeHtml getDetails(final DocumentUserPermissionsReport permissions) { DocumentPermission maxPermission = null; DescriptionBuilder sb = new DescriptionBuilder(); @@ -220,7 +217,7 @@ private SafeHtml getDetails(final DocumentTypes documentTypes, } final Set explicitCreatePerms = permissions.getExplicitCreatePermissions(); - final SafeHtml explicitTypesHtml = docTypesToSortedDisplayList(explicitCreatePerms, documentTypes); + final SafeHtml explicitTypesHtml = docTypesToSortedDisplayList(explicitCreatePerms); if (explicitTypesHtml != null) { sb.addNewLine(); @@ -242,7 +239,7 @@ private SafeHtml getDetails(final DocumentTypes documentTypes, .forEach(entry -> { final String type = entry.getKey(); final List path = entry.getValue(); - final DocumentType docType = documentTypes.getDocumentType(type); + final ClientDocumentType docType = ClientDocumentTypeRegistry.get(type); if (docType != null && GwtNullSafe.hasItems(path)) { final SvgImage icon = docType.getIcon(); final String pathStr = String.join(" & ", path); @@ -272,19 +269,18 @@ private SafeHtml getDetails(final DocumentTypes documentTypes, /** * May return null */ - private SafeHtml docTypesToSortedDisplayList(final Set types, - final DocumentTypes documentTypes) { + private SafeHtml docTypesToSortedDisplayList(final Set types) { if (GwtNullSafe.hasItems(types)) { //noinspection SimplifyStreamApiCallChains // Cos GWT - final List sortedDocTypes = documentTypes.getTypes() + final List sortedDocTypes = ClientDocumentTypeRegistry.getTypes() .stream() .filter(docType -> types.contains(docType.getType())) - .sorted(Comparator.comparing(DocumentType::getType)) + .sorted(Comparator.comparing(ClientDocumentType::getType)) .collect(Collectors.toList()); if (GwtNullSafe.hasItems(sortedDocTypes)) { final HtmlBuilder htmlBuilder = HtmlBuilder.builder(); for (int i = 0; i < sortedDocTypes.size(); i++) { - final DocumentType docType = sortedDocTypes.get(i); + final ClientDocumentType docType = sortedDocTypes.get(i); final SvgImage icon = docType.getIcon(); htmlBuilder.br() .span(spanBuilder -> spanBuilder diff --git a/stroom-core-shared/src/main/java/stroom/explorer/shared/ExplorerConstants.java b/stroom-core-shared/src/main/java/stroom/explorer/shared/ExplorerConstants.java index febe4bd7292..9b27b02d5eb 100644 --- a/stroom-core-shared/src/main/java/stroom/explorer/shared/ExplorerConstants.java +++ b/stroom-core-shared/src/main/java/stroom/explorer/shared/ExplorerConstants.java @@ -17,7 +17,6 @@ public final class ExplorerConstants { public static final ExplorerNode SYSTEM_NODE = ExplorerNode.builder() .docRef(SYSTEM_DOC_REF) .rootNodeUuid(SYSTEM_DOC_REF.getUuid()) - .icon(SvgImage.DOCUMENT_SYSTEM) .build(); public static final String FAVOURITES = "Favourites"; @@ -26,7 +25,6 @@ public final class ExplorerConstants { public static final ExplorerNode FAVOURITES_NODE = ExplorerNode.builder() .docRef(FAVOURITES_DOC_REF) .rootNodeUuid(FAVOURITES_DOC_REF.getUuid()) - .icon(SvgImage.FAVOURITES) .build(); private ExplorerConstants() { diff --git a/stroom-core-shared/src/main/java/stroom/explorer/shared/ExplorerNode.java b/stroom-core-shared/src/main/java/stroom/explorer/shared/ExplorerNode.java index f08d0c86575..02533d566e6 100644 --- a/stroom-core-shared/src/main/java/stroom/explorer/shared/ExplorerNode.java +++ b/stroom-core-shared/src/main/java/stroom/explorer/shared/ExplorerNode.java @@ -18,7 +18,6 @@ import stroom.docref.DocRef; import stroom.docref.HasDisplayValue; -import stroom.svg.shared.SvgImage; import stroom.util.shared.GwtNullSafe; import stroom.util.shared.Severity; @@ -60,8 +59,6 @@ public class ExplorerNode implements HasDisplayValue { @JsonProperty private final int depth; @JsonProperty - private final SvgImage icon; - @JsonProperty private final List children; @JsonProperty private final String rootNodeUuid; @@ -86,7 +83,6 @@ public ExplorerNode(@JsonProperty("type") final String type, @JsonProperty("name") final String name, @JsonProperty("tags") final Set tags, @JsonProperty("depth") final int depth, - @JsonProperty("icon") final SvgImage icon, @JsonProperty("children") final List children, @JsonProperty("rootNodeUuid") final String rootNodeUuid, @JsonProperty("uniqueKey") final ExplorerNodeKey uniqueKey, @@ -97,7 +93,6 @@ public ExplorerNode(@JsonProperty("type") final String type, this.name = name; this.tags = tags; this.depth = depth; - this.icon = icon; this.children = GwtNullSafe.get(children, Collections::unmodifiableList); this.rootNodeUuid = rootNodeUuid; this.uniqueKey = uniqueKey; @@ -138,10 +133,6 @@ public int getDepth() { return depth; } - public SvgImage getIcon() { - return icon; - } - public List getChildren() { return children; } @@ -336,7 +327,6 @@ public static final class Builder { private String name; private Set tags; private int depth; - private SvgImage icon; private List children; private String rootNodeUuid; private List nodeInfoList; @@ -352,7 +342,6 @@ private Builder(final ExplorerNode explorerNode) { this.name = explorerNode.name; this.tags = explorerNode.tags; this.depth = explorerNode.depth; - this.icon = explorerNode.icon; this.children = GwtNullSafe.get(explorerNode.children, ArrayList::new); this.rootNodeUuid = explorerNode.rootNodeUuid; this.nodeInfoList = GwtNullSafe.get(explorerNode.nodeInfoList, ArrayList::new); @@ -432,11 +421,6 @@ public Builder depth(final int depth) { return this; } - public Builder icon(final SvgImage icon) { - this.icon = icon; - return this; - } - public Builder children(final List children) { this.children = children; return this; @@ -599,7 +583,6 @@ public ExplorerNode build() { name, tags, depth, - icon, children, rootNodeUuid, new ExplorerNodeKey(type, uuid, rootNodeUuid), diff --git a/stroom-core-shared/src/main/java/stroom/explorer/shared/FindInContentResult.java b/stroom-core-shared/src/main/java/stroom/explorer/shared/FindInContentResult.java index aec88bf8863..f894ff5e4cb 100644 --- a/stroom-core-shared/src/main/java/stroom/explorer/shared/FindInContentResult.java +++ b/stroom-core-shared/src/main/java/stroom/explorer/shared/FindInContentResult.java @@ -17,7 +17,6 @@ package stroom.explorer.shared; import stroom.docref.DocContentMatch; -import stroom.svg.shared.SvgImage; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; @@ -34,18 +33,14 @@ public class FindInContentResult { @JsonProperty private final String path; @JsonProperty - private final SvgImage icon; - @JsonProperty private final boolean isFavourite; @JsonCreator public FindInContentResult(@JsonProperty("docContentMatch") final DocContentMatch docContentMatch, @JsonProperty("path") final String path, - @JsonProperty("icon") final SvgImage icon, @JsonProperty("isFavourite") final boolean isFavourite) { this.docContentMatch = docContentMatch; this.path = path; - this.icon = icon; this.isFavourite = isFavourite; } @@ -57,10 +52,6 @@ public String getPath() { return path; } - public SvgImage getIcon() { - return icon; - } - public boolean getIsFavourite() { return isFavourite; } @@ -75,14 +66,13 @@ public boolean equals(final Object o) { } final FindInContentResult that = (FindInContentResult) o; return isFavourite == that.isFavourite && - Objects.equals(docContentMatch, that.docContentMatch) && - Objects.equals(path, that.path) && - Objects.equals(icon, that.icon); + Objects.equals(docContentMatch, that.docContentMatch) && + Objects.equals(path, that.path); } @Override public int hashCode() { - return Objects.hash(docContentMatch, path, icon, isFavourite); + return Objects.hash(docContentMatch, path, isFavourite); } public static Builder builder() { @@ -101,7 +91,6 @@ public static final class Builder { private DocContentMatch docContentMatch; private String path; - private SvgImage icon; private boolean isFavourite; private Builder() { @@ -110,7 +99,6 @@ private Builder() { private Builder(final FindInContentResult findInContentResult) { this.docContentMatch = findInContentResult.docContentMatch; this.path = findInContentResult.path; - this.icon = findInContentResult.icon; this.isFavourite = findInContentResult.isFavourite; } @@ -124,11 +112,6 @@ public Builder path(final String path) { return this; } - public Builder icon(final SvgImage icon) { - this.icon = icon; - return this; - } - public Builder isFavourite(final boolean isFavourite) { this.isFavourite = isFavourite; return this; @@ -138,7 +121,6 @@ public FindInContentResult build() { return new FindInContentResult( docContentMatch, path, - icon, isFavourite); } } diff --git a/stroom-core-shared/src/main/java/stroom/explorer/shared/FindResult.java b/stroom-core-shared/src/main/java/stroom/explorer/shared/FindResult.java index 3f1253c335d..ac8ccc6bb17 100644 --- a/stroom-core-shared/src/main/java/stroom/explorer/shared/FindResult.java +++ b/stroom-core-shared/src/main/java/stroom/explorer/shared/FindResult.java @@ -17,7 +17,6 @@ package stroom.explorer.shared; import stroom.docref.DocRef; -import stroom.svg.shared.SvgImage; import stroom.util.shared.GwtNullSafe; import com.fasterxml.jackson.annotation.JsonCreator; @@ -34,16 +33,12 @@ public class FindResult { private final DocRef docRef; @JsonProperty private final String path; - @JsonProperty - private final SvgImage icon; @JsonCreator public FindResult(@JsonProperty("docRef") final DocRef docRef, - @JsonProperty("path") final String path, - @JsonProperty("icon") final SvgImage icon) { + @JsonProperty("path") final String path) { this.docRef = docRef; this.path = path; - this.icon = icon; } public DocRef getDocRef() { @@ -57,10 +52,6 @@ public String getPath() { return path; } - public SvgImage getIcon() { - return icon; - } - @Override public boolean equals(final Object o) { if (this == o) { @@ -71,13 +62,12 @@ public boolean equals(final Object o) { } final FindResult that = (FindResult) o; return Objects.equals(docRef, that.docRef) && - Objects.equals(path, that.path) && - Objects.equals(icon, that.icon); + Objects.equals(path, that.path); } @Override public int hashCode() { - return Objects.hash(docRef, path, icon); + return Objects.hash(docRef, path); } public static Builder builder() { @@ -100,7 +90,6 @@ public static final class Builder { private DocRef docRef; private String path; - private SvgImage icon; private Builder() { } @@ -108,7 +97,6 @@ private Builder() { private Builder(final FindResult findResult) { this.docRef = findResult.docRef; this.path = findResult.path; - this.icon = findResult.icon; } public Builder docRef(final DocRef docRef) { @@ -121,16 +109,10 @@ public Builder path(final String path) { return this; } - public Builder icon(final SvgImage icon) { - this.icon = icon; - return this; - } - public FindResult build() { return new FindResult( docRef, - path, - icon); + path); } } } diff --git a/stroom-core-shared/src/main/java/stroom/query/shared/QueryHelpRow.java b/stroom-core-shared/src/main/java/stroom/query/shared/QueryHelpRow.java index 3e3a01e7535..15908ac5439 100644 --- a/stroom-core-shared/src/main/java/stroom/query/shared/QueryHelpRow.java +++ b/stroom-core-shared/src/main/java/stroom/query/shared/QueryHelpRow.java @@ -16,8 +16,6 @@ package stroom.query.shared; -import stroom.svg.shared.SvgImage; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -35,7 +33,7 @@ public class QueryHelpRow { @JsonProperty private final boolean hasChildren; @JsonProperty - private final SvgImage icon; + private final String documentType; @JsonProperty private final String iconTooltip; @JsonProperty @@ -47,14 +45,14 @@ public class QueryHelpRow { public QueryHelpRow(@JsonProperty("type") final QueryHelpType type, @JsonProperty("id") final String id, @JsonProperty("hasChildren") final boolean hasChildren, - @JsonProperty("icon") final SvgImage icon, + @JsonProperty("documentType") final String documentType, @JsonProperty("iconTooltip") final String iconTooltip, @JsonProperty("title") final String title, @JsonProperty("data") final QueryHelpData data) { this.type = type; this.id = id; this.hasChildren = hasChildren; - this.icon = icon; + this.documentType = documentType; this.iconTooltip = iconTooltip; this.title = title; this.data = data; @@ -76,8 +74,8 @@ public String getTitle() { return title; } - public SvgImage getIcon() { - return icon; + public String getDocumentType() { + return documentType; } public String getIconTooltip() { @@ -121,7 +119,7 @@ public static class Builder { private QueryHelpType type = QueryHelpType.TITLE; private String id; private boolean hasChildren; - private SvgImage icon; + private String documentType; private String iconTooltip; private String title; private QueryHelpData data; @@ -133,7 +131,7 @@ public Builder(final QueryHelpRow row) { this.type = row.type; this.id = row.id; this.hasChildren = row.hasChildren; - this.icon = row.icon; + this.documentType = row.documentType; this.iconTooltip = row.iconTooltip; this.title = row.title; this.data = row.data; @@ -155,8 +153,8 @@ public Builder hasChildren(final boolean hasChildren) { return this; } - public Builder icon(final SvgImage icon) { - this.icon = icon; + public Builder documentType(final String documentType) { + this.documentType = documentType; return this; } @@ -176,7 +174,7 @@ public Builder data(final QueryHelpData data) { } public QueryHelpRow build() { - return new QueryHelpRow(type, id, hasChildren, icon, iconTooltip, title, data); + return new QueryHelpRow(type, id, hasChildren, documentType, iconTooltip, title, data); } } } diff --git a/stroom-explorer/stroom-explorer-impl-db/src/main/java/stroom/explorer/impl/db/ExplorerTreeDaoImpl.java b/stroom-explorer/stroom-explorer-impl-db/src/main/java/stroom/explorer/impl/db/ExplorerTreeDaoImpl.java index b432d534985..573561f99eb 100644 --- a/stroom-explorer/stroom-explorer-impl-db/src/main/java/stroom/explorer/impl/db/ExplorerTreeDaoImpl.java +++ b/stroom-explorer/stroom-explorer-impl-db/src/main/java/stroom/explorer/impl/db/ExplorerTreeDaoImpl.java @@ -12,7 +12,6 @@ import stroom.explorer.impl.db.jooq.tables.records.ExplorerPathRecord; import stroom.explorer.shared.ExplorerConstants; import stroom.explorer.shared.ExplorerNode; -import stroom.svg.shared.SvgImage; import jakarta.inject.Inject; import org.jooq.Condition; @@ -25,7 +24,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.function.Function; import java.util.stream.Collectors; import static stroom.explorer.impl.db.jooq.tables.ExplorerNode.EXPLORER_NODE; @@ -161,8 +159,7 @@ public ExplorerTreeNode getRoot(final ExplorerTreeNode node) { } @Override - public TreeModel createModel(final Function iconProvider, - final long id, + public TreeModel createModel(final long id, final long creationTime) { final TreeModel treeModel = new TreeModel(id, creationTime); @@ -190,7 +187,6 @@ public TreeModel createModel(final Function iconProvider, .uuid(rec.getUuid()) .name(rec.getName()) .tags(NodeTagSerialiser.deserialise(rec.getTags())) - .icon(iconProvider.apply(rec.getType())) .addNodeFlag(ExplorerFlags.getStandardFlagByDocType(rec.getType()) .orElse(null)) .build())); diff --git a/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerServiceImpl.java b/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerServiceImpl.java index bd82b099799..9172b79501c 100644 --- a/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerServiceImpl.java +++ b/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerServiceImpl.java @@ -63,7 +63,6 @@ import stroom.security.shared.DocumentUserPermissions; import stroom.security.shared.FetchDocumentUserPermissionsRequest; import stroom.suggestions.api.SuggestionsQueryHandler; -import stroom.svg.shared.SvgImage; import stroom.util.NullSafe; import stroom.util.entityevent.EntityAction; import stroom.util.entityevent.EntityEvent; @@ -521,7 +520,6 @@ private ExplorerNode createSearchableNode(final DocRef docRef) { .addNodeFlag(NodeFlag.DATA_SOURCE) .addNodeFlag(NodeFlag.LEAF) .depth(1) - .icon(SvgImage.DOCUMENT_SEARCHABLE) .build(); } @@ -1576,7 +1574,7 @@ public ResultPage find(final DocumentFindRequest request) { node.getDocRef() != null && !ExplorerConstants.isRootNode(node)) { final String pathStr = ExplorerNode.buildDocRefPathString(path); - results.add(new FindResult(node.getDocRef(), pathStr, node.getIcon())); + results.add(new FindResult(node.getDocRef(), pathStr)); } return true; }); @@ -1660,7 +1658,7 @@ public ResultPage advancedFind(final AdvancedDocumentFindRequest req private FindResult createFindResult(final SequencedSet path, final ExplorerNode node) { final String pathStr = ExplorerNode.buildDocRefPathString(path); - return new FindResult(node.getDocRef(), pathStr, node.getIcon()); + return new FindResult(node.getDocRef(), pathStr); } private void applyExpressionFilter(final AdvancedDocumentFindRequest request, @@ -1889,12 +1887,9 @@ public ResultPage findInContent(final FindInContentRequest } } - final ExplorerActionHandler explorerActionHandler = - explorerActionHandlers.getHandler(docContentMatch.getDocRef().getType()); final FindInContentResult explorerDocContentMatch = FindInContentResult.builder() .docContentMatch(docContentMatch) .path(parentPath.toString()) - .icon(explorerActionHandler.getDocumentType().getIcon()) .build(); list.add(explorerDocContentMatch); } diff --git a/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerTreeDao.java b/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerTreeDao.java index 239385716b5..038abe546d6 100644 --- a/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerTreeDao.java +++ b/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerTreeDao.java @@ -16,15 +16,11 @@ package stroom.explorer.impl; -import stroom.svg.shared.SvgImage; - import java.util.List; -import java.util.function.Function; public interface ExplorerTreeDao { - TreeModel createModel(Function iconUrlProvider, - long id, + TreeModel createModel(long id, long creationTime); void update(ExplorerTreeNode node); diff --git a/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerTreeModel.java b/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerTreeModel.java index f15b6191cc7..45618706f0e 100644 --- a/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerTreeModel.java +++ b/stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerTreeModel.java @@ -17,11 +17,9 @@ package stroom.explorer.impl; import stroom.docref.DocRef; -import stroom.explorer.shared.DocumentType; import stroom.explorer.shared.ExplorerNode; import stroom.explorer.shared.ExplorerNode.NodeInfo; import stroom.security.api.SecurityContext; -import stroom.svg.shared.SvgImage; import stroom.task.api.TaskContextFactory; import stroom.util.NullSafe; import stroom.util.entityevent.EntityAction; @@ -98,8 +96,8 @@ class ExplorerTreeModel implements EntityEvent.Handler { private boolean isSynchronousUpdateRequired(final long minId, final long now) { return currentModel == null || - currentModel.getId() < minId || - currentModel.getCreationTime() < now - ONE_HOUR; + currentModel.getId() < minId || + currentModel.getCreationTime() < now - ONE_HOUR; } UnmodifiableTreeModel getModel() { @@ -172,7 +170,7 @@ private UnmodifiableTreeModel updateModel(final long id, final long creationTime try { LOGGER.debug("Updating model for id {}", id); newModel = LOGGER.logDurationIfDebugEnabled(() -> - explorerTreeDao.createModel(this::getIcon, id, creationTime), + explorerTreeDao.createModel(id, creationTime), "Create model"); // Make sure the cache is fresh for our new model @@ -223,19 +221,10 @@ private List buildNodeInfo(final Set brokenDeps) { } } - private SvgImage getIcon(final String type) { - final DocumentType documentType = explorerActionHandlers.getType(type); - if (documentType == null) { - return null; - } - - return documentType.getIcon(); - } - private synchronized void setCurrentModel(final UnmodifiableTreeModel treeModel) { if (currentModel == null - || treeModel == null - || currentModel.getId() < treeModel.getId()) { + || treeModel == null + || currentModel.getId() < treeModel.getId()) { LOGGER.debug(() -> LogUtil.message("Setting new model old id: {}, new id {}", NullSafe.toStringOrElse(currentModel, UnmodifiableTreeModel::getId, "null"), @@ -267,10 +256,10 @@ public void onChange(final EntityEvent event) { // The model doesn't care about UPDATE as that is an update of the content of the doc // rather than an update to the node (e.g. tags). case CREATE, - DELETE, - UPDATE_EXPLORER_NODE, - DELETE_EXPLORER_NODE, - CREATE_EXPLORER_NODE -> { + DELETE, + UPDATE_EXPLORER_NODE, + DELETE_EXPLORER_NODE, + CREATE_EXPLORER_NODE -> { // E.g. tags on a node have changed LOGGER.debug("Rebuilding tree model due to entity event {}", event); rebuild(); diff --git a/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/DataSources.java b/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/DataSources.java index 1be1cbc4725..7e87351b807 100644 --- a/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/DataSources.java +++ b/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/DataSources.java @@ -18,7 +18,6 @@ import stroom.docref.DocRef; import stroom.docref.StringMatch.MatchType; -import stroom.explorer.api.ExplorerActionHandler; import stroom.query.common.v2.DataSourceProviderRegistry; import stroom.query.shared.CompletionItem; import stroom.query.shared.CompletionValue; @@ -28,7 +27,6 @@ import stroom.query.shared.QueryHelpDocument; import stroom.query.shared.QueryHelpRow; import stroom.query.shared.QueryHelpType; -import stroom.svg.shared.SvgImage; import stroom.util.logging.LambdaLogger; import stroom.util.logging.LambdaLoggerFactory; import stroom.util.logging.LogUtil; @@ -44,10 +42,7 @@ import java.util.Comparator; import java.util.List; -import java.util.Map; import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; @Singleton public class DataSources { @@ -65,17 +60,10 @@ public class DataSources { public static final int INITIAL_SCORE = 500; private final Provider dataSourceProviderRegistryProvider; - private final Map icons; @Inject - DataSources(final Set explorerActionHandlers, - final Provider dataSourceProviderRegistryProvider) { + DataSources(final Provider dataSourceProviderRegistryProvider) { this.dataSourceProviderRegistryProvider = dataSourceProviderRegistryProvider; - icons = explorerActionHandlers - .stream() - .collect(Collectors - .toMap(c -> c.getDocumentType().getType(), - c -> c.getDocumentType().getIcon())); } public void addRows(final PageRequest pageRequest, @@ -85,8 +73,8 @@ public void addRows(final PageRequest pageRequest, if (parentPath.isBlank()) { final boolean hasChildren = hasChildren(stringMatcher); if (hasChildren || - MatchType.ANY.equals(stringMatcher.getMatchType()) || - stringMatcher.match(ROOT.getTitle()).isPresent()) { + MatchType.ANY.equals(stringMatcher.getMatchType()) || + stringMatcher.match(ROOT.getTitle()).isPresent()) { resultConsumer.add(ROOT.copy().hasChildren(hasChildren).build()); } } else if (parentPath.startsWith(DATA_SOURCE_ID + ".")) { @@ -100,7 +88,7 @@ public void addRows(final PageRequest pageRequest, .builder() .type(QueryHelpType.DATA_SOURCE) .id(DATA_SOURCE_ID + "." + docRef.getUuid()) - .icon(getIcon(docRef)) + .documentType(docRef.getType()) .iconTooltip(docRef.getType() + " - " + docRef.getDisplayValue()) .title(docRef.getDisplayValue()) .data(new QueryHelpDocument(docRef)) @@ -162,7 +150,7 @@ public Optional fetchDetail(final QueryHelpRow row) { return Optional.of(new QueryHelpDetail(insertType, insertText, documentation)); } else if (QueryHelpType.DATA_SOURCE.equals(row.getType()) && - row.getId().startsWith(DATA_SOURCE_ID + ".")) { + row.getId().startsWith(DATA_SOURCE_ID + ".")) { final QueryHelpDocument dataSource = (QueryHelpDocument) row.getData(); final DocRef docRef = dataSource.getDocRef(); final InsertType insertType = InsertType.plainText(docRef.getName()); @@ -218,12 +206,4 @@ private boolean hasChildren(final StringMatcher stringMatcher) { } return false; } - - private SvgImage getIcon(final DocRef docRef) { - SvgImage svgImage = icons.get(docRef.getType()); - if (svgImage == null) { - svgImage = SvgImage.DOCUMENT_SEARCHABLE; - } - return svgImage; - } } diff --git a/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/Dictionaries.java b/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/Dictionaries.java index 5b692958ab0..5b5861dc97f 100644 --- a/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/Dictionaries.java +++ b/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/Dictionaries.java @@ -28,7 +28,6 @@ import stroom.query.shared.QueryHelpDocument; import stroom.query.shared.QueryHelpRow; import stroom.query.shared.QueryHelpType; -import stroom.svg.shared.SvgImage; import stroom.util.logging.LambdaLogger; import stroom.util.logging.LambdaLoggerFactory; import stroom.util.logging.LogUtil; @@ -88,7 +87,7 @@ public void addRows(final PageRequest pageRequest, .builder() .type(QueryHelpType.DICTIONARY) .id(DICTIONARY_ID + "." + docRef.getUuid()) - .icon(SvgImage.DOCUMENT_DICTIONARY) + .documentType(DictionaryDoc.DOCUMENT_TYPE) .iconTooltip(docRef.getType() + " - " + docRef.getDisplayValue()) .title(docRef.getDisplayValue()) .data(new QueryHelpDocument(docRef)) diff --git a/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/Visualisations.java b/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/Visualisations.java index 7660a5ed1f4..b9beb31385b 100644 --- a/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/Visualisations.java +++ b/stroom-query/stroom-query-impl/src/main/java/stroom/query/impl/Visualisations.java @@ -31,7 +31,6 @@ import stroom.query.shared.QueryHelpDocument; import stroom.query.shared.QueryHelpRow; import stroom.query.shared.QueryHelpType; -import stroom.svg.shared.SvgImage; import stroom.util.NullSafe; import stroom.util.json.JsonUtil; import stroom.util.logging.LambdaLogger; @@ -112,7 +111,7 @@ public void addRows(final PageRequest pageRequest, .builder() .type(QueryHelpType.VISUALISATION) .id(VISUALISATION_ID + "." + docRef.getUuid()) - .icon(SvgImage.DOCUMENT_VISUALISATION) + .documentType(VisualisationDoc.DOCUMENT_TYPE) .iconTooltip(docRef.getType() + " - " + docRef.getDisplayValue()) .title(docRef.getDisplayValue()) .data(new QueryHelpDocument(docRef))