use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class TestMappingDynamicSysVar method testPasswordString.
@Test
public void testPasswordString() throws Exception {
// WHEN
PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = evaluator.evaluateMappingDynamicReplace("mapping-script-system-variables-password.xml", "testPasswordString", // target
"employeeType", // changed property
new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), // changed values
evaluator.createProtectedString("weighAnch0r"));
// THEN
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTriplePlus(outputTriple, "weighAnch0r");
PrismAsserts.assertTripleMinus(outputTriple, "d3adM3nT3llN0Tal3s");
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class TestMappingDynamicSysVar method testScriptSystemVariablesConditionTrueToFalse.
public void testScriptSystemVariablesConditionTrueToFalse(String filename) throws Exception {
// GIVEN
final String TEST_NAME = "testScriptSystemVariablesConditionTrueToFalse";
System.out.println("===[ " + TEST_NAME + "]===");
ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("name"), evaluator.getPrismContext(), "Jack");
delta.addModificationDeleteProperty(evaluator.toPath("employeeType"), "CAPTAIN");
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(filename, TEST_NAME, "title", delta);
PrismObject<UserType> user = (PrismObject<UserType>) mapping.getSourceContext().getOldObject();
user.asObjectable().getEmployeeType().add("CAPTAIN");
mapping.getSourceContext().recompute();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTripleNoPlus(outputTriple);
PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack"));
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class FocusProjectionsTabPanel method updateShadowActivation.
private void updateShadowActivation(AjaxRequestTarget target, List<FocusSubwrapperDto<ShadowType>> accounts, boolean enabled) {
if (!isAnyProjectionSelected(target, projectionModel)) {
return;
}
for (FocusSubwrapperDto<ShadowType> account : accounts) {
if (!account.isLoadedOK()) {
continue;
}
ObjectWrapper<ShadowType> wrapper = account.getObject();
ContainerWrapper<ActivationType> activation = wrapper.findContainerWrapper(new ItemPath(ShadowType.F_ACTIVATION));
if (activation == null) {
warn(getString("pageAdminFocus.message.noActivationFound", wrapper.getDisplayName()));
continue;
}
PropertyWrapper enabledProperty = (PropertyWrapper) activation.findPropertyWrapper(ActivationType.F_ADMINISTRATIVE_STATUS);
if (enabledProperty == null || enabledProperty.getValues().size() != 1) {
warn(getString("pageAdminFocus.message.noEnabledPropertyFound", wrapper.getDisplayName()));
continue;
}
ValueWrapper value = (ValueWrapper) enabledProperty.getValues().get(0);
ActivationStatusType status = enabled ? ActivationStatusType.ENABLED : ActivationStatusType.DISABLED;
((PrismPropertyValue) value.getValue()).setValue(status);
wrapper.setSelected(false);
}
target.add(getFeedbackPanel(), get(createComponentPath(ID_SHADOWS)));
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class PersonaProcessor method processPersonaChangesFocus.
public <F extends FocusType> HookOperationMode processPersonaChangesFocus(LensContext<F> context, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException {
DeltaSetTriple<EvaluatedAssignmentImpl<F>> evaluatedAssignmentTriple = (DeltaSetTriple) context.getEvaluatedAssignmentTriple();
if (evaluatedAssignmentTriple == null || evaluatedAssignmentTriple.isEmpty()) {
return HookOperationMode.FOREGROUND;
}
DeltaSetTriple<PersonaKey> activePersonaKeyTriple = new DeltaSetTriple<>();
ComplexConstructionConsumer<PersonaKey, PersonaConstruction<F>> consumer = new ComplexConstructionConsumer<PersonaKey, PersonaConstruction<F>>() {
@Override
public boolean before(PersonaKey key) {
return true;
}
@Override
public void onAssigned(PersonaKey key, String desc) {
activePersonaKeyTriple.addToPlusSet(key);
}
@Override
public void onUnchangedValid(PersonaKey key, String desc) {
activePersonaKeyTriple.addToZeroSet(key);
}
@Override
public void onUnchangedInvalid(PersonaKey key, String desc) {
}
@Override
public void onUnassigned(PersonaKey key, String desc) {
activePersonaKeyTriple.addToMinusSet(key);
}
@Override
public void after(PersonaKey key, String desc, DeltaMapTriple<PersonaKey, ConstructionPack<PersonaConstruction<F>>> constructionMapTriple) {
}
};
DeltaMapTriple<PersonaKey, ConstructionPack<PersonaConstruction<F>>> constructionMapTriple = constructionProcessor.processConstructions(context, evaluatedAssignmentTriple, evaluatedAssignment -> evaluatedAssignment.getPersonaConstructionTriple(), construction -> new PersonaKey(construction.getConstructionType()), consumer, task, result);
LOGGER.trace("activePersonaKeyTriple:\n{}", activePersonaKeyTriple.debugDumpLazily());
List<FocusType> existingPersonas = readExistingPersonas(context, task, result);
LOGGER.trace("existingPersonas:\n{}", existingPersonas);
for (PersonaKey key : activePersonaKeyTriple.getNonNegativeValues()) {
FocusType existingPersona = findPersona(existingPersonas, key);
LOGGER.trace("existingPersona: {}", existingPersona);
// TODO: add ability to merge several constructions
ConstructionPack<PersonaConstruction<F>> pack = constructionMapTriple.getPlusMap().get(key);
if (pack == null) {
pack = constructionMapTriple.getZeroMap().get(key);
}
Collection<PrismPropertyValue<PersonaConstruction<F>>> constructions = pack.getConstructions();
if (constructions.isEmpty()) {
continue;
}
if (constructions.size() > 1) {
throw new UnsupportedOperationException("Merging of multiple persona constructions is not supported yet");
}
PersonaConstruction<F> construction = constructions.iterator().next().getValue();
LOGGER.trace("construction:\n{}", construction.debugDumpLazily());
if (existingPersona == null) {
personaAdd(context, key, construction, task, result);
} else {
personaModify(context, key, construction, existingPersona.asPrismObject(), task, result);
}
}
for (PersonaKey key : activePersonaKeyTriple.getMinusSet()) {
FocusType existingPersona = findPersona(existingPersonas, key);
if (existingPersona != null) {
personaDelete(context, key, existingPersona, task, result);
}
}
return HookOperationMode.FOREGROUND;
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class LockoutStatusPanel method initLayout.
private void initLayout(final IModel<LockoutStatusType> model) {
WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
add(container);
Label label = new Label(ID_LABEL, new IModel<String>() {
@Override
public String getObject() {
LockoutStatusType object = model != null ? model.getObject() : null;
String labelValue = object == null ? ((PageBase) getPage()).createStringResource("LockoutStatusType.UNDEFINED").getString() : WebComponentUtil.createLocalizedModelForEnum(object, getLabel()).getObject();
if (!isInitialState) {
labelValue += " " + ((PageBase) getPage()).createStringResource("LockoutStatusPanel.changesSaving").getString();
}
return labelValue;
}
@Override
public void setObject(String s) {
}
@Override
public void detach() {
}
});
label.setOutputMarkupId(true);
container.add(label);
AjaxButton button = new AjaxButton(ID_BUTTON, getButtonModel()) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
PrismPropertyValue oldValue = (PrismPropertyValue) valueWrapper.getOldValue();
if (!isInitialState) {
model.setObject(initialValue);
oldValue.setValue(initialValue);
valueWrapper.setStatus(ValueStatus.NOT_CHANGED);
} else {
model.setObject(LockoutStatusType.NORMAL);
if (oldValue.getValue() != null) {
oldValue.setValue(null);
}
}
isInitialState = !isInitialState;
ajaxRequestTarget.add(getButton());
ajaxRequestTarget.add(getLabel());
}
};
button.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return true;
}
});
button.setOutputMarkupId(true);
container.add(button);
}
Aggregations