Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gchq/stroom into planb
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed Jan 23, 2025
2 parents c7c70d2 + a311e30 commit c062002
Show file tree
Hide file tree
Showing 17 changed files with 175 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private List<Processor> getProcessor(final AnalyticRuleDoc analyticRuleDoc) {
private ResultPage<ProcessorFilter> getProcessorFilters(final Processor processor) {
final ExpressionOperator filterExpression = ExpressionOperator.builder()
.addIdTerm(
ProcessorFilterFields.PROCESSOR_ID,
ProcessorFields.ID,
ExpressionTerm.Condition.EQUALS,
processor.getId())
.addBooleanTerm(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,12 @@ void addFeedColumn() {

void addStreamTypeColumn() {
dataGrid.addResizableColumn(
DataGridUtil.textColumnBuilder((MetaRow metaRow) ->
DataGridUtil.copyTextColumnBuilder((MetaRow metaRow) ->
Optional.ofNullable(metaRow)
.map(MetaRow::getMeta)
.map(Meta::getTypeName)
.orElse(""))
.orElse(""),
getEventBus())
.withSorting(MetaFields.TYPE)
.build(),
"Type",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,46 +168,49 @@ public void render(final Context context, final DocRefProvider<T_ROW> value, fin
sb.append(SafeHtmlUtils.EMPTY_SAFE_HTML);
} else {
final DocRef docRef = GwtNullSafe.get(value, DocRefProvider::getDocRef);
final SafeHtml cellHtmlText;
if (cellTextFunction != null) {
cellHtmlText = cellTextFunction.apply(value);
if (docRef == null || GwtNullSafe.isBlankString(docRef.getName())) {
sb.append(SafeHtmlUtils.EMPTY_SAFE_HTML);

} else {
cellHtmlText = getTextFromDocRef(value);
}
final SafeHtml cellHtmlText;
if (cellTextFunction != null) {
cellHtmlText = cellTextFunction.apply(value);
} else {
cellHtmlText = getTextFromDocRef(value);
}

String cssClasses = "docRefLinkText";
if (cssClassFunction != null) {
final String additionalClasses = cssClassFunction.apply(value.getRow());
if (additionalClasses != null) {
cssClasses += " " + additionalClasses;
String cssClasses = "docRefLinkText";
if (cssClassFunction != null) {
final String additionalClasses = cssClassFunction.apply(value.getRow());
if (additionalClasses != null) {
cssClasses += " " + additionalClasses;
}
}
}
final SafeHtml textDiv = template.div(cssClasses, cellHtmlText);

final String containerClasses = String.join(
" ",
HOVER_ICON_CONTAINER_CLASS_NAME,
"docRefLinkContainer");

sb.appendHtmlConstant("<div class=\"" + containerClasses + "\">");
if (showIcon && docRef != null) {
final DocumentType documentType = DocumentTypeRegistry.get(docRef.getType());
if (documentType != null) {
final SvgImage svgImage = documentType.getIcon();
final SafeHtml iconDiv = SvgImageUtil.toSafeHtml(
documentType.getDisplayType(),
svgImage,
ICON_CLASS_NAME,
"docRefLinkIcon");
sb.append(iconDiv);
final SafeHtml textDiv = template.div(cssClasses, cellHtmlText);

final String containerClasses = String.join(
" ",
HOVER_ICON_CONTAINER_CLASS_NAME,
"docRefLinkContainer");

sb.appendHtmlConstant("<div class=\"" + containerClasses + "\">");
if (showIcon) {
final DocumentType documentType = DocumentTypeRegistry.get(docRef.getType());
if (documentType != null) {
final SvgImage svgImage = documentType.getIcon();
final SafeHtml iconDiv = SvgImageUtil.toSafeHtml(
documentType.getDisplayType(),
svgImage,
ICON_CLASS_NAME,
"docRefLinkIcon");
sb.append(iconDiv);
}
}
}

sb.append(textDiv);
sb.append(textDiv);

// This DocRefCell gets used for pipeline props which sometimes are a docRef
// and other times just a simple string
if (docRef != null) {
// This DocRefCell gets used for pipeline props which sometimes are a docRef
// and other times just a simple string
final SafeHtml copy = SvgImageUtil.toSafeHtml(
SvgImage.COPY,
ICON_CLASS_NAME,
Expand All @@ -227,9 +230,8 @@ public void render(final Context context, final DocRefProvider<T_ROW> value, fin
"Open " + docRef.getType() + " " + docRef.getName() + " in new tab",
open));
}
sb.appendHtmlConstant("</div>");
}

sb.appendHtmlConstant("</div>");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,31 +742,39 @@ public void open(final DocRef docRef,
final boolean fullScreen,
final CommonDocLinkTab selectedLinkTab,
final TaskMonitorFactory taskMonitorFactory) {
final DocumentPlugin<?> documentPlugin = documentPluginRegistry.get(docRef.getType());
if (documentPlugin != null) {
// Decorate the DocRef with its name from the info service (required by the doc presenter)
restFactory
.create(EXPLORER_RESOURCE)
.method(res ->
res.decorate(DecorateRequest.create(docRef)))
.onSuccess(decoratedDocRef -> {
documentPlugin.open(
decoratedDocRef,
forceOpen,
fullScreen,
selectedLinkTab,
new DefaultTaskMonitorFactory(this));
highlight(decoratedDocRef, explorerListener);
})
.onFailure(error -> {
AlertEvent.fireError(DocumentPluginEventManager.this,
buildNotFoundMessage(docRef),
null);
})
.taskMonitorFactory(taskMonitorFactory)
.exec();
} else {
throw new IllegalArgumentException("Document type '" + docRef.getType() + "' not registered");
if (docRef != null && docRef.getType() != null) {
final DocumentPlugin<?> documentPlugin = documentPluginRegistry.get(docRef.getType());
if (documentPlugin != null) {
// Decorate the DocRef with its name from the info service (required by the doc presenter)
restFactory
.create(EXPLORER_RESOURCE)
.method(res ->
res.decorate(DecorateRequest.create(docRef)))
.onSuccess(decoratedDocRef -> {
if (decoratedDocRef == null) {
AlertEvent.fireError(DocumentPluginEventManager.this,
buildNotFoundMessage(docRef),
null);
} else {
documentPlugin.open(
decoratedDocRef,
forceOpen,
fullScreen,
selectedLinkTab,
new DefaultTaskMonitorFactory(this));
highlight(decoratedDocRef, explorerListener);
}
})
.onFailure(error -> {
AlertEvent.fireError(DocumentPluginEventManager.this,
buildNotFoundMessage(docRef),
null);
})
.taskMonitorFactory(taskMonitorFactory)
.exec();
} else {
throw new IllegalArgumentException("Document type '" + docRef.getType() + "' not registered");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
import stroom.alert.client.event.ConfirmEvent;
import stroom.analytics.shared.AnalyticRuleDoc;
import stroom.data.client.presenter.ExpressionPresenter;
import stroom.datasource.api.v2.QueryField;
import stroom.dispatch.client.DefaultErrorHandler;
import stroom.dispatch.client.RestFactory;
import stroom.docref.DocRef;
import stroom.entity.client.presenter.HasDocumentRead;
import stroom.pipeline.shared.PipelineDoc;
import stroom.processor.shared.ProcessorFields;
import stroom.processor.shared.ProcessorFilter;
import stroom.processor.shared.ProcessorFilterFields;
import stroom.processor.shared.ProcessorFilterResource;
Expand Down Expand Up @@ -59,6 +61,7 @@
import com.gwtplatform.mvp.client.MyPresenterWidget;
import com.gwtplatform.mvp.client.View;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -242,9 +245,12 @@ private void onFilter() {
e.hide();
};

final List<QueryField> fields = new ArrayList<>();
fields.addAll(ProcessorFields.getFields());
fields.addAll(ProcessorFilterFields.getFields());
presenter.read(processorListPresenter.getExpression(),
ProcessorFilterFields.PROCESSOR_FILTERS_DOC_REF,
ProcessorFilterFields.getFields());
fields);

presenter.getWidget().getElement().addClassName("default-min-sizes");
final PopupSize popupSize = PopupSize.resizable(800, 600);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public class UserDependenciesListPresenter

private UserRef userRef;
private RestDataProvider<UserDependency, ResultPage<UserDependency>> dataProvider;
private ResultPage<UserDependency> currentData = null;
private Consumer<ResultPage<UserDependency>> resultPageConsumer;
private String filter;

@Inject
Expand Down Expand Up @@ -137,11 +135,7 @@ protected void exec(final Range range,

@Override
protected void changeData(final ResultPage<UserDependency> data) {
currentData = data;
super.changeData(data);
if (resultPageConsumer != null) {
resultPageConsumer.accept(data);
}
if (!data.isEmpty()) {
selectionModel.setSelected(data.getFirst());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public class UserTabPresenter
.build();

private final UserInfoPresenter userInfoPresenter;
private final ClientSecurityContext clientSecurityContext;
private final LazyValue<UserPermissionReportPresenter> userPermsReportPresenterLazyValue;
private final LazyValue<UserDependenciesListPresenter> userDependenciesListPresenterLazyValue;
private final LazyValue<ApiKeysPresenter> apiKeysListPresenterLazyValue;
Expand All @@ -70,7 +69,6 @@ public class UserTabPresenter
private UserRef userRef;
private String label;
private PresenterWidget<?> currentContent;
private TabData selectedTab;

@Inject
public UserTabPresenter(final EventBus eventBus,
Expand All @@ -84,7 +82,6 @@ public UserTabPresenter(final EventBus eventBus,
final Provider<UserAndGroupsPresenter> userAndGroupsPresenterProvider) {
super(eventBus, view);
this.userInfoPresenter = userInfoPresenter;
this.clientSecurityContext = clientSecurityContext;
this.userPermsReportPresenterLazyValue = new LazyValue<>(
userPermsReportPresenterProvider,
userPermissionReportPresenter -> {
Expand Down Expand Up @@ -151,7 +148,6 @@ public void selectTab(final TabData tab) {
getView().getLayerContainer().show((Layer) currentContent);
// Update the selected tab.
getView().getTabBar().selectTab(tab);
selectedTab = tab;
afterSelectTab(content);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ public class ProcessorFields {
public static final QueryField PROCESSOR_TYPE = QueryField.createText("Processor Type");
public static final QueryField PIPELINE = QueryField.createDocRefByUuid(
PipelineDoc.TYPE, "Processor Pipeline");
public static final QueryField ANALYTIC_RULE = QueryField.createDocRefByUuid(
AnalyticRuleDoc.TYPE, "Analytic Rule");
public static final QueryField ENABLED = QueryField.createBoolean("Processor Enabled");
public static final QueryField DELETED = QueryField.createBoolean("Processor Deleted");
public static final QueryField UUID = QueryField.createText("Processor UUID");
public static final QueryField ANALYTIC_RULE = QueryField.createDocRefByUuid(
AnalyticRuleDoc.TYPE, "Analytic Rule");

static {
FIELDS.add(ID);
FIELDS.add(PROCESSOR_TYPE);
FIELDS.add(PIPELINE);
FIELDS.add(ANALYTIC_RULE);
FIELDS.add(ENABLED);
FIELDS.add(DELETED);
FIELDS.add(UUID);
FIELDS.add(ANALYTIC_RULE);

ALL_FIELD_MAP = FIELDS.stream().collect(Collectors.toMap(QueryField::getFldName, Function.identity()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class ProcessorFilterFields {
public static final QueryField PRIORITY = QueryField.createInteger("Processor Filter Priority");
public static final QueryField ENABLED = QueryField.createBoolean("Processor Filter Enabled");
public static final QueryField DELETED = QueryField.createBoolean("Processor Filter Deleted");
public static final QueryField PROCESSOR_ID = QueryField.createId("Processor Id");
public static final QueryField UUID = QueryField.createText("Processor Filter UUID");
public static final QueryField RUN_AS_USER = QueryField
.builder()
Expand All @@ -47,7 +46,6 @@ public class ProcessorFilterFields {
FIELDS.add(PRIORITY);
FIELDS.add(ENABLED);
FIELDS.add(DELETED);
FIELDS.add(PROCESSOR_ID);
FIELDS.add(UUID);
FIELDS.add(RUN_AS_USER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public DictionaryDoc fetch(final String uuid) {
final DictionaryDoc dictionaryDoc = documentResourceHelperProvider.get()
.read(dictionaryStoreProvider.get(), getDocRef(uuid));

//
if (NullSafe.hasItems(dictionaryDoc.getImports())) {
final DocRefInfoService docRefInfoService = docRefInfoServiceProvider.get();
final List<DocRef> decoratedImports = dictionaryDoc.getImports()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import stroom.util.entityevent.EntityAction;
import stroom.util.entityevent.EntityEvent;
import stroom.util.entityevent.EntityEventHandler;
import stroom.util.logging.LambdaLogger;
import stroom.util.logging.LambdaLoggerFactory;
import stroom.util.shared.Clearable;

import jakarta.inject.Inject;
Expand All @@ -48,7 +50,7 @@
EntityAction.UPDATE_EXPLORER_NODE})
class DocRefInfoCache implements EntityEvent.Handler, Clearable {

private static final Logger LOGGER = LoggerFactory.getLogger(DocRefInfoCache.class);
private static final LambdaLogger LOGGER = LambdaLoggerFactory.getLogger(DocRefInfoCache.class);
private static final String CACHE_NAME = "Doc Ref Info Cache";

// Effectively docUuid => optDocRefInfo
Expand Down Expand Up @@ -87,7 +89,7 @@ private Optional<DocRefInfo> loadDocRefInfo(final DocRef docRef) {
}
});
} catch (final RuntimeException e) {
LOGGER.debug(e.getMessage(), e);
LOGGER.debug(e::getMessage, e);
}
return Optional.ofNullable(docRefInfo);
}
Expand All @@ -103,6 +105,7 @@ private DocRefInfo getDocRefInfoWithoutType(final DocRef docRef) {
try {
return handler.info(docRef);
} catch (DocumentNotFoundException e) {
LOGGER.debug(e::getMessage, e);
return null;
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import stroom.meta.shared.SelectionSummary;
import stroom.meta.shared.SimpleMeta;
import stroom.meta.shared.Status;
import stroom.pipeline.shared.PipelineDoc;
import stroom.query.api.v2.ExpressionOperator;
import stroom.query.api.v2.ExpressionOperator.Builder;
import stroom.query.api.v2.ExpressionTerm;
Expand Down Expand Up @@ -604,7 +605,13 @@ public SelectionSummary getReprocessSelectionSummary(final FindMetaCriteria crit
private DocRef getPipeline(final Meta meta) {
if (meta.getPipelineUuid() != null) {
final Optional<DocRefInfo> optionalDocRefInfo = docRefInfoService.info(meta.getPipelineUuid());
return optionalDocRefInfo.map(DocRefInfo::getDocRef).orElse(null);
return optionalDocRefInfo
.map(DocRefInfo::getDocRef)
.orElse(DocRef
.builder()
.type(PipelineDoc.TYPE)
.uuid(meta.getPipelineUuid())
.build());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ class ProcessorFilterDaoImpl implements ProcessorFilterDao {
expressionMapper.map(ProcessorFilterFields.PRIORITY, PROCESSOR_FILTER.PRIORITY, Integer::valueOf);
expressionMapper.map(ProcessorFilterFields.ENABLED, PROCESSOR_FILTER.ENABLED, Boolean::valueOf);
expressionMapper.map(ProcessorFilterFields.DELETED, PROCESSOR_FILTER.DELETED, Boolean::valueOf);
expressionMapper.map(ProcessorFilterFields.PROCESSOR_ID, PROCESSOR_FILTER.FK_PROCESSOR_ID, Integer::valueOf);
expressionMapper.map(ProcessorFilterFields.UUID, PROCESSOR_FILTER.UUID, value -> value);
expressionMapper.map(ProcessorFilterFields.RUN_AS_USER, PROCESSOR_FILTER.RUN_AS_USER_UUID, value -> value);

expressionMapper.map(ProcessorFields.ID, PROCESSOR.ID, Integer::valueOf);
expressionMapper.map(ProcessorFields.ID, PROCESSOR_FILTER.FK_PROCESSOR_ID, Integer::valueOf);
expressionMapper.map(ProcessorFields.PROCESSOR_TYPE, PROCESSOR.TASK_TYPE, String::valueOf);
expressionMapper.map(ProcessorFields.ANALYTIC_RULE, PROCESSOR.PIPELINE_UUID, value -> value, false);
expressionMapper.map(ProcessorFields.PIPELINE, PROCESSOR.PIPELINE_UUID, value -> value, false);
Expand Down
Loading

0 comments on commit c062002

Please sign in to comment.