-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
natural key and mergers moved to prism
- Loading branch information
Showing
23 changed files
with
1,233 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
infra/prism-api/src/main/java/com/evolveum/midpoint/prism/ItemMergerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (C) 2010-2024 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.prism; | ||
|
||
import com.evolveum.midpoint.prism.delta.ItemMerger; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface ItemMergerFactory { | ||
|
||
@Nullable | ||
ItemMerger createMerger(@NotNull ItemDefinition<?> definition, @NotNull MergeStrategy strategy, @Nullable OriginMarker originMarker); | ||
} |
50 changes: 50 additions & 0 deletions
50
infra/prism-api/src/main/java/com/evolveum/midpoint/prism/MergeStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2010-2024 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.prism; | ||
|
||
public enum MergeStrategy { | ||
|
||
/** | ||
* Merge the values from the source item to the target item. | ||
* | ||
* If the target item already contains a value: | ||
* * for containers, the values are merged recursively | ||
* * for other items (property, reference), the value is *preserved* | ||
* | ||
* If the source item contains a value that is not present in the target item, it is added. | ||
* | ||
* If the source item doesn't contain value present in target, value is *not changed* in target. | ||
* | ||
* Example scenario: | ||
* Source: resource template | ||
* Target: resource that uses the template | ||
* | ||
* The overlay strategy is used to merge the resource template to the resource to create the final resource object. | ||
*/ | ||
OVERLAY, | ||
|
||
/** | ||
* Merge the values from the source item to the target item. | ||
* | ||
* If the target item already contains a value: | ||
* * for containers, the values are merged recursively | ||
* * for other items (property, reference), the value is *replaced* | ||
* | ||
* If the source item contains a value that is not present in the target item, it is added. | ||
* | ||
* If the source item doesn't contain value present in target, value is *removed* from target. | ||
* | ||
* Example scenario: | ||
* Source: local object in studio project (file without PCV ids) | ||
* Target: object in midPoint (with PCV ids) | ||
* | ||
* To create minimal diff we need to merge source object to target object and then with result and | ||
* target object we can create proper diff (object delta) without phantom (add/remove containers). | ||
*/ | ||
FULL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
infra/prism-api/src/main/java/com/evolveum/midpoint/prism/OriginMarker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2010-2024 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.prism; | ||
|
||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
|
||
/** | ||
* Sets the origin information in prism values being merged. | ||
* | ||
* In order to track the origin of individual prism item values in the merged object, the mergers are obliged to fill-in | ||
* this information on any values being processed. Specifically, when a prism value `V` is inherited from the source | ||
* (super-)object `S`, this fact is recorded in the {@link com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType} | ||
* of `V` by setting `provenance/acquisition/originRef` to the reference to `S`. | ||
* | ||
* Notes: | ||
* | ||
* . When a composite value ({@link PrismContainerValue}) is inherited, only the root value gets the metadata. It's not necessary | ||
* (and therefore it's avoided) to set the metadata on each of the contained ("inner") values. | ||
* . When a value is passed through multiple layers of inheritance (e.g. inherited from `O1` to `O2` and finally to `O3`), | ||
* only the "real" origin (i.e. `O1`) is recorded. | ||
* . Origin for values not passing through the inheritance relation (i.e. values at the bottom of the inheritance hierarchy) | ||
* are not marked - not even if the containing resource has an OID. | ||
* | ||
* For some examples please see `TestResourceTemplateMerge`. | ||
* | ||
* Important assumption: | ||
* | ||
* - The current implementation assumes that there is no value metadata stored in the (original) objects being merged; i.e. | ||
* that all metadata come from this {@link OriginMarker}. | ||
*/ | ||
public interface OriginMarker { | ||
|
||
/** Imprints the origin into the value. */ | ||
void mark(PrismValue value) throws SchemaException; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
infra/prism-api/src/main/java/com/evolveum/midpoint/prism/delta/ItemMerger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2010-2024 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.prism.delta; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.evolveum.midpoint.prism.PrismContainerValue; | ||
import com.evolveum.midpoint.prism.key.NaturalKey; | ||
import com.evolveum.midpoint.prism.path.ItemName; | ||
import com.evolveum.midpoint.util.exception.ConfigurationException; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
|
||
public interface ItemMerger { | ||
|
||
NaturalKey getNaturalKey(); | ||
|
||
/** | ||
* Merges all data about specific item (named `itemName`) from `source` container value to `target` one, according | ||
* to (its own) strategy. | ||
* | ||
* So, `source` is not modified; the `target` is. | ||
* | ||
* The implementation is responsible for setting origin information on all prism values copied from `source` to `target`. | ||
*/ | ||
void merge(@NotNull ItemName itemName, @NotNull PrismContainerValue<?> target, @NotNull PrismContainerValue<?> source) | ||
throws ConfigurationException, SchemaException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.