-
Notifications
You must be signed in to change notification settings - Fork 188
/
BaseBuiltinMetadataMapping.java
56 lines (45 loc) · 1.74 KB
/
BaseBuiltinMetadataMapping.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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);
}
}
}