-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Evolveum/midpoint
- Loading branch information
Showing
26 changed files
with
924 additions
and
271 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
infra/schema/src/main/java/com/evolveum/midpoint/schema/merger/BaseMergeOperation.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,58 @@ | ||
/* | ||
* Copyright (C) 2010-2022 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.schema.merger; | ||
|
||
import com.evolveum.midpoint.prism.Containerable; | ||
import com.evolveum.midpoint.prism.Item; | ||
import com.evolveum.midpoint.prism.PrismContainerValue; | ||
import com.evolveum.midpoint.prism.path.ItemName; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.prism.path.PathKeyedMap; | ||
import com.evolveum.midpoint.util.exception.ConfigurationException; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Implements the actual merging of two objects ({@link Containerable}) of the same type. | ||
* | ||
* @param <C> type of objects to be merged | ||
*/ | ||
public abstract class BaseMergeOperation<C extends Containerable> { | ||
|
||
@NotNull private final C target; | ||
@NotNull private final C source; | ||
@NotNull private final ItemMerger rootMerger; | ||
|
||
protected BaseMergeOperation(@NotNull C target, @NotNull C source, @NotNull ItemMerger rootMerger) { | ||
this.target = target; | ||
this.source = source; | ||
this.rootMerger = rootMerger; | ||
} | ||
|
||
public void execute() throws ConfigurationException, SchemaException { | ||
rootMerger.merge(target.asPrismContainerValue(), source.asPrismContainerValue()); | ||
} | ||
|
||
protected static boolean hasValue(PrismContainerValue<?> pcv, @NotNull ItemName itemName) { | ||
Item<?, ?> item = pcv.findItem(itemName); | ||
return item != null && item.hasAnyValue(); | ||
} | ||
|
||
protected static PathKeyedMap<ItemMerger> createPathMap(Map<ItemPath, ItemMerger> sourceMap) { | ||
PathKeyedMap<ItemMerger> newMap = new PathKeyedMap<>(); | ||
newMap.putAll(sourceMap); | ||
return newMap; | ||
} | ||
|
||
protected static PathKeyedMap<ItemMerger> emptyPathMap() { | ||
return new PathKeyedMap<>(); | ||
} | ||
} |
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
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
39 changes: 39 additions & 0 deletions
39
...om/evolveum/midpoint/schema/merger/objdef/ResourceObjectTypeDefinitionMergeOperation.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,39 @@ | ||
/* | ||
* Copyright (C) 2010-2022 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.schema.merger.objdef; | ||
|
||
import static com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType.F_ABSTRACT; | ||
|
||
import java.util.Map; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.evolveum.midpoint.schema.merger.BaseMergeOperation; | ||
import com.evolveum.midpoint.schema.merger.GenericItemMerger; | ||
import com.evolveum.midpoint.schema.merger.IgnoreSourceItemMerger; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType; | ||
|
||
/** | ||
* Merges {@link ResourceObjectTypeDefinitionType} objects. | ||
*/ | ||
public class ResourceObjectTypeDefinitionMergeOperation extends BaseMergeOperation<ResourceObjectTypeDefinitionType> { | ||
|
||
public ResourceObjectTypeDefinitionMergeOperation( | ||
@NotNull ResourceObjectTypeDefinitionType target, | ||
@NotNull ResourceObjectTypeDefinitionType source) { | ||
|
||
super(target, | ||
source, | ||
new GenericItemMerger( | ||
createPathMap( | ||
Map.of( | ||
F_ABSTRACT, IgnoreSourceItemMerger.INSTANCE // otherwise everything would be abstract | ||
// TODO attribute/associations (natural keys)! | ||
)))); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
infra/schema/src/main/java/com/evolveum/midpoint/schema/merger/package-info.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,15 @@ | ||
/* | ||
* Copyright (C) 2010-2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
/** | ||
* Supports merging of (usually) configuration beans. | ||
* | ||
* For example, resource inheritance and object type inheritance is implemented here. | ||
* | ||
* Other uses will be considered in the future. | ||
*/ | ||
package com.evolveum.midpoint.schema.merger; |
Oops, something went wrong.