Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add built-in metadata mappings support
Still very preliminary and incomplete implementation. Support for storage/creationTimestamp is provided. Related to MID-6275.
- Loading branch information
Showing
16 changed files
with
951 additions
and
608 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
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
1,124 changes: 563 additions & 561 deletions
1,124
infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
56 changes: 56 additions & 0 deletions
56
...n/java/com/evolveum/midpoint/model/common/mapping/builtin/BaseBuiltinMetadataMapping.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,56 @@ | ||
/* | ||
* Copyright (c) 2020 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.model.common.mapping.builtin; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import com.evolveum.midpoint.prism.PrismContainerValue; | ||
import com.evolveum.midpoint.prism.PrismProperty; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
abstract class BaseBuiltinMetadataMapping implements BuiltinMetadataMapping { | ||
|
||
@NotNull private final ItemPath targetPath; | ||
// private ItemDefinition<?> targetDefinition; | ||
|
||
// @Autowired private PrismContext prismContext; | ||
@Autowired private BuiltinMetadataMappingsRegistry registry; | ||
|
||
BaseBuiltinMetadataMapping(@NotNull ItemPath targetItem) { | ||
this.targetPath = targetItem; | ||
} | ||
|
||
@PostConstruct | ||
void register() { | ||
registry.registerBuiltinMapping(this); | ||
// targetDefinition = Objects.requireNonNull( | ||
// prismContext.getSchemaRegistry().getValueMetadataDefinition().findItemDefinition(targetPath), | ||
// () -> "No definition for metadata item " + targetPath); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public ItemPath getTargetPath() { | ||
return targetPath; | ||
} | ||
|
||
void addPropertyRealValue(PrismContainerValue<?> outputMetadata, Object value) throws SchemaException { | ||
if (value != null) { | ||
PrismProperty property = outputMetadata.findOrCreateProperty(targetPath); | ||
//noinspection unchecked | ||
property.addRealValue(value); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../main/java/com/evolveum/midpoint/model/common/mapping/builtin/BuiltinMetadataMapping.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) 2020 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.model.common.mapping.builtin; | ||
|
||
import com.evolveum.midpoint.model.common.mapping.MappingImpl; | ||
import com.evolveum.midpoint.prism.PrismContainerValue; | ||
import com.evolveum.midpoint.prism.PrismValue; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
public interface BuiltinMetadataMapping { | ||
|
||
void apply(List<PrismValue> valuesTuple, PrismContainerValue<ValueMetadataType> outputMetadata, | ||
MappingImpl<?, ?> dataMapping, OperationResult result) throws SchemaException; | ||
|
||
@NotNull | ||
ItemPath getTargetPath(); | ||
} |
30 changes: 30 additions & 0 deletions
30
...a/com/evolveum/midpoint/model/common/mapping/builtin/BuiltinMetadataMappingsRegistry.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,30 @@ | ||
/* | ||
* Copyright (c) 2020 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.model.common.mapping.builtin; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Registry for built-in metadata mappings. | ||
*/ | ||
@Component | ||
public class BuiltinMetadataMappingsRegistry { | ||
|
||
private final List<BuiltinMetadataMapping> mappings = new ArrayList<>(); | ||
|
||
public List<BuiltinMetadataMapping> getMappings() { | ||
return mappings; | ||
} | ||
|
||
void registerBuiltinMapping(BaseBuiltinMetadataMapping mapping) { | ||
mappings.add(mapping); | ||
} | ||
} |
Oops, something went wrong.