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 85edb6ddc8 CAUSEWAY-3630: tabular data columns: include all
non-mixed-in props by default
85edb6ddc8 is described below
commit 85edb6ddc863a04bdb85f6eeea94abd273f6f2e1
Author: Andi Huber <[email protected]>
AuthorDate: Tue Mar 5 07:50:52 2024 +0100
CAUSEWAY-3630: tabular data columns: include all non-mixed-in props by
default
- don't exclude readonly props
---
.../core/metamodel/tabular/simple/DataTable.java | 36 +++++++++++++++++++---
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git
a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/tabular/simple/DataTable.java
b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/tabular/simple/DataTable.java
index f2de63f5fe..9bb9e6e333 100644
---
a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/tabular/simple/DataTable.java
+++
b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/tabular/simple/DataTable.java
@@ -64,7 +64,9 @@ public class DataTable implements Serializable {
/**
* Returns an empty {@link DataTable} for given domain object type.
- * It can be populated later on using {@link
DataTable#setDataElements(Iterable)}.
+ * <p>
+ * The table can be populated later on using {@link
DataTable#setDataElements(Iterable)} or
+ * {@link #setDataElementPojos(Iterable)}.
*/
public static DataTable forDomainType(final Class<?> domainType) {
val elementType =
MetaModelContext.instanceElseFail().specForTypeElseFail(domainType);
@@ -72,8 +74,12 @@ public class DataTable implements Serializable {
}
/**
- * Returns an empty {@link DataTable} for given domain object type.
- * It can be populated later on using {@link
DataTable#setDataElements(Iterable)}.
+ * Returns an empty {@link DataTable} for given domain object type,
+ * with all properties as columns, excluding mixed-in ones.
+ * (For more control on which columns to include, consider a different
constructor.)
+ * <p>
+ * The table can be populated later on using {@link
DataTable#setDataElements(Iterable)} or
+ * {@link #setDataElementPojos(Iterable)}.
*/
public DataTable(
final @NonNull ObjectSpecification elementType) {
@@ -81,14 +87,34 @@ public class DataTable implements Serializable {
elementType.getSingularName(),
elementType
.streamProperties(MixedIn.EXCLUDED)
- .filter(prop->prop.isIncludedWithSnapshots())
+ .collect(Can.toCan()),
+ Can.empty());
+ }
+
+ /**
+ * Returns an empty {@link DataTable} for given domain object type,
+ * with all (including mixed-in) associations as columns,
+ * that pass given {@code columnFilter}.
+ * <p>
+ * The table can be populated later on using {@link
DataTable#setDataElements(Iterable)} or
+ * {@link #setDataElementPojos(Iterable)}.
+ */
+ public DataTable(
+ final @NonNull ObjectSpecification elementType, final
Predicate<ObjectAssociation> columnFilter) {
+ this(elementType,
+ elementType.getSingularName(),
+ elementType
+ .streamAssociations(MixedIn.INCLUDED)
+ .filter(columnFilter)
.collect(Can.toCan()),
Can.empty());
}
/**
* Returns an empty {@link DataTable} for given domain object type.
- * It can be populated later on using {@link
DataTable#setDataElements(Iterable)}.
+ * <p>
+ * The table can be populated later on using {@link
DataTable#setDataElements(Iterable)} or
+ * {@link #setDataElementPojos(Iterable)}.
*/
public DataTable(
final @NonNull ObjectSpecification elementType,