Skip to content

Commit

Permalink
Fix MID-6786 preliminarily
Browse files Browse the repository at this point in the history
Here we replace very ugly hack that uses t:ItemDeltaType to pass values
from library function to its clients by a little less ugly use
of t:ItemType.

The whole "solution" is still very hacky, and should be reviewed.

Overall, the support for class-less containers and their values has
to be improved.
  • Loading branch information
mederly committed Mar 1, 2021
1 parent eb2927b commit ded6893
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Expand Up @@ -89,7 +89,7 @@ public XNodeImpl marshall(@Nullable Object inputBean, @Nullable SerializationCon
// Special hack (MID-5803) -- we should NEVER get PrismValue here; but not enough time to fix this right now
Object bean;
if (inputBean instanceof PrismValue) {
bean = ((PrismValue) inputBean).getRealValue();
bean = getRealValue((PrismValue) inputBean);
if (bean == null) {
return null;
}
Expand Down Expand Up @@ -129,6 +129,21 @@ public XNodeImpl marshall(@Nullable Object inputBean, @Nullable SerializationCon
}
}

@Nullable
private Object getRealValue(@NotNull PrismValue prismValue) {
if (prismValue instanceof PrismContainerValue<?>) {
PrismContainerValue<?> pcv = (PrismContainerValue<?>) prismValue;
if (pcv.getCompileTimeClass() != null) {
return prismValue.getRealValue();
} else {
// This is an ugly hack. Reconsider!
return new RawType(prismValue, null, prismContext);
}
} else {
return prismValue.getRealValue();
}
}

private XNodeImpl marshalToPrimitive(Object bean, SerializationContext ctx) {
return createPrimitiveXNode(bean, null, false, ctx);
}
Expand Down
Expand Up @@ -17,11 +17,12 @@
<name>name</name>
<type>xsd:string</type>
</parameter>
<returnType>t:ItemDeltaType</returnType>
<returnType>t:ItemType</returnType>
<script>
<code>
import com.evolveum.midpoint.model.intest.misc.TestTracing
import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType
import com.evolveum.prism.xml.ns._public.types_3.ItemType
import com.evolveum.prism.xml.ns._public.types_3.RawType

import static com.evolveum.midpoint.model.intest.misc.TestTracing.NAME_EMBEDDED
Expand All @@ -47,10 +48,9 @@
log.info('created PCV:\n{}', rootPcv.debugDump())
rootPcv

idt = new ItemDeltaType()
idt.value.add(new RawType(rootPcv, TYPE_MY_CONTAINER, midpoint.prismContext))
// idt.value.add(rootPcv)
idt
item = new ItemType()
item.value.add(rootPcv)
item
</code>
</script>
</function>
Expand Down
Expand Up @@ -18,9 +18,8 @@
<expression>
<script>
<code>
raw = hacking.execute("createContainerValue", [name: name]).getValue().get(0)
pcv = raw.getParsedValue(null, null) // brutal hack
log.info('value = {}', pcv)
pcv = hacking.execute("createContainerValue", [name: name]).getValue().get(0)
log.info('value = {}', pcv.debugDump())
pcv
</code>
</script>
Expand Down

0 comments on commit ded6893

Please sign in to comment.