Skip to content

Commit 99f79b7

Browse files
author
Michal Zelencik
committed
Smart Integration: Force schema match recomputation on explicit regenerate action
Add `forceRecomputeSchemaMatch` flag to the smart suggestion flow so that clicking the regenerate (refresh) button in the GUI bypasses the existing schema match cache and recomputes from scratch. - Add `forceRecomputeSchemaMatch` element to ObjectTypeRelatedSuggestionWorkDefinitionType (XSD) - Read the flag in ObjectTypeRelatedSuggestionWorkDefinition - Skip the early-exit schema match lookup in CorrelationSuggestionSchemaMatchingActivityRun and MappingsSuggestionSchemaMatchingActivityRun when the flag is true Signed-off-by: Michal Zelencik <michal.zelencik@evolveum.com>
1 parent fb19e43 commit 99f79b7

File tree

14 files changed

+98
-23
lines changed

14 files changed

+98
-23
lines changed

gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/resource/component/AssociationTypesPanel.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ protected void performSuggestOperation(AjaxRequestTarget target,
392392
onSuggestValue(createContainerModel(), target);
393393
}
394394

395+
@Override
396+
protected void performRegenerateSuggestOperation(AjaxRequestTarget target,
397+
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions) {
398+
onSuggestValue(createContainerModel(), target);
399+
}
400+
395401
@Override
396402
protected void onSuggestionFinish(AjaxRequestTarget target) {
397403
getTableComponent().refreshAndDetach(target);

gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/resource/component/SchemaHandlingObjectsPanel.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ protected void performSuggestOperation(AjaxRequestTarget target,
135135
// We override the generate button, so this method should not be called at all.
136136
}
137137

138+
@Override
139+
protected void performRegenerateSuggestOperation(AjaxRequestTarget target,
140+
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions) {
141+
// We override the generate button, so this method should not be called at all.
142+
}
143+
138144
@Override
139145
protected @NotNull AjaxIconButton createGenerateButton(String buttonId) {
140146
// We override this button, because we want to redirect to suggestion page without any confirmation

gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/resource/component/wizard/schemaHandling/objectType/attribute/mapping/AttributeMappingsTableWizardPanel.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ protected void addAdditionalNoValueToolbarButtons(@NotNull List<Component> toolb
287287
() -> new ButtonWithConfirmationOptionsDialog.ButtonHandlers<>(target -> {
288288
},
289289
(target, confirmedOptions) -> {
290-
performSuggestOperation(target, confirmedOptions);
290+
AttributeMappingsTableWizardPanel.this.performSuggestOperation(target, confirmedOptions, false);
291291
refreshAfterSuggestionOperationSubmitted(target);
292292
}),
293293
getPageBase());
@@ -421,7 +421,14 @@ protected StatusInfo<MappingsSuggestionType> load() {
421421
@Override
422422
protected void performSuggestOperation(AjaxRequestTarget target,
423423
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions) {
424-
AttributeMappingsTableWizardPanel.this.performSuggestOperation(target, confirmedOptions);
424+
AttributeMappingsTableWizardPanel.this.performSuggestOperation(target, confirmedOptions, false);
425+
refreshAfterSuggestionOperationSubmitted(target);
426+
}
427+
428+
@Override
429+
protected void performRegenerateSuggestOperation(AjaxRequestTarget target,
430+
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions) {
431+
AttributeMappingsTableWizardPanel.this.performSuggestOperation(target, confirmedOptions, true);
425432
refreshAfterSuggestionOperationSubmitted(target);
426433
}
427434

@@ -451,7 +458,8 @@ protected void onRefresh(@NotNull AjaxRequestTarget target) {
451458
}
452459

453460
private void performSuggestOperation(AjaxRequestTarget target,
454-
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions) {
461+
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions,
462+
boolean forceRecomputeSchemaMatch) {
455463
final List<DataAccessPermissionType> permissions = confirmedOptions.getObject().stream()
456464
.map(ConfirmationOption::option)
457465
.map(DataAccessPermission::toSchemaType)
@@ -476,6 +484,7 @@ private void performSuggestOperation(AjaxRequestTarget target,
476484
inbound,
477485
getTargetPathsToIgnore(),
478486
permissions,
487+
forceRecomputeSchemaMatch,
479488
task,
480489
result);
481490
});

gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/resource/component/wizard/schemaHandling/objectType/correlation/CorrelationItemsTableWizardPanel.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,18 @@ protected void newItemPerformed(
313313
@Override
314314
protected void performSuggestOperation(AjaxRequestTarget target,
315315
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions) {
316+
submitSuggestCorrelation(target, confirmedOptions, false);
317+
}
318+
319+
@Override
320+
protected void performRegenerateSuggestOperation(AjaxRequestTarget target,
321+
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions) {
322+
submitSuggestCorrelation(target, confirmedOptions, true);
323+
}
324+
325+
private void submitSuggestCorrelation(AjaxRequestTarget target,
326+
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions,
327+
boolean forceRecomputeSchemaMatch) {
316328
final List<DataAccessPermissionType> permissions = confirmedOptions.getObject().stream()
317329
.map(ConfirmationOption::option)
318330
.map(DataAccessPermission::toSchemaType)
@@ -325,7 +337,7 @@ protected void performSuggestOperation(AjaxRequestTarget target,
325337
.withHideInProgress(true))
326338
.runVoid((task, result) -> service
327339
.submitSuggestCorrelationOperation(resourceOid, objectTypeIdentification, permissions,
328-
task, result));
340+
forceRecomputeSchemaMatch, task, result));
329341
}
330342

331343
@Override

gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/resource/component/wizard/schemaHandling/objectType/correlation/SmartCorrelationTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ protected void onSuggestNewPerformed(AjaxRequestTarget target,
564564
.withHideInProgress(true))
565565
.runVoid((task, result) -> {
566566
service.submitSuggestCorrelationOperation(getResourceOid(), objectTypeIdentification, permissions,
567-
task, result);
567+
false, task, result);
568568
refreshAndDetach(target);
569569
});
570570
}

gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/resource/component/wizard/schemaHandling/objectType/smart/component/SmartAlertGeneratingPanel.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,17 @@ protected void performShowSuggestOperation(@NotNull AjaxRequestTarget target) {
307307
protected void performRegenerateOperation(AjaxRequestTarget target,
308308
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions) {
309309
getModelObject().removeExistingSuggestionTask(getPageBase());
310-
performSuggestOperation(target, confirmedOptions);
310+
performRegenerateSuggestOperation(target, confirmedOptions);
311311
}
312312

313313
/** Must be implemented to trigger suggestion generation. */
314314
protected abstract void performSuggestOperation(AjaxRequestTarget target,
315315
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions);
316316

317+
/** Must be implemented to trigger suggestion regeneration (re-run after removing existing task). */
318+
protected abstract void performRegenerateSuggestOperation(AjaxRequestTarget target,
319+
IModel<List<ConfirmationOption<DataAccessPermission>>> confirmedOptions);
320+
317321
/** Must be implemented to refresh UI components related to suggestions. */
318322
protected abstract void onRefresh(AjaxRequestTarget target);
319323

infra/schema/src/main/resources/xml/ns/public/common/common-tasks-3.xsd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10649,6 +10649,18 @@
1064910649
</xsd:appinfo>
1065010650
</xsd:annotation>
1065110651
</xsd:element>
10652+
<xsd:element name="forceRecomputeSchemaMatch" type="xsd:boolean" minOccurs="0">
10653+
<xsd:annotation>
10654+
<xsd:documentation>
10655+
If true, forces recomputation of the schema match even if a valid (non-expired) schema
10656+
match object already exists. Typically set when the user explicitly triggers a regenerate
10657+
action from the GUI.
10658+
</xsd:documentation>
10659+
<xsd:appinfo>
10660+
<a:displayName>ObjectTypeRelatedSuggestionWorkDefinitionType.forceRecomputeSchemaMatch</a:displayName>
10661+
</xsd:appinfo>
10662+
</xsd:annotation>
10663+
</xsd:element>
1065210664
</xsd:sequence>
1065310665
</xsd:extension>
1065410666
</xsd:complexContent>

model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/smart/TestSmartIntegrationService.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public void test200SuggestCorrelation() throws CommonException {
332332
var token = smartIntegrationService.submitSuggestCorrelationOperation(
333333
RESOURCE_DUMMY_FOR_SUGGEST_CORRELATION_AND_MAPPINGS.oid, ACCOUNT_DEFAULT,
334334
List.of(DataAccessPermissionType.SCHEMA_ACCESS),
335-
task, result);
335+
false, task, result);
336336

337337
then("returned token is not null");
338338
assertThat(token).isNotNull();
@@ -376,7 +376,8 @@ public void test300SuggestMappings() throws CommonException {
376376
when("submitting 'suggest mappings' operation request");
377377
var token = smartIntegrationService.submitSuggestMappingsOperation(
378378
RESOURCE_DUMMY_FOR_SUGGEST_CORRELATION_AND_MAPPINGS.oid, ACCOUNT_DEFAULT, true, null, List.of(
379-
DataAccessPermissionType.SCHEMA_ACCESS, DataAccessPermissionType.RAW_DATA_ACCESS), task, result);
379+
DataAccessPermissionType.SCHEMA_ACCESS, DataAccessPermissionType.RAW_DATA_ACCESS),
380+
false, task, result);
380381

