use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceAcquisitionType in project midpoint by Evolveum.
the class WebPrismUtil method createAcquition.
public static ProvenanceAcquisitionType createAcquition() {
MidPointApplication app = MidPointApplication.get();
ProvenanceAcquisitionType acquisitionType = new ProvenanceAcquisitionType(app.getPrismContext());
GuiProfiledPrincipal principal = AuthUtil.getPrincipalUser();
if (principal != null) {
FocusType focus = principal.getFocus();
if (focus != null) {
acquisitionType.setActorRef(ObjectTypeUtil.createObjectRef(focus, app.getPrismContext()));
}
}
acquisitionType.setChannel(GuiChannel.USER.getUri());
acquisitionType.setTimestamp(app.getClock().currentTimeXMLGregorianCalendar());
return acquisitionType;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceAcquisitionType in project midpoint by Evolveum.
the class ProvenanceMetadataPanel method createAcquisitionPanel.
private WebMarkupContainer createAcquisitionPanel(IModel<PrismContainerWrapper<ProvenanceAcquisitionType>> listPropertyModel) {
WebMarkupContainer container = new WebMarkupContainer(ID_ACQUISITION_HEADER);
ListView<PrismContainerValueWrapper<ProvenanceAcquisitionType>> acquisition = new ListView<PrismContainerValueWrapper<ProvenanceAcquisitionType>>(ID_ACQUISITIONS, new PropertyModel<>(listPropertyModel, "values")) {
@Override
protected void populateItem(ListItem<PrismContainerValueWrapper<ProvenanceAcquisitionType>> listItem) {
ProvenanceAcquisitionHeaderPanel panel = new ProvenanceAcquisitionHeaderPanel(ID_ACQUISITION, new ItemRealValueModel<>(listItem.getModel()));
panel.setOutputMarkupId(true);
listItem.add(panel);
}
};
container.add(acquisition);
return container;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceAcquisitionType in project midpoint by Evolveum.
the class ProvenanceAcquisitionHeaderPanel method initLayout.
private void initLayout() {
LinkedReferencePanel<ObjectReferenceType> source = new LinkedReferencePanel<>(ID_SOURCE, new ReadOnlyModel<>(() -> {
ProvenanceAcquisitionType acquisitionType = getModelObject();
if (acquisitionType == null) {
return null;
}
ObjectReferenceType ref = acquisitionType.getResourceRef();
if (ref != null && ref.getOid() != null) {
return ref;
}
ObjectReferenceType originRef = acquisitionType.getOriginRef();
if (originRef != null && originRef.getOid() != null) {
return originRef;
}
return null;
}));
add(source);
source.add(new VisibleBehaviour(() -> isNotEmpty(getModelObject().getResourceRef()) || isNotEmpty(getModelObject().getOriginRef())));
ReadOnlyModel<GuiChannel> channelModel = new ReadOnlyModel<>(() -> GuiChannel.findChannel(getModelObject().getChannel()));
WebMarkupContainer channelIcon = new WebMarkupContainer(ID_CHANNEL_ICON);
add(channelIcon);
channelIcon.add(AttributeAppender.replace("class", new PropertyModel<>(channelModel, "iconCssClass")));
Label channel = new Label(ID_CHANNEL, getPageBase().createStringResource(channelModel.getObject()));
add(channel);
channel.add(new VisibleBehaviour(() -> getModelObject() != null && (getModelObject().getOriginRef() == null || getModelObject().getOriginRef().getOid() == null) && (getModelObject().getResourceRef() == null || getModelObject().getResourceRef().getOid() == null)));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceAcquisitionType 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.ProvenanceAcquisitionType in project midpoint by Evolveum.
the class TestMappingMetadata method testAddJackRestWithTimestampWithExisting.
/**
* Jack has acquisition origins: user, rest
* Sparrow has acquisition origins: user
* target (Jack Sparrow) has origins: user, rest (in the form of m:user+rest).
*
* (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 testAddJackRestWithTimestampWithExisting() 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, existingValuesCustomizer(createJackSparrowOriginal()));
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);
}
Aggregations