Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ItemDefinitionTransformer in SchemaTransformator
Implemented minimal subset of "MutableDefinition" contracts to satisfy GUI and other tests.
- Loading branch information
1 parent
4384822
commit 5423dbd
Showing
10 changed files
with
1,134 additions
and
135 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
48 changes: 48 additions & 0 deletions
48
...in/java/com/evolveum/midpoint/model/impl/schema/transform/DefinitionsToTransformable.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,48 @@ | ||
package com.evolveum.midpoint.model.impl.schema.transform; | ||
|
||
import com.evolveum.midpoint.prism.ComplexTypeDefinition; | ||
import com.evolveum.midpoint.prism.ItemDefinition; | ||
import com.evolveum.midpoint.prism.ItemDefinitionTransformer; | ||
import com.evolveum.midpoint.prism.TypeDefinition; | ||
import com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition; | ||
import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; | ||
|
||
public class DefinitionsToTransformable implements ItemDefinitionTransformer { | ||
|
||
@Override | ||
public <T extends TypeDefinition> T applyValue(ComplexTypeDefinition parentDef, ItemDefinition<?> itemDef, | ||
T valueDef) { | ||
if (valueDef instanceof ComplexTypeDefinition) { | ||
if (itemDef instanceof TransformableContainerDefinition) { | ||
TransformableComplexTypeDefinition maybe = ((TransformableContainerDefinition) itemDef).getComplexTypeDefinition(); | ||
if (valueDef.getTypeName().equals(maybe.getTypeName())) { | ||
return (T) maybe; | ||
} | ||
} | ||
return (T) TransformableComplexTypeDefinition.from((ComplexTypeDefinition) valueDef); | ||
} | ||
return valueDef; | ||
} | ||
|
||
|
||
@Override | ||
public <I extends ItemDefinition<?>> I transformItem(ComplexTypeDefinition parentDef, I currentDef) { | ||
if (currentDef == null || currentDef instanceof TransformableItemDefinition) { | ||
return currentDef; | ||
} | ||
// Parent is transformable | ||
if (parentDef instanceof TransformableComplexTypeDefinition) { | ||
if (currentDef instanceof ResourceAttributeDefinition) { | ||
return (I) TransformablePropertyDefinition.of((ResourceAttributeDefinition) currentDef); | ||
} | ||
if (currentDef instanceof ResourceAttributeContainerDefinition) { | ||
return (I) TransformableContainerDefinition.of((ResourceAttributeContainerDefinition) currentDef); | ||
} | ||
ItemDefinition<?> defFromParent = parentDef.findLocalItemDefinition(currentDef.getItemName()); | ||
if (defFromParent != null) { | ||
return (I) defFromParent; | ||
} | ||
} | ||
return TransformableItemDefinition.publicFrom(currentDef); | ||
} | ||
} |
Oops, something went wrong.