381382
then("returned token is not null");
382383
assertThat(token).isNotNull();
@@ -420,7 +421,8 @@ public void test310SuggestMappingsWithFailure() throws CommonException {
420421
when("submitting 'suggest mappings' operation request");
421422
var token = smartIntegrationService.submitSuggestMappingsOperation(
422423
RESOURCE_DUMMY_FOR_SUGGEST_CORRELATION_AND_MAPPINGS.oid, ACCOUNT_DEFAULT, true, null, List.of(
423-
DataAccessPermissionType.SCHEMA_ACCESS, DataAccessPermissionType.RAW_DATA_ACCESS), task, result);
424+
DataAccessPermissionType.SCHEMA_ACCESS, DataAccessPermissionType.RAW_DATA_ACCESS),
425+
false, task, result);
424426

425427
then("returned token is not null");
426428
assertThat(token).isNotNull();
@@ -483,7 +485,7 @@ public void test400SuggestMappingsCategorical() throws CommonException {
483485
List.of(DataAccessPermissionType.SCHEMA_ACCESS,
484486
DataAccessPermissionType.STATISTICS_ACCESS,
485487
DataAccessPermissionType.RAW_DATA_ACCESS),
486-
task, result);
488+
false, task, result);
487489

488490
then("returned token is not null");
489491
assertThat(token).isNotNull();
@@ -550,7 +552,7 @@ public void test410SuggestMappingsCategoricalWithoutRawDataAccess() throws Commo
550552
RESOURCE_DUMMY_FOR_SUGGEST_CATEGORICAL_MAPPINGS.oid, ACCOUNT_DEFAULT, true, null,
551553
List.of(DataAccessPermissionType.SCHEMA_ACCESS,
552554
DataAccessPermissionType.STATISTICS_ACCESS),
553-
task, result);
555+
false, task, result);
554556

555557
then("returned token is not null");
556558
assertThat(token).isNotNull();

model/rest-impl/src/main/java/com/evolveum/midpoint/rest/impl/SmartIntegrationRestController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public ResponseEntity<?> suggestCorrelations(
9696
ShadowKindType.fromValue(kind),
9797
intent
9898
);
99-
var oid = smartIntegrationService.submitSuggestCorrelationOperation(resourceOid, resourceObjectTypeIdentification, List.of(), task, result);
99+
var oid = smartIntegrationService.submitSuggestCorrelationOperation(resourceOid, resourceObjectTypeIdentification, List.of(), false, task, result);
100100
result.setBackgroundTaskOid(oid);
101101

102102
var suggestionOperationStatus = smartIntegrationService.getSuggestCorrelationOperationStatus(oid, task, result);
@@ -139,7 +139,7 @@ public ResponseEntity<?> suggestMappings(
139139
);
140140
var oid = smartIntegrationService.submitSuggestMappingsOperation(resourceOid,
141141
resourceObjectTypeIdentification, isInbound, null, List.of(DataAccessPermissionType.SCHEMA_ACCESS,
142-
DataAccessPermissionType.RAW_DATA_ACCESS), task, result);
142+
DataAccessPermissionType.RAW_DATA_ACCESS), false, task, result);
143143
result.setBackgroundTaskOid(oid);
144144

145145
var suggestionOperationStatus = smartIntegrationService.getSuggestMappingsOperationStatus(oid, task, result);

model/smart-api/src/main/java/com/evolveum/midpoint/smart/api/SmartIntegrationService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ String submitSuggestCorrelationOperation(
230230
String resourceOid,
231231
ResourceObjectTypeIdentification typeIdentification,
232232
List<DataAccessPermissionType> permissions,
233+
boolean forceRecomputeSchemaMatch,
233234
Task task,
234235
OperationResult result)
235236
throws CommonException;
@@ -297,6 +298,7 @@ String submitSuggestMappingsOperation(
297298
Boolean isInbound,
298299
List<ItemPathType> targetPathsToIgnore,
299300
List<DataAccessPermissionType> permissions,
301+
boolean forceRecomputeSchemaMatch,
300302
Task task,
301303
OperationResult result)
302304
throws CommonException;

0 commit comments

Comments
 (0)