Search in sources :

Example 1 with ProvenanceMetadataType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceMetadataType 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();
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) ProvenanceMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceMetadataType) ValueMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType)

Example 2 with ProvenanceMetadataType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceMetadataType 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");
}
Also used : java.util(java.util) DeltaFactory(com.evolveum.midpoint.prism.delta.DeltaFactory) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) ModelExpressionThreadLocalHolder(com.evolveum.midpoint.model.common.expression.ModelExpressionThreadLocalHolder) ExpressionEnvironment(com.evolveum.midpoint.model.common.expression.ExpressionEnvironment) com.evolveum.midpoint.model.api.context(com.evolveum.midpoint.model.api.context) DeltaSetTriple(com.evolveum.midpoint.prism.delta.DeltaSetTriple) PrismTestUtil(com.evolveum.midpoint.prism.util.PrismTestUtil) PrismValueDeltaSetTriple(com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) TEST_DIR(com.evolveum.midpoint.model.common.mapping.MappingTestEvaluator.TEST_DIR) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PrismTestUtil.getPrismContext(com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext) AbstractModelCommonTest(com.evolveum.midpoint.model.common.AbstractModelCommonTest) PrismAsserts(com.evolveum.midpoint.prism.util.PrismAsserts) BeforeClass(org.testng.annotations.BeforeClass) IOException(java.io.IOException) MiscUtil(com.evolveum.midpoint.util.MiscUtil) Task(com.evolveum.midpoint.task.api.Task) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) AssertJUnit.fail(org.testng.AssertJUnit.fail) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) ExpressionTestUtil(com.evolveum.midpoint.model.common.expression.ExpressionTestUtil) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) Nullable(org.jetbrains.annotations.Nullable) ObjectTreeDeltas(com.evolveum.midpoint.schema.ObjectTreeDeltas) TestResource(com.evolveum.midpoint.test.TestResource) Stream(java.util.stream.Stream) ExpressionProfile(com.evolveum.midpoint.schema.expression.ExpressionProfile) SAXException(org.xml.sax.SAXException) ProgressInformation(com.evolveum.midpoint.model.api.ProgressInformation) NotNull(org.jetbrains.annotations.NotNull) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test) AbstractModelCommonTest(com.evolveum.midpoint.model.common.AbstractModelCommonTest)

Example 3 with ProvenanceMetadataType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceMetadataType 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);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) Label(org.apache.wicket.markup.html.basic.Label) ValueMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Containerable(com.evolveum.midpoint.prism.Containerable) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)

Example 4 with ProvenanceMetadataType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceMetadataType in project midpoint by Evolveum.

the class TestMappingMetadata method testAsIsDeleteSparrowUserWithRangeAll.

/**
 * 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 testAsIsDeleteSparrowUserWithRangeAll() 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_ALL_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");
}
Also used : java.util(java.util) DeltaFactory(com.evolveum.midpoint.prism.delta.DeltaFactory) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) ModelExpressionThreadLocalHolder(com.evolveum.midpoint.model.common.expression.ModelExpressionThreadLocalHolder) ExpressionEnvironment(com.evolveum.midpoint.model.common.expression.ExpressionEnvironment) com.evolveum.midpoint.model.api.context(com.evolveum.midpoint.model.api.context) DeltaSetTriple(com.evolveum.midpoint.prism.delta.DeltaSetTriple) PrismTestUtil(com.evolveum.midpoint.prism.util.PrismTestUtil) PrismValueDeltaSetTriple(com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) TEST_DIR(com.evolveum.midpoint.model.common.mapping.MappingTestEvaluator.TEST_DIR) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PrismTestUtil.getPrismContext(com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext) AbstractModelCommonTest(com.evolveum.midpoint.model.common.AbstractModelCommonTest) PrismAsserts(com.evolveum.midpoint.prism.util.PrismAsserts) BeforeClass(org.testng.annotations.BeforeClass) IOException(java.io.IOException) MiscUtil(com.evolveum.midpoint.util.MiscUtil) Task(com.evolveum.midpoint.task.api.Task) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) AssertJUnit.fail(org.testng.AssertJUnit.fail) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) ExpressionTestUtil(com.evolveum.midpoint.model.common.expression.ExpressionTestUtil) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) Nullable(org.jetbrains.annotations.Nullable) ObjectTreeDeltas(com.evolveum.midpoint.schema.ObjectTreeDeltas) TestResource(com.evolveum.midpoint.test.TestResource) Stream(java.util.stream.Stream) ExpressionProfile(com.evolveum.midpoint.schema.expression.ExpressionProfile) SAXException(org.xml.sax.SAXException) ProgressInformation(com.evolveum.midpoint.model.api.ProgressInformation) NotNull(org.jetbrains.annotations.NotNull) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test) AbstractModelCommonTest(com.evolveum.midpoint.model.common.AbstractModelCommonTest)

Example 5 with ProvenanceMetadataType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceMetadataType in project midpoint by Evolveum.

the class AbstractExpressionEvaluator method addInternalOrigin.

/**
 * Adds Internal origin for given prismValue. Assumes that value has no metadata.
 * (Currently does not fill-in actorRef nor channel.)
 */
public void addInternalOrigin(PrismValue value, ExpressionEvaluationContext context) throws SchemaException {
    if (value != null && !value.hasValueMetadata() && context.getValueMetadataComputer() != null) {
        ValueMetadataType metadata = new ValueMetadataType(prismContext).beginProvenance().beginAcquisition().originRef(SystemObjectsType.ORIGIN_INTERNAL.value(), ServiceType.COMPLEX_TYPE).timestamp(XmlTypeConverter.createXMLGregorianCalendar()).<ProvenanceMetadataType>end().end();
        // noinspection unchecked
        value.getValueMetadataAsContainer().add(metadata.asPrismContainerValue());
    }
}
Also used : ValueMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType)

Aggregations

ValueMetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType)3 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)2 ProgressInformation (com.evolveum.midpoint.model.api.ProgressInformation)2 com.evolveum.midpoint.model.api.context (com.evolveum.midpoint.model.api.context)2 AbstractModelCommonTest (com.evolveum.midpoint.model.common.AbstractModelCommonTest)2 ExpressionEnvironment (com.evolveum.midpoint.model.common.expression.ExpressionEnvironment)2 ExpressionTestUtil (com.evolveum.midpoint.model.common.expression.ExpressionTestUtil)2 ModelExpressionThreadLocalHolder (com.evolveum.midpoint.model.common.expression.ModelExpressionThreadLocalHolder)2 TEST_DIR (com.evolveum.midpoint.model.common.mapping.MappingTestEvaluator.TEST_DIR)2 com.evolveum.midpoint.prism (com.evolveum.midpoint.prism)2 DeltaFactory (com.evolveum.midpoint.prism.delta.DeltaFactory)2 DeltaSetTriple (com.evolveum.midpoint.prism.delta.DeltaSetTriple)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 PrismValueDeltaSetTriple (com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 PrismAsserts (com.evolveum.midpoint.prism.util.PrismAsserts)2 PrismTestUtil (com.evolveum.midpoint.prism.util.PrismTestUtil)2 PrismTestUtil.getPrismContext (com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext)2 XmlTypeConverter (com.evolveum.midpoint.prism.xml.XmlTypeConverter)2 ObjectTreeDeltas (com.evolveum.midpoint.schema.ObjectTreeDeltas)2