Search in sources :

Example 1 with ExpressionType

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

the class StaticExpressionUtil method getStaticOutput.

/**
	 * Returns either Object (if result is supposed to be single-value) or Collection<X> (if result is supposed to be multi-value) 
	 */
public static Object getStaticOutput(ExpressionType expressionType, PrismPropertyDefinition outputDefinition, String contextDescription, ExpressionReturnMultiplicityType preferredMultiplicity, PrismContext prismContext) throws SchemaException {
    PrismProperty<?> output = getPropertyStatic(expressionType, outputDefinition, contextDescription, prismContext);
    ExpressionReturnMultiplicityType multiplicity = preferredMultiplicity;
    if (expressionType.getReturnMultiplicity() != null) {
        multiplicity = expressionType.getReturnMultiplicity();
    } else if (output != null && output.size() > 1) {
        multiplicity = ExpressionReturnMultiplicityType.MULTI;
    }
    if (output == null) {
        switch(multiplicity) {
            case MULTI:
                return new ArrayList<Object>(0);
            case SINGLE:
                return null;
            default:
                throw new IllegalStateException("Unknown return type " + multiplicity);
        }
    } else {
        switch(multiplicity) {
            case MULTI:
                return output.getRealValues();
            case SINGLE:
                return output.getRealValue();
            default:
                throw new IllegalStateException("Unknown return type " + multiplicity);
        }
    }
}
Also used : ExpressionReturnMultiplicityType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionReturnMultiplicityType) ArrayList(java.util.ArrayList)

Example 2 with ExpressionType

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

the class ExpressionHandlerImplTest method testEvaluateExpression.

@SuppressWarnings("unchecked")
@Test
public void testEvaluateExpression() throws Exception {
    PrismObject<ShadowType> account = PrismTestUtil.parseObject(new File(TEST_FOLDER, "account.xml"));
    ShadowType accountType = account.asObjectable();
    PrismObject<ResourceType> resource = PrismTestUtil.parseObject(new File(TEST_FOLDER_COMMON, "resource-dummy.xml"));
    ResourceType resourceType = resource.asObjectable();
    accountType.setResource(resourceType);
    ObjectSynchronizationType synchronization = resourceType.getSynchronization().getObjectSynchronization().get(0);
    for (ConditionalSearchFilterType filter : synchronization.getCorrelation()) {
        MapXNode clauseXNode = filter.getFilterClauseXNode();
        // key = q:equal, value = map (path + expression)
        RootXNode expressionNode = ((MapXNode) clauseXNode.getSingleSubEntry("filter value").getValue()).getEntryAsRoot(new QName(SchemaConstants.NS_C, "expression"));
        ExpressionType expression = PrismTestUtil.getPrismContext().parserFor(expressionNode).parseRealValue(ExpressionType.class);
        LOGGER.debug("Expression: {}", SchemaDebugUtil.prettyPrint(expression));
        OperationResult result = new OperationResult("testCorrelationRule");
        String name = expressionHandler.evaluateExpression(accountType, expression, "test expression", null, result);
        LOGGER.info(result.debugDump());
        assertEquals("Wrong expression result", "hbarbossa", name);
    }
}
Also used : ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) File(java.io.File) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) Test(org.testng.annotations.Test)

Example 3 with ExpressionType

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

the class MappingEditorDialog method initLayout.

