use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType in project midpoint by Evolveum.
the class WebPrismUtil method getNewYieldValue.
// TODO find better place
public static PrismContainerValue<ValueMetadataType> getNewYieldValue() {
MidPointApplication app = MidPointApplication.get();
ProvenanceMetadataType provenanceMetadataType = new ProvenanceMetadataType(app.getPrismContext()).acquisition(WebPrismUtil.createAcquition());
ValueMetadataType valueMetadataType = new ValueMetadataType(app.getPrismContext()).provenance(provenanceMetadataType);
return valueMetadataType.asPrismContainerValue();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType in project midpoint by Evolveum.
the class TestMappingMetadata method testAsIsDeleteSparrowUserWithRange.
/**
* Jack has acquisition origins: user, rest
*
* (see user-jack-metadata.xml)
*
* Delta: replace givenName Jackie (user)
* Existing: Jack Sparrow (m:hr, user)
*
* Expected result:
* - Jackie (user) in plus set
* - Jack (no MD) in minus set
* - Jack Sparrow (m:hr) in minus set (because of range)
*/
@Test
public void testAsIsDeleteSparrowUserWithRange() throws Exception {
PrismPropertyValue<PolyString> jackieUser = evaluator.getPrismContext().itemFactory().createPropertyValue(new PolyString("Jackie"));
// noinspection unchecked
((PrismContainer<ValueMetadataType>) (PrismContainer) jackieUser.getValueMetadata()).createNewValue().asContainerable().beginProvenance().beginAcquisition().originRef("user", ServiceType.COMPLEX_TYPE);
PrismPropertyValue<PolyString> jackSparrowHr = evaluator.getPrismContext().itemFactory().createPropertyValue(PrismTestUtil.createPolyString("Jack Sparrow"));
// noinspection unchecked
((PrismContainer<ValueMetadataType>) (PrismContainer) jackSparrowHr.getValueMetadata()).createNewValue().asContainerable().beginProvenance().mappingSpec(createMappingSpec()).beginAcquisition().originRef("hr", ServiceType.COMPLEX_TYPE).<ProvenanceMetadataType>end().beginAcquisition().originRef("user", ServiceType.COMPLEX_TYPE).end();
ObjectDelta<UserType> delta = evaluator.getPrismContext().deltaFor(UserType.class).item(UserType.F_GIVEN_NAME).replace(jackieUser).asObjectDelta(null);
MappingImpl<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluate(MAPPING_ASIS_FULLNAME_METADATA_RANGE_XML, delta, existingValuesCustomizer(jackSparrowHr));
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
displayDumpable("triple", outputTriple);
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Jackie"));
PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Jack"), PrismTestUtil.createPolyString("Jack Sparrow"));
assertOrigins(MiscUtil.extractSingleton(outputTriple.getPlusSet()), "user");
// noinspection ConstantConditions
assertNoMetadata(outputTriple.getMinusSet().stream().filter(v -> v.getRealValue().getOrig().equals("Jack")).findAny().orElse(null));
// noinspection ConstantConditions
assertOrigins(outputTriple.getMinusSet().stream().filter(v -> v.getRealValue().getOrig().equals("Jack Sparrow")).findAny().orElse(null), "hr", "user");
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType in project midpoint by Evolveum.
the class TestMappingMetadata method testAddJackRestWithTimestamp.
/**
* Jack has acquisition origins: user, rest
* Sparrow has acquisition origins: user
*
* (see user-jack-metadata.xml)
*
* Delta: add givenName Jack (rest+timestamp).
*
* Expected result: user, rest+timestamp (in zero set, because no real value is being added).
*/
@Test
public void testAddJackRestWithTimestamp() throws Exception {
XMLGregorianCalendar now = XmlTypeConverter.createXMLGregorianCalendar();
PrismPropertyValue<PolyString> jackRestWithTs = evaluator.getPrismContext().itemFactory().createPropertyValue(new PolyString("Jack"));
// noinspection unchecked
((PrismContainer<ValueMetadataType>) (PrismContainer) jackRestWithTs.getValueMetadata()).createNewValue().asContainerable().beginProvenance().beginAcquisition().originRef("rest", ServiceType.COMPLEX_TYPE).timestamp(now);
ObjectDelta<UserType> delta = evaluator.getPrismContext().deltaFor(UserType.class).item(UserType.F_GIVEN_NAME).add(jackRestWithTs).asObjectDelta(null);
MappingImpl<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluate(MAPPING_SCRIPT_FULLNAME_METADATA_XML, delta);
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
displayDumpable("triple", outputTriple);
PrismAsserts.assertTripleZero(outputTriple, PrismTestUtil.createPolyString("Jack Sparrow"));
PrismAsserts.assertTripleNoPlus(outputTriple);
PrismAsserts.assertTripleNoMinus(outputTriple);
PrismPropertyValue<PolyString> jackSparrow = MiscUtil.extractSingleton(outputTriple.getZeroSet());
assertOrigins(jackSparrow, "user", "rest");
List<ProvenanceAcquisitionType> acquisitions = ((ValueMetadataType) jackSparrow.getValueMetadata().getValue().asContainerable()).getProvenance().getAcquisition();
XMLGregorianCalendar timestamp = acquisitions.stream().filter(acq -> acq.getOriginRef().getOid().equals("rest")).findAny().orElseThrow(() -> new AssertionError("no origin rest value")).getTimestamp();
assertThat(timestamp).isEqualTo(now);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType in project midpoint by Evolveum.
the class ValueMetadataWrapperFactoryImpl method createValueWrapper.
@Override
public PrismContainerValueWrapper<ValueMetadataType> createValueWrapper(PrismContainerWrapper<ValueMetadataType> parent, PrismContainerValue<ValueMetadataType> value, ValueStatus status, WrapperContext context) throws SchemaException {
WrapperContext ctx = context.clone();
ctx.setMetadata(true);
ctx.setCreateOperational(true);
PrismContainerValueWrapper<ValueMetadataType> v = super.createValueWrapper(parent, value, status, ctx);
return v;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType in project midpoint by Evolveum.
the class ProvenanceMetadataPanel method createMetadataDetailsPanel.
private void createMetadataDetailsPanel(ListItem<PrismContainerValueWrapper<ProvenanceMetadataType>> provenanceListItem, ListItem<PrismContainerValueWrapper<ValueMetadataType>> valueMetadataListItem) {
WebMarkupContainer panel = createAcquisitionPanel(PrismContainerWrapperModel.fromContainerValueWrapper(provenanceListItem.getModel(), ProvenanceMetadataType.F_ACQUISITION));
provenanceListItem.add(panel);
ToggleIconButton<Void> showMore = createShowMoreButton(provenanceListItem.getModel());
provenanceListItem.add(showMore);
IModel<PrismContainerWrapper<Containerable>> detailsModel = createDetailsModel(valueMetadataListItem.getModel());
Label label = new Label(ID_YIELD_HEADER, createDetailsDescriptionModel(detailsModel));
provenanceListItem.add(label);
label.add(new VisibleBehaviour(() -> provenanceListItem.getModelObject().isShowEmpty()));
MetadataContainerPanel<Containerable> defaultPanel = createDefaultPanel(detailsModel, provenanceListItem.getModel());
defaultPanel.add(new VisibleBehaviour(() -> !getModelObject().isShowMetadataDetails() && provenanceListItem.getModelObject().isShowEmpty()));
provenanceListItem.add(defaultPanel);
ItemPanelSettings settings = getSettings().copy();
settings.setVisibilityHandler(w -> createItemVisibilityBehavior(w));
ValueMetadataPanel<ValueMetadataType, PrismContainerValueWrapper<ValueMetadataType>> valueMetadataPanel = new ValueMetadataPanel<>(ID_VALUE_METADATA_DETAILS, valueMetadataListItem.getModel(), settings);
valueMetadataPanel.add(new VisibleBehaviour(() -> getModelObject().isShowMetadataDetails() && provenanceListItem.getModelObject().isShowEmpty()));
provenanceListItem.add(valueMetadataPanel);
}
Aggregations