From 80e45dd74ea9449f5822f6757692c9d11e59df21 Mon Sep 17 00:00:00 2001 From: Katarina Valalikova Date: Wed, 8 Sep 2021 10:34:36 +0200 Subject: [PATCH 01/19] fixing typo --- .../gui/impl/page/admin/focus/component/FocusCasesPanel.java | 2 +- .../{FocusCassesCounter.java => FocusCasesCounter.java} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/{FocusCassesCounter.java => FocusCasesCounter.java} (91%) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/focus/component/FocusCasesPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/focus/component/FocusCasesPanel.java index c12c478a505..c8ea34106f2 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/focus/component/FocusCasesPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/focus/component/FocusCasesPanel.java @@ -30,7 +30,7 @@ status = ItemStatus.NOT_CHANGED, applicableFor = FocusType.class, display = @PanelDisplay(label = "pageAdminFocus.cases", icon = GuiStyleConstants.EVO_CASE_OBJECT_ICON, order = 50)) -@Counter(provider = FocusCassesCounter.class) +@Counter(provider = FocusCasesCounter.class) public class FocusCasesPanel extends AbstractObjectMainPanel> { private static final long serialVersionUID = 1L; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/FocusCassesCounter.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/FocusCasesCounter.java similarity index 91% rename from gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/FocusCassesCounter.java rename to gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/FocusCasesCounter.java index b8d826a8942..3b1468ce1a3 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/FocusCassesCounter.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/FocusCasesCounter.java @@ -17,9 +17,9 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType; -public class FocusCassesCounter extends SimpleCounter, F> { +public class FocusCasesCounter extends SimpleCounter, F> { - public FocusCassesCounter() { + public FocusCasesCounter() { super(); } From 841c9b29cef60bd137b2668e2c5aacdf408ce446 Mon Sep 17 00:00:00 2001 From: Katarina Valalikova Date: Wed, 8 Sep 2021 12:09:24 +0200 Subject: [PATCH 02/19] repo call optimization --- .../menu/DetailsNavigationPanel.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/menu/DetailsNavigationPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/menu/DetailsNavigationPanel.java index 932a502c81a..416063c8e5d 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/menu/DetailsNavigationPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/menu/DetailsNavigationPanel.java @@ -152,9 +152,8 @@ private void addLabel(AjaxLink link, ListItem link, ListItem item) { - IModel countModel = createCountModel(item.getModel()); - Label label = new Label(ID_COUNT, countModel); - label.add(new VisibleBehaviour(() -> countModel.getObject() != null)); + Label label = new Label(ID_COUNT, createCountModel(item.getModel())); + label.add(new VisibleBehaviour(() -> getCounterProvider(item.getModel()) != null)); link.add(label); } @@ -189,19 +188,26 @@ protected void onClickPerformed(ContainerPanelConfigurationType config, AjaxRequ private IModel createCountModel(IModel panelModel) { return new ReadOnlyModel<>( () -> { - ContainerPanelConfigurationType config = panelModel.getObject(); - String panelInstanceIdentifier = config.getIdentifier(); - - SimpleCounter, O> counter = getPageBase().getCounterProvider(panelInstanceIdentifier); - if (counter == null || counter.getClass().equals(SimpleCounter.class)) { + SimpleCounter, O> counter = getCounterProvider(panelModel); + if (counter == null) { return null; } - int count = counter.count(objectDetailsModel, getPageBase()); return String.valueOf(count); }); } + private SimpleCounter, O> getCounterProvider(IModel panelModel) { + ContainerPanelConfigurationType config = panelModel.getObject(); + String panelInstanceIdentifier = config.getIdentifier(); + + SimpleCounter, O> counter = getPageBase().getCounterProvider(panelInstanceIdentifier); + if (counter == null || counter.getClass().equals(SimpleCounter.class)) { + return null; + } + return counter; + } + private boolean isMenuItemVisible(ContainerPanelConfigurationType config) { if (config == null) { return true; From 0572f69d12a210059cde7a4c5ecf3aa068673e42 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 8 Sep 2021 16:24:23 +0200 Subject: [PATCH 03/19] repo-sqale: added support for "sqale" profile that actually runs tests --- repo/repo-sqale/pom.xml | 19 +++++++++++++++++++ repo/repo-sqale/testng-unit.xml | 23 +++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 repo/repo-sqale/testng-unit.xml diff --git a/repo/repo-sqale/pom.xml b/repo/repo-sqale/pom.xml index 908a11fb72c..c0b194875b8 100644 --- a/repo/repo-sqale/pom.xml +++ b/repo/repo-sqale/pom.xml @@ -141,4 +141,23 @@ test + + + + sqale + + false + + + false + + + + + maven-surefire-plugin + + + + + diff --git a/repo/repo-sqale/testng-unit.xml b/repo/repo-sqale/testng-unit.xml new file mode 100644 index 00000000000..75000098ff6 --- /dev/null +++ b/repo/repo-sqale/testng-unit.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + From 31a07e90200d277aa6b1f11cd4290a900955b313 Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Wed, 8 Sep 2021 16:48:01 +0200 Subject: [PATCH 04/19] sqale: Added support for rightHandSide paths in filters --- .../sqale/mapping/ExtensionItemSqlMapper.java | 7 + .../repo/sqale/func/SqaleRepoSearchTest.java | 17 ++ .../sqlbase/filtering/FilterProcessor.java | 4 + .../sqlbase/filtering/RightHandProcessor.java | 11 ++ .../filtering/ValueFilterProcessor.java | 49 +++++- .../sqlbase/filtering/ValueFilterValues.java | 152 ++++++++++++------ .../item/DetailTableItemFilterProcessor.java | 1 + .../item/EnumItemFilterProcessor.java | 10 ++ .../item/EnumOrdinalItemFilterProcessor.java | 10 ++ .../item/ItemValueFilterProcessor.java | 16 +- .../item/PolyStringItemFilterProcessor.java | 39 +++++ .../item/SimpleItemFilterProcessor.java | 9 ++ .../item/SinglePathItemFilterProcessor.java | 8 + .../item/TimestampItemFilterProcessor.java | 9 ++ .../sqlbase/mapping/DefaultItemSqlMapper.java | 7 + .../repo/sqlbase/mapping/ItemSqlMapper.java | 5 + 16 files changed, 299 insertions(+), 55 deletions(-) create mode 100644 repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/RightHandProcessor.java diff --git a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java index b5c734e95c8..2fed2830071 100644 --- a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java +++ b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java @@ -33,6 +33,7 @@ import com.evolveum.midpoint.repo.sqale.update.SqaleUpdateContext; import com.evolveum.midpoint.repo.sqlbase.QueryException; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; +import com.evolveum.midpoint.repo.sqlbase.filtering.RightHandProcessor; import com.evolveum.midpoint.repo.sqlbase.filtering.item.ItemValueFilterProcessor; import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; @@ -97,6 +98,12 @@ public ExtensionItemSqlMapper( holderType); } + @Override + public > @Nullable RightHandProcessor createRightHandProcessor( + SqlQueryContext sqlQueryContext) { + return createRightHandProcessor(sqlQueryContext); + } + @Override public ItemDeltaProcessor createItemDeltaProcessor( SqaleUpdateContext sqlUpdateContext) { diff --git a/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java b/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java index 81f880f06d8..8ea80842a67 100644 --- a/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java +++ b/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java @@ -274,6 +274,8 @@ public void initObjects() throws Exception { user4Oid = repositoryService.addObject( new UserType(prismContext).name("user-4") + .givenName("John") + .fullName("John") .costCenter("51") .parentOrgRef(org111Oid, OrgType.COMPLEX_TYPE) .subtype("workerB") @@ -1707,6 +1709,21 @@ public void test700SearchUsersWithAccountsOnSpecificResource() } // endregion + @Test + public void test800SearchUsersWithSimplePath() throws SchemaException { + searchUsersTest("fullName does not equals fname", + f -> f.item(UserType.F_FULL_NAME).eq().item(UserType.F_GIVEN_NAME), + user4Oid); + } + + @Test(expectedExceptions = SystemException.class) + public void test820SearchUsersWithReferencedPath() throws SchemaException { + searchUsersTest("fullName does not equals fname", + f -> f.not().item(ObjectType.F_METADATA, MetadataType.F_CREATE_TIMESTAMP).eq().item(UserType.F_ASSIGNMENT, AssignmentType.F_METADATA, MetadataType.F_CREATE_TIMESTAMP), + user1Oid, user2Oid, user3Oid, user4Oid); + // Should fail because right hand side nesting into multivalue container is not supported + } + // region special cases @Test public void test900SearchByWholeContainerIsNotPossible() { diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/FilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/FilterProcessor.java index 9e9be3a7b65..d5a804cece8 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/FilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/FilterProcessor.java @@ -33,4 +33,8 @@ public interface FilterProcessor { Predicate process(O filter) throws RepositoryException; + + default Predicate process(O filter, RightHandProcessor rightPath) throws RepositoryException { + throw new RepositoryException("Right hand side filter is not supported for " + filter.toString()); + } } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/RightHandProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/RightHandProcessor.java new file mode 100644 index 00000000000..3fb6625fa1c --- /dev/null +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/RightHandProcessor.java @@ -0,0 +1,11 @@ +package com.evolveum.midpoint.repo.sqlbase.filtering; + +import com.evolveum.midpoint.prism.query.ValueFilter; +import com.evolveum.midpoint.repo.sqlbase.RepositoryException; +import com.querydsl.core.types.Expression; + +public interface RightHandProcessor { + + public Expression rightHand(ValueFilter filter) throws RepositoryException; + +} diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterProcessor.java index c0999ef20bd..e40ff586bc5 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterProcessor.java @@ -56,14 +56,24 @@ public Predicate process(ValueFilter filter) throws RepositoryException { return process(filter.getPath(), filter); } - private , TR> Predicate process( + @Override + public Predicate process(ValueFilter filter, RightHandProcessor rightPath) throws RepositoryException { + return process(filter.getPath(), filter, rightPath); + } + + private Predicate process( ItemPath path, ValueFilter filter) throws RepositoryException { + final RightHandProcessor right; if (filter.getRightHandSidePath() != null) { - // TODO implement - throw new QueryException( - "Filter with right-hand-side path is not supported YET: " + path); + right = processRight(filter.getRightHandSidePath(), filter); + } else { + right = null; } + return process(path, filter, right); + } + private , TR> Predicate process( + ItemPath path, ValueFilter filter, RightHandProcessor right) throws RepositoryException { // isSingleName/asSingleName or firstName don't work for T_ID (OID) if (path.size() == 1) { QName itemName = path.firstToQName(); @@ -74,7 +84,9 @@ private , TR> Predicate process( throw new QueryException("Filtering on " + path + " is not supported."); // this should not even happen, we can't even create a Query that would cause this } - + if (right != null) { + return filterProcessor.process(filter, right); + } return filterProcessor.process(filter); } else { ItemRelationResolver resolver = mapping.relationResolver(path); @@ -82,7 +94,7 @@ private , TR> Predicate process( SqlQueryContext subcontext = resolution.context; ValueFilterProcessor nestedProcessor = new ValueFilterProcessor<>(subcontext, resolution.mapping); - Predicate predicate = nestedProcessor.process(path.rest(), filter); + Predicate predicate = nestedProcessor.process(path.rest(), filter, right); if (resolution.subquery) { return subcontext.sqlQuery() .where(predicate) @@ -92,4 +104,29 @@ private , TR> Predicate process( } } } + + private , TR> RightHandProcessor processRight(ItemPath path, ValueFilter filter) throws RepositoryException { + SqlQueryContext root = context; + if (path.size() == 1) { + QName itemName = path.firstToQName(); + RightHandProcessor filterProcessor = + mapping.itemMapper(itemName) + .createRightHandProcessor(context); + if (filterProcessor == null) { + throw new QueryException("Filtering on " + path + " is not supported."); + // this should not even happen, we can't even create a Query that would cause this + } + return filterProcessor; + } else { + ItemRelationResolver resolver = mapping.relationResolver(path); + ItemRelationResolver.ResolutionResult resolution = resolver.resolve(context); + SqlQueryContext subcontext = resolution.context; + ValueFilterProcessor nestedProcessor = + new ValueFilterProcessor<>(subcontext, resolution.mapping); + if (resolution.subquery) { + throw new RepositoryException("Righ path " + path + "is not single value"); + } + return nestedProcessor.processRight(path.rest(), filter); + } + } } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterValues.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterValues.java index 27968547e81..7882988da62 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterValues.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterValues.java @@ -20,6 +20,7 @@ import com.evolveum.midpoint.prism.query.PropertyValueFilter; import com.evolveum.midpoint.prism.query.ValueFilter; import com.evolveum.midpoint.repo.sqlbase.QueryException; +import com.querydsl.core.types.Expression; /** * Object wraps zero, one or multiple values and makes their processing easier. @@ -37,95 +38,152 @@ * @param type of filter value * @param type of value after conversion (can by the same like T) */ -public class ValueFilterValues { +public abstract class ValueFilterValues { - @NotNull private final PropertyValueFilter filter; - @Nullable private final Function conversionFunction; + @NotNull protected final PropertyValueFilter filter; public static ValueFilterValues from(@NotNull PropertyValueFilter filter) { - return new ValueFilterValues<>(filter, null); + return new Constant(filter, null); + } + + public static ValueFilterValuesfrom(@NotNull PropertyValueFilter filter, Expression expression) { + return new Expr(filter, expression); } public static ValueFilterValues from( @NotNull PropertyValueFilter filter, @Nullable Function conversionFunction) { - return new ValueFilterValues<>(filter, conversionFunction); + return new Constant(filter, conversionFunction); } private ValueFilterValues( - @NotNull PropertyValueFilter filter, - @Nullable Function conversionFunction) { + @NotNull PropertyValueFilter filter) { this.filter = Objects.requireNonNull(filter); - this.conversionFunction = conversionFunction; } /** * Returns single value or null or fails if there are multiple values, all converted. */ - public @Nullable V singleValue() throws QueryException { - return convert(filter.getSingleValue()); - } + public abstract @Nullable V singleValue() throws QueryException; /** * Returns single value or null or fails if there are multiple values without conversion. * Null-safe version of {@link ValueFilter#getSingleValue()} followed by * {@link PrismPropertyValue#getRealValue()}. */ - public @Nullable T singleValueRaw() { - final PrismPropertyValue singleValue = filter.getSingleValue(); - return singleValue != null ? singleValue.getRealValue() : null; - } + public abstract @Nullable T singleValueRaw(); /** * Returns multiple values, all converted, or empty list - never null. */ public @NotNull List allValues() { - if (filter.getValues() == null) { return Collections.emptyList(); - } - Stream realValueStream = filter.getValues().stream() - .map(ppv -> ppv.getRealValue()); - if (conversionFunction == null) { - //noinspection unchecked - return (List) realValueStream.collect(Collectors.toList()); - } - return realValueStream - .map(conversionFunction) - .collect(Collectors.toList()); } /** * Returns multiple real values without conversion or empty list - never null. */ public @NotNull List allValuesRaw() { - if (filter.getValues() == null) { - return Collections.emptyList(); - } - return filter.getValues().stream() - .map(ppv -> ppv.getRealValue()) - .collect(Collectors.toList()); + return Collections.emptyList(); } - private V convert(PrismPropertyValue value) throws QueryException { - if (value == null) { - return null; + public boolean isEmpty() { + return false; + } + + public boolean isMultiValue() { + return false; + } + + private static class Constant extends ValueFilterValues { + + @Nullable private final Function conversionFunction; + + public Constant(@NotNull PropertyValueFilter filter, @Nullable Function conversionFunction) { + super(filter); + this.conversionFunction = conversionFunction; } - if (conversionFunction == null) { - //noinspection unchecked - return (V) value.getRealValue(); + + @Override + public @Nullable V singleValue() throws QueryException { + return convert(filter.getSingleValue()); } - try { - return conversionFunction.apply(value.getRealValue()); - } catch (IllegalArgumentException | ClassCastException e) { - throw new QueryException(e); + + @Override + public @Nullable T singleValueRaw() { + final PrismPropertyValue singleValue = filter.getSingleValue(); + return singleValue != null ? singleValue.getRealValue() : null; } - } - public boolean isEmpty() { - return filter.getValues() == null || filter.getValues().isEmpty(); + @Override + public @NotNull List allValues() { + if (filter.getValues() == null) { + return Collections.emptyList(); + } + Stream realValueStream = filter.getValues().stream() + .map(ppv -> ppv.getRealValue()); + if (conversionFunction == null) { + //noinspection unchecked + return (List) realValueStream.collect(Collectors.toList()); + } + return realValueStream + .map(conversionFunction) + .collect(Collectors.toList()); + } + + @Override + public @NotNull List allValuesRaw() { + if (filter.getValues() == null) { + return Collections.emptyList(); + } + return filter.getValues().stream() + .map(ppv -> ppv.getRealValue()) + .collect(Collectors.toList()); + } + + private V convert(PrismPropertyValue value) throws QueryException { + if (value == null) { + return null; + } + if (conversionFunction == null) { + //noinspection unchecked + return (V) value.getRealValue(); + } + try { + return conversionFunction.apply(value.getRealValue()); + } catch (IllegalArgumentException | ClassCastException e) { + throw new QueryException(e); + } + } + + @Override + public boolean isEmpty() { + return filter.getValues() == null || filter.getValues().isEmpty(); + } + + @Override + public boolean isMultiValue() { + return filter.getValues() != null && filter.getValues().size() > 1; + } } - public boolean isMultiValue() { - return filter.getValues() != null && filter.getValues().size() > 1; + private static class Expr extends ValueFilterValues { + + private @Nullable Expression expression; + + public Expr(@NotNull PropertyValueFilter filter, Expression expression) { + super(filter); + this.expression = expression; + } + + @Override + public @Nullable V singleValue() throws QueryException { + return (V) this.expression; + } + + @Override + public @Nullable T singleValueRaw() { + return (T) this.expression; + } } } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/DetailTableItemFilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/DetailTableItemFilterProcessor.java index 19aec10e35d..b49b0bd12e4 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/DetailTableItemFilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/DetailTableItemFilterProcessor.java @@ -110,4 +110,5 @@ public Predicate process(PropertyValueFilter filter) throws RepositoryEx return subquery.where(predicate).exists(); } } + } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/EnumItemFilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/EnumItemFilterProcessor.java index 563980070bc..47edfa83484 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/EnumItemFilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/EnumItemFilterProcessor.java @@ -16,7 +16,9 @@ import com.evolveum.midpoint.prism.query.PropertyValueFilter; import com.evolveum.midpoint.prism.query.ValueFilter; import com.evolveum.midpoint.repo.sqlbase.QueryException; +import com.evolveum.midpoint.repo.sqlbase.RepositoryException; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; +import com.evolveum.midpoint.repo.sqlbase.filtering.RightHandProcessor; import com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterValues; import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; import com.evolveum.midpoint.repo.sqlbase.querydsl.QuerydslUtils; @@ -43,6 +45,14 @@ public Predicate process(PropertyValueFilter filter) throws QueryException { return createBinaryCondition(filter, path, ValueFilterValues.from(filter)); } + + @Override + public Predicate process(PropertyValueFilter filter, RightHandProcessor rightPath) + throws RepositoryException { + return createBinaryCondition(filter, path, + ValueFilterValues.from(filter, rightPath.rightHand(filter))); + } + @Override protected FilterOperation operation(ValueFilter filter) throws QueryException { if (filter instanceof EqualFilter && filter.getMatchingRule() == null) { diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/EnumOrdinalItemFilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/EnumOrdinalItemFilterProcessor.java index 28405e413ff..1b8c0f902a7 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/EnumOrdinalItemFilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/EnumOrdinalItemFilterProcessor.java @@ -15,7 +15,9 @@ import com.evolveum.midpoint.prism.query.PropertyValueFilter; import com.evolveum.midpoint.repo.sqlbase.QueryException; +import com.evolveum.midpoint.repo.sqlbase.RepositoryException; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; +import com.evolveum.midpoint.repo.sqlbase.filtering.RightHandProcessor; import com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterValues; import com.evolveum.midpoint.repo.sqlbase.mapping.DefaultItemSqlMapper; import com.evolveum.midpoint.repo.sqlbase.mapping.ItemSqlMapper; @@ -85,4 +87,12 @@ public Predicate process(PropertyValueFilter filter) throws QueryException { return createBinaryCondition(filter, path, ValueFilterValues.from(filter, conversionFunction)); } + + + @Override + public Predicate process(PropertyValueFilter filter, RightHandProcessor rightPath) + throws RepositoryException { + return createBinaryCondition(filter, path, + ValueFilterValues.from(filter, rightPath.rightHand(filter))); + } } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/ItemValueFilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/ItemValueFilterProcessor.java index 9a2b86ba5b0..653d811004b 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/ItemValueFilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/ItemValueFilterProcessor.java @@ -15,8 +15,10 @@ import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.query.*; import com.evolveum.midpoint.repo.sqlbase.QueryException; +import com.evolveum.midpoint.repo.sqlbase.RepositoryException; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; import com.evolveum.midpoint.repo.sqlbase.filtering.FilterProcessor; +import com.evolveum.midpoint.repo.sqlbase.filtering.RightHandProcessor; import com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterProcessor; import com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterValues; import com.evolveum.midpoint.repo.sqlbase.mapping.QueryTableMapping; @@ -31,7 +33,7 @@ * See {@link ValueFilterProcessor} for details how complex paths are resolved to its last part. */ public abstract class ItemValueFilterProcessor> - implements FilterProcessor { + implements FilterProcessor, RightHandProcessor { protected final SqlQueryContext context; @@ -113,7 +115,11 @@ protected Predicate createBinaryCondition( protected Predicate singleValuePredicate( Expression path, FilterOperation operation, Object value) { path = operation.treatPath(path); - value = operation.treatValue(value); + if (value instanceof Expression) { + value = operation.treatPath((Expression) value); + } else { + value = operation.treatValue(value); + } Predicate predicate = ExpressionUtils.predicate(operation.operator, path, value instanceof Expression ? (Expression) value : ConstantImpl.create(value)); return predicateWithNotTreated(path, predicate); @@ -128,4 +134,10 @@ protected Predicate predicateWithNotTreated(Expression path, Predicate predic ? ExpressionUtils.and(predicate, ExpressionUtils.predicate(Ops.IS_NOT_NULL, path)) : predicate; } + + @Override + public Expression rightHand(ValueFilter filter) throws RepositoryException { + throw new RepositoryException("Path " + filter.getRightHandSidePath() + "is not supported as right hand side."); + } + } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/PolyStringItemFilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/PolyStringItemFilterProcessor.java index 947a8581259..24b5250c6b2 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/PolyStringItemFilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/PolyStringItemFilterProcessor.java @@ -9,6 +9,7 @@ import java.util.function.Function; import com.google.common.base.Strings; +import com.querydsl.core.types.Expression; import com.querydsl.core.types.ExpressionUtils; import com.querydsl.core.types.Predicate; import com.querydsl.core.types.dsl.StringPath; @@ -19,7 +20,9 @@ import com.evolveum.midpoint.prism.query.PropertyValueFilter; import com.evolveum.midpoint.prism.query.ValueFilter; import com.evolveum.midpoint.repo.sqlbase.QueryException; +import com.evolveum.midpoint.repo.sqlbase.RepositoryException; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; +import com.evolveum.midpoint.repo.sqlbase.filtering.RightHandProcessor; import com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterValues; import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @@ -124,4 +127,40 @@ public static String extractOrig(Object value) { "Value [" + value + "] is neither String nor PolyString(Type)."); } } + + @Override + public Expression rightHand(ValueFilter filter) throws RepositoryException { + return origPath; + } + + @Override + public Predicate process(PropertyValueFilter filter, RightHandProcessor rightPath) throws RepositoryException { + FilterOperation operation = operation(filter); + if (rightPath instanceof PolyStringItemFilterProcessor) { + return processPoly(filter, (PolyStringItemFilterProcessor) rightPath); + } + return singleValuePredicate(this.normPath, operation, rightPath.rightHand(filter)); + } + + private Predicate processPoly(PropertyValueFilter filter, PolyStringItemFilterProcessor rightPath) throws QueryException { + String matchingRule = filter.getMatchingRule() != null + ? filter.getMatchingRule().getLocalPart() : null; + + if (Strings.isNullOrEmpty(matchingRule) || DEFAULT.equals(matchingRule) + || STRICT.equals(matchingRule) || STRICT_IGNORE_CASE.equals(matchingRule)) { + return ExpressionUtils.and( + createBinaryCondition(filter, normPath, + ValueFilterValues.from(filter, rightPath.normPath)), + createBinaryCondition(filter, origPath, + ValueFilterValues.from(filter, rightPath.origPath))); + } else if (ORIG.equals(matchingRule) || ORIG_IGNORE_CASE.equals(matchingRule)) { + return createBinaryCondition(filter, origPath, + ValueFilterValues.from(filter, rightPath.origPath)); + } else if (NORM.equals(matchingRule) || NORM_IGNORE_CASE.equals(matchingRule)) { + return createBinaryCondition(filter, normPath, + ValueFilterValues.from(filter, this.normPath)); + } else { + throw new QueryException("Unknown matching rule '" + matchingRule + "'."); + } + } } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/SimpleItemFilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/SimpleItemFilterProcessor.java index 2854956b146..5102246e300 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/SimpleItemFilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/SimpleItemFilterProcessor.java @@ -13,7 +13,9 @@ import com.evolveum.midpoint.prism.query.PropertyValueFilter; import com.evolveum.midpoint.repo.sqlbase.QueryException; +import com.evolveum.midpoint.repo.sqlbase.RepositoryException; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; +import com.evolveum.midpoint.repo.sqlbase.filtering.RightHandProcessor; import com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterValues; import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; @@ -35,4 +37,11 @@ public , R> SimpleItemFilterProcessor( public Predicate process(PropertyValueFilter filter) throws QueryException { return createBinaryCondition(filter, path, ValueFilterValues.from(filter)); } + + @Override + public Predicate process(PropertyValueFilter filter, RightHandProcessor rightPath) + throws RepositoryException { + return createBinaryCondition(filter, path, + ValueFilterValues.from(filter, rightPath.rightHand(filter))); + } } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/SinglePathItemFilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/SinglePathItemFilterProcessor.java index d990f07c7c6..f47cbcd4946 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/SinglePathItemFilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/SinglePathItemFilterProcessor.java @@ -8,9 +8,12 @@ import java.util.function.Function; +import com.querydsl.core.types.Expression; import com.querydsl.core.types.Path; import com.evolveum.midpoint.prism.query.PropertyValueFilter; +import com.evolveum.midpoint.prism.query.ValueFilter; +import com.evolveum.midpoint.repo.sqlbase.RepositoryException; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; @@ -34,4 +37,9 @@ public , R> SinglePathItemFilterProcesso super(context); this.path = rootToQueryItem.apply(context.path()); } + + @Override + public Expression rightHand(ValueFilter filter) throws RepositoryException { + return path; + } } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/TimestampItemFilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/TimestampItemFilterProcessor.java index 8c78b460876..a4b2bf293bc 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/TimestampItemFilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/item/TimestampItemFilterProcessor.java @@ -17,7 +17,9 @@ import com.evolveum.midpoint.prism.query.PropertyValueFilter; import com.evolveum.midpoint.repo.sqlbase.QueryException; +import com.evolveum.midpoint.repo.sqlbase.RepositoryException; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; +import com.evolveum.midpoint.repo.sqlbase.filtering.RightHandProcessor; import com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterValues; import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; import com.evolveum.midpoint.repo.sqlbase.querydsl.QuerydslUtils; @@ -42,6 +44,13 @@ public Predicate process(PropertyValueFilter filter) throws QueryExcepti ValueFilterValues.from(filter, this::convertToPathType)); } + @Override + public Predicate process(PropertyValueFilter filter, RightHandProcessor rightPath) + throws RepositoryException { + return createBinaryCondition(filter, path, + ValueFilterValues.from(filter, rightPath.rightHand(filter))); + } + // Used instead of Object to conform to unknown type of path above private T convertToPathType(@NotNull Object value) { return QuerydslUtils.convertTimestampToPathType(value, path); diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/DefaultItemSqlMapper.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/DefaultItemSqlMapper.java index 35f86a40467..70526f786d7 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/DefaultItemSqlMapper.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/DefaultItemSqlMapper.java @@ -17,6 +17,7 @@ import com.evolveum.midpoint.prism.query.ValueFilter; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; import com.evolveum.midpoint.repo.sqlbase.filtering.FilterProcessor; +import com.evolveum.midpoint.repo.sqlbase.filtering.RightHandProcessor; import com.evolveum.midpoint.repo.sqlbase.filtering.item.ItemValueFilterProcessor; import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; @@ -87,4 +88,10 @@ public DefaultItemSqlMapper( return filterProcessorFactory .apply((SqlQueryContext) sqlQueryContext); } + + @Override + public > @Nullable RightHandProcessor createRightHandProcessor( + SqlQueryContext sqlQueryContext) { + return filterProcessorFactory.apply((SqlQueryContext) sqlQueryContext); + } } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/ItemSqlMapper.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/ItemSqlMapper.java index 217116509af..3685cf8ced6 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/ItemSqlMapper.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/ItemSqlMapper.java @@ -14,6 +14,7 @@ import com.evolveum.midpoint.prism.query.ValueFilter; import com.evolveum.midpoint.repo.sqlbase.QueryException; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; +import com.evolveum.midpoint.repo.sqlbase.filtering.RightHandProcessor; import com.evolveum.midpoint.repo.sqlbase.filtering.item.ItemValueFilterProcessor; import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; @@ -45,4 +46,8 @@ public interface ItemSqlMapper, R> { */ @Nullable > ItemValueFilterProcessor createFilterProcessor( SqlQueryContext sqlQueryContext); + + @Nullable > RightHandProcessor createRightHandProcessor( + SqlQueryContext sqlQueryContext); + } From 1b85d72c09177ab13b39338cc9e1fe9786403057 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 8 Sep 2021 19:03:45 +0200 Subject: [PATCH 05/19] further "sqale" Job tuning: old repo tests are skipped + sqale logging --- repo/repo-sqale/pom.xml | 7 ---- .../src/test/resources/logback-test.xml | 38 +++++++++++++++++++ repo/repo-sql-impl-test/pom.xml | 10 +++++ 3 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 repo/repo-sqale/src/test/resources/logback-test.xml diff --git a/repo/repo-sqale/pom.xml b/repo/repo-sqale/pom.xml index c0b194875b8..07515bb596d 100644 --- a/repo/repo-sqale/pom.xml +++ b/repo/repo-sqale/pom.xml @@ -151,13 +151,6 @@ false - - - - maven-surefire-plugin - - - diff --git a/repo/repo-sqale/src/test/resources/logback-test.xml b/repo/repo-sqale/src/test/resources/logback-test.xml new file mode 100644 index 00000000000..f9bca40864b --- /dev/null +++ b/repo/repo-sqale/src/test/resources/logback-test.xml @@ -0,0 +1,38 @@ + + + + + + ./target/test.log + + %date [%thread] %-5level \(%logger{46}\): %message%n + + + + + %date [%thread] %-5level \(%logger{46}\): %message%n + + + + + + + + + + + + + + + + + + + + diff --git a/repo/repo-sql-impl-test/pom.xml b/repo/repo-sql-impl-test/pom.xml index 7b49efe5392..f8000ee02cf 100644 --- a/repo/repo-sql-impl-test/pom.xml +++ b/repo/repo-sql-impl-test/pom.xml @@ -255,5 +255,15 @@ + + + sqale + + false + + + true + + From fc62a498d9a1b3704b83dcff262ee46e6675feac Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Wed, 8 Sep 2021 19:19:17 +0200 Subject: [PATCH 06/19] sqale: Fixed wrong recursion in ExtensionMapper Signed-off-by: Tony Tkacik --- .../midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java index 2fed2830071..e1646df1a15 100644 --- a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java +++ b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java @@ -101,7 +101,7 @@ public ExtensionItemSqlMapper( @Override public > @Nullable RightHandProcessor createRightHandProcessor( SqlQueryContext sqlQueryContext) { - return createRightHandProcessor(sqlQueryContext); + return createFilterProcessor(sqlQueryContext); } @Override From f2cb7baa1c90edfbe30bcad3440c8faa77517e37 Mon Sep 17 00:00:00 2001 From: Katarina Valalikova Date: Wed, 8 Sep 2021 19:57:01 +0200 Subject: [PATCH 07/19] support for new and old design --- .../api/DefaultGuiConfigurationCompiler.java | 5 ++ .../gui/api/component/DisplayNamePanel.java | 16 +++-- .../gui/api/util/WebComponentUtil.java | 58 ++++++++++++++++--- .../menu/DetailsNavigationPanel.java | 12 +++- .../impl/component/menu/LeftMenuPanel.java | 51 ++++++++-------- .../gui/impl/component/menu/PageTypes.java | 43 ++++++++------ .../page/admin/AbstractPageObjectDetails.java | 39 ++++++++----- .../impl/page/admin/ObjectDetailsModels.java | 4 ++ .../component/AbstractRoleMemberPanel.java | 5 ++ .../PageAssignmentHolderDetails.java | 15 +++-- .../gui/impl/page/admin/cases/PageCase.java | 15 +++-- .../page/admin/focus/PageFocusDetails.java | 14 ++++- .../gui/impl/page/admin/org/PageOrg.java | 5 ++ .../admin/org/component/OrgMemberPanel.java | 3 + .../impl/page/admin/report/PageReport.java | 4 ++ .../page/admin/resource/PageResource.java | 5 ++ .../gui/impl/page/admin/role/PageRole.java | 5 ++ .../impl/page/admin/service/PageService.java | 5 ++ .../gui/impl/page/admin/task/PageTask.java | 4 ++ .../gui/impl/page/admin/user/PageUser.java | 13 +++-- .../user/component/DelegatedToMePanel.java | 2 +- .../user/component/UserDelegationsPanel.java | 2 +- .../component/data/column/ColumnUtils.java | 2 - .../xml/ns/public/common/common-gui-3.xsd | 24 ++++++++ .../authentication/CompiledGuiProfile.java | 10 ++++ .../impl/security/GuiProfileCompiler.java | 3 + 26 files changed, 272 insertions(+), 92 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/DefaultGuiConfigurationCompiler.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/DefaultGuiConfigurationCompiler.java index 70d1569b26f..03db406030e 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/DefaultGuiConfigurationCompiler.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/DefaultGuiConfigurationCompiler.java @@ -11,6 +11,7 @@ import java.util.*; import javax.annotation.PostConstruct; +import com.evolveum.midpoint.gui.api.prism.ItemStatus; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; @@ -241,6 +242,10 @@ private ContainerPanelConfigurationType compileContainerPanelConfiguration(Class if (panelInstance.defaultPanel()) { config.setDefault(true); } + if (Arrays.stream(panelInstance.status()).filter(s -> ItemStatus.ADDED == s).count() == 1) { + config.setVisibleForAdd(true); + } + return config; } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/DisplayNamePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/DisplayNamePanel.java index 2ab6ef2aaec..0652601b48b 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/DisplayNamePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/DisplayNamePanel.java @@ -82,9 +82,7 @@ public void onClick(AjaxRequestTarget ajaxRequestTarget) { } } }; - navigateToObject.add(new VisibleBehaviour(() -> DisplayNamePanel.this.getModelObject() instanceof ObjectType && - StringUtils.isNotEmpty(((ObjectType) DisplayNamePanel.this.getModelObject()).getOid()) && - WebComponentUtil.getObjectDetailsPage(((ObjectType) DisplayNamePanel.this.getModelObject()).getClass()) != null)); + navigateToObject.add(new VisibleBehaviour(() -> hasDetailsPage())); navigateToObject.setOutputMarkupId(true); add(navigateToObject); @@ -110,9 +108,17 @@ protected void populateItem(ListItem item) { }; add(descriptionLabels); + } -// add(new Label(ID_DESCRIPTION, getDescriptionLabelsModel())); -// add(new Label(ID_PENDING_OPERATION, getPendingOperationLabelModel())); + private boolean hasDetailsPage() { + C containerable = getModelObject(); + if (!(containerable instanceof ObjectType)) { + return false; + } + if (((ObjectType) containerable).getOid().isBlank()) { + return false; + } + return WebComponentUtil.hasDetailsPage(containerable.getClass()); } protected WebMarkupContainer createTypeImagePanel(String idTypeImage) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java index 2423a29cd08..6253b70da96 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/util/WebComponentUtil.java @@ -26,6 +26,8 @@ import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.component.assignmentType.AbstractAssignmentTypePanel; import com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels; +import com.evolveum.midpoint.gui.impl.page.admin.org.PageOrg; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.*; import org.apache.commons.lang3.math.NumberUtils; @@ -220,6 +222,9 @@ public final class WebComponentUtil { private static final Map, Class> OBJECT_DETAILS_PAGE_MAP; private static final Map, Class> CREATE_NEW_OBJECT_PAGE_MAP; + + private static final Map, Class> OBJECT_DETAILS_PAGE_MAP_NEW; + static { OBJECT_DETAILS_PAGE_MAP = new HashMap<>(); OBJECT_DETAILS_PAGE_MAP.put(UserType.class, PageUser.class); @@ -237,6 +242,23 @@ public final class WebComponentUtil { OBJECT_DETAILS_PAGE_MAP.put(ObjectTemplateType.class, PageObjectTemplate.class); } + static { + OBJECT_DETAILS_PAGE_MAP_NEW = new HashMap<>(); + OBJECT_DETAILS_PAGE_MAP_NEW.put(UserType.class, com.evolveum.midpoint.gui.impl.page.admin.user.PageUser.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(OrgType.class, PageOrg.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(RoleType.class, com.evolveum.midpoint.gui.impl.page.admin.role.PageRole.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(ServiceType.class, com.evolveum.midpoint.gui.impl.page.admin.service.PageService.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(ResourceType.class, com.evolveum.midpoint.gui.impl.page.admin.resource.PageResource.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(TaskType.class, com.evolveum.midpoint.gui.impl.page.admin.task.PageTask.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(ReportType.class, com.evolveum.midpoint.gui.impl.page.admin.report.PageReport.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(ValuePolicyType.class, PageValuePolicy.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(CaseType.class, com.evolveum.midpoint.gui.impl.page.admin.cases.PageCase.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(ArchetypeType.class, PageArchetype.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(ShadowType.class, PageAccount.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(ObjectCollectionType.class, PageObjectCollection.class); + OBJECT_DETAILS_PAGE_MAP_NEW.put(ObjectTemplateType.class, PageObjectTemplate.class); + } + static { CREATE_NEW_OBJECT_PAGE_MAP = new HashMap<>(); CREATE_NEW_OBJECT_PAGE_MAP.put(ResourceType.class, PageResourceWizard.class); @@ -818,7 +840,7 @@ public static boolean isAuthorized(Collection actions) { } public static boolean isAuthorized(Class clazz) { - Class detailsPage = WebComponentUtil.getObjectDetailsPage(clazz); + Class detailsPage = getObjectDetailsPage(clazz); if (detailsPage == null) { return false; } @@ -2476,6 +2498,21 @@ public static void dispatchToObjectDetailsPage(PrismObject obj, Component compon dispatchToObjectDetailsPage(obj, false, component); } + private static boolean isNewDesignEnabled() { + MidPointApplication app = MidPointApplication.get(); + ModelInteractionService service = app.getModelInteractionService(); + Task task = app.createSimpleTask("get compiledGui profile"); + OperationResult result = task.getResult(); + try { + CompiledGuiProfile compiledGuiProfile = service.getCompiledGuiProfile(task, result); + return compiledGuiProfile.isUseNewDesign(); + } catch (Throwable e) { + LOGGER.error("Cannot get compiled gui profile, {}", e.getMessage(), e); + } + //if somthing happen just return true, by default we want new design + return true; + } + // shows the actual object that is passed via parameter (not its state in repository) public static void dispatchToObjectDetailsPage(PrismObject obj, boolean isNewObject, Component component) { Class newObjectPageClass = isNewObject ? getNewlyCreatedObjectPage(obj.getCompileTimeClass()) : getObjectDetailsPage(obj.getCompileTimeClass()); @@ -2490,8 +2527,13 @@ public static void dispatchToObjectDetailsPage(PrismObject obj, boolean isNewObj constructor = newObjectPageClass.getConstructor(PageParameters.class); page = (PageBase) constructor.newInstance(new PageParameters()); } else { - constructor = newObjectPageClass.getConstructor(PrismObject.class, boolean.class); - page = (PageBase) constructor.newInstance(obj, isNewObject); + if (isNewDesignEnabled()) { + constructor = newObjectPageClass.getConstructor(PrismObject.class); + page = (PageBase) constructor.newInstance(obj); + } else { + constructor = newObjectPageClass.getConstructor(PrismObject.class, boolean.class); + page = (PageBase) constructor.newInstance(obj, isNewObject); + } } if (component.getPage() instanceof PageBase) { @@ -2531,11 +2573,10 @@ public static boolean hasDetailsPage(Class clazz) { return OBJECT_DETAILS_PAGE_MAP.containsKey(clazz); } - public static String getStorageKeyForTableId(TableId tableId) { - return STORAGE_TABLE_ID_MAP.get(tableId); - } - public static Class getObjectDetailsPage(Class type) { + if (isNewDesignEnabled()) { + return OBJECT_DETAILS_PAGE_MAP_NEW.get(type); + } return OBJECT_DETAILS_PAGE_MAP.get(type); } @@ -2543,6 +2584,9 @@ public static Class getNewlyCreatedObjectPage(Class { private static final String OPERATION_LOAD_WORK_ITEM_COUNT = DOT_CLASS + "loadWorkItemCount"; private static final String OPERATION_LOAD_CERT_WORK_ITEM_COUNT = DOT_CLASS + "loadCertificationWorkItemCount"; - private LoadableModel workItemCountModel; - private LoadableModel certWorkItemCountModel; - private LoadableModel> sideBarMenuModel; + private final LoadableModel workItemCountModel; + private final LoadableModel certWorkItemCountModel; + private final LoadableModel> sideBarMenuModel; public LeftMenuPanel(String id) { super(id); - sideBarMenuModel = new LoadableModel>(false) { + sideBarMenuModel = new LoadableModel<>(false) { private static final long serialVersionUID = 1L; @@ -101,7 +101,7 @@ protected List load() { } }; - workItemCountModel = new LoadableModel(false) { + workItemCountModel = new LoadableModel<>(false) { private static final long serialVersionUID = 1L; @Override @@ -110,7 +110,7 @@ protected String load() { Task task = getPageBase().createSimpleTask(OPERATION_LOAD_WORK_ITEM_COUNT); S_FilterEntryOrEmpty q = getPrismContext().queryFor(CaseWorkItemType.class); ObjectQuery query = QueryUtils.filterForAssignees(q, getPageBase().getPrincipal(), - OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, getPageBase().getRelationRegistry()) + OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, getPageBase().getRelationRegistry()) .and() .item(CaseWorkItemType.F_CLOSE_TIMESTAMP) .isNull() @@ -126,7 +126,7 @@ OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, getPageBase().getRelationRe } } }; - certWorkItemCountModel = new LoadableModel(false) { + certWorkItemCountModel = new LoadableModel<>(false) { private static final long serialVersionUID = 1L; @Override @@ -135,11 +135,11 @@ protected String load() { AccessCertificationService acs = getPageBase().getCertificationService(); Task task = getPageBase().createSimpleTask(OPERATION_LOAD_CERT_WORK_ITEM_COUNT); OperationResult result = task.getResult(); - Integer openCertWorkItems = acs.countOpenWorkItems(getPrismContext().queryFactory().createQuery(), true, null, task, result); - if (openCertWorkItems == null || openCertWorkItems == 0) { + int openCertWorkItems = acs.countOpenWorkItems(getPrismContext().queryFactory().createQuery(), true, null, task, result); + if (openCertWorkItems == 0) { return null; } - return openCertWorkItems.toString(); + return Integer.toString(openCertWorkItems); } catch (Exception e) { LoggingUtils.logExceptionAsWarning(LOGGER, "Couldn't load certification work item count", e); return null; @@ -446,12 +446,24 @@ private void createBasicAssignmentHolderMenuItems(MainMenuItem mainMenuItem, Pag if (PageTypes.CASE != pageDesc) { createFocusPageNewEditMenu(mainMenuItem, "PageAdmin.menu.top." + pageDesc.getIdentifier() + ".new", - "PageAdmin.menu.top." + pageDesc.getIdentifier() + ".edit", pageDesc.getDetailsPage()); + "PageAdmin.menu.top." + pageDesc.getIdentifier() + ".edit", getDetailsPage(pageDesc)); + } + } + + private Class getDetailsPage(PageTypes pageDesc) { + CompiledGuiProfile guiProfile = getPageBase().getCompiledGuiProfile(); + if (guiProfile.isUseNewDesign()) { + return pageDesc.getDetailsPage(); } + return pageDesc.getOldDetailsPage(); } private boolean isEditForAdminObjectDetails() { PageBase pageBase = getPageBase(); + if (pageBase instanceof AbstractPageObjectDetails) { + AbstractPageObjectDetails page = (AbstractPageObjectDetails) pageBase; + return page.isEditObject(); + } if (pageBase instanceof PageAdminObjectDetails) { PageAdminObjectDetails page = (PageAdminObjectDetails) pageBase; return page.isOidParameterExists() || page.isEditingFocus(); @@ -470,17 +482,8 @@ private boolean isEditForResourceWizzard() { return false; } - private boolean isAddForResourceWizzard() { - PageBase pageBase = getPageBase(); - if (!(pageBase instanceof PageResourceWizard)) { - return false; - } - - return ((PageResourceWizard) pageBase).isNewResource(); - } - private void createFocusPageNewEditMenu(MainMenuItem mainMenuItem, String newKey, String editKey, - final Class newPageClass) { + final Class newPageClass) { boolean addActive = classMatches(newPageClass) && !isEditForAdminObjectDetails() && !isEditForResourceWizzard(); MenuItem newMenu = new MenuItem(newKey, diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/menu/PageTypes.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/menu/PageTypes.java index 4b7d0673129..d847f8401b6 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/menu/PageTypes.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/menu/PageTypes.java @@ -8,49 +8,54 @@ import com.evolveum.midpoint.gui.api.GuiStyleConstants; import com.evolveum.midpoint.gui.api.page.PageBase; +import com.evolveum.midpoint.gui.impl.page.admin.AbstractPageObjectDetails; +import com.evolveum.midpoint.gui.impl.page.admin.org.PageOrg; +import com.evolveum.midpoint.gui.impl.page.admin.report.PageReport; +import com.evolveum.midpoint.gui.impl.page.admin.resource.PageResource; +import com.evolveum.midpoint.gui.impl.page.admin.role.PageRole; +import com.evolveum.midpoint.gui.impl.page.admin.service.PageService; +import com.evolveum.midpoint.gui.impl.page.admin.task.PageTask; +import com.evolveum.midpoint.gui.impl.page.admin.user.PageUser; import com.evolveum.midpoint.web.page.admin.PageAdmin; import com.evolveum.midpoint.web.page.admin.cases.PageCases; import com.evolveum.midpoint.web.page.admin.orgs.PageOrgUnit; import com.evolveum.midpoint.web.page.admin.orgs.PageOrgs; -import com.evolveum.midpoint.web.page.admin.reports.PageReport; import com.evolveum.midpoint.web.page.admin.reports.PageReports; -import com.evolveum.midpoint.web.page.admin.resources.PageResource; import com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard; import com.evolveum.midpoint.web.page.admin.resources.PageResources; -import com.evolveum.midpoint.web.page.admin.roles.PageRole; import com.evolveum.midpoint.web.page.admin.roles.PageRoles; -import com.evolveum.midpoint.web.page.admin.server.PageTask; import com.evolveum.midpoint.web.page.admin.server.PageTasks; -import com.evolveum.midpoint.web.page.admin.services.PageService; import com.evolveum.midpoint.web.page.admin.services.PageServices; -import com.evolveum.midpoint.web.page.admin.users.PageUser; import com.evolveum.midpoint.web.page.admin.users.PageUsers; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import javax.xml.namespace.QName; +//TODO remove in 4.5 public enum PageTypes { - USER("users", GuiStyleConstants.CLASS_OBJECT_USER_ICON, PageUsers.class, PageUser.class, UserType.COMPLEX_TYPE), - ROLE("roles", GuiStyleConstants.CLASS_OBJECT_ROLE_ICON, PageRoles.class, PageRole.class, RoleType.COMPLEX_TYPE), - SERVICE("services", GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON, PageServices.class, PageService.class, ServiceType.COMPLEX_TYPE), - ORG("orgs", GuiStyleConstants.CLASS_OBJECT_ORG_ICON, PageOrgs.class, PageOrgUnit.class, OrgType.COMPLEX_TYPE), - TASK("tasks", GuiStyleConstants.CLASS_OBJECT_TASK_ICON, PageTasks.class, PageTask.class, TaskType.COMPLEX_TYPE), - RESOURCE("resources", GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON, PageResources.class, PageResourceWizard.class, ResourceType.COMPLEX_TYPE), - CASE("cases", GuiStyleConstants.EVO_CASE_OBJECT_ICON, PageCases.class, null, CaseType.COMPLEX_TYPE), - REPORT("reports", GuiStyleConstants.CLASS_REPORT_ICON, PageReports .class, PageReport.class, ReportType.COMPLEX_TYPE); + USER("users", GuiStyleConstants.CLASS_OBJECT_USER_ICON, PageUsers.class, PageUser.class, com.evolveum.midpoint.web.page.admin.users.PageUser.class, UserType.COMPLEX_TYPE), + ROLE("roles", GuiStyleConstants.CLASS_OBJECT_ROLE_ICON, PageRoles.class, PageRole.class, com.evolveum.midpoint.web.page.admin.roles.PageRole.class, RoleType.COMPLEX_TYPE), + SERVICE("services", GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON, PageServices.class, PageService.class, com.evolveum.midpoint.web.page.admin.services.PageService.class, ServiceType.COMPLEX_TYPE), + ORG("orgs", GuiStyleConstants.CLASS_OBJECT_ORG_ICON, PageOrgs.class, PageOrg.class, PageOrgUnit.class, OrgType.COMPLEX_TYPE), + TASK("tasks", GuiStyleConstants.CLASS_OBJECT_TASK_ICON, PageTasks.class, PageTask.class, com.evolveum.midpoint.web.page.admin.server.PageTask.class, TaskType.COMPLEX_TYPE), + RESOURCE("resources", GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON, PageResources.class, PageResource.class, PageResourceWizard.class, ResourceType.COMPLEX_TYPE), + CASE("cases", GuiStyleConstants.EVO_CASE_OBJECT_ICON, PageCases.class, null, null, CaseType.COMPLEX_TYPE), + REPORT("reports", GuiStyleConstants.CLASS_REPORT_ICON, PageReports .class, PageReport.class, com.evolveum.midpoint.web.page.admin.reports.PageReport.class, ReportType.COMPLEX_TYPE); private String identifier; private String icon; private Class listClass; - private Class detailsPage; + private Class detailsPage; + private Class oldDetailsPage; private QName typeName; - PageTypes(String identifier, String icon, Class listClass, Class detailsPage, QName typeName) { + PageTypes(String identifier, String icon, Class listClass, Class detailsPage, Class oldDetailsPage, QName typeName) { this.identifier = identifier; this.icon = icon; this.listClass = listClass; this.detailsPage = detailsPage; + this.oldDetailsPage = oldDetailsPage; this.typeName = typeName; } @@ -66,10 +71,14 @@ public Class getListClass() { return listClass; } - public Class getDetailsPage() { + public Class getDetailsPage() { return detailsPage; } + public Class getOldDetailsPage() { + return oldDetailsPage; + } + public QName getTypeName() { return typeName; } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java index 50fd3a5060f..b359f2d3ad8 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java @@ -9,31 +9,27 @@ import java.time.Duration; import java.util.*; +import com.evolveum.midpoint.gui.api.prism.ItemStatus; import com.evolveum.midpoint.gui.impl.component.menu.DetailsNavigationPanel; import com.evolveum.midpoint.gui.impl.page.admin.component.OperationalButtonsPanel; -import com.evolveum.midpoint.prism.delta.ChangeType; - -import com.evolveum.midpoint.util.MiscUtil; - import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.web.component.util.VisibleBehaviour; + import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.wicket.Component; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.AjaxSelfUpdatingTimerBehavior; -import org.apache.wicket.behavior.AttributeAppender; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.markup.repeater.RepeatingView; import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.util.string.StringValue; -import com.evolveum.midpoint.gui.api.GuiStyleConstants; import com.evolveum.midpoint.gui.api.model.LoadableModel; import com.evolveum.midpoint.gui.api.page.PageBase; import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper; @@ -48,7 +44,6 @@ import com.evolveum.midpoint.util.logging.LoggingUtils; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.web.component.AjaxIconButton; import com.evolveum.midpoint.web.component.form.MidpointForm; import com.evolveum.midpoint.web.component.progress.ProgressPanel; import com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto; @@ -82,13 +77,22 @@ public abstract class AbstractPageObjectDetails object) { + this(null, object); + } + private AbstractPageObjectDetails(PageParameters params, PrismObject object) { + super(params); + objectDetailsModels = createObjectDetailsModels(object); initLayout(); - } protected ObjectDetailsModels getObjectDetailsModels() { @@ -96,15 +100,18 @@ protected ObjectDetailsModels getObjectDetailsModels() { } //TODO should be abstract?? - protected ODM createObjectDetailsModels() { - return (ODM) new ObjectDetailsModels<>(createPrismObejctModel(), this); + protected ODM createObjectDetailsModels(PrismObject object) { + return (ODM) new ObjectDetailsModels<>(createPrismObejctModel(object), this); } - protected LoadableModel> createPrismObejctModel() { + protected LoadableModel> createPrismObejctModel(PrismObject object) { return new LoadableModel<>(false) { @Override protected PrismObject load() { + if (object != null) { + return object; + } return loadPrismObject(); } }; @@ -136,7 +143,9 @@ private void initDetailsPanel() { private Panel initSummaryPanel() { LoadableModel summaryModel = objectDetailsModels.getSummaryModel(); - return createSummaryPanel(ID_SUMMARY, summaryModel); + Panel summaryPanel = createSummaryPanel(ID_SUMMARY, summaryModel); + summaryPanel.add(new VisibleBehaviour(() -> objectDetailsModels.getObjectStatus() != ItemStatus.ADDED)); + return summaryPanel; } private void initButtons(MidpointForm form) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/ObjectDetailsModels.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/ObjectDetailsModels.java index 8521be95225..235bfbc99f7 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/ObjectDetailsModels.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/ObjectDetailsModels.java @@ -273,4 +273,8 @@ public O getObjectType() { protected boolean isReadonly() { return false; } + + public ItemStatus getObjectStatus() { + return objectWrapperModel.getObject().getStatus(); + } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/abstractrole/component/AbstractRoleMemberPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/abstractrole/component/AbstractRoleMemberPanel.java index 4dd401973b6..38726b028ce 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/abstractrole/component/AbstractRoleMemberPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/abstractrole/component/AbstractRoleMemberPanel.java @@ -12,6 +12,7 @@ import com.evolveum.midpoint.gui.api.component.MainObjectListPanel; import com.evolveum.midpoint.gui.api.model.LoadableModel; import com.evolveum.midpoint.gui.api.page.PageBase; +import com.evolveum.midpoint.gui.api.prism.ItemStatus; import com.evolveum.midpoint.gui.api.util.WebComponentUtil; import com.evolveum.midpoint.gui.api.util.WebDisplayTypeUtil; import com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon; @@ -91,15 +92,19 @@ @PanelInstances(instances = { @PanelInstance(identifier = "roleMembers", applicableFor = RoleType.class, + status = ItemStatus.NOT_CHANGED, display = @PanelDisplay(label = "pageRole.members", order = 80)), @PanelInstance(identifier = "roleGovernance", applicableFor = RoleType.class, + status = ItemStatus.NOT_CHANGED, display = @PanelDisplay(label = "pageRole.governance", order = 90)), @PanelInstance(identifier = "serviceMembers", applicableFor = ServiceType.class, + status = ItemStatus.NOT_CHANGED, display = @PanelDisplay(label = "pageRole.members", order = 80)), @PanelInstance(identifier = "serviceGovernance", applicableFor = ServiceType.class, + status = ItemStatus.NOT_CHANGED, display = @PanelDisplay(label = "pageRole.governance", order = 90)) }) @PanelDisplay(label = "Members", order = 60) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/PageAssignmentHolderDetails.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/PageAssignmentHolderDetails.java index 6e25678c267..0fdb8d7725c 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/PageAssignmentHolderDetails.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/PageAssignmentHolderDetails.java @@ -11,7 +11,6 @@ import com.evolveum.midpoint.gui.api.util.WebComponentUtil; import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils; import com.evolveum.midpoint.gui.impl.page.admin.AbstractPageObjectDetails; -import com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels; import com.evolveum.midpoint.gui.impl.page.admin.component.AssignmentHolderOperationalButtonsPanel; import com.evolveum.midpoint.gui.impl.page.admin.component.OperationalButtonsPanel; import com.evolveum.midpoint.model.api.context.ModelContext; @@ -33,7 +32,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.wicket.Session; import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.markup.repeater.RepeatingView; import org.apache.wicket.protocol.http.WebSession; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -46,10 +44,19 @@ public abstract class PageAssignmentHolderDetails> extends AbstractPageObjectDetails implements ProgressReportingAwarePage { private static final Trace LOGGER = TraceManager.getTrace(PageAssignmentHolderDetails.class); + + public PageAssignmentHolderDetails() { + super(); + } + public PageAssignmentHolderDetails(PageParameters pageParameters) { super(pageParameters); } + public PageAssignmentHolderDetails(PrismObject assignmentHolder) { + super(assignmentHolder); + } + @Override protected OperationalButtonsPanel createButtonsPanel(String id, LoadableModel> wrapperModel) { return new AssignmentHolderOperationalButtonsPanel<>(id, wrapperModel) { @@ -220,8 +227,8 @@ public void continueEditing(AjaxRequestTarget target) { target.add(this); } - protected AHDM createObjectDetailsModels() { - return (AHDM) new AssignmentHolderDetailsModel<>(createPrismObejctModel(), this); + protected AHDM createObjectDetailsModels(PrismObject object) { + return (AHDM) new AssignmentHolderDetailsModel<>(createPrismObejctModel(object), this); } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/cases/PageCase.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/cases/PageCase.java index e5d382c8a39..0a8fae44bc1 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/cases/PageCase.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/cases/PageCase.java @@ -13,9 +13,7 @@ import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails; import com.evolveum.midpoint.gui.impl.page.admin.cases.component.CaseOperationalButtonsPanel; import com.evolveum.midpoint.gui.impl.page.admin.component.OperationalButtonsPanel; -import com.evolveum.midpoint.gui.impl.page.admin.component.TaskOperationalButtonsPanel; -import com.evolveum.midpoint.gui.impl.page.admin.task.PageTask; -import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.web.application.AuthorizationAction; import com.evolveum.midpoint.web.application.PageDescriptor; @@ -24,9 +22,6 @@ import com.evolveum.midpoint.web.util.OnePageParameterEncoder; import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; - -import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -47,6 +42,10 @@ public PageCase(PageParameters pageParameters) { super(pageParameters); } + public PageCase(PrismObject caseType) { + super(caseType); + } + @Override protected Class getType() { return CaseType.class; @@ -58,8 +57,8 @@ protected Panel createSummaryPanel(String id, LoadableModel summaryMod } @Override - protected AssignmentHolderDetailsModel createObjectDetailsModels() { - return new CaseDetailsModels(createPrismObejctModel(), this); + protected AssignmentHolderDetailsModel createObjectDetailsModels(PrismObject object) { + return new CaseDetailsModels(createPrismObejctModel(object), this); } @Override diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/focus/PageFocusDetails.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/focus/PageFocusDetails.java index 90f85053882..def91923775 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/focus/PageFocusDetails.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/focus/PageFocusDetails.java @@ -8,11 +8,11 @@ import com.evolveum.midpoint.gui.api.model.LoadableModel; import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper; -import com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels; import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.FocusDetailsModels; import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails; import com.evolveum.midpoint.gui.impl.page.admin.component.FocusOperationalButtonsPanel; import com.evolveum.midpoint.gui.impl.page.admin.component.OperationalButtonsPanel; +import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.wicket.ajax.AjaxRequestTarget; @@ -20,10 +20,18 @@ public abstract class PageFocusDetails> extends PageAssignmentHolderDetails { + public PageFocusDetails() { + super(); + } + public PageFocusDetails(PageParameters pageParameters) { super(pageParameters); } + public PageFocusDetails(PrismObject focus) { + super(focus); + } + @Override protected OperationalButtonsPanel createButtonsPanel(String id, LoadableModel> wrapperModel) { return new FocusOperationalButtonsPanel(id, wrapperModel) { @@ -42,7 +50,7 @@ protected void previewPerformed(AjaxRequestTarget target) { } @Override - protected FDM createObjectDetailsModels() { - return (FDM) new FocusDetailsModels<>(createPrismObejctModel(), this); + protected FDM createObjectDetailsModels(PrismObject object) { + return (FDM) new FocusDetailsModels<>(createPrismObejctModel(object), this); } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/PageOrg.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/PageOrg.java index 1b8eb1bb24c..63c7fef0e43 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/PageOrg.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/PageOrg.java @@ -9,6 +9,7 @@ import com.evolveum.midpoint.gui.api.model.LoadableModel; import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.FocusDetailsModels; import com.evolveum.midpoint.gui.impl.page.admin.focus.PageFocusDetails; +import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.web.application.AuthorizationAction; import com.evolveum.midpoint.web.application.PageDescriptor; @@ -37,6 +38,10 @@ public PageOrg(PageParameters pageParameters) { super(pageParameters); } + public PageOrg(PrismObject org) { + super(org); + } + @Override protected Class getType() { return OrgType.class; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/component/OrgMemberPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/component/OrgMemberPanel.java index e311dcbaa8f..be55dec362a 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/component/OrgMemberPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/component/OrgMemberPanel.java @@ -11,6 +11,7 @@ import java.util.List; import javax.xml.namespace.QName; +import com.evolveum.midpoint.gui.api.prism.ItemStatus; import com.evolveum.midpoint.web.application.PanelDisplay; import com.evolveum.midpoint.web.application.PanelInstance; import com.evolveum.midpoint.web.application.PanelInstances; @@ -32,8 +33,10 @@ @PanelType(name = "orgMembers") @PanelInstances(instances = { @PanelInstance(identifier = "orgMembers", applicableFor = OrgType.class, + status = ItemStatus.NOT_CHANGED, display = @PanelDisplay(label = "pageRole.members", order = 60)), @PanelInstance(identifier = "orgGovernance", applicableFor = OrgType.class, + status = ItemStatus.NOT_CHANGED, display = @PanelDisplay(label = "pageRole.governance", order = 60)) }) public class OrgMemberPanel extends AbstractRoleMemberPanel { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/report/PageReport.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/report/PageReport.java index 4eab7a85361..26e01461678 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/report/PageReport.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/report/PageReport.java @@ -69,6 +69,10 @@ public PageReport(PageParameters pageParameters) { super(pageParameters); } + public PageReport(PrismObject report) { + super(report); + } + @Override protected Class getType() { return ReportType.class; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/resource/PageResource.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/resource/PageResource.java index 1c631059286..be96728f5e1 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/resource/PageResource.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/resource/PageResource.java @@ -14,6 +14,7 @@ import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails; import com.evolveum.midpoint.gui.impl.page.admin.component.OperationalButtonsPanel; import com.evolveum.midpoint.gui.impl.page.admin.component.ResourceOperationalButtonsPanel; +import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.web.application.AuthorizationAction; import com.evolveum.midpoint.web.application.PageDescriptor; @@ -48,6 +49,10 @@ public PageResource(PageParameters pageParameters) { super(pageParameters); } + public PageResource(PrismObject resource) { + super(resource); + } + @Override protected Class getType() { return ResourceType.class; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/role/PageRole.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/role/PageRole.java index 7f808cd5a2c..cfcbf9d4ef8 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/role/PageRole.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/role/PageRole.java @@ -11,6 +11,7 @@ import com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels; import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.FocusDetailsModels; import com.evolveum.midpoint.gui.impl.page.admin.focus.PageFocusDetails; +import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.web.application.AuthorizationAction; import com.evolveum.midpoint.web.application.PageDescriptor; @@ -35,6 +36,10 @@ public PageRole(PageParameters pageParameters) { super(pageParameters); } + public PageRole(PrismObject role) { + super(role); + } + @Override protected Class getType() { return RoleType.class; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/service/PageService.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/service/PageService.java index 3c9c9ffc79c..55a4d8cc627 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/service/PageService.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/service/PageService.java @@ -9,6 +9,7 @@ import com.evolveum.midpoint.gui.api.model.LoadableModel; import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.FocusDetailsModels; import com.evolveum.midpoint.gui.impl.page.admin.focus.PageFocusDetails; +import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.web.application.AuthorizationAction; import com.evolveum.midpoint.web.application.PageDescriptor; @@ -40,6 +41,10 @@ public PageService(PageParameters pageParameters) { super(pageParameters); } + public PageService(PrismObject service) { + super(service); + } + @Override protected Class getType() { return ServiceType.class; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/task/PageTask.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/task/PageTask.java index 0c40e5465df..20cc947c238 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/task/PageTask.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/task/PageTask.java @@ -94,6 +94,10 @@ public PageTask(PageParameters pageParameters) { super(pageParameters); } + public PageTask(PrismObject task) { + super(task); + } + @Override protected Class getType() { return TaskType.class; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/PageUser.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/PageUser.java index 3f8348707bf..f1377539f79 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/PageUser.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/PageUser.java @@ -6,7 +6,7 @@ */ package com.evolveum.midpoint.gui.impl.page.admin.user; -import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.FocusDetailsModels; +import com.evolveum.midpoint.prism.PrismObject; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -41,13 +41,18 @@ public class PageUser extends PageFocusDetails { private static final Trace LOGGER = TraceManager.getTrace(PageUser.class); public PageUser() { - this(null); + super(); } public PageUser(PageParameters params) { super(params); } + public PageUser(PrismObject user) { + super(user); + + } + @Override protected Class getType() { return UserType.class; @@ -59,8 +64,8 @@ protected Panel createSummaryPanel(String id, LoadableModel summaryMod } @Override - protected UserDetailsModel createObjectDetailsModels() { - return new UserDetailsModel(createPrismObejctModel(), this); + protected UserDetailsModel createObjectDetailsModels(PrismObject object) { + return new UserDetailsModel(createPrismObejctModel(object), this); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/component/DelegatedToMePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/component/DelegatedToMePanel.java index 456ef38c20c..e5b8602324d 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/component/DelegatedToMePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/component/DelegatedToMePanel.java @@ -41,7 +41,7 @@ * @author shood */ @PanelType(name = "delegatedToMe") -@PanelInstance(identifier = "delegatedToMe", status = ItemStatus.NOT_CHANGED, applicableFor = UserType.class, +@PanelInstance(identifier = "delegatedToMe", applicableFor = UserType.class, display = @PanelDisplay(label = "FocusType.delegatedToMe", order = 80)) @Counter(provider = DelegatedToMeCounter.class) public class DelegatedToMePanel extends AbstractObjectMainPanel { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/component/UserDelegationsPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/component/UserDelegationsPanel.java index dbaf699545f..79b41deb255 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/component/UserDelegationsPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/user/component/UserDelegationsPanel.java @@ -44,7 +44,7 @@ * Created by honchar */ @PanelType(name = "userDelegations") -@PanelInstance(identifier = "userDelegations", status = ItemStatus.NOT_CHANGED, applicableFor = UserType.class, +@PanelInstance(identifier = "userDelegations", applicableFor = UserType.class, display = @PanelDisplay(label = "FocusType.delegations", order = 70)) @Counter(provider = UserDelegationsCounter.class) public class UserDelegationsPanel extends AbstractObjectMainPanel { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/ColumnUtils.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/ColumnUtils.java index 5b82ee3fd26..9a765df608b 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/ColumnUtils.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/ColumnUtils.java @@ -12,8 +12,6 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.gui.api.component.ObjectListPanel; - import com.evolveum.midpoint.gui.api.util.WebDisplayTypeUtil; import com.evolveum.midpoint.web.page.admin.orgs.PageOrgUnit; import com.evolveum.midpoint.web.util.OnePageParameterEncoder; diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-gui-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-gui-3.xsd index bbdc28d858f..89dbdca002a 100644 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-gui-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-gui-3.xsd @@ -284,6 +284,20 @@ + + + +

+ If the old or new design should be used. Temporary, will be removed in 4.5 when + the old design will be fully replaced with the new one. +

+
+ + 4.4 + AdminGuiConfigurationType.enableOldView + +
+
@@ -3741,6 +3755,16 @@ + + + +

+ TRANSIENT. Temporary used for distinguish if the panel is visible while creating new object. + Some panels should be shown only for existing objects, e.g Cases panel, Triggers panel, etc. +

+
+
+
diff --git a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/authentication/CompiledGuiProfile.java b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/authentication/CompiledGuiProfile.java index 208b213c3a4..977e6f91400 100644 --- a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/authentication/CompiledGuiProfile.java +++ b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/authentication/CompiledGuiProfile.java @@ -44,6 +44,7 @@ public class CompiledGuiProfile implements DebugDumpable, Serializable { private String defaultTimezone; private String preferredDataLanguage; private Boolean enableExperimentalFeatures; + private Boolean useNewDesign = true; //default private List additionalMenuLink = new ArrayList<>(); private List userDashboardLink = new ArrayList<>(); private List objectCollectionViews = new ArrayList<>(); @@ -84,6 +85,14 @@ public void setEnableExperimentalFeatures(Boolean enableExperimentalFeatures) { this.enableExperimentalFeatures = enableExperimentalFeatures; } + public void setUseNewDesign(Boolean useNewDesign) { + this.useNewDesign = useNewDesign; + } + + public Boolean isUseNewDesign() { + return useNewDesign; + } + @NotNull public List getAdditionalMenuLink() { return additionalMenuLink; @@ -396,6 +405,7 @@ public String debugDump(int indent) { DebugUtil.debugDumpWithLabelLn(sb, "defaultTimezone", defaultTimezone, indent + 1); DebugUtil.debugDumpWithLabelLn(sb, "preferredDataLanguage", preferredDataLanguage, indent + 1); DebugUtil.debugDumpWithLabelLn(sb, "enableExperimentalFeatures", enableExperimentalFeatures, indent + 1); + DebugUtil.debugDumpWithLabelLn(sb, "enableExperimentalFeatures", useNewDesign, indent + 1); DebugUtil.debugDumpWithLabelLn(sb, "additionalMenuLink", additionalMenuLink, indent + 1); DebugUtil.debugDumpWithLabelLn(sb, "userDashboardLink", userDashboardLink, indent + 1); DebugUtil.debugDumpWithLabelLn(sb, "objectCollectionViews", objectCollectionViews, indent + 1); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/GuiProfileCompiler.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/GuiProfileCompiler.java index 093c1b3f2d8..90318cc5810 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/GuiProfileCompiler.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/GuiProfileCompiler.java @@ -189,6 +189,9 @@ private void applyAdminGuiConfiguration(CompiledGuiProfile composite, AdminGuiCo if (adminGuiConfiguration.isEnableExperimentalFeatures() != null) { composite.setEnableExperimentalFeatures(adminGuiConfiguration.isEnableExperimentalFeatures()); } + if (adminGuiConfiguration.isUseNewDesign() != null) { + composite.setUseNewDesign(adminGuiConfiguration.isUseNewDesign()); + } if (adminGuiConfiguration.getDefaultExportSettings() != null) { composite.setDefaultExportSettings(adminGuiConfiguration.getDefaultExportSettings().clone()); } From 7be7913d07de5403ed1f05c348b5cff149d90018 Mon Sep 17 00:00:00 2001 From: Katarina Valalikova Date: Wed, 8 Sep 2021 20:06:03 +0200 Subject: [PATCH 08/19] create from template page --- .../page/admin/AbstractPageObjectDetails.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java index b359f2d3ad8..852801d103c 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java @@ -13,13 +13,18 @@ import com.evolveum.midpoint.gui.impl.component.menu.DetailsNavigationPanel; import com.evolveum.midpoint.gui.impl.page.admin.component.OperationalButtonsPanel; +import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; +import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.web.component.util.VisibleBehaviour; +import com.evolveum.midpoint.web.page.admin.PageCreateFromTemplate; + import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.wicket.Component; +import org.apache.wicket.RestartResponseException; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.AjaxSelfUpdatingTimerBehavior; import org.apache.wicket.markup.html.WebMarkupContainer; @@ -78,7 +83,15 @@ public abstract class AbstractPageObjectDetails applicableArchetypes = getCompiledGuiProfile().findAllApplicableArchetypeViews(objectType.getTypeQName()); + if (!applicableArchetypes.isEmpty()) { + PageParameters params = new PageParameters(); + params.add("type", objectType.getRestType()); + throw new RestartResponseException(PageCreateFromTemplate.class, params); + } + } } public AbstractPageObjectDetails(PageParameters pageParameters) { From 03eb929e6461ab7da77b9c0e7db224de292be23a Mon Sep 17 00:00:00 2001 From: lskublik Date: Wed, 8 Sep 2021 21:16:54 +0200 Subject: [PATCH 09/19] fix for assignments and inducements subpanels --- .../gui/api/component/AssignmentPopup.java | 4 +- .../MultivalueContainerListPanel.java | 7 +- .../page/admin/AbstractPageObjectDetails.java | 2 +- .../AbstractAssignmentTypePanel.java | 95 ++++++++++++-- .../assignment/AbstractAssignmentPanel.java | 81 ------------ .../AbstractRoleAssignmentPanel.java | 14 +- .../DirectAndIndirectAssignmentPanel.java | 124 ++++++++++++++++-- .../inducement/AbstractInducementPanel.java | 8 +- .../inducement/AllInducementsPanel.java | 9 +- .../ConstructionInducementsPanel.java | 12 +- .../FocusMappingsInducementsPanel.java | 32 ++++- .../inducement/InducedEntitlementsPanel.java | 6 + .../inducement/OrgInducementsPanel.java | 11 +- .../PolicyRuleInducementsPanel.java | 2 +- .../inducement/RoleInducementsPanel.java | 6 + .../inducement/ServiceInducementsPanel.java | 12 +- .../wrapper/AssignmentValueWrapperImpl.java | 1 - 17 files changed, 292 insertions(+), 134 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/AssignmentPopup.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/AssignmentPopup.java index 6c7a5647464..c077774b216 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/AssignmentPopup.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/AssignmentPopup.java @@ -56,6 +56,8 @@ import com.evolveum.midpoint.web.component.util.VisibleBehaviour; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import org.jetbrains.annotations.NotNull; + /** * Created by honchar. */ @@ -77,7 +79,7 @@ public class AssignmentPopup extends BasePanel implements Po private static final String DOT_CLASS = AssignmentPopup.class.getName() + "."; protected static final String OPERATION_LOAD_ASSIGNMENT_HOLDER_SPECIFICATION = DOT_CLASS + "loadAssignmentHolderSpecification"; - public AssignmentPopup(String id, IModel model) { + public AssignmentPopup(String id, @NotNull IModel model) { super(id, model); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/MultivalueContainerListPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/MultivalueContainerListPanel.java index e3dc1d17d11..93f1f2a8719 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/MultivalueContainerListPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/component/MultivalueContainerListPanel.java @@ -11,6 +11,7 @@ import com.evolveum.midpoint.gui.api.component.MainObjectListPanel; import com.evolveum.midpoint.gui.api.page.PageBase; +import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails; import com.evolveum.midpoint.gui.impl.page.admin.user.PageUser; import com.evolveum.midpoint.web.component.*; @@ -199,9 +200,9 @@ public PrismObject getFocusObject(){ return mainPanel.getObjectWrapper().getObject(); } PageBase pageBase = getPageBase(); - if (pageBase != null && pageBase instanceof PageUser) { - PageUser pageUser = (PageUser) pageBase; - return (PrismObject) pageUser.getPrismObject(); + if (pageBase != null && pageBase instanceof PageAssignmentHolderDetails) { + PageAssignmentHolderDetails pageAssignmentHolderDetails = (PageAssignmentHolderDetails) pageBase; + return (PrismObject) pageAssignmentHolderDetails.getPrismObject(); } return null; } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java index 50fd3a5060f..77340bd388b 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java @@ -91,7 +91,7 @@ public AbstractPageObjectDetails(PageParameters pageParameters) { } - protected ObjectDetailsModels getObjectDetailsModels() { + public ObjectDetailsModels getObjectDetailsModels() { return objectDetailsModels; } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/AbstractAssignmentTypePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/AbstractAssignmentTypePanel.java index b6fd508c0af..7b5f12a5e02 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/AbstractAssignmentTypePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/AbstractAssignmentTypePanel.java @@ -23,16 +23,22 @@ import com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon; import com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder; import com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle; +import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.component.assignmentType.assignment.AbstractAssignmentPanel; import com.evolveum.midpoint.gui.impl.prism.wrapper.PrismReferenceValueWrapperImpl; +import com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification; +import com.evolveum.midpoint.model.api.AssignmentObjectRelation; import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.prism.query.RefFilter; import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.QNameUtil; +import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -66,8 +72,11 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; +import org.jetbrains.annotations.NotNull; +import javax.xml.namespace.QName; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public abstract class AbstractAssignmentTypePanel extends MultivalueContainerListPanelWithDetailsPanel { @@ -118,12 +127,6 @@ protected List, String>> crea columns.add(createAssignmentNameColumn()); columns.add(new PrismContainerWrapperColumn<>(getContainerModel(), AssignmentType.F_ACTIVATION, getPageBase())); -// -// -// if (getAssignmentType() == null) { -// columns.add(createAssignmentMoreDataColumn()); -// } - List, String>> additionalColumns = initColumns(); if (additionalColumns != null) { columns.addAll(additionalColumns); @@ -132,6 +135,7 @@ protected List, String>> crea return columns; } + @NotNull protected abstract List, String>> initColumns(); private IColumn, String> createAssignmentActionColumn() { @@ -411,14 +415,89 @@ protected PrismObject getFocusObject() { } protected List getObjectTypesList() { - return WebComponentUtil.createAssignableTypesList(); + QName assignmentType = getAssignmentType(); + if (assignmentType == null) { + return Collections.EMPTY_LIST; + } + return Collections.singletonList(ObjectTypes.getObjectTypeFromTypeQName(assignmentType)); + } + + protected RefFilter getTargetTypeFilter() { + QName targetType = getAssignmentType(); + RefFilter targetRefFilter = null; + if (targetType != null) { + ObjectReferenceType ort = new ObjectReferenceType(); + ort.setType(targetType); + ort.setRelation(new QName(PrismConstants.NS_QUERY, "any")); + targetRefFilter = (RefFilter) getPageBase().getPrismContext().queryFor(AssignmentType.class) + .item(AssignmentType.F_TARGET_REF) + .ref(ort.asReferenceValue()) + .buildFilter(); + targetRefFilter.setOidNullAsAny(true); + } + return targetRefFilter; } protected ObjectFilter getSubtypeFilter() { return null; } - protected abstract IModel createAssignmentPopupModel(); + @NotNull + protected IModel createAssignmentPopupModel() { + return new LoadableModel<>(false) { + + @Override + protected AssignmentPopupDto load() { + List assignmentObjectRelations = getAssignmentObjectRelationList(); + return new AssignmentPopupDto(assignmentObjectRelations); + } + }; + } + + private List getAssignmentObjectRelationList() { + if (AbstractAssignmentTypePanel.this.getContainerModel().getObject() == null) { + return null; + } + + List assignmentRelationsList = + WebComponentUtil.divideAssignmentRelationsByAllValues(loadAssignmentTargetRelationsList()); + if (assignmentRelationsList == null || assignmentRelationsList.isEmpty()) { + return assignmentRelationsList; + } + QName assignmentType = getAssignmentType(); + if (assignmentType == null) { + return assignmentRelationsList; + } + List assignmentRelationsListFilteredByType = + new ArrayList<>(); + assignmentRelationsList.forEach(assignmentRelation -> { + QName objectType = assignmentRelation.getObjectTypes() != null + && !assignmentRelation.getObjectTypes().isEmpty() + ? assignmentRelation.getObjectTypes().get(0) : null; + if (QNameUtil.match(assignmentType, objectType)) { + assignmentRelationsListFilteredByType.add(assignmentRelation); + } + }); + return assignmentRelationsListFilteredByType; + } + + protected abstract QName getAssignmentType(); + + @NotNull + private List loadAssignmentTargetRelationsList() { + OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNMENT_TARGET_RELATIONS); + List assignmentTargetRelations = new ArrayList<>(); + PrismObject obj = getFocusObject(); + try { + AssignmentCandidatesSpecification spec = getPageBase().getModelInteractionService() + .determineAssignmentTargetSpecification(obj, result); + assignmentTargetRelations = spec != null ? spec.getAssignmentObjectRelations() : new ArrayList<>(); + } catch (SchemaException | ConfigurationException ex) { + result.recordPartialError(ex.getLocalizedMessage()); + LOGGER.error("Couldn't load assignment target specification for the object {} , {}", obj.getName(), ex.getLocalizedMessage()); + } + return assignmentTargetRelations; + } protected void addSelectedAssignmentsPerformed(AjaxRequestTarget target, List newAssignmentsList) { if (CollectionUtils.isEmpty(newAssignmentsList)) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/AbstractAssignmentPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/AbstractAssignmentPanel.java index 07f69ac73f1..53c86c6330f 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/AbstractAssignmentPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/AbstractAssignmentPanel.java @@ -62,90 +62,11 @@ protected List, String>> init return null; } - protected IModel createAssignmentPopupModel() { - return new LoadableModel<>(false) { - - @Override - protected AssignmentPopupDto load() { - List assignmentObjectRelations = getAssignmentObjectRelationList(); - return new AssignmentPopupDto(assignmentObjectRelations); - } - }; - } - - private List getAssignmentObjectRelationList() { - if (AbstractAssignmentPanel.this.getContainerModel().getObject() == null) { - return null; - } - - List assignmentRelationsList = - WebComponentUtil.divideAssignmentRelationsByAllValues(loadAssignmentTargetRelationsList()); - if (assignmentRelationsList == null || assignmentRelationsList.isEmpty()) { - return assignmentRelationsList; - } - QName assignmentType = getAssignmentType(); - if (assignmentType == null) { - return assignmentRelationsList; - } - List assignmentRelationsListFilteredByType = - new ArrayList<>(); - assignmentRelationsList.forEach(assignmentRelation -> { - QName objectType = assignmentRelation.getObjectTypes() != null - && !assignmentRelation.getObjectTypes().isEmpty() - ? assignmentRelation.getObjectTypes().get(0) : null; - if (QNameUtil.match(assignmentType, objectType)) { - assignmentRelationsListFilteredByType.add(assignmentRelation); - } - }); - return assignmentRelationsListFilteredByType; - } - @Override protected String getAssignmentsTabStorageKey() { return SessionStorage.KEY_ASSIGNMENTS_TAB; } - @NotNull - private List loadAssignmentTargetRelationsList() { - OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNMENT_TARGET_RELATIONS); - List assignmentTargetRelations = new ArrayList<>(); - PrismObject obj = getFocusObject(); - try { - AssignmentCandidatesSpecification spec = getPageBase().getModelInteractionService() - .determineAssignmentTargetSpecification(obj, result); - assignmentTargetRelations = spec != null ? spec.getAssignmentObjectRelations() : new ArrayList<>(); - } catch (SchemaException | ConfigurationException ex) { - result.recordPartialError(ex.getLocalizedMessage()); - LOGGER.error("Couldn't load assignment target specification for the object {} , {}", obj.getName(), ex.getLocalizedMessage()); - } - return assignmentTargetRelations; - } - - @Override - protected List getObjectTypesList() { - QName assignmentType = getAssignmentType(); - if (assignmentType == null) { - return Collections.EMPTY_LIST; - } - return Collections.singletonList(ObjectTypes.getObjectTypeFromTypeQName(assignmentType)); - } - - protected RefFilter getTargetTypeFilter() { - QName targetType = getAssignmentType(); - RefFilter targetRefFilter = null; - if (targetType != null) { - ObjectReferenceType ort = new ObjectReferenceType(); - ort.setType(targetType); - ort.setRelation(new QName(PrismConstants.NS_QUERY, "any")); - targetRefFilter = (RefFilter) getPageBase().getPrismContext().queryFor(AssignmentType.class) - .item(AssignmentType.F_TARGET_REF) - .ref(ort.asReferenceValue()) - .buildFilter(); - targetRefFilter.setOidNullAsAny(true); - } - return targetRefFilter; - } - @Override protected void addSpecificSearchableItems(PrismContainerDefinition containerDef, List defs) { if (getAssignmentType() == null) { @@ -158,8 +79,6 @@ protected void addSpecificSearchableItems(PrismContainerDefinition IModel getIdentifierLabelModel(Pri return Model.of(""); } PrismObject targetObject = loadTargetObject(assignmentContainer.getRealValue()); - AR targetRefObject = targetObject.asObjectable(); - if (StringUtils.isNotEmpty(targetRefObject.getIdentifier())) { - return Model.of(targetRefObject.getIdentifier()); - } - if (targetRefObject.getDisplayName() != null && !targetRefObject.getName().getOrig().equals(targetRefObject.getDisplayName().getOrig())) { - return Model.of(targetRefObject.getName().getOrig()); + if (targetObject != null) { + AR targetRefObject = targetObject.asObjectable(); + if (StringUtils.isNotEmpty(targetRefObject.getIdentifier())) { + return Model.of(targetRefObject.getIdentifier()); + } + if (targetRefObject.getDisplayName() != null && !targetRefObject.getName().getOrig().equals(targetRefObject.getDisplayName().getOrig())) { + return Model.of(targetRefObject.getName().getOrig()); + } } return Model.of(""); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/DirectAndIndirectAssignmentPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/DirectAndIndirectAssignmentPanel.java index 992223bcb33..29834f28aff 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/DirectAndIndirectAssignmentPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/DirectAndIndirectAssignmentPanel.java @@ -7,29 +7,45 @@ package com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.component.assignmentType.assignment; import com.evolveum.midpoint.gui.api.model.LoadableModel; -import com.evolveum.midpoint.gui.api.page.PageBase; import com.evolveum.midpoint.gui.api.prism.wrapper.AssignmentValueWrapper; import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper; +import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper; import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper; import com.evolveum.midpoint.gui.api.util.WebComponentUtil; import com.evolveum.midpoint.gui.api.util.WebDisplayTypeUtil; +import com.evolveum.midpoint.gui.api.util.WebPrismUtil; import com.evolveum.midpoint.gui.impl.component.data.column.AbstractItemWrapperColumn.ColumnType; import com.evolveum.midpoint.gui.impl.component.data.column.PrismPropertyWrapperColumn; import com.evolveum.midpoint.gui.impl.component.data.column.PrismReferenceWrapperColumn; +import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails; import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.component.AssignmentHolderAssignmentPanel; +import com.evolveum.midpoint.model.api.ModelExecuteOptions; +import com.evolveum.midpoint.model.api.context.EvaluatedAssignment; +import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget; +import com.evolveum.midpoint.model.api.context.EvaluatedResourceObjectConstruction; +import com.evolveum.midpoint.model.api.context.ModelContext; import com.evolveum.midpoint.prism.PrismContainerDefinition; +import com.evolveum.midpoint.prism.delta.DeltaSetTriple; +import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.web.application.PanelDisplay; import com.evolveum.midpoint.web.application.PanelInstance; import com.evolveum.midpoint.web.application.PanelType; import com.evolveum.midpoint.web.component.assignment.AssignmentsUtil; import com.evolveum.midpoint.web.component.data.column.AjaxLinkColumn; import com.evolveum.midpoint.web.component.data.column.IconColumn; +import com.evolveum.midpoint.web.component.prism.ValueStatus; import com.evolveum.midpoint.web.component.search.SearchFactory; import com.evolveum.midpoint.web.component.search.SearchItemDefinition; -import com.evolveum.midpoint.web.page.admin.PageAdminFocus; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.wicket.AttributeModifier; @@ -43,9 +59,7 @@ import org.apache.wicket.model.Model; import javax.xml.namespace.QName; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; /** * @author lskublik @@ -58,33 +72,38 @@ public class DirectAndIndirectAssignmentPanel extends AbstractAssignmentPanel { private static final long serialVersionUID = 1L; + private static final Trace LOGGER = TraceManager.getTrace(DirectAndIndirectAssignmentPanel.class); + + private static final String DOT_CLASS = DirectAndIndirectAssignmentPanel.class.getName() + "."; + private static final String OPERATION_RECOMPUTE_ASSIGNMENTS = DOT_CLASS + "recomputeAssignments"; + private LoadableModel>> allAssignmentModel = null; - public DirectAndIndirectAssignmentPanel(String id, LoadableModel> assignmentContainerWrapperModel, ContainerPanelConfigurationType config) { - super(id, assignmentContainerWrapperModel, config); + public DirectAndIndirectAssignmentPanel(String id, LoadableModel> objectModel, ContainerPanelConfigurationType config) { + super(id, objectModel, config); } @Override protected IModel>> loadValuesModel() { - PageBase pageBase = getPageBase(); - if (pageBase instanceof PageAdminFocus) { if (allAssignmentModel == null) { allAssignmentModel = new LoadableModel<>() { @Override protected List> load() { - return (List) ((PageAdminFocus) pageBase).showAllAssignmentsPerformed(getContainerModel()); + try { + return loadEvaluatedAssignments(getContainerModel()); + } catch (CommonException e) { + LOGGER.error("Couldn't load all assignments", e); + } + return getContainerModel().getObject().getValues(); } }; } return allAssignmentModel; - } else { - return super.loadValuesModel(); - } } @Override - protected List, String>> initColumns() { + protected List, String>> createDefaultColumns() { List, String>> columns = new ArrayList<>(); columns.add(new IconColumn<>(Model.of("")) { @@ -219,6 +238,83 @@ public void refreshTable(AjaxRequestTarget ajaxRequestTarget) { } + private List> loadEvaluatedAssignments(IModel> parent) + throws SchemaException, ExpressionEvaluationException, CommunicationException, SecurityViolationException, ConfigurationException, ObjectNotFoundException, PolicyViolationException, ObjectAlreadyExistsException { + if (!(getPageBase() instanceof PageAssignmentHolderDetails)) { + return parent.getObject().getValues(); + } + Task task = getPageBase().createSimpleTask(OPERATION_RECOMPUTE_ASSIGNMENTS); + OperationResult result = new OperationResult(OPERATION_RECOMPUTE_ASSIGNMENTS); + Set assignmentValueWrapperSet = new LinkedHashSet<>(); + + ((PageAssignmentHolderDetails) getPageBase()).getObjectDetailsModels().collectDeltas(result); + ObjectDelta delta = ((PageAssignmentHolderDetails) getPageBase()).getObjectDetailsModels().getDelta(); + ModelExecuteOptions options = getPageBase().executeOptions().evaluateAllAssignmentRelationsOnRecompute(); + ModelContext modelContext = getPageBase().getModelInteractionService().previewChanges( + Collections.singleton(delta), options, task, result); + Collection> evaluatedAssignments = modelContext.getNonNegativeEvaluatedAssignments(); + + for (EvaluatedAssignment evaluatedAssignment : evaluatedAssignments) { + if (!evaluatedAssignment.isValid()) { + continue; + } + // roles and orgs + DeltaSetTriple targetsTriple = evaluatedAssignment.getRoles(); + Collection targets = targetsTriple.getNonNegativeValues(); + for (EvaluatedAssignmentTarget target : targets) { + target.getTarget(); + if (ArchetypeType.class.equals(target.getTarget().getCompileTimeClass())) { + continue; + } + if (target.appliesToFocusWithAnyRelation(getPageBase().getRelationRegistry())) { + AssignmentType assignmentType = target.getAssignment(); + assignmentType.setDescription(target.getTarget().asObjectable().getDescription()); + assignmentType.getTargetRef().setTargetName(new PolyStringType(target.getTarget().getName())); + assignmentType.getTargetRef().setType(target.getTarget().getComplexTypeDefinition().getTypeName()); + ValueStatus status = evaluatedAssignment.getAssignment(true) == null ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED; + AssignmentValueWrapper assignmentValueWrapper = WebPrismUtil.createNewValueWrapper(parent.getObject(), + assignmentType.asPrismContainerValue(), status, getPageBase()); + assignmentValueWrapper.setDirectAssignment(target.isDirectlyAssigned()); + assignmentValueWrapper.setAssignmentParent(target.getAssignmentPath()); + assignmentValueWrapperSet.add(assignmentValueWrapper); + } + } + + // all resources + DeltaSetTriple evaluatedConstructionsTriple = evaluatedAssignment + .getEvaluatedConstructions(task, result); + Collection evaluatedConstructions = evaluatedConstructionsTriple + .getNonNegativeValues(); + for (EvaluatedResourceObjectConstruction construction : evaluatedConstructions) { + if (!construction.isWeak()) { + PrismContainerDefinition assignmentDef = getPrismContext().getSchemaRegistry() + .findContainerDefinitionByCompileTimeClass(AssignmentType.class); + AssignmentType assignmentType = assignmentDef.instantiate().createNewValue().asContainerable(); + ObjectReferenceType targetRef = new ObjectReferenceType(); + targetRef.setOid(construction.getResource().getOid()); + targetRef.setType(ResourceType.COMPLEX_TYPE); + targetRef.setTargetName(new PolyStringType(construction.getResource().getName())); + assignmentType.setTargetRef(targetRef); + ConstructionType constructionType = new ConstructionType(); + constructionType.setResourceRef(targetRef); + constructionType.setKind(construction.getKind()); + constructionType.setIntent(construction.getIntent()); + assignmentType.setConstruction(constructionType); + assignmentType.setDescription(construction.getResource().asObjectable().getDescription()); + ValueStatus status = evaluatedAssignment.getAssignment(true) == null ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED; + AssignmentValueWrapper assignmentValueWrapper = WebPrismUtil.createNewValueWrapper(parent.getObject(), + assignmentType.asPrismContainerValue(), status, getPageBase()); + assignmentValueWrapper.setDirectAssignment(construction.isDirectlyAssigned()); + assignmentValueWrapper.setAssignmentParent(construction.getAssignmentPath()); + assignmentValueWrapperSet.add(assignmentValueWrapper); + } + } + } + + return new ArrayList<>(assignmentValueWrapperSet); + + } + @Override protected QName getAssignmentType() { return null; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AbstractInducementPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AbstractInducementPanel.java index ecbefa2ea5e..7cf61f29bc9 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AbstractInducementPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AbstractInducementPanel.java @@ -7,9 +7,11 @@ package com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.component.assignmentType.inducement; import com.evolveum.midpoint.gui.api.component.AssignmentPopupDto; +import com.evolveum.midpoint.gui.api.model.LoadableModel; import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper; import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper; import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.component.assignmentType.AbstractAssignmentTypePanel; +import com.evolveum.midpoint.model.api.AssignmentObjectRelation; import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.web.component.search.SearchItemDefinition; @@ -24,6 +26,8 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; import org.apache.wicket.model.IModel; +import javax.xml.namespace.QName; +import java.util.ArrayList; import java.util.List; public class AbstractInducementPanel extends AbstractAssignmentTypePanel { @@ -34,11 +38,11 @@ public AbstractInducementPanel(String id, IModel> model, @Override protected List, String>> initColumns() { - return null; + return new ArrayList<>(); } @Override - protected IModel createAssignmentPopupModel() { + protected QName getAssignmentType() { return null; } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AllInducementsPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AllInducementsPanel.java index da7e5de54f0..540a85906a8 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AllInducementsPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AllInducementsPanel.java @@ -26,17 +26,10 @@ @PanelInstance(identifier = "allInducements", applicableFor = AbstractRoleType.class, childOf = AbstractRoleInducementPanel.class, - display = @PanelDisplay(label = "AssignmentPanel.allLabel", icon = GuiStyleConstants.EVO_ASSIGNMENT_ICON, order = 10)) + display = @PanelDisplay(label = "AssignmentPanel.allLabel", order = 10)) public class AllInducementsPanel extends AbstractInducementPanel { public AllInducementsPanel(String id, LoadableModel> model, ContainerPanelConfigurationType config) { super(id, model, config); } - - @Override - protected List, String>> initColumns() { - return null; - } - - } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/ConstructionInducementsPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/ConstructionInducementsPanel.java index 7acf6559221..667f55e35be 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/ConstructionInducementsPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/ConstructionInducementsPanel.java @@ -15,18 +15,28 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; + +import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; + import org.apache.wicket.model.IModel; +import javax.xml.namespace.QName; + @PanelType(name = "constructionInducements") @PanelInstance(identifier = "constructionInducements", applicableFor = AbstractRoleType.class, childOf = AbstractRoleInducementPanel.class, - display = @PanelDisplay(label = "ObjectType.ResourceType", icon = GuiStyleConstants.CLASS_OBJECT_ROLE_ICON, order = 50)) + display = @PanelDisplay(label = "ObjectType.ResourceType", icon = GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON, order = 50)) public class ConstructionInducementsPanel extends AbstractInducementPanel { public ConstructionInducementsPanel(String id, IModel> model, ContainerPanelConfigurationType config) { super(id, model, config); } + @Override + protected QName getAssignmentType() { + return ResourceType.COMPLEX_TYPE; + } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/FocusMappingsInducementsPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/FocusMappingsInducementsPanel.java index 06ebdd84f63..8b5ed77ce42 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/FocusMappingsInducementsPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/FocusMappingsInducementsPanel.java @@ -6,27 +6,51 @@ */ package com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.component.assignmentType.inducement; -import com.evolveum.midpoint.gui.api.GuiStyleConstants; import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper; import com.evolveum.midpoint.gui.impl.page.admin.abstractrole.component.AbstractRoleInducementPanel; +import com.evolveum.midpoint.prism.PrismContainerDefinition; +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.web.application.PanelDisplay; import com.evolveum.midpoint.web.application.PanelInstance; import com.evolveum.midpoint.web.application.PanelType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType; +import com.evolveum.midpoint.web.component.search.SearchFactory; +import com.evolveum.midpoint.web.component.search.SearchItemDefinition; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.wicket.model.IModel; +import java.util.ArrayList; +import java.util.List; + @PanelType(name = "focusMappingsInducements") @PanelInstance(identifier = "focusMappingsInducements", applicableFor = AbstractRoleType.class, childOf = AbstractRoleInducementPanel.class, - display = @PanelDisplay(label = "AssignmentType.focusMappings", icon = GuiStyleConstants.CLASS_OBJECT_ROLE_ICON, order = 80)) + display = @PanelDisplay(label = "AssignmentType.focusMappings", order = 80)) public class FocusMappingsInducementsPanel extends AbstractInducementPanel { public FocusMappingsInducementsPanel(String id, IModel> model, ContainerPanelConfigurationType config) { super(id, model, config); } + @Override + protected List createSearchableItems(PrismContainerDefinition containerDef) { + List defs = new ArrayList<>(); + + SearchFactory.addSearchPropertyDef(containerDef, ItemPath.create(AssignmentType.F_FOCUS_MAPPINGS, MappingsType.F_DESCRIPTION), defs); + SearchFactory.addSearchPropertyDef(containerDef, ItemPath.create(AssignmentType.F_FOCUS_MAPPINGS, MappingsType.F_MAPPING, MappingType.F_NAME), defs); + SearchFactory.addSearchPropertyDef(containerDef, ItemPath.create(AssignmentType.F_FOCUS_MAPPINGS, MappingsType.F_MAPPING, MappingType.F_STRENGTH), defs); + + defs.addAll(SearchFactory.createExtensionDefinitionList(containerDef)); + return defs; + } + + @Override + protected ObjectQuery getCustomizeQuery() { + return PrismContext.get().queryFor(AssignmentType.class) + .exists(AssignmentType.F_FOCUS_MAPPINGS).build(); + } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/InducedEntitlementsPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/InducedEntitlementsPanel.java index 08cf67d66bc..6220b29647c 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/InducedEntitlementsPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/InducedEntitlementsPanel.java @@ -45,6 +45,7 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; +import javax.xml.namespace.QName; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -255,4 +256,9 @@ protected UserProfileStorage.TableId getTableId() { protected String getAssignmentsTabStorageKey() { return SessionStorage.KEY_INDUCED_ENTITLEMENTS_TAB; } + + @Override + protected QName getAssignmentType() { + return ResourceType.COMPLEX_TYPE; + } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/OrgInducementsPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/OrgInducementsPanel.java index bae8503cd3d..c1473d58cd3 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/OrgInducementsPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/OrgInducementsPanel.java @@ -15,18 +15,25 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; + import org.apache.wicket.model.IModel; +import javax.xml.namespace.QName; + @PanelType(name = "orgInducements") @PanelInstance(identifier = "orgInducements", applicableFor = AbstractRoleType.class, childOf = AbstractRoleInducementPanel.class, - display = @PanelDisplay(label = "ObjectType.OrgType", icon = GuiStyleConstants.CLASS_OBJECT_ROLE_ICON, order = 30)) + display = @PanelDisplay(label = "ObjectType.OrgType", icon = GuiStyleConstants.CLASS_OBJECT_ORG_ICON, order = 30)) public class OrgInducementsPanel extends AbstractInducementPanel { public OrgInducementsPanel(String id, IModel> model, ContainerPanelConfigurationType config) { super(id, model, config); } - + @Override + protected QName getAssignmentType() { + return OrgType.COMPLEX_TYPE; + } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/PolicyRuleInducementsPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/PolicyRuleInducementsPanel.java index 81fccb1fdfb..4e34e4b620b 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/PolicyRuleInducementsPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/PolicyRuleInducementsPanel.java @@ -21,7 +21,7 @@ @PanelInstance(identifier = "policyRuleInducements", applicableFor = AbstractRoleType.class, childOf = AbstractRoleInducementPanel.class, - display = @PanelDisplay(label = "AssignmentType.policyRule", icon = GuiStyleConstants.CLASS_OBJECT_ROLE_ICON, order = 60)) + display = @PanelDisplay(label = "AssignmentType.policyRule", icon = GuiStyleConstants.CLASS_POLICY_RULES_ICON, order = 60)) public class PolicyRuleInducementsPanel extends AbstractInducementPanel { public PolicyRuleInducementsPanel(String id, IModel> model, ContainerPanelConfigurationType config) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/RoleInducementsPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/RoleInducementsPanel.java index 0aa4bd852ab..fe56f359a4d 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/RoleInducementsPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/RoleInducementsPanel.java @@ -20,6 +20,7 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; import org.apache.wicket.model.IModel; +import javax.xml.namespace.QName; import java.util.List; @PanelType(name = "roleInducements") @@ -42,4 +43,9 @@ protected List, String>> init return columns; } + @Override + protected QName getAssignmentType() { + return RoleType.COMPLEX_TYPE; + } + } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/ServiceInducementsPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/ServiceInducementsPanel.java index 954e975eaa8..20800e62c3f 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/ServiceInducementsPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/ServiceInducementsPanel.java @@ -15,18 +15,28 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; + +import com.evolveum.midpoint.xml.ns._public.common.common_3.ServiceType; + import org.apache.wicket.model.IModel; +import javax.xml.namespace.QName; + @PanelType(name = "serviceInducements") @PanelInstance(identifier = "serviceInducements", applicableFor = AbstractRoleType.class, childOf = AbstractRoleInducementPanel.class, - display = @PanelDisplay(label = "ObjectType.ServiceType", icon = GuiStyleConstants.CLASS_OBJECT_ROLE_ICON, order = 40)) + display = @PanelDisplay(label = "ObjectType.ServiceType", icon = GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON, order = 40)) public class ServiceInducementsPanel extends AbstractInducementPanel { public ServiceInducementsPanel(String id, IModel> model, ContainerPanelConfigurationType config) { super(id, model, config); } + @Override + protected QName getAssignmentType() { + return ServiceType.COMPLEX_TYPE; + } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/wrapper/AssignmentValueWrapperImpl.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/wrapper/AssignmentValueWrapperImpl.java index c129ac8c63e..f720324dd77 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/wrapper/AssignmentValueWrapperImpl.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/wrapper/AssignmentValueWrapperImpl.java @@ -25,7 +25,6 @@ /** * @author skublik - * */ public class AssignmentValueWrapperImpl extends PrismContainerValueWrapperImpl implements AssignmentValueWrapper, Comparable { From ad0e843f9d63f6c9680bd9746256db2dc30be402 Mon Sep 17 00:00:00 2001 From: Katarina Valalikova Date: Wed, 8 Sep 2021 21:30:51 +0200 Subject: [PATCH 10/19] - configurable option for selecting new or old design - reviving create from template - a but of cleanup (navigate to details panel for mainObjectListPanel) --- .../api/component/MainObjectListPanel.java | 12 +++++++ .../page/admin/AbstractPageObjectDetails.java | 20 ++++++------ .../component/AbstractRoleMemberPanel.java | 21 +++++-------- .../cases/component/ChildCasesPanel.java | 7 ----- .../gui/impl/page/admin/org/PageOrg.java | 4 +++ .../impl/page/admin/report/PageReport.java | 4 +++ .../component/ResourceTasksPanel.java | 7 ----- .../gui/impl/page/admin/role/PageRole.java | 4 +++ .../impl/page/admin/service/PageService.java | 4 +++ .../gui/impl/page/admin/task/PageTask.java | 4 +++ .../web/application/PageDescriptor.java | 5 +++ .../page/admin/archetype/PageArchetypes.java | 11 ------- .../page/admin/cases/ChildCasesTabPanel.java | 7 ----- .../PageObjectCollections.java | 6 ---- .../objectTemplate/PageObjectTemplates.java | 6 ---- .../web/page/admin/orgs/PageOrgs.java | 10 ------ .../web/page/admin/reports/PageReports.java | 8 +---- .../admin/resources/PageConnectorHosts.java | 3 -- .../page/admin/resources/PageResources.java | 17 ---------- .../admin/resources/ResourceTasksPanel.java | 18 ----------- .../admin/roles/AbstractRoleMemberPanel.java | 14 --------- .../web/page/admin/roles/PageRoles.java | 10 ------ .../page/admin/server/CasesTablePanel.java | 31 ------------------- .../web/page/admin/server/TaskTablePanel.java | 11 ------- .../web/page/admin/services/PageServices.java | 15 --------- .../web/page/admin/users/PageUsers.java | 13 ++++---- .../xml/ns/public/common/common-gui-3.xsd | 4 +-- 27 files changed, 66 insertions(+), 210 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/MainObjectListPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/MainObjectListPanel.java index 5d09cc83d82..a8f044ab139 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/MainObjectListPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/component/MainObjectListPanel.java @@ -30,6 +30,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.wicket.Component; +import org.apache.wicket.RestartResponseException; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.behavior.AttributeAppender; import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; @@ -575,4 +576,15 @@ public IModel getConfirmationMessageModel(){ } }; } + + @Override + protected void objectDetailsPerformed(AjaxRequestTarget target, O object) { + if (WebComponentUtil.hasDetailsPage(object.getClass())) { + WebComponentUtil.dispatchToObjectDetailsPage(object.getClass(), object.getOid(), this, true); + } else { + error("Could not find proper response page"); + throw new RestartResponseException(getPageBase()); + } + } + } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java index 852801d103c..7d44ed430c8 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/AbstractPageObjectDetails.java @@ -83,15 +83,7 @@ public abstract class AbstractPageObjectDetails applicableArchetypes = getCompiledGuiProfile().findAllApplicableArchetypeViews(objectType.getTypeQName()); - if (!applicableArchetypes.isEmpty()) { - PageParameters params = new PageParameters(); - params.add("type", objectType.getRestType()); - throw new RestartResponseException(PageCreateFromTemplate.class, params); - } - } + this(null, null); } public AbstractPageObjectDetails(PageParameters pageParameters) { @@ -104,6 +96,16 @@ public AbstractPageObjectDetails(PrismObject object) { private AbstractPageObjectDetails(PageParameters params, PrismObject object) { super(params); + + if (params == null && object == null) { + ObjectTypes objectType = ObjectTypes.getObjectTypeIfKnown(getType()); + Collection applicableArchetypes = getCompiledGuiProfile().findAllApplicableArchetypeViews(objectType.getTypeQName()); + if (!applicableArchetypes.isEmpty()) { + PageParameters templateParams = new PageParameters(); + templateParams.add("type", objectType.getRestType()); + throw new RestartResponseException(PageCreateFromTemplate.class, templateParams); + } + } objectDetailsModels = createObjectDetailsModels(object); initLayout(); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/abstractrole/component/AbstractRoleMemberPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/abstractrole/component/AbstractRoleMemberPanel.java index 38726b028ce..dc2a076d313 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/abstractrole/component/AbstractRoleMemberPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/abstractrole/component/AbstractRoleMemberPanel.java @@ -179,11 +179,6 @@ protected UserProfileStorage.TableId getTableId() { return AbstractRoleMemberPanel.this.getTableId(getComplexTypeQName()); } - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, AH object) { - detailsPerformed(object); - } - @Override protected boolean isObjectDetailsEnabled(IModel> rowModel) { if (rowModel == null || rowModel.getObject() == null @@ -1040,14 +1035,14 @@ protected ObjectQuery createAllMemberQuery(Collection relations) { .build(); } - protected void detailsPerformed(ObjectType object) { - if (WebComponentUtil.hasDetailsPage(object.getClass())) { - WebComponentUtil.dispatchToObjectDetailsPage(object.getClass(), object.getOid(), this, true); - } else { - error("Could not find proper response page"); - throw new RestartResponseException(getPageBase()); - } - } +// protected void detailsPerformed(ObjectType object) { +// if (WebComponentUtil.hasDetailsPage(object.getClass())) { +// WebComponentUtil.dispatchToObjectDetailsPage(object.getClass(), object.getOid(), this, true); +// } else { +// error("Could not find proper response page"); +// throw new RestartResponseException(getPageBase()); +// } +// } private Collection> getSearchOptions() { return SelectorOptions.createCollection(GetOperationOptions.createDistinct()); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/cases/component/ChildCasesPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/cases/component/ChildCasesPanel.java index a8ce2ccc7d1..d7ac7384430 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/cases/component/ChildCasesPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/cases/component/ChildCasesPanel.java @@ -60,13 +60,6 @@ protected void initLayout() { MainObjectListPanel table = new MainObjectListPanel(ID_CHILD_CASES_PANEL, CaseType.class, Collections.emptyList()) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, CaseType caseInstance) { - PageParameters pageParameters = new PageParameters(); - pageParameters.add(OnePageParameterEncoder.PARAMETER, caseInstance.getOid()); - ChildCasesPanel.this.getPageBase().navigateToNext(PageCase.class, pageParameters); - } - @Override protected List, String>> createDefaultColumns() { List, String>> columns = new ArrayList, String>>(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/PageOrg.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/PageOrg.java index 63c7fef0e43..76cd2ea5599 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/PageOrg.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/org/PageOrg.java @@ -34,6 +34,10 @@ description = "PageOrgUnit.auth.orgUnit.description") }) public class PageOrg extends PageFocusDetails> { + public PageOrg() { + super(); + } + public PageOrg(PageParameters pageParameters) { super(pageParameters); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/report/PageReport.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/report/PageReport.java index 26e01461678..7bb1288cdcb 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/report/PageReport.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/report/PageReport.java @@ -65,6 +65,10 @@ public class PageReport extends PageAssignmentHolderDetails createInlineMenu() { return null; } - @Override - public void objectDetailsPerformed(AjaxRequestTarget target, TaskType task) { - PageParameters parameters = new PageParameters(); - parameters.add(OnePageParameterEncoder.PARAMETER, task.getOid()); - getPageBase().navigateToNext(PageTask.class, parameters); - } - @Override protected void newObjectPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation, CompiledObjectCollectionView collectionView) { if (collectionView == null) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/role/PageRole.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/role/PageRole.java index cfcbf9d4ef8..39fe3aa894a 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/role/PageRole.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/role/PageRole.java @@ -32,6 +32,10 @@ @AuthorizationAction(actionUri = AuthorizationConstants.AUTZ_UI_ROLE_URL, label = "PageRole.auth.role.label", description = "PageRole.auth.role.description") }) public class PageRole extends PageFocusDetails> { + public PageRole() { + super(); + } + public PageRole(PageParameters pageParameters) { super(pageParameters); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/service/PageService.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/service/PageService.java index 55a4d8cc627..4fc043d5304 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/service/PageService.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/service/PageService.java @@ -37,6 +37,10 @@ description = "PageService.auth.role.description") }) public class PageService extends PageFocusDetails> { + public PageService() { + super(); + } + public PageService(PageParameters pageParameters) { super(pageParameters); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/task/PageTask.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/task/PageTask.java index 20cc947c238..26cf6a8c3d7 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/task/PageTask.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/task/PageTask.java @@ -90,6 +90,10 @@ }) public class PageTask extends PageAssignmentHolderDetails> { + public PageTask() { + super(); + } + public PageTask(PageParameters pageParameters) { super(pageParameters); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/PageDescriptor.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/PageDescriptor.java index 31335ec65e8..bb18516489d 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/PageDescriptor.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/application/PageDescriptor.java @@ -35,6 +35,11 @@ */ boolean loginPage() default false; + /** + * If set to true, page is available only if the experimental features are turned on. + * Also, the link in the sidebar panel (on the left) is visible for experimental pages only + * if the experimental featires are on. + */ boolean experimental() default false; } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/archetype/PageArchetypes.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/archetype/PageArchetypes.java index e617e7e9126..49c1532aa23 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/archetype/PageArchetypes.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/archetype/PageArchetypes.java @@ -69,23 +69,12 @@ private void initLayout() { add(mainForm); MainObjectListPanel table = new MainObjectListPanel(ID_TABLE, ArchetypeType.class) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, ArchetypeType archetype) { - PageParameters pageParameters = new PageParameters(); - pageParameters.add(OnePageParameterEncoder.PARAMETER, archetype.getOid()); - navigateToNext(PageArchetype.class, pageParameters); - } @Override protected TableId getTableId() { return UserProfileStorage.TableId.TABLE_ARCHETYPES; } -// @Override -// protected List, String>> createDefaultColumns() { -// return ColumnUtils.getDefaultArchetypeColumns(); -// } - @Override protected IColumn, String> createCheckboxColumn() { return null; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/cases/ChildCasesTabPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/cases/ChildCasesTabPanel.java index f382d40cd92..b827ef87ca9 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/cases/ChildCasesTabPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/cases/ChildCasesTabPanel.java @@ -59,13 +59,6 @@ private void initLayout() { MainObjectListPanel table = new MainObjectListPanel(ID_CHILD_CASES_PANEL, CaseType.class, Collections.emptyList()) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, CaseType caseInstance) { - PageParameters pageParameters = new PageParameters(); - pageParameters.add(OnePageParameterEncoder.PARAMETER, caseInstance.getOid()); - ChildCasesTabPanel.this.getPageBase().navigateToNext(PageCase.class, pageParameters); - } - @Override protected List, String>> createDefaultColumns() { List, String>> columns = new ArrayList, String>>(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/objectCollection/PageObjectCollections.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/objectCollection/PageObjectCollections.java index fa195a4cf72..537e7707565 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/objectCollection/PageObjectCollections.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/objectCollection/PageObjectCollections.java @@ -77,12 +77,6 @@ private void initLayout() { add(mainForm); MainObjectListPanel table = new MainObjectListPanel(ID_TABLE, ObjectCollectionType.class) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectCollectionType collection) { - PageParameters pageParameters = new PageParameters(); - pageParameters.add(OnePageParameterEncoder.PARAMETER, collection.getOid()); - navigateToNext(PageObjectCollection.class, pageParameters); - } @Override protected UserProfileStorage.TableId getTableId() { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/objectTemplate/PageObjectTemplates.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/objectTemplate/PageObjectTemplates.java index 76e980b6938..cb4ba795938 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/objectTemplate/PageObjectTemplates.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/objectTemplate/PageObjectTemplates.java @@ -79,12 +79,6 @@ private void initLayout() { add(mainForm); MainObjectListPanel table = new MainObjectListPanel(ID_TABLE, ObjectTemplateType.class) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectTemplateType template) { - PageParameters pageParameters = new PageParameters(); - pageParameters.add(OnePageParameterEncoder.PARAMETER, template.getOid()); - navigateToNext(PageObjectTemplate.class, pageParameters); - } @Override protected UserProfileStorage.TableId getTableId() { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/PageOrgs.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/PageOrgs.java index 8c81502c6d2..81e030e2047 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/PageOrgs.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/PageOrgs.java @@ -84,10 +84,6 @@ protected void initLayout() { add(mainForm); MainObjectListPanel table = new MainObjectListPanel(ID_TABLE, OrgType.class, getQueryOptions()) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, OrgType org) { - PageOrgs.this.orgDetailsPerformed(target, org.getOid()); - } @Override protected UserProfileStorage.TableId getTableId() { @@ -135,12 +131,6 @@ private Collection> getQueryOptions() { .build(); } - private void orgDetailsPerformed(AjaxRequestTarget target, String oid) { - PageParameters parameters = new PageParameters(); - parameters.add(OnePageParameterEncoder.PARAMETER, oid); - navigateToNext(PageOrg.class, parameters); - } - private IModel getConfirmationMessageModel(ColumnMenuAction action, String actionName){ return WebComponentUtil.createAbstractRoleConfirmationMessage(actionName, action, getObjectListPanel(), this); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/PageReports.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/PageReports.java index 524f5f763c4..658dfd4209f 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/PageReports.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/PageReports.java @@ -78,13 +78,7 @@ private void initLayout() { add(mainForm); MainObjectListPanel table = new MainObjectListPanel(ID_TABLE, ReportType.class) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, ReportType reportType) { - PageParameters pageParameters = new PageParameters(); - pageParameters.add(OnePageParameterEncoder.PARAMETER, reportType.getOid()); - navigateToNext(PageReport.class, pageParameters); - } - + @Override protected UserProfileStorage.TableId getTableId() { return UserProfileStorage.TableId.PAGE_REPORTS; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageConnectorHosts.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageConnectorHosts.java index 25847b6ad99..7d64403f2d6 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageConnectorHosts.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageConnectorHosts.java @@ -113,9 +113,6 @@ protected void initLayout() { MainObjectListPanel table = new MainObjectListPanel(ID_TABLE, ConnectorHostType.class, getQueryOptions()) { @Override protected void objectDetailsPerformed(AjaxRequestTarget target, ConnectorHostType host) { - PageParameters parameters = new PageParameters(); - parameters.add(OnePageParameterEncoder.PARAMETER, host.getOid()); - navigateToNext(PageUser.class, parameters); } @Override diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java index a0c21289617..b38429fdc78 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java @@ -107,10 +107,6 @@ protected void initLayout() { add(mainForm); MainObjectListPanel table = new MainObjectListPanel(ID_TABLE, ResourceType.class, getQueryOptions()) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, ResourceType resource) { - PageResources.this.resourceDetailsPerformed(target, resource.getOid()); - } @Override protected UserProfileStorage.TableId getTableId() { @@ -122,11 +118,6 @@ protected List, String>> createDefaultColum return PageResources.this.initResourceColumns(); } -// @Override -// protected IColumn, String> createCheckboxColumn() { -// return null; -// } - @Override protected List createInlineMenu() { return PageResources.this.createRowMenuItems(); @@ -335,14 +326,6 @@ private List, String>> initResourceColumns( return columns; } - private void resourceDetailsPerformed(AjaxRequestTarget target, String oid) { - clearSessionStorageForResourcePage(); - - PageParameters parameters = new PageParameters(); - parameters.add(OnePageParameterEncoder.PARAMETER, oid); - navigateToNext(PageResource.class, parameters); - } - private List isAnyResourceSelected(AjaxRequestTarget target, ResourceType single) { return single != null ? Collections.singletonList(single) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/ResourceTasksPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/ResourceTasksPanel.java index 2019d5d720e..897943a0140 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/ResourceTasksPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/ResourceTasksPanel.java @@ -113,34 +113,16 @@ protected UserProfileStorage.TableId getTableId() { return UserProfileStorage.TableId.PAGE_RESOURCE_TASKS_PANEL; } -// @Override -// protected ISelectableDataProvider> createProvider() { -// return new SelectableListDataProvider<>(pageBase, tasks); -// } - @Override protected ISelectableDataProvider> createProvider() { return createSelectableBeanObjectDataProvider(() -> createResourceTasksQuery(), null); } -// @Override -// protected ObjectQuery getCustomizeContentQuery() { -// return -// -// } - @Override protected List createInlineMenu() { return null; } - @Override - public void objectDetailsPerformed(AjaxRequestTarget target, TaskType task) { - PageParameters parameters = new PageParameters(); - parameters.add(OnePageParameterEncoder.PARAMETER, task.getOid()); - getPageBase().navigateToNext(PageTask.class, parameters); - } - @Override protected void newObjectPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation, CompiledObjectCollectionView collectionView) { if (collectionView == null) { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/AbstractRoleMemberPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/AbstractRoleMemberPanel.java index 0513d6f3440..2d9c0583cb2 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/AbstractRoleMemberPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/AbstractRoleMemberPanel.java @@ -155,11 +155,6 @@ protected UserProfileStorage.TableId getTableId() { return AbstractRoleMemberPanel.this.getTableId(getComplexTypeQName()); } - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, AH object) { - detailsPerformed(object); - } - @Override protected boolean isObjectDetailsEnabled(IModel> rowModel) { if (rowModel == null || rowModel.getObject() == null @@ -994,15 +989,6 @@ protected ObjectQuery createAllMemberQuery(Collection relations) { .build(); } - protected void detailsPerformed(ObjectType object) { - if (WebComponentUtil.hasDetailsPage(object.getClass())) { - WebComponentUtil.dispatchToObjectDetailsPage(object.getClass(), object.getOid(), this, true); - } else { - error("Could not find proper response page"); - throw new RestartResponseException(getPageBase()); - } - } - private Collection> getSearchOptions() { return SelectorOptions.createCollection(GetOperationOptions.createDistinct()); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/PageRoles.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/PageRoles.java index c9fbd2a4bb4..61fb7232631 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/PageRoles.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/PageRoles.java @@ -83,10 +83,6 @@ protected void initLayout() { add(mainForm); MainObjectListPanel table = new MainObjectListPanel(ID_TABLE, RoleType.class) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, RoleType role) { - PageRoles.this.roleDetailsPerformed(target, role.getOid()); - } @Override protected UserProfileStorage.TableId getTableId() { @@ -128,12 +124,6 @@ protected List getFixedSearchItems() { mainForm.add(table); } - private void roleDetailsPerformed(AjaxRequestTarget target, String oid) { - PageParameters parameters = new PageParameters(); - parameters.add(OnePageParameterEncoder.PARAMETER, oid); - navigateToNext(PageRole.class, parameters); - } - private IModel getConfirmationMessageModel(ColumnMenuAction action, String actionName){ return WebComponentUtil.createAbstractRoleConfirmationMessage(actionName, action, getObjectListPanel(), this); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/CasesTablePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/CasesTablePanel.java index e3afb292a1a..7df82a67f53 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/CasesTablePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/CasesTablePanel.java @@ -45,13 +45,6 @@ public CasesTablePanel(String id, Collection, String>> createDefaultColumns() { return ColumnUtils.getDefaultCaseColumns(getPageBase(), isDashboard()); @@ -59,30 +52,6 @@ protected List, String>> createDefaultColumns() @Override protected ISelectableDataProvider> createProvider() { -// PageStorage storage = getPageStorage(); -// SelectableBeanObjectDataProvider provider = new SelectableBeanObjectDataProvider( -// getPageBase(), getSearchModel(), null) { -// private static final long serialVersionUID = 1L; -// -// @Override -// protected PageStorage getPageStorage() { -// return storage; -// } -// -// @NotNull -// @Override -// protected List createObjectOrderings(SortParam sortParam) { -// return WebComponentUtil.createMetadataOrdering(sortParam, "createTimestamp", getPrismContext()); -// } -// -// @Override -// protected ObjectQuery getCustomizeContentQuery() { -// return CasesTablePanel.this.getCustomizeContentQuery(); -// } -// }; -// provider.setCompiledObjectCollectionView(getObjectCollectionView()); -// provider.setOptions(createOptions()); - SelectableBeanObjectDataProvider provider = createSelectableBeanObjectDataProvider(() -> getCustomizeContentQuery(), (sortParam) -> WebComponentUtil.createMetadataOrdering(sortParam, "createTimestamp", getPrismContext())); provider.setSort(MetadataType.F_CREATE_TIMESTAMP.getLocalPart(), SortOrder.DESCENDING); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/TaskTablePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/TaskTablePanel.java index a436eaa105d..4f59a3c635c 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/TaskTablePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/TaskTablePanel.java @@ -100,11 +100,6 @@ public TaskTablePanel(String id, Collection super(id, TaskType.class, options); } - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, TaskType object) { - taskDetailsPerformed(object.getOid()); - } - @Override protected boolean isObjectDetailsEnabled(IModel> rowModel) { return rowModel.getObject().getValue().getOid() != null; @@ -180,12 +175,6 @@ private void synchronizeTasksPerformed(AjaxRequestTarget target) { clearCache(); } - private void taskDetailsPerformed(String oid) { - PageParameters parameters = new PageParameters(); - parameters.add(OnePageParameterEncoder.PARAMETER, oid); - getPageBase().navigateToNext(PageTask.class, parameters); - } - private List, String>> initTaskColumns() { List, String>> columns = new ArrayList<>(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/services/PageServices.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/services/PageServices.java index 4f1090aa77f..38226252f58 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/services/PageServices.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/services/PageServices.java @@ -89,10 +89,6 @@ protected void initLayout() { add(mainForm); MainObjectListPanel table = new MainObjectListPanel(ID_TABLE, ServiceType.class) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, ServiceType service) { - serviceDetailsPerformed(target, service); - } @Override protected UserProfileStorage.TableId getTableId() { @@ -115,11 +111,6 @@ protected IModel getConfirmationMessageModel(ColumnMenuAction action, St return listInlineMenuHelper.createRowActions(getType()); } -// @Override -// protected List, String>> createDefaultColumns() { -// return ColumnUtils.getDefaultServiceColumns(); -// } - @Override protected List getFixedSearchItems() { List fixedSearchItems = new ArrayList<>(); @@ -133,12 +124,6 @@ protected List getFixedSearchItems() { mainForm.add(table); } - protected void serviceDetailsPerformed(AjaxRequestTarget target, ServiceType service) { - PageParameters parameters = new PageParameters(); - parameters.add(OnePageParameterEncoder.PARAMETER, service.getOid()); - navigateToNext(PageService.class, parameters); - } - private IModel getConfirmationMessageModel(ColumnMenuAction action, String actionName){ return WebComponentUtil.createAbstractRoleConfirmationMessage(actionName, action, getObjectListPanel(), this); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/users/PageUsers.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/users/PageUsers.java index da5597a5971..9bee362670f 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/users/PageUsers.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/users/PageUsers.java @@ -116,12 +116,13 @@ protected void initLayout() { add(mainForm); MainObjectListPanel table = new MainObjectListPanel<>(ID_TABLE, UserType.class) { - @Override - protected void objectDetailsPerformed(AjaxRequestTarget target, UserType user) { - PageParameters parameters = new PageParameters(); - parameters.add(OnePageParameterEncoder.PARAMETER, user.getOid()); - navigateToNext(PageUser.class, parameters); - } +// @Override +// protected void objectDetailsPerformed(AjaxRequestTarget target, UserType user) { +// WebComponentUtil.dispatchToObjectDetailsPage(UserType.class, user.getOid(), this, false); +// PageParameters parameters = new PageParameters(); +// parameters.add(OnePageParameterEncoder.PARAMETER, user.getOid()); +// navigateToNext(PageUser.class, parameters); +// } @Override protected UserProfileStorage.TableId getTableId() { diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-gui-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-gui-3.xsd index 89dbdca002a..950e3beed1e 100644 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-gui-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-gui-3.xsd @@ -284,7 +284,7 @@ - +

@@ -294,7 +294,7 @@ 4.4 - AdminGuiConfigurationType.enableOldView + AdminGuiConfigurationType.useNewDesign From 64cc9ab3ba436db4c815ef44349e9ea93ca3f917 Mon Sep 17 00:00:00 2001 From: Katarina Valalikova Date: Wed, 8 Sep 2021 21:59:23 +0200 Subject: [PATCH 11/19] fixing old GUI user page tests --- .../java/com/evolveum/midpoint/gui/TestPageUser.java | 10 ++++++---- .../src/test/resources/common/system-configuration.xml | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageUser.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageUser.java index 93d17591ca2..5ffe92e82b5 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageUser.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageUser.java @@ -15,6 +15,8 @@ import com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel; import com.evolveum.midpoint.web.component.objectdetails.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; + import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.util.tester.FormTester; import org.springframework.boot.test.context.SpringBootTest; @@ -160,7 +162,7 @@ public void test013renderCasesTab() { @Test public void test014renderPersonasTab() { - renderPage(); + renderPage(USER_ADMINISTRATOR_OID); clickOnTab(6); String panel = "mainPanel:mainForm:tabPanel:panel"; @@ -169,7 +171,7 @@ public void test014renderPersonasTab() { @Test public void test015renderDelegationsTab() { - renderPage(); + renderPage(USER_ADMINISTRATOR_OID); clickOnTab(7); String panel = "mainPanel:mainForm:tabPanel:panel"; @@ -178,7 +180,7 @@ public void test015renderDelegationsTab() { @Test public void test016renderDelegatedToMeTab() { - renderPage(); + renderPage(SystemObjectsType.USER_ADMINISTRATOR.value()); clickOnTab(8); String panel = "mainPanel:mainForm:tabPanel:panel"; @@ -187,7 +189,7 @@ public void test016renderDelegatedToMeTab() { @Test public void test017renderTriggersTab() { - renderPage(); + renderPage(SystemObjectsType.USER_ADMINISTRATOR.value()); clickOnTab(5); String panel = "mainPanel:mainForm:tabPanel:panel"; diff --git a/gui/admin-gui/src/test/resources/common/system-configuration.xml b/gui/admin-gui/src/test/resources/common/system-configuration.xml index 6fe47aeeb79..c95558e2948 100644 --- a/gui/admin-gui/src/test/resources/common/system-configuration.xml +++ b/gui/admin-gui/src/test/resources/common/system-configuration.xml @@ -113,6 +113,7 @@ + false /self/profile From 1101e41031a47e3adea801ce7a746bcffd6081b4 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 8 Sep 2021 19:26:01 +0200 Subject: [PATCH 12/19] repo-sqale: right-hand path treatment cleanup --- .../sqale/mapping/ExtensionItemSqlMapper.java | 2 +- .../sqlbase/filtering/RightHandProcessor.java | 12 +++++++--- .../filtering/ValueFilterProcessor.java | 24 ++++++++++--------- .../sqlbase/mapping/DefaultItemSqlMapper.java | 6 ++--- .../repo/sqlbase/mapping/ItemSqlMapper.java | 3 +-- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java index e1646df1a15..864d428929a 100644 --- a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java +++ b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/mapping/ExtensionItemSqlMapper.java @@ -99,7 +99,7 @@ public ExtensionItemSqlMapper( } @Override - public > @Nullable RightHandProcessor createRightHandProcessor( + public @Nullable RightHandProcessor createRightHandProcessor( SqlQueryContext sqlQueryContext) { return createFilterProcessor(sqlQueryContext); } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/RightHandProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/RightHandProcessor.java index 3fb6625fa1c..dcb2d323c98 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/RightHandProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/RightHandProcessor.java @@ -1,11 +1,17 @@ +/* + * Copyright (C) 2010-2021 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ package com.evolveum.midpoint.repo.sqlbase.filtering; +import com.querydsl.core.types.Expression; + import com.evolveum.midpoint.prism.query.ValueFilter; import com.evolveum.midpoint.repo.sqlbase.RepositoryException; -import com.querydsl.core.types.Expression; public interface RightHandProcessor { - public Expression rightHand(ValueFilter filter) throws RepositoryException; - + Expression rightHand(ValueFilter filter) throws RepositoryException; } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterProcessor.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterProcessor.java index e40ff586bc5..f724749ab56 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterProcessor.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/filtering/ValueFilterProcessor.java @@ -26,7 +26,7 @@ * * Despite the class name it does not directly contain code that creates conditions based on values. * This is still a structural processor and the name "value filter" merely reflects the type of - * a filter which it processes. + * filter which it processes. * * If the path has multiple names it creates new instance of this filter processor for each * step to preserve contextual information - e.g. when predicate needs to be applied to the current @@ -65,7 +65,7 @@ private Predicate process( ItemPath path, ValueFilter filter) throws RepositoryException { final RightHandProcessor right; if (filter.getRightHandSidePath() != null) { - right = processRight(filter.getRightHandSidePath(), filter); + right = processRight(filter.getRightHandSidePath()); } else { right = null; } @@ -73,7 +73,7 @@ private Predicate process( } private , TR> Predicate process( - ItemPath path, ValueFilter filter, RightHandProcessor right) throws RepositoryException { + ItemPath path, ValueFilter filter, RightHandProcessor right) throws RepositoryException { // isSingleName/asSingleName or firstName don't work for T_ID (OID) if (path.size() == 1) { QName itemName = path.firstToQName(); @@ -89,8 +89,9 @@ private , TR> Predicate process( } return filterProcessor.process(filter); } else { - ItemRelationResolver resolver = mapping.relationResolver(path); - ItemRelationResolver.ResolutionResult resolution = resolver.resolve(context); + //noinspection DuplicatedCode + ItemRelationResolver.ResolutionResult resolution = + mapping.relationResolver(path).resolve(context); SqlQueryContext subcontext = resolution.context; ValueFilterProcessor nestedProcessor = new ValueFilterProcessor<>(subcontext, resolution.mapping); @@ -105,8 +106,8 @@ private , TR> Predicate process( } } - private , TR> RightHandProcessor processRight(ItemPath path, ValueFilter filter) throws RepositoryException { - SqlQueryContext root = context; + private , TR> RightHandProcessor processRight(ItemPath path) + throws RepositoryException { if (path.size() == 1) { QName itemName = path.firstToQName(); RightHandProcessor filterProcessor = @@ -118,15 +119,16 @@ private , TR> RightHandProcessor proce } return filterProcessor; } else { - ItemRelationResolver resolver = mapping.relationResolver(path); - ItemRelationResolver.ResolutionResult resolution = resolver.resolve(context); + //noinspection DuplicatedCode + ItemRelationResolver.ResolutionResult resolution = + mapping.relationResolver(path).resolve(context); SqlQueryContext subcontext = resolution.context; ValueFilterProcessor nestedProcessor = new ValueFilterProcessor<>(subcontext, resolution.mapping); if (resolution.subquery) { - throw new RepositoryException("Righ path " + path + "is not single value"); + throw new RepositoryException("Right path " + path + "is not single value"); } - return nestedProcessor.processRight(path.rest(), filter); + return nestedProcessor.processRight(path.rest()); } } } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/DefaultItemSqlMapper.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/DefaultItemSqlMapper.java index 70526f786d7..5144fd2a5cd 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/DefaultItemSqlMapper.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/DefaultItemSqlMapper.java @@ -85,12 +85,12 @@ public DefaultItemSqlMapper( @SuppressWarnings({ "unchecked", "rawtypes" }) public @Nullable > ItemValueFilterProcessor createFilterProcessor( SqlQueryContext sqlQueryContext) { - return filterProcessorFactory - .apply((SqlQueryContext) sqlQueryContext); + return filterProcessorFactory.apply((SqlQueryContext) sqlQueryContext); } @Override - public > @Nullable RightHandProcessor createRightHandProcessor( + @SuppressWarnings({ "unchecked", "rawtypes" }) + public @Nullable RightHandProcessor createRightHandProcessor( SqlQueryContext sqlQueryContext) { return filterProcessorFactory.apply((SqlQueryContext) sqlQueryContext); } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/ItemSqlMapper.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/ItemSqlMapper.java index 3685cf8ced6..ab80671f269 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/ItemSqlMapper.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/ItemSqlMapper.java @@ -7,7 +7,6 @@ package com.evolveum.midpoint.repo.sqlbase.mapping; import com.querydsl.core.types.Expression; - import org.jetbrains.annotations.Nullable; import com.evolveum.midpoint.prism.ItemDefinition; @@ -47,7 +46,7 @@ public interface ItemSqlMapper, R> { @Nullable > ItemValueFilterProcessor createFilterProcessor( SqlQueryContext sqlQueryContext); - @Nullable > RightHandProcessor createRightHandProcessor( + @Nullable RightHandProcessor createRightHandProcessor( SqlQueryContext sqlQueryContext); } From 891ec1bb2eba548a7ff38aa7a0a76919f978ff4e Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 8 Sep 2021 19:31:53 +0200 Subject: [PATCH 13/19] new audit: start of searchObjectsIterative, WIP Common search support methods were put to SqaleServiceBase.java --- .../audit/api/AuditResultHandler.java | 24 +- .../midpoint/audit/api/AuditService.java | 20 ++ .../audit/impl/LoggerAuditServiceImpl.java | 16 +- .../midpoint/repo/api/RepositoryService.java | 38 +-- repo/repo-sqale/sql/pgnew-repo.sql | 1 - .../repo/sqale/SqaleRepositoryService.java | 33 +-- .../midpoint/repo/sqale/SqaleServiceBase.java | 37 ++- .../repo/sqale/audit/SqaleAuditService.java | 258 +++++++++++++++++- .../repo/sql/SqlAuditServiceImpl.java | 10 + .../midpoint/test/DummyAuditService.java | 20 +- .../midpoint/init/AuditServiceProxy.java | 28 +- 11 files changed, 402 insertions(+), 83 deletions(-) diff --git a/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditResultHandler.java b/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditResultHandler.java index b28ec310bb1..72f3c15d911 100644 --- a/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditResultHandler.java +++ b/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditResultHandler.java @@ -1,21 +1,27 @@ /* - * Copyright (c) 2010-2019 Evolveum and contributors + * Copyright (C) 2010-2021 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ package com.evolveum.midpoint.audit.api; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.util.annotation.Experimental; import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType; +/** + * Handler interface for {@link AuditService#searchObjectsIterative}. + */ +@FunctionalInterface +@Experimental public interface AuditResultHandler { - @Deprecated - default boolean handle(AuditEventRecord auditRecord){ - return true; - } - - boolean handle(AuditEventRecordType auditRecord); - - int getProgress(); + /** + * Handle a single audit event record. + * + * @param eventRecord audit event record to process + * @return true if the operation should proceed, false if it should stop + */ + boolean handle(AuditEventRecordType eventRecord, OperationResult parentResult); } diff --git a/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditService.java b/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditService.java index 251309ad082..916e7021d68 100644 --- a/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditService.java +++ b/repo/audit-api/src/main/java/com/evolveum/midpoint/audit/api/AuditService.java @@ -14,9 +14,11 @@ import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.SearchResultList; +import com.evolveum.midpoint.schema.SearchResultMetadata; import com.evolveum.midpoint.schema.SelectorOptions; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.annotation.Experimental; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType; @@ -35,6 +37,8 @@ public interface AuditService { String OP_CLEANUP_AUDIT_MAX_RECORDS = "cleanupAuditMaxRecords"; String OP_COUNT_OBJECTS = "countObjects"; String OP_SEARCH_OBJECTS = "searchObjects"; + String OP_SEARCH_OBJECTS_ITERATIVE = "searchObjectsIterative"; + String OP_SEARCH_OBJECTS_ITERATIVE_PAGE = "searchObjectsIterativePage"; void audit(AuditEventRecord record, Task task, OperationResult result); @@ -87,4 +91,20 @@ SearchResultList searchObjects( @Nullable Collection> options, @NotNull OperationResult parentResult) throws SchemaException; + + /** + * Executes iterative search using the provided `handler` to process each object. + * + * @param query search query + * @param handler result handler + * @param options get options to use for the search + * @param parentResult parent OperationResult (in/out) + * @return summary information about the search result + */ + @Experimental + SearchResultMetadata searchObjectsIterative( + @Nullable ObjectQuery query, + @NotNull AuditResultHandler handler, + @Nullable Collection> options, + @NotNull OperationResult parentResult) throws SchemaException; } diff --git a/repo/audit-log-impl/src/main/java/com/evolveum/midpoint/audit/impl/LoggerAuditServiceImpl.java b/repo/audit-log-impl/src/main/java/com/evolveum/midpoint/audit/impl/LoggerAuditServiceImpl.java index b941a9f2b7f..4229df6ca63 100644 --- a/repo/audit-log-impl/src/main/java/com/evolveum/midpoint/audit/impl/LoggerAuditServiceImpl.java +++ b/repo/audit-log-impl/src/main/java/com/evolveum/midpoint/audit/impl/LoggerAuditServiceImpl.java @@ -18,17 +18,16 @@ import org.slf4j.LoggerFactory; import com.evolveum.midpoint.audit.api.AuditEventRecord; +import com.evolveum.midpoint.audit.api.AuditResultHandler; import com.evolveum.midpoint.audit.api.AuditService; import com.evolveum.midpoint.common.LoggingConfigurationManager; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ObjectDeltaOperation; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; @@ -169,4 +168,13 @@ public SearchResultList searchObjects( @NotNull OperationResult parentResult) { throw new UnsupportedOperationException("searchObjects not supported"); } + + @Override + public SearchResultMetadata searchObjectsIterative( + @Nullable ObjectQuery query, + @NotNull AuditResultHandler handler, + @Nullable Collection> options, + @NotNull OperationResult parentResult) throws SchemaException { + throw new UnsupportedOperationException("searchObjectsIterative not supported"); + } } diff --git a/repo/repo-api/src/main/java/com/evolveum/midpoint/repo/api/RepositoryService.java b/repo/repo-api/src/main/java/com/evolveum/midpoint/repo/api/RepositoryService.java index f9ec139353a..572d273ce8f 100644 --- a/repo/repo-api/src/main/java/com/evolveum/midpoint/repo/api/RepositoryService.java +++ b/repo/repo-api/src/main/java/com/evolveum/midpoint/repo/api/RepositoryService.java @@ -390,24 +390,29 @@ int countObjects(Class type, ObjectQuery query, OperationResult parentResult) throws SchemaException; /** - *

Search for objects in the repository in an iterative fashion.

- *

Searches through all object types. Calls a specified handler for each object found. - * If no search criteria specified, list of all objects of specified type is returned.

- *

+ * Search for objects in the repository in an iterative fashion. + * + * Searches through all object types. Calls a specified handler for each object found. + * If no search criteria specified, list of all objects of specified type is returned. + * * Searches through all object types. * Returns a list of objects that match search criteria. - *

+ * * Returns empty list if object type is correct but there are no objects of * that type. The ordering of the results is not significant and may be arbitrary * unless sorting in the paging is used. - *

+ * * Should fail if object type is wrong. Should fail if unknown property is * specified in the query. - *

- *

- * A note related to iteration method: - *

- * There are three iteration methods (see IterationMethodType): + * + * [NOTE] + * ==== + * New repository uses single reliable iteration method similar to strictly sequential paging + * and supports custom ordering (currently only one). + * New repository ignores strictlySequential parameter and related get options completely. + * + * In old repository there are three iteration methods (see IterationMethodType): + * * - SINGLE_TRANSACTION: Fetches objects in single DB transaction. Not supported for all DBMSs. * - SIMPLE_PAGING: Uses the "simple paging" method: takes objects (e.g.) numbered 0 to 49, then 50 to 99, * then 100 to 149, and so on. The disadvantage is that if the order of objects is changed @@ -416,15 +421,16 @@ int countObjects(Class type, ObjectQuery query, * - STRICTLY_SEQUENTIAL_PAGING: Uses the "strictly sequential paging" method: sorting returned objects by OID. This * is (almost) reliable in such a way that no object would be skipped. However, custom * paging cannot be used in this mode. - *

+ * * If GetOperationOptions.iterationMethod is specified, it is used without any further considerations. * Otherwise, the repository configuration determines whether to use SINGLE_TRANSACTION or a paging. In the latter case, * strictlySequential flag determines between SIMPLE_PAGING (if false) and STRICTLY_SEQUENTIAL_PAGING (if true). - *

+ * * If explicit GetOperationOptions.iterationMethod is not provided, and paging is prescribed, and strictlySequential flag * is true and client-provided paging conflicts with the paging used by the iteration method, a warning is issued, and * iteration method is switched to SIMPLE_PAGING. - *

+ * ==== + * * Sources of conflicts: * - ordering is specified * - offset is specified @@ -432,9 +438,9 @@ int countObjects(Class type, ObjectQuery query, * * @param query search query * @param handler result handler - * @param strictlySequential takes care not to skip any object nor to process objects more than once; see below + * @param strictlySequential takes care not to skip any object nor to process objects more than once * @param parentResult parent OperationResult (in/out) - * @return all objects of specified type that match search criteria (subject to paging) + * @return summary information about the search result * @throws IllegalArgumentException wrong object type * @throws SchemaException unknown property used in search query */ diff --git a/repo/repo-sqale/sql/pgnew-repo.sql b/repo/repo-sqale/sql/pgnew-repo.sql index cb1671e9c88..86e858c553f 100644 --- a/repo/repo-sqale/sql/pgnew-repo.sql +++ b/repo/repo-sqale/sql/pgnew-repo.sql @@ -754,7 +754,6 @@ BEGIN END IF; END; $$; -- endregion --- endregion -- region OTHER object tables -- Represents ResourceType, see https://wiki.evolveum.com/display/midPoint/Resource+Configuration diff --git a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleRepositoryService.java b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleRepositoryService.java index b459dc118df..45234f18da5 100644 --- a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleRepositoryService.java +++ b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleRepositoryService.java @@ -978,7 +978,7 @@ private SearchResultMetadata executeSearchObjectsIterativ prismContext())); // we don't call public searchObject to avoid subresults and query simplification - logSearchInputParameters(type, pagedQuery, "Search object iterative page "); + logSearchInputParameters(type, pagedQuery, "Search object iterative page"); List> objects = executeSearchObject( type, pagedQuery, options, OP_SEARCH_OBJECTS_ITERATIVE_PAGE); @@ -1201,33 +1201,6 @@ private SearchResultList executeSearchContainers(Cl registerOperationFinish(opHandle, 1); } } - - private void logSearchInputParameters(Class type, ObjectQuery query, String operation) { - ObjectPaging paging = query != null ? query.getPaging() : null; - logger.debug( - "{} of type '{}', query on trace level, offset {}, limit {}.", - operation, type.getSimpleName(), - paging != null ? paging.getOffset() : "undefined", - paging != null ? paging.getMaxSize() : "undefined"); - - logger.trace("Full query\n{}", - query == null ? "undefined" : query.debugDumpLazily()); - } - - private ObjectQuery simplifyQuery(ObjectQuery query) { - if (query != null) { - // simplify() creates new filter instance which can be modified - ObjectFilter filter = ObjectQueryUtil.simplify(query.getFilter(), prismContext()); - query = query.cloneWithoutFilter(); - query.setFilter(filter instanceof AllFilter ? null : filter); - } - - return query; - } - - private boolean isNoneQuery(ObjectQuery query) { - return query != null && query.getFilter() instanceof NoneFilter; - } // endregion @Override @@ -1910,8 +1883,4 @@ private boolean pruneDiagnosticInformation( public SqlPerformanceMonitorImpl getPerformanceMonitor() { return performanceMonitor; } - - private PrismContext prismContext() { - return sqlRepoContext.prismContext(); - } } diff --git a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleServiceBase.java b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleServiceBase.java index 2f9a119d65f..0206770c123 100644 --- a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleServiceBase.java +++ b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleServiceBase.java @@ -13,12 +13,14 @@ import com.evolveum.midpoint.prism.Containerable; import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.query.*; import com.evolveum.midpoint.repo.api.SqlPerformanceMonitorsCollection; import com.evolveum.midpoint.repo.sqlbase.JdbcRepositoryConfiguration; import com.evolveum.midpoint.repo.sqlbase.JdbcSession; import com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.util.exception.SystemException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -59,6 +61,10 @@ protected JdbcRepositoryConfiguration repositoryConfiguration() { return sqlRepoContext.getJdbcRepositoryConfiguration(); } + protected PrismContext prismContext() { + return sqlRepoContext.prismContext(); + } + // region exception handling /** @@ -128,6 +134,35 @@ protected boolean isFatalException(Throwable ex) { } // endregion + // region search support methods + protected void logSearchInputParameters(Class type, ObjectQuery query, String operation) { + ObjectPaging paging = query != null ? query.getPaging() : null; + logger.debug( + "{} of type '{}' (full query on trace level), offset {}, limit {}.", + operation, type.getSimpleName(), + paging != null ? paging.getOffset() : "undefined", + paging != null ? paging.getMaxSize() : "undefined"); + + logger.trace("Full query\n{}", + query == null ? "undefined" : query.debugDumpLazily()); + } + + protected ObjectQuery simplifyQuery(ObjectQuery query) { + if (query != null) { + // simplify() creates new filter instance which can be modified + ObjectFilter filter = ObjectQueryUtil.simplify(query.getFilter(), prismContext()); + query = query.cloneWithoutFilter(); + query.setFilter(filter instanceof AllFilter ? null : filter); + } + + return query; + } + + protected boolean isNoneQuery(ObjectQuery query) { + return query != null && query.getFilter() instanceof NoneFilter; + } + // endregion + // region perf monitoring /** diff --git a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/audit/SqaleAuditService.java b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/audit/SqaleAuditService.java index 17c29609fdc..bf564414bfa 100644 --- a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/audit/SqaleAuditService.java +++ b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/audit/SqaleAuditService.java @@ -6,6 +6,8 @@ */ package com.evolveum.midpoint.repo.sqale.audit; +import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; + import static com.evolveum.midpoint.schema.util.SystemConfigurationAuditUtil.isEscapingInvalidCharacters; import java.io.ByteArrayInputStream; @@ -21,18 +23,20 @@ import com.querydsl.sql.dml.DefaultMapper; import com.querydsl.sql.dml.SQLInsertClause; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.Validate; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import com.evolveum.midpoint.audit.api.AuditEventRecord; import com.evolveum.midpoint.audit.api.AuditReferenceValue; +import com.evolveum.midpoint.audit.api.AuditResultHandler; import com.evolveum.midpoint.audit.api.AuditService; import com.evolveum.midpoint.prism.SerializationOptions; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.CanonicalItemPath; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.prism.query.*; import com.evolveum.midpoint.prism.util.CloneUtil; import com.evolveum.midpoint.repo.api.SqlPerformanceMonitorsCollection; import com.evolveum.midpoint.repo.sqale.*; @@ -46,6 +50,7 @@ import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SystemException; @@ -472,7 +477,14 @@ public SearchResultList searchObjects( .build(); try { - return executeSearchObjects(query, options); + logSearchInputParameters(AuditEventRecordType.class, query, "Search audit"); + + query = simplifyQuery(query); + if (isNoneQuery(query)) { + return new SearchResultList<>(); + } + + return executeSearchObjects(query, options, OP_SEARCH_OBJECTS); } catch (RepositoryException | RuntimeException e) { throw handledGeneralException(e, operationResult); } catch (Throwable t) { @@ -485,9 +497,11 @@ public SearchResultList searchObjects( private SearchResultList executeSearchObjects( @Nullable ObjectQuery query, - @Nullable Collection> options) + @Nullable Collection> options, + String operationKind) throws RepositoryException, SchemaException { - long opHandle = registerOperationStart(OP_SEARCH_OBJECTS); + + long opHandle = registerOperationStart(operationKind); try { return sqlQueryExecutor.list( SqaleQueryContext.from(AuditEventRecordType.class, sqlRepoContext), @@ -497,6 +511,242 @@ private SearchResultList executeSearchObjects( } } + @Override + public SearchResultMetadata searchObjectsIterative( + @Nullable ObjectQuery query, + @NotNull AuditResultHandler handler, + @Nullable Collection> options, + @NotNull OperationResult parentResult) throws SchemaException { + Validate.notNull(handler, "Result handler must not be null."); + Validate.notNull(parentResult, "Operation result must not be null."); + + OperationResult operationResult = parentResult.subresult(opNamePrefix + OP_SEARCH_OBJECTS_ITERATIVE) + .addParam("type", AuditEventRecordType.class.getName()) + .addParam("query", query) + .build(); + + try { + logSearchInputParameters(AuditEventRecordType.class, query, "Iterative search audit"); + + query = simplifyQuery(query); + if (isNoneQuery(query)) { + return new SearchResultMetadata().approxNumberOfAllResults(0); + } + + return executeSearchObjectsIterative(query, handler, options, operationResult); + } catch (RepositoryException | RuntimeException e) { + throw handledGeneralException(e, operationResult); + } catch (Throwable t) { + operationResult.recordFatalError(t); + throw t; + } finally { + operationResult.computeStatusIfUnknown(); + } + } + + private SearchResultMetadata executeSearchObjectsIterative( + ObjectQuery originalQuery, + AuditResultHandler handler, + Collection> options, + OperationResult operationResult) throws SchemaException, RepositoryException { + + try { + ObjectPaging originalPaging = originalQuery != null ? originalQuery.getPaging() : null; + // this is total requested size of the search + Integer maxSize = originalPaging != null ? originalPaging.getMaxSize() : null; + + IterativeSearchOrdering ordering = new IterativeSearchOrdering(originalPaging); + + ObjectQuery pagedQuery = prismContext().queryFactory().createQuery(); + ObjectPaging paging = prismContext().queryFactory().createPaging(); + if (originalPaging != null && originalPaging.getOrderingInstructions() != null) { + originalPaging.getOrderingInstructions().forEach(o -> + paging.addOrderingInstruction(o.getOrderBy(), o.getDirection())); + } + paging.addOrderingInstruction(AuditEventRecordType.F_REPO_ID, OrderDirection.ASCENDING); + pagedQuery.setPaging(paging); + + int pageSize = Math.min( + repositoryConfiguration().getIterativeSearchByPagingBatchSize(), + defaultIfNull(maxSize, Integer.MAX_VALUE)); + pagedQuery.getPaging().setMaxSize(pageSize); + + AuditEventRecordType lastProcessedObject = null; + int handledObjectsTotal = 0; + + while (true) { + if (maxSize != null && maxSize - handledObjectsTotal < pageSize) { + // relevant only for the last page + pagedQuery.getPaging().setMaxSize(maxSize - handledObjectsTotal); + } + + // filterAnd() is quite null safe, even for both nulls + pagedQuery.setFilter(ObjectQueryUtil.filterAnd( + originalQuery != null ? originalQuery.getFilter() : null, + lastOidCondition(lastProcessedObject, ordering), + prismContext())); + + // we don't call public searchObject to avoid subresults and query simplification + logSearchInputParameters(AuditEventRecordType.class, pagedQuery, "Search audit iterative page"); + List resultPage = executeSearchObjects( + pagedQuery, options, OP_SEARCH_OBJECTS_ITERATIVE_PAGE); + + // process page results + for (AuditEventRecordType auditEvent : resultPage) { + lastProcessedObject = auditEvent; + if (!handler.handle(auditEvent, operationResult)) { + return new SearchResultMetadata() + .approxNumberOfAllResults(handledObjectsTotal + 1) + .pagingCookie(lastProcessedObject.getRepoId().toString()) + .partialResults(true); + } + handledObjectsTotal += 1; + + if (maxSize != null && handledObjectsTotal >= maxSize) { + return new SearchResultMetadata() + .approxNumberOfAllResults(handledObjectsTotal) + .pagingCookie(lastProcessedObject.getRepoId().toString()); + } + } + + if (resultPage.isEmpty() || resultPage.size() < pageSize) { + return new SearchResultMetadata() + .approxNumberOfAllResults(handledObjectsTotal) + .pagingCookie(lastProcessedObject != null + ? lastProcessedObject.getRepoId().toString() : null); + } + } + } finally { + // This just counts the operation and adds zero/minimal time not to confuse user + // with what could be possibly very long duration. + registerOperationFinish(registerOperationStart(OP_SEARCH_OBJECTS_ITERATIVE), 1); + } + } + + private void checkProvidedOrdering(List providedOrdering) throws RepositoryException { + if (providedOrdering != null && providedOrdering.size() > 1) { + throw new RepositoryException("searchObjectsIterative() does not support ordering" + + " by multiple paths (yet): " + providedOrdering); + } + } + + private class IterativeSearchOrdering { + + private final List providedOrdering; + + private IterativeSearchOrdering(ObjectPaging originalPaging) throws RepositoryException { + providedOrdering = originalPaging != null + ? originalPaging.getOrderingInstructions() + : null; + +// if (providedOrdering != null) { +// TODO +// if (providedOrdering.stream().anyMatch(o -> QNameUtil.equals()o.getOrderBy())) +// checkProvidedOrdering(providedOrdering); +// } + } + } + + /** + * Without requested ordering, this is easy: `WHERE id > lastId AND timestamp > lastTimestamp`. + * Timestamp is used to help with partition pruning and is part of the PK anyway. + * + * But with outside ordering we need to respect it and for ordering by X, Y, Z use: + * + * ---- + * -- the first part of WHERE with original conditions is taken care of outside of this method + * ... WHERE original conditions AND ( + * X > last.X + * OR (X = last.X AND Y > last.Y) + * OR (X = last.X AND Y = last.Y AND Z > last.Z) + * OR (X = last.X AND Y = last.Y ...if all equal + * AND id > lastId AND timestamp > lastTimestamp) -- only here is ID + timestamp + * ---- + * + * This can be further complicated by the fact that both ID (F_REPO_ID) and timestamp + * (F_TIMESTAMP) can be part of custom ordering, in which case it must be omitted + * from the internally added conditions and ordering. + * + * This is suddenly much more fun, isn't it? + * Of course the condition `>` or `<` depends on `ASC` vs `DESC`. + * + * TODO: Currently, single path ordering is supported. Finish multi-path too. + * TODO: What about nullable columns? + */ + @Nullable + private ObjectFilter lastOidCondition( + AuditEventRecordType lastProcessedObject, IterativeSearchOrdering providedOrdering) { + /* + if (lastProcessedObject == null) { + return null; + } + + String lastProcessedOid = lastProcessedObject.getOid(); + if (providedOrdering == null || providedOrdering.isEmpty()) { + return prismContext() + .queryFor(lastProcessedObject.getCompileTimeClass()) + .item(OID_PATH).gt(lastProcessedOid).buildFilter(); + } + + if (providedOrdering.size() == 1) { + ObjectOrdering objectOrdering = providedOrdering.get(0); + ItemPath orderByPath = objectOrdering.getOrderBy(); + boolean asc = objectOrdering.getDirection() == OrderDirection.ASCENDING; + S_ConditionEntry filter = prismContext() + .queryFor(lastProcessedObject.getCompileTimeClass()) + .item(orderByPath); + //noinspection rawtypes + Item item = lastProcessedObject.findItem(orderByPath); + if (item.size() > 1) { + throw new IllegalArgumentException( + "Multi-value property for ordering is forbidden - item: " + item); + } else if (item.isEmpty()) { + // TODO what if it's nullable? is it null-first or last? + // See: https://www.postgresql.org/docs/13/queries-order.html + // "By default, null values sort as if larger than any non-null value; that is, + // NULLS FIRST is the default for DESC order, and NULLS LAST otherwise." + } else { + S_MatchingRuleEntry matchingRuleEntry = + asc ? filter.gt(item.getRealValue()) : filter.lt(item.getRealValue()); + filter = matchingRuleEntry.or() + .block() + .item(orderByPath).eq(item.getRealValue()) + .and() + .item(OID_PATH); + return (asc ? filter.gt(lastProcessedOid) : filter.lt(lastProcessedOid)) + .endBlock() + .buildFilter(); + } + } + */ + + throw new IllegalArgumentException( + "Shouldn't get here with check in executeSearchObjectsIterative()"); + /* + TODO: Unfinished - this is painful with fluent API. Should I call + prismContext().queryFor(lastProcessedObject.getCompileTimeClass()) for each component + and then use ObjectQueryUtil.filterAnd/Or? + // we need to handle the complicated case with externally provided ordering + S_FilterEntryOrEmpty orBlock = prismContext() + .queryFor(lastProcessedObject.getCompileTimeClass()).block(); + orLoop: + for (ObjectOrdering orMasterOrdering : providedOrdering) { + Iterator iterator = providedOrdering.iterator(); + while (iterator.hasNext()) { + S_FilterEntryOrEmpty andBlock = orBlock.block(); + ObjectOrdering ordering = iterator.next(); + if (ordering.equals(orMasterOrdering)) { + // ... + continue orLoop; + } + orBlock = andBlock.endBlock(); + } + + } + return orBlock.endBlock().buildFilter(); + */ + } + protected long registerOperationStart(String kind) { return registerOperationStart(kind, AuditEventRecordType.class); } diff --git a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlAuditServiceImpl.java b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlAuditServiceImpl.java index c2c412a71a6..82278a49f01 100644 --- a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlAuditServiceImpl.java +++ b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlAuditServiceImpl.java @@ -24,6 +24,7 @@ import com.evolveum.midpoint.audit.api.AuditEventRecord; import com.evolveum.midpoint.audit.api.AuditReferenceValue; +import com.evolveum.midpoint.audit.api.AuditResultHandler; import com.evolveum.midpoint.audit.api.AuditService; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.SerializationOptions; @@ -729,4 +730,13 @@ public SearchResultList searchObjects( operationResult.computeStatusIfUnknown(); } } + + @Override + public SearchResultMetadata searchObjectsIterative( + @Nullable ObjectQuery query, + @NotNull AuditResultHandler handler, + @Nullable Collection> options, + @NotNull OperationResult parentResult) throws SchemaException { + throw new UnsupportedOperationException("searchObjectsIterative not supported in old repository audit"); + } } diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/DummyAuditService.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/DummyAuditService.java index 6bcf6d15e6d..f7d6c74c1e2 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/DummyAuditService.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/DummyAuditService.java @@ -17,10 +17,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import com.evolveum.midpoint.audit.api.AuditEventRecord; -import com.evolveum.midpoint.audit.api.AuditEventStage; -import com.evolveum.midpoint.audit.api.AuditEventType; -import com.evolveum.midpoint.audit.api.AuditService; +import com.evolveum.midpoint.audit.api.*; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.delta.ChangeType; @@ -29,15 +26,13 @@ import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ObjectDeltaOperation; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.DebugUtil; +import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; @@ -558,4 +553,13 @@ public SearchResultList searchObjects( @NotNull OperationResult parentResult) { throw new UnsupportedOperationException("searchObjects not supported"); } + + @Override + public SearchResultMetadata searchObjectsIterative( + @Nullable ObjectQuery query, + @NotNull AuditResultHandler handler, + @Nullable Collection> options, + @NotNull OperationResult parentResult) throws SchemaException { + throw new UnsupportedOperationException("searchObjectsIterative not supported"); + } } diff --git a/repo/system-init/src/main/java/com/evolveum/midpoint/init/AuditServiceProxy.java b/repo/system-init/src/main/java/com/evolveum/midpoint/init/AuditServiceProxy.java index 950d131892e..5a0e0d58cee 100644 --- a/repo/system-init/src/main/java/com/evolveum/midpoint/init/AuditServiceProxy.java +++ b/repo/system-init/src/main/java/com/evolveum/midpoint/init/AuditServiceProxy.java @@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import com.evolveum.midpoint.audit.api.AuditEventRecord; +import com.evolveum.midpoint.audit.api.AuditResultHandler; import com.evolveum.midpoint.audit.api.AuditService; import com.evolveum.midpoint.audit.spi.AuditServiceRegistry; import com.evolveum.midpoint.prism.PrismContext; @@ -235,17 +236,28 @@ public SearchResultList searchObjects( @Nullable Collection> options, @NotNull OperationResult parentResult) throws SchemaException { - // does it even make sense to merge multiple results for audit? - SearchResultList result = new SearchResultList<>(); for (AuditService service : services) { if (service.supportsRetrieval()) { - SearchResultList oneResult = - service.searchObjects(query, options, parentResult); - if (!oneResult.isEmpty()) { - result.addAll(oneResult); - } + return service.searchObjects(query, options, parentResult); } } - return result; + + return new SearchResultList<>(); + } + + @Override + @NotNull + public SearchResultMetadata searchObjectsIterative( + @Nullable ObjectQuery query, + @NotNull AuditResultHandler handler, + @Nullable Collection> options, + @NotNull OperationResult parentResult) throws SchemaException { + for (AuditService service : services) { + if (service.supportsRetrieval()) { + return service.searchObjectsIterative(query, handler, options, parentResult); + } + } + + return new SearchResultMetadata(); } } From 33a6867bb61b3ed2f14f13701caea4d1358b79aa Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 8 Sep 2021 22:03:47 +0200 Subject: [PATCH 14/19] repo-sql-impl-test: sqale profile compiles the tests without running This fixes the complaining dependency plugin (gosh, how I "love" it). --- repo/repo-sql-impl-test/pom.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/repo/repo-sql-impl-test/pom.xml b/repo/repo-sql-impl-test/pom.xml index f8000ee02cf..90b27916ace 100644 --- a/repo/repo-sql-impl-test/pom.xml +++ b/repo/repo-sql-impl-test/pom.xml @@ -262,7 +262,11 @@ false - true + + true From d76fe43c9efe581cda5c568637c70209128ebadc Mon Sep 17 00:00:00 2001 From: Katarina Valalikova Date: Wed, 8 Sep 2021 22:05:45 +0200 Subject: [PATCH 15/19] adapting midscale test for new user creation --- .../test/java/com/evolveum/midpoint/gui/MidScaleGuiTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/MidScaleGuiTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/MidScaleGuiTest.java index 7a804d3a372..26ecc9b1738 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/MidScaleGuiTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/MidScaleGuiTest.java @@ -9,6 +9,7 @@ import java.io.File; import com.evolveum.midpoint.gui.api.component.MainObjectListPanel; +import com.evolveum.midpoint.gui.impl.page.admin.user.PageUser; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.schema.constants.ObjectTypes; @@ -41,7 +42,6 @@ import com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest; import com.evolveum.midpoint.web.page.admin.home.PageDashboardInfo; import com.evolveum.midpoint.web.page.admin.orgs.PageOrgTree; -import com.evolveum.midpoint.web.page.admin.users.PageUser; import com.evolveum.midpoint.web.page.admin.users.PageUsers; import com.evolveum.midpoint.web.page.self.PageAssignmentShoppingCart; import com.evolveum.midpoint.web.page.self.PageSelfCredentials; From 2a366eb599ae0c68d4ca87313f7f4e0f3b4942e7 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 8 Sep 2021 23:02:33 +0200 Subject: [PATCH 16/19] old/new AuditSearchTest(s) fixes to deal with unmodifiable result --- .../midpoint/repo/sqale/func/AuditSearchTest.java | 8 ++++++-- .../com/evolveum/midpoint/repo/sql/AuditSearchTest.java | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/AuditSearchTest.java b/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/AuditSearchTest.java index c67779abdff..c4d738e2b7f 100644 --- a/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/AuditSearchTest.java +++ b/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/AuditSearchTest.java @@ -15,6 +15,7 @@ import java.util.Comparator; import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; @@ -966,14 +967,17 @@ public void test281SearchByResourceOidAnyValue() throws SchemaException { @Test public void test300SearchReturnsMappedToManyAttributes() throws SchemaException { when("searching audit with query without any conditions and paging"); - SearchResultList result = searchObjects(prismContext + List result = searchObjects(prismContext .queryFor(AuditEventRecordType.class) .asc(AuditEventRecordType.F_PARAMETER) .build()); then("all audit events are returned"); assertThat(result).hasSize(4); - result.sort(Comparator.comparing(AuditEventRecordType::getParameter)); + // using stream, it's unmodifiable list + result = result.stream() + .sorted(Comparator.comparing(AuditEventRecordType::getParameter)) + .collect(Collectors.toList()); and("record 1 has all the attributes filled"); AuditEventRecordType record1 = result.get(0); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditSearchTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditSearchTest.java index 75836acfd8e..60c54374eab 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditSearchTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditSearchTest.java @@ -14,6 +14,7 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; import org.jetbrains.annotations.NotNull; import org.springframework.test.annotation.DirtiesContext; @@ -930,14 +931,17 @@ public void test273SearchByTimestampMultipleValues() throws SchemaException { @Test public void test300SearchReturnsMappedToManyAttributes() throws SchemaException { when("searching audit with query without any conditions and paging"); - SearchResultList result = searchObjects(prismContext + List result = searchObjects(prismContext .queryFor(AuditEventRecordType.class) .asc(AuditEventRecordType.F_PARAMETER) .build()); then("all audit events are returned"); assertThat(result).hasSize(3); - result.sort(Comparator.comparing(AuditEventRecordType::getParameter)); + // using stream, it's unmodifiable list + result = result.stream() + .sorted(Comparator.comparing(AuditEventRecordType::getParameter)) + .collect(Collectors.toList()); and("record 1 has all the attributes filled"); AuditEventRecordType record1 = result.get(0); From 44f6a2221eb2e09dde0989c87dbb8e1715ad4fd0 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 8 Sep 2021 23:26:03 +0200 Subject: [PATCH 17/19] new repo: itemDefinition is available in QueryModelMapping This is moved up from QueryTableMapping, which is a very tentative step towards support of EXISTS with embedded containers (e.g. metadata). This currently does not work and throws better exception now. All is documented by test350ExistsWithEmbeddedContainer(). ItemDefinition can still be useful higher and probably belongs there. --- .../filtering/ExistsFilterProcessor.java | 6 ++++ .../repo/sqale/func/SqaleRepoSearchTest.java | 18 ++++++++++++ .../repo/sqlbase/SqlQueryContext.java | 2 +- .../sqlbase/mapping/QueryModelMapping.java | 9 ++++++ .../sqlbase/mapping/QueryTableMapping.java | 29 ++----------------- 5 files changed, 36 insertions(+), 28 deletions(-) diff --git a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/filtering/ExistsFilterProcessor.java b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/filtering/ExistsFilterProcessor.java index 9e4355dca2b..b4683ec785d 100644 --- a/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/filtering/ExistsFilterProcessor.java +++ b/repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/filtering/ExistsFilterProcessor.java @@ -13,10 +13,12 @@ import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.repo.sqale.SqaleQueryContext; import com.evolveum.midpoint.repo.sqale.mapping.CountMappingResolver; +import com.evolveum.midpoint.repo.sqlbase.QueryException; import com.evolveum.midpoint.repo.sqlbase.RepositoryException; import com.evolveum.midpoint.repo.sqlbase.filtering.FilterProcessor; import com.evolveum.midpoint.repo.sqlbase.mapping.ItemRelationResolver; import com.evolveum.midpoint.repo.sqlbase.mapping.QueryModelMapping; +import com.evolveum.midpoint.repo.sqlbase.mapping.QueryTableMapping; import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; /** @@ -68,6 +70,10 @@ private , TR> Predicate process( ItemRelationResolver.ResolutionResult resolution = resolver.resolve(context); //noinspection unchecked SqaleQueryContext subcontext = (SqaleQueryContext) resolution.context; + if (!(resolution.mapping instanceof QueryTableMapping)) { + throw new QueryException("Repository supports exists only for multi-value containers (for now)"); + } + ExistsFilterProcessor nestedProcessor = new ExistsFilterProcessor<>(subcontext, resolution.mapping); Predicate predicate = nestedProcessor.process(path.rest(), filter); diff --git a/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java b/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java index 8ea80842a67..3922fea658d 100644 --- a/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java +++ b/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java @@ -923,6 +923,24 @@ public void test325ExistsFilterWithSizeColumn() throws SchemaException { EQUAL: output/outcome, ))) , null paging} */ + + @Test + public void test350ExistsWithEmbeddedContainer() { + // TODO this does not work currently, because implementation creates query sub-contexts + // only for table mapping, not embedded ones. It needs multiple changes and perhaps + // multi-type hierarchy like update context uses. Possible approach: + // a) like in update, having simpler common context type that can support non-table mappings; + // b) support non-table mappings with current types, but that is less clean and probably more problematic. + assertThatThrownBy(() -> + searchUsersTest("matching the exists filter for metadata (embedded mapping)", + f -> f.exists(UserType.F_METADATA) + .item(MetadataType.F_CREATOR_REF).isNull(), + user1Oid)) + // At least we say it clearly with the exception instead of confusing "mapper not found" deeper. + .isInstanceOf(SystemException.class) + .hasMessage("Repository supports exists only for multi-value containers (for now)"); + } + // endregion // region refs and dereferencing diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/SqlQueryContext.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/SqlQueryContext.java index 9bfb93f8d5e..6504ea6c0cd 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/SqlQueryContext.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/SqlQueryContext.java @@ -236,7 +236,7 @@ private , CR> Expression orderingPa throw new QueryException("Item path '" + orderByItemPath + "' cannot be used for ordering because subquery is used to resolve it."); } - // CQ/CR for the next loop may be actually different then before, but that's OK + // CQ/CR for the next loop may be actually different than before, but that's OK mapping = (QueryModelMapping) resolution.mapping; context = (SqlQueryContext) resolution.context; containerDefinition = containerDefinition.findLocalItemDefinition( diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/QueryModelMapping.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/QueryModelMapping.java index 030c9d6d652..8961fbadd4e 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/QueryModelMapping.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/QueryModelMapping.java @@ -16,7 +16,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismConstants; +import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectFilter; @@ -49,6 +51,7 @@ public class QueryModelMapping, R> { private final Class schemaType; private final Class queryType; + private final ItemDefinition itemDefinition; private final Map> itemMappings = new LinkedHashMap<>(); private final Map> itemRelationResolvers = new HashMap<>(); @@ -58,6 +61,8 @@ public QueryModelMapping( @NotNull Class queryType) { this.schemaType = schemaType; this.queryType = queryType; + this.itemDefinition = PrismContext.get().getSchemaRegistry() + .findItemDefinitionByCompileTimeClass(schemaType, ItemDefinition.class); } /** Returns schema type as class - refers to midPoint schema, not DB schema. */ @@ -179,4 +184,8 @@ ItemRelationResolver getRelationResolver(QName itemName) { public final @NotNull Map> getItemMappings() { return new LinkedHashMap<>(itemMappings); } + + public Object itemDefinition() { + return itemDefinition; + } } diff --git a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/QueryTableMapping.java b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/QueryTableMapping.java index c7c4d14eabb..66fb1b2ea84 100644 --- a/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/QueryTableMapping.java +++ b/repo/repo-sqlbase/src/main/java/com/evolveum/midpoint/repo/sqlbase/mapping/QueryTableMapping.java @@ -22,11 +22,9 @@ import com.querydsl.sql.ColumnMetadata; import org.jetbrains.annotations.NotNull; -import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.repo.sqlbase.JdbcSession; -import com.evolveum.midpoint.repo.sqlbase.QueryException; import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; import com.evolveum.midpoint.repo.sqlbase.SqlRepoContext; import com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor; @@ -36,7 +34,6 @@ import com.evolveum.midpoint.repo.sqlbase.querydsl.UuidPath; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.SelectorOptions; -import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.SchemaException; /** @@ -68,7 +65,6 @@ public abstract class QueryTableMapping itemDefinition; /** * Extension columns, key = propertyName which may differ from ColumnMetadata.getName(). @@ -99,8 +95,6 @@ protected QueryTableMapping( this.tableName = tableName; this.defaultAliasName = defaultAliasName; this.repositoryContext = repositoryContext; - this.itemDefinition = repositoryContext.prismContext().getSchemaRegistry() - .findItemDefinitionByCompileTimeClass(schemaType, ItemDefinition.class); } /** @@ -254,21 +248,6 @@ public synchronized Q defaultAlias() { return detailFetchMappers.values(); } - /** - * Returns {@link SqlDetailFetchMapper} registered for the specified {@link ItemName}. - * TODO remove in 2022 if not used - */ - public final SqlDetailFetchMapper detailFetchMapper(ItemName itemName) - throws QueryException { - SqlDetailFetchMapper mapper = - QNameUtil.getByQName(detailFetchMappers, itemName); - if (mapper == null) { - throw new QueryException("Missing detail fetch mapping for " + itemName - + " in mapping " + getClass().getSimpleName()); - } - return mapper; - } - /** * Registers extension columns. At this moment all are treated as strings. */ @@ -284,8 +263,8 @@ public Map getExtensionColumns() { } /** - * By default uses {@link #selectExpressionsWithCustomColumns} and does not use options. - * Can be overridden to fulfil other needs, e.g. to select just full object.. + * By default, uses {@link #selectExpressionsWithCustomColumns} and does not use options. + * Can be overridden to fulfil other needs, e.g. to select just full object. */ public @NotNull Path[] selectExpressions( Q entity, @@ -351,10 +330,6 @@ public void processResult(List data, Q entityPath, JdbcSession jdbcSessio // nothing by default } - public Object itemDefinition() { - return itemDefinition; - } - @Override public String toString() { return "QueryTableMapping{" + From 044a422c21a0cd5437a652bc15c9be6f1a28b3ac Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Thu, 9 Sep 2021 00:26:32 +0200 Subject: [PATCH 18/19] audit-log-impl/pom.xml: forgotten new dependency to our utils --- repo/audit-log-impl/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/repo/audit-log-impl/pom.xml b/repo/audit-log-impl/pom.xml index fce8e5d9f29..211efd1eeca 100644 --- a/repo/audit-log-impl/pom.xml +++ b/repo/audit-log-impl/pom.xml @@ -53,6 +53,12 @@ audit-api ${project.version} + + com.evolveum.commons + util + ${project.version} + + org.apache.commons From 51a5281c3ebcdc89099babdf490d979586852701 Mon Sep 17 00:00:00 2001 From: lskublik Date: Thu, 9 Sep 2021 07:27:19 +0200 Subject: [PATCH 19/19] fix for inducements tabs (not need define assignmentObjectRelations) --- .../AbstractAssignmentTypePanel.java | 55 +------------------ .../assignment/AbstractAssignmentPanel.java | 55 +++++++++++++++++++ .../inducement/AbstractInducementPanel.java | 12 ++++ 3 files changed, 68 insertions(+), 54 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/AbstractAssignmentTypePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/AbstractAssignmentTypePanel.java index 7b5f12a5e02..e6e6765f960 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/AbstractAssignmentTypePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/AbstractAssignmentTypePanel.java @@ -442,63 +442,10 @@ protected ObjectFilter getSubtypeFilter() { return null; } - @NotNull - protected IModel createAssignmentPopupModel() { - return new LoadableModel<>(false) { - - @Override - protected AssignmentPopupDto load() { - List assignmentObjectRelations = getAssignmentObjectRelationList(); - return new AssignmentPopupDto(assignmentObjectRelations); - } - }; - } - - private List getAssignmentObjectRelationList() { - if (AbstractAssignmentTypePanel.this.getContainerModel().getObject() == null) { - return null; - } - - List assignmentRelationsList = - WebComponentUtil.divideAssignmentRelationsByAllValues(loadAssignmentTargetRelationsList()); - if (assignmentRelationsList == null || assignmentRelationsList.isEmpty()) { - return assignmentRelationsList; - } - QName assignmentType = getAssignmentType(); - if (assignmentType == null) { - return assignmentRelationsList; - } - List assignmentRelationsListFilteredByType = - new ArrayList<>(); - assignmentRelationsList.forEach(assignmentRelation -> { - QName objectType = assignmentRelation.getObjectTypes() != null - && !assignmentRelation.getObjectTypes().isEmpty() - ? assignmentRelation.getObjectTypes().get(0) : null; - if (QNameUtil.match(assignmentType, objectType)) { - assignmentRelationsListFilteredByType.add(assignmentRelation); - } - }); - return assignmentRelationsListFilteredByType; - } + protected abstract IModel createAssignmentPopupModel(); protected abstract QName getAssignmentType(); - @NotNull - private List loadAssignmentTargetRelationsList() { - OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNMENT_TARGET_RELATIONS); - List assignmentTargetRelations = new ArrayList<>(); - PrismObject obj = getFocusObject(); - try { - AssignmentCandidatesSpecification spec = getPageBase().getModelInteractionService() - .determineAssignmentTargetSpecification(obj, result); - assignmentTargetRelations = spec != null ? spec.getAssignmentObjectRelations() : new ArrayList<>(); - } catch (SchemaException | ConfigurationException ex) { - result.recordPartialError(ex.getLocalizedMessage()); - LOGGER.error("Couldn't load assignment target specification for the object {} , {}", obj.getName(), ex.getLocalizedMessage()); - } - return assignmentTargetRelations; - } - protected void addSelectedAssignmentsPerformed(AjaxRequestTarget target, List newAssignmentsList) { if (CollectionUtils.isEmpty(newAssignmentsList)) { warn(getPageBase().getString("AssignmentTablePanel.message.noAssignmentSelected")); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/AbstractAssignmentPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/AbstractAssignmentPanel.java index 53c86c6330f..0f925f432c8 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/AbstractAssignmentPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/assignment/AbstractAssignmentPanel.java @@ -114,4 +114,59 @@ protected ObjectQuery getCustomizeQuery() { } return query; } + + @NotNull + protected IModel createAssignmentPopupModel() { + return new LoadableModel<>(false) { + + @Override + protected AssignmentPopupDto load() { + List assignmentObjectRelations = getAssignmentObjectRelationList(); + return new AssignmentPopupDto(assignmentObjectRelations); + } + }; + } + + private List getAssignmentObjectRelationList() { + if (AbstractAssignmentPanel.this.getContainerModel().getObject() == null) { + return null; + } + + List assignmentRelationsList = + WebComponentUtil.divideAssignmentRelationsByAllValues(loadAssignmentTargetRelationsList()); + if (assignmentRelationsList == null || assignmentRelationsList.isEmpty()) { + return assignmentRelationsList; + } + QName assignmentType = getAssignmentType(); + if (assignmentType == null) { + return assignmentRelationsList; + } + List assignmentRelationsListFilteredByType = + new ArrayList<>(); + assignmentRelationsList.forEach(assignmentRelation -> { + QName objectType = assignmentRelation.getObjectTypes() != null + && !assignmentRelation.getObjectTypes().isEmpty() + ? assignmentRelation.getObjectTypes().get(0) : null; + if (QNameUtil.match(assignmentType, objectType)) { + assignmentRelationsListFilteredByType.add(assignmentRelation); + } + }); + return assignmentRelationsListFilteredByType; + } + + @NotNull + private List loadAssignmentTargetRelationsList() { + OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNMENT_TARGET_RELATIONS); + List assignmentTargetRelations = new ArrayList<>(); + PrismObject obj = getFocusObject(); + try { + AssignmentCandidatesSpecification spec = getPageBase().getModelInteractionService() + .determineAssignmentTargetSpecification(obj, result); + assignmentTargetRelations = spec != null ? spec.getAssignmentObjectRelations() : new ArrayList<>(); + } catch (SchemaException | ConfigurationException ex) { + result.recordPartialError(ex.getLocalizedMessage()); + LOGGER.error("Couldn't load assignment target specification for the object {} , {}", obj.getName(), ex.getLocalizedMessage()); + } + return assignmentTargetRelations; + } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AbstractInducementPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AbstractInducementPanel.java index 7cf61f29bc9..d5b5bf9b3c7 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AbstractInducementPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/assignmentholder/component/assignmentType/inducement/AbstractInducementPanel.java @@ -25,6 +25,7 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; import org.apache.wicket.model.IModel; +import org.jetbrains.annotations.NotNull; import javax.xml.namespace.QName; import java.util.ArrayList; @@ -41,6 +42,17 @@ protected List, String>> init return new ArrayList<>(); } + @NotNull + protected IModel createAssignmentPopupModel() { + return new LoadableModel<>(false) { + + @Override + protected AssignmentPopupDto load() { + return new AssignmentPopupDto(null); + } + }; + } + @Override protected QName getAssignmentType() { return null;