public void initLayout(WebMarkupContainer content) {
    Form form = new Form(ID_MAIN_FORM);
    form.setOutputMarkupId(true);
    content.add(form);
    TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<String>(model, MappingTypeDto.F_MAPPING + ".name"), createStringResource("MappingEditorDialog.label.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    name.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(name);
    TextAreaFormGroup description = new TextAreaFormGroup(ID_DESCRIPTION, new PropertyModel<String>(model, MappingTypeDto.F_MAPPING + ".description"), createStringResource("MappingEditorDialog.label.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    description.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(description);
    CheckFormGroup authoritative = new CheckFormGroup(ID_AUTHORITATIVE, new PropertyModel<Boolean>(model, MappingTypeDto.F_MAPPING + ".authoritative"), createStringResource("MappingEditorDialog.label.authoritative"), "SchemaHandlingStep.mapping.tooltip.authoritative", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
    authoritative.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(authoritative);
    CheckFormGroup exclusive = new CheckFormGroup(ID_EXCLUSIVE, new PropertyModel<Boolean>(model, MappingTypeDto.F_MAPPING + ".exclusive"), createStringResource("MappingEditorDialog.label.exclusive"), "SchemaHandlingStep.mapping.tooltip.exclusive", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
    exclusive.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(exclusive);
    DropDownFormGroup strength = new DropDownFormGroup<>(ID_STRENGTH, new PropertyModel<MappingStrengthType>(model, MappingTypeDto.F_MAPPING + ".strength"), WebComponentUtil.createReadonlyModelFromEnum(MappingStrengthType.class), new EnumChoiceRenderer<MappingStrengthType>(this), createStringResource("MappingEditorDialog.label.strength"), "SchemaHandlingStep.mapping.tooltip.strength", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    strength.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(strength);
    MultiValueDropDownPanel channel = new MultiValueDropDownPanel<String>(ID_CHANNEL, new PropertyModel<List<String>>(model, MappingTypeDto.F_MAPPING + ".channel"), true, readOnlyModel) {

        @Override
        protected String createNewEmptyItem() {
            return "";
        }

        @Override
        protected IModel<List<String>> createChoiceList() {
            return new AbstractReadOnlyModel<List<String>>() {

                @Override
                public List<String> getObject() {
                    return WebComponentUtil.getChannelList();
                }
            };
        }

        @Override
        protected IChoiceRenderer<String> createRenderer() {
            return new StringChoiceRenderer("Channel.", "#");
        }
    };
    form.add(channel);
    MultiValueDropDownPanel exceptChannel = new MultiValueDropDownPanel<String>(ID_EXCEPT_CHANNEL, new PropertyModel<List<String>>(model, MappingTypeDto.F_MAPPING + ".exceptChannel"), true, readOnlyModel) {

        @Override
        protected String createNewEmptyItem() {
            return "";
        }

        @Override
        protected IModel<List<String>> createChoiceList() {
            return new AbstractReadOnlyModel<List<String>>() {

                @Override
                public List<String> getObject() {
                    return WebComponentUtil.getChannelList();
                }
            };
        }

        @Override
        protected IChoiceRenderer<String> createRenderer() {
            return new StringChoiceRenderer("Channel.", "#");
        }
    };
    form.add(exceptChannel);
    // TODO - create some nice ItemPathType editor in near future
    MultiValueTextPanel source = new MultiValueTextPanel<>(ID_SOURCE, new PropertyModel<List<String>>(model, MappingTypeDto.F_SOURCE), readOnlyModel, true);
    form.add(source);
    // TODO - create some nice ItemPathType editor in near future
    TextFormGroup target = new TextFormGroup(ID_TARGET, new PropertyModel<String>(model, MappingTypeDto.F_TARGET), createStringResource("MappingEditorDialog.label.target"), "SchemaHandlingStep.mapping.tooltip.target", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, isTargetRequired);
    target.setOutputMarkupId(true);
    target.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(target);
    DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType> expressionType = new DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType>(ID_EXPRESSION_TYPE, new PropertyModel<ExpressionUtil.ExpressionEvaluatorType>(model, MappingTypeDto.F_EXPRESSION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class), new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this), createStringResource("MappingEditorDialog.label.expressionType"), "SchemaHandlingStep.mapping.tooltip.expressionType", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<ExpressionUtil.ExpressionEvaluatorType>> choices, IChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    expressionType.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpression();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION_LANG));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION_POLICY_REF));
        }
    });
    expressionType.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(expressionType);
    DropDownFormGroup expressionLanguage = new DropDownFormGroup<>(ID_EXPRESSION_LANG, new PropertyModel<ExpressionUtil.Language>(model, MappingTypeDto.F_EXPRESSION_LANG), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class), new EnumChoiceRenderer<ExpressionUtil.Language>(this), createStringResource("MappingEditorDialog.label.language"), "SchemaHandlingStep.mapping.tooltip.expressionLanguage", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    expressionLanguage.setOutputMarkupId(true);
    expressionLanguage.setOutputMarkupPlaceholderTag(true);
    expressionLanguage.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(model.getObject().getExpressionType());
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    form.add(expressionLanguage);
    expressionLanguage.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpressionLanguage();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
        }
    });
    DropDownFormGroup<ObjectReferenceType> expressionGeneratePolicy = new DropDownFormGroup<ObjectReferenceType>(ID_EXPRESSION_POLICY_REF, new PropertyModel<ObjectReferenceType>(model, MappingTypeDto.F_EXPRESSION_POLICY_REF), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

        @Override
        public List<ObjectReferenceType> getObject() {
            return WebModelServiceUtils.createObjectReferenceList(ValuePolicyType.class, getPageBase(), policyMap);
        }
    }, new ObjectReferenceChoiceRenderer(policyMap), createStringResource("MappingEditorDialog.label.passPolicyRef"), "SchemaHandlingStep.mapping.tooltip.expressionValuePolicyRef", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<ObjectReferenceType>> choices, IChoiceRenderer<ObjectReferenceType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    expressionGeneratePolicy.setOutputMarkupId(true);
    expressionGeneratePolicy.setOutputMarkupPlaceholderTag(true);
    expressionGeneratePolicy.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.GENERATE.equals(model.getObject().getExpressionType());
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    expressionGeneratePolicy.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpressionGeneratePolicy();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
        }
    });
    form.add(expressionGeneratePolicy);
    AceEditorFormGroup expression = new AceEditorFormGroup(ID_EXPRESSION, new PropertyModel<String>(model, MappingTypeDto.F_EXPRESSION), createStringResource("MappingEditorDialog.label.expression"), "SchemaHandlingStep.mapping.tooltip.expression", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, CODE_ROW_COUNT);
    expression.setOutputMarkupId(true);
    expression.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(expression);
    DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType> conditionType = new DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType>(ID_CONDITION_TYPE, new PropertyModel<ExpressionUtil.ExpressionEvaluatorType>(model, MappingTypeDto.F_CONDITION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class), new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this), createStringResource("MappingEditorDialog.label.conditionType"), "SchemaHandlingStep.mapping.tooltip.conditionType", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<ExpressionUtil.ExpressionEvaluatorType>> choices, IChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    conditionType.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateCondition();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION_LANG));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION_POLICY_REF));
        }
    });
    form.add(conditionType);
    conditionType.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    DropDownFormGroup conditionLanguage = new DropDownFormGroup<>(ID_CONDITION_LANG, new PropertyModel<ExpressionUtil.Language>(model, MappingTypeDto.F_CONDITION_LANG), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class), new EnumChoiceRenderer<ExpressionUtil.Language>(this), createStringResource("MappingEditorDialog.label.language"), "SchemaHandlingStep.mapping.tooltip.conditionLanguage", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    conditionLanguage.setOutputMarkupId(true);
    conditionLanguage.setOutputMarkupPlaceholderTag(true);
    conditionLanguage.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(model.getObject().getConditionType());
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    conditionLanguage.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateConditionLanguage();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
        }
    });
    form.add(conditionLanguage);
    DropDownFormGroup<ObjectReferenceType> conditionGeneratePolicy = new DropDownFormGroup<ObjectReferenceType>(ID_CONDITION_POLICY_REF, new PropertyModel<ObjectReferenceType>(model, MappingTypeDto.F_CONDITION_POLICY_REF), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

        @Override
        public List<ObjectReferenceType> getObject() {
            return WebModelServiceUtils.createObjectReferenceList(ValuePolicyType.class, getPageBase(), policyMap);
        }
    }, new ObjectReferenceChoiceRenderer(policyMap), createStringResource("MappingEditorDialog.label.passPolicyRef"), "SchemaHandlingStep.mapping.tooltip.conditionValuePolicyRef", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<ObjectReferenceType>> choices, IChoiceRenderer<ObjectReferenceType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    conditionGeneratePolicy.setOutputMarkupId(true);
    conditionGeneratePolicy.setOutputMarkupPlaceholderTag(true);
    conditionGeneratePolicy.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.GENERATE.equals(model.getObject().getConditionType());
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    conditionGeneratePolicy.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateConditionGeneratePolicy();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
        }
    });
    form.add(conditionGeneratePolicy);
    AceEditorFormGroup condition = new AceEditorFormGroup(ID_CONDITION, new PropertyModel<String>(model, MappingTypeDto.F_CONDITION), createStringResource("MappingEditorDialog.label.condition"), "SchemaHandlingStep.mapping.tooltip.condition", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, CODE_ROW_COUNT);
    condition.setOutputMarkupId(true);
    condition.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(condition);
    Label channelTooltip = new Label(ID_T_CHANNEL);
    channelTooltip.add(new InfoTooltipBehavior(true));
    form.add(channelTooltip);
    Label exceptChannelTooltip = new Label(ID_T_EXCEPT_CHANNEL);
    exceptChannelTooltip.add(new InfoTooltipBehavior(true));
    form.add(exceptChannelTooltip);
    Label sourceTooltip = new Label(ID_T_SOURCE);
    sourceTooltip.add(new InfoTooltipBehavior(true));
    form.add(sourceTooltip);
    AjaxButton cancel = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("MappingEditorDialog.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    form.add(cancel);
    AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("MappingEditorDialog.button.apply")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getPageBase().getFeedbackPanel(), getContent());
        }
    };
    save.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    form.add(save);
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) ObjectReferenceChoiceRenderer(com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) Form(org.apache.wicket.markup.html.form.Form) Label(org.apache.wicket.markup.html.basic.Label) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) MultiValueDropDownPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueDropDownPanel) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) MultiValueTextPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) IModel(org.apache.wicket.model.IModel) MappingStrengthType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingStrengthType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) StringChoiceRenderer(com.evolveum.midpoint.web.component.input.StringChoiceRenderer) ExpressionUtil(com.evolveum.midpoint.web.util.ExpressionUtil)

