This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/master by this push:
new 00f7081bd3 CAUSEWAY-3762: adds TableSearchUiService (interface)
00f7081bd3 is described below
commit 00f7081bd38395288077fa8698ac59a638851902
Author: Andi Huber <[email protected]>
AuthorDate: Wed Jun 5 07:02:53 2024 +0200
CAUSEWAY-3762: adds TableSearchUiService (interface)
---
.../services/search/TableSearchUiService.java | 60 ++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git
a/viewers/commons/applib/src/main/java/org/apache/causeway/viewer/commons/applib/services/search/TableSearchUiService.java
b/viewers/commons/applib/src/main/java/org/apache/causeway/viewer/commons/applib/services/search/TableSearchUiService.java
new file mode 100644
index 0000000000..9d21c21aa6
--- /dev/null
+++
b/viewers/commons/applib/src/main/java/org/apache/causeway/viewer/commons/applib/services/search/TableSearchUiService.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.viewer.commons.applib.services.search;
+
+import java.util.Optional;
+import java.util.function.Predicate;
+
+import org.springframework.lang.Nullable;
+
+import org.apache.causeway.core.metamodel.spec.ObjectSpecification;
+
+import lombok.NonNull;
+
+/**
+ * EXPERIMENTAL/DRAFT
+ * <p>
+ * If a {@link TableSearchUiService} is registered with Spring's context,
+ * viewer implementations (like Wicket Viewer) should show
+ * a quick-search prompt, which is rendered on top of the UI table that
+ * presents the collection in question.
+ *
+ * @since 2.1, 3.1 {@index}
+ */
+public interface TableSearchUiService {
+
+ /**
+ * Optionally returns a {@link Predicate} that filters collections
+ * of given {@code domainType} by a nullable {@code searchString},
+ * based on whether the search is supported.
+ * <p>
+ * For example, the searchString could be parsed into tokens, and then
matched against the
+ * domain object's title say.
+ *
+ * @param domainType - entity or view-model type to be rendered as row in
a table
+ * @param objSpec - meta-model accompanied with the domainType
+ * @param searchString - nullable, e.g. the searchString could be parsed
into tokens, and then matched against the
+ * domain object's title say
+ */
+ <T> Optional<Predicate<T>> search(
+ @NonNull Class<T> domainType,
+ @NonNull ObjectSpecification objSpec,
+ @Nullable String searchString);
+
+}
\ No newline at end of file