Example 4 with ExpressionType

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

the class ConditionalSearchFilterEditor method initLayout.

protected void initLayout(PageResourceWizard parentPage) {
    ExpressionEditorPanel expressionEditor = new ExpressionEditorPanel(ID_EXPRESSION_PANEL, new PropertyModel<ExpressionType>(getModel(), ConditionalSearchFilterType.F_CONDITION.getLocalPart()), parentPage) {

        @Override
        public void performExpressionHook(AjaxRequestTarget target) {
            if (getExpressionDtoModel().getObject() != null) {
                ExpressionType expression = getExpressionDtoModel().getObject().getExpressionObject();
                ConditionalSearchFilterEditor.this.getModel().getObject().setCondition(expression);
            }
        }

        @Override
        public String getTypeLabelKey() {
            return "ConditionalSearchFilterEditor.condition.type.label";
        }

        @Override
        public String getDescriptionLabelKey() {
            return "ConditionalSearchFilterEditor.condition.description.label";
        }

        @Override
        public String getUpdateLabelKey() {
            return "ConditionalSearchFilterEditor.condition.update.label";
        }

        @Override
        public String getExpressionLabelKey() {
            return "ConditionalSearchFilterEditor.condition.label";
        }
    };
    add(expressionEditor);
    SearchFilterPanel filterClauseEditor = new SearchFilterPanel<>(ID_FILTER_CLAUSE_PANEL, (NonEmptyModel<ConditionalSearchFilterType>) getModel(), parentPage.getReadOnlyModel());
    add(filterClauseEditor);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) SearchFilterPanel(com.evolveum.midpoint.web.component.input.SearchFilterPanel) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) ExpressionEditorPanel(com.evolveum.midpoint.web.component.input.ExpressionEditorPanel)

Example 5 with ExpressionType

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

the class TestExpression method testIterationCondition.

@Test
public void testIterationCondition() throws Exception {
    final String TEST_NAME = "testIterationCondition";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestExpression.class.getName() + "." + TEST_NAME);
    rememberScriptExecutionCount();
    ExpressionType expressionType = PrismTestUtil.parseAtomicValue(EXPRESSION_ITERATION_CONDITION_FILE, ExpressionType.COMPLEX_TYPE);
    PrismPropertyDefinition<Boolean> outputDefinition = new PrismPropertyDefinitionImpl<>(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN, prismContext);
    Expression<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> expression = expressionFactory.makeExpression(expressionType, outputDefinition, TEST_NAME, null, result);
    ExpressionVariables variables = new ExpressionVariables();
    PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_FILE);
    variables.addVariableDefinition(ExpressionConstants.VAR_FOCUS, user);
    variables.addVariableDefinition(ExpressionConstants.VAR_USER, user);
    PrismObject<ShadowType> account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMYFILE);
    variables.addVariableDefinition(ExpressionConstants.VAR_SHADOW, account);
    variables.addVariableDefinition(ExpressionConstants.VAR_ITERATION, 1);
    variables.addVariableDefinition(ExpressionConstants.VAR_ITERATION_TOKEN, "001");
    ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(null, variables, TEST_NAME, null, result);
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = expression.evaluate(expressionContext);
    // THEN
    assertNotNull(outputTriple);
    outputTriple.checkConsistence();
    // Make sure that the script is executed only once. There is no delta in the variables, no need to do it twice.
    assertScriptExecutionIncrement(1);
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

ExpressionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)19 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 QName (javax.xml.namespace.QName)8 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)7 ArrayList (java.util.ArrayList)7 ExpressionEvaluationContext (com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext)6 ExpressionVariables (com.evolveum.midpoint.repo.common.expression.ExpressionVariables)6 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)6 Test (org.testng.annotations.Test)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)5 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)5 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)4 Task (com.evolveum.midpoint.task.api.Task)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 MappingType (com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType)4 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)3 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)3