Search in sources :

Example 56 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class ResourceAttributePanel method customEditItemPerformed.

// private void manageMappings(boolean outbound) {
// if (outbound) {
// collectionOutbounds();
// }
// PrismContainerWrapper<ResourceAttributeDefinitionType> resourceAttributeDefinition = getModelObject();
// 
// }
// 
// private void collectionOutbounds() {
// PrismContainerWrapper<ResourceAttributeDefinitionType> resourceAttributeDef = getModelObject();
// 
// for (PrismContainerValueWrapper<ResourceAttributeDefinitionType> resourceAttributeDefVal : resourceAttributeDef.getValues()) {
// ResourceAttributeDefinitionType resourceAttrRealValue = resourceAttributeDefVal.getRealValue();
// if (resourceAttributeDef == null) {
// continue;
// }
// MappingType mappingType = resourceAttrRealValue.getOutbound();
// if (mappingType == null) {
// continue;
// }
// 
// }
// }
@Override
protected boolean customEditItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ResourceAttributeDefinitionType>> rowModel, List<PrismContainerValueWrapper<ResourceAttributeDefinitionType>> listItems) {
    if (getConfig() == null) {
        return false;
    }
    AbstractPageObjectDetails parent = findParent(AbstractPageObjectDetails.class);
    if (parent == null) {
        return false;
    }
    ContainerPanelConfigurationType detailsPanel = new ContainerPanelConfigurationType(getPrismContext());
    detailsPanel.setPanelType("attributeDefinitionDetails");
    PrismContainerValueWrapper<ResourceAttributeDefinitionType> attrDef;
    if (rowModel != null) {
        attrDef = rowModel.getObject();
    } else {
        attrDef = listItems.iterator().next();
    }
    // VirtualContainersSpecificationType virtualContainer = new VirtualContainersSpecificationType(getPrismContext());
    detailsPanel.setPath(new ItemPathType(attrDef.getPath()));
    // detailsPanel.getContainer().add(virtualContainer);
    detailsPanel.setIdentifier("attributeDefinitionDetails");
    DisplayType displayType = new DisplayType();
    displayType.setLabel(new PolyStringType(attrDef.getDisplayName()));
    IconType icon = new IconType();
    icon.setCssClass("fa fa-navicon");
    displayType.setIcon(icon);
    detailsPanel.setDisplay(displayType);
    getPageBase().getSessionStorage().setObjectDetailsStorage("details" + parent.getType().getSimpleName(), detailsPanel);
    ResourceAttributePanel.this.getConfig().getPanel().add(detailsPanel);
    target.add(parent);
    parent.replacePanel(detailsPanel, target);
    return true;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) AbstractPageObjectDetails(com.evolveum.midpoint.gui.impl.page.admin.AbstractPageObjectDetails)

Example 57 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class FullTextSearchUtil method getFullTextSearchItemPaths.

@NotNull
public static Set<ItemPath> getFullTextSearchItemPaths(@NotNull FullTextSearchConfigurationType config, Class<? extends ObjectType> clazz) {
    List<QName> types = ObjectTypes.getObjectType(clazz).thisAndSupertypes().stream().map(ot -> ot.getTypeQName()).collect(Collectors.toList());
    Set<ItemPath> paths = new HashSet<>();
    for (FullTextSearchIndexedItemsConfigurationType indexed : config.getIndexed()) {
        if (isApplicable(indexed, types)) {
            for (ItemPathType itemPathType : indexed.getItem()) {
                ItemPath path = itemPathType.getItemPath();
                if (!ItemPath.isEmpty(path) && !ItemPathCollectionsUtil.containsEquivalent(paths, path)) {
                    paths.add(path);
                }
            }
        }
    }
    return paths;
}
Also used : PrismValue(com.evolveum.midpoint.prism.PrismValue) java.util(java.util) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Item(com.evolveum.midpoint.prism.Item) FullTextSearchIndexedItemsConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FullTextSearchIndexedItemsConfigurationType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Trace(com.evolveum.midpoint.util.logging.Trace) FullTextSearchConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FullTextSearchConfigurationType) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Nullable(org.jetbrains.annotations.Nullable) QNameUtil(com.evolveum.midpoint.util.QNameUtil) PrismContext(com.evolveum.midpoint.prism.PrismContext) ItemPathCollectionsUtil(com.evolveum.midpoint.prism.path.ItemPathCollectionsUtil) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) QName(javax.xml.namespace.QName) NotNull(org.jetbrains.annotations.NotNull) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) FullTextSearchIndexedItemsConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FullTextSearchIndexedItemsConfigurationType) QName(javax.xml.namespace.QName) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) NotNull(org.jetbrains.annotations.NotNull)

Example 58 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class GetOperationOptionsUtil method selectorToSelectorType.

private static OptionObjectSelectorType selectorToSelectorType(ObjectSelector selector) {
    if (selector == null) {
        return null;
    }
    OptionObjectSelectorType selectorType = new OptionObjectSelectorType();
    selectorType.setPath(new ItemPathType(selector.getPath()));
    return selectorType;
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) OptionObjectSelectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.OptionObjectSelectorType)

Example 59 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class PopulatorUtil method evaluatePopulateExpression.

public static <IV extends PrismValue, ID extends ItemDefinition, C extends Containerable> ItemDelta<IV, ID> evaluatePopulateExpression(PopulateItemType populateItem, VariablesMap variables, ExpressionEvaluationContext context, PrismContainerDefinition<C> targetContainerDefinition, String contextDescription, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
    ExpressionType expressionType = populateItem.getExpression();
    if (expressionType == null) {
        LOGGER.warn("No expression in populateObject in assignment expression in {}, " + "skipping. Subsequent operations will most likely fail", contextDescription);
        return null;
    }
    VariableBindingDefinitionType targetType = populateItem.getTarget();
    if (targetType == null) {
        LOGGER.warn("No target in populateObject in assignment expression in {}, " + "skipping. Subsequent operations will most likely fail", contextDescription);
        return null;
    }
    ItemPathType itemPathType = targetType.getPath();
    if (itemPathType == null) {
        throw new SchemaException("No path in target definition in " + contextDescription);
    }
    ItemPath targetPath = itemPathType.getItemPath();
    ID propOutputDefinition = ExpressionUtil.resolveDefinitionPath(targetPath, variables, targetContainerDefinition, "target definition in " + contextDescription);
    if (propOutputDefinition == null) {
        throw new SchemaException("No target item that would conform to the path " + targetPath + " in " + contextDescription);
    }
    String expressionDesc = "expression in populate expression in " + contextDescription;
    ExpressionFactory expressionFactory = context.getExpressionFactory();
    Expression<IV, ID> expression = expressionFactory.makeExpression(expressionType, propOutputDefinition, context.getExpressionProfile(), expressionDesc, task, result);
    ExpressionEvaluationContext localContext = new ExpressionEvaluationContext(null, variables, expressionDesc, task);
    localContext.setExpressionFactory(expressionFactory);
    localContext.setValuePolicySupplier(context.getValuePolicySupplier());
    localContext.setSkipEvaluationMinus(true);
    localContext.setSkipEvaluationPlus(false);
    localContext.setVariableProducer(context.getVariableProducer());
    localContext.setLocalContextDescription(context.getLocalContextDescription());
    PrismValueDeltaSetTriple<IV> outputTriple = expression.evaluate(localContext, result);
    LOGGER.trace("output triple:\n{}", DebugUtil.debugDumpLazily(outputTriple, 1));
    if (outputTriple == null) {
        return null;
    }
    Collection<IV> pvalues = outputTriple.getNonNegativeValues();
    // Maybe not really clean but it works. TODO: refactor later
    if (targetPath.startsWithVariable()) {
        targetPath = targetPath.rest();
    }
    // noinspection unchecked
    ItemDelta<IV, ID> itemDelta = propOutputDefinition.createEmptyDelta(targetPath);
    itemDelta.addValuesToAdd(PrismValueCollectionsUtil.cloneCollection(pvalues));
    LOGGER.trace("Item delta:\n{}", itemDelta.debugDumpLazily(1));
    return itemDelta;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionFactory(com.evolveum.midpoint.repo.common.expression.ExpressionFactory) ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) VariableBindingDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 60 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class MappingTypeDto method prepareDtoToSave.

public MappingType prepareDtoToSave(PrismContext prismContext) throws SchemaException {
    if (mappingObject == null) {
        mappingObject = new MappingType();
    }
    if (target != null) {
        VariableBindingDefinitionType mappingTarget = new VariableBindingDefinitionType();
        mappingTarget.setPath(new ItemPathType(target));
        mappingObject.setTarget(mappingTarget);
    } else {
        mappingObject.setTarget(null);
    }
    mappingObject.getSource().clear();
    List<VariableBindingDefinitionType> mappingSourceList = new ArrayList<>();
    for (String s : source) {
        if (s == null) {
            continue;
        }
        VariableBindingDefinitionType mappingSource = new VariableBindingDefinitionType();
        mappingSource.setPath(new ItemPathType(s));
        mappingSourceList.add(mappingSource);
    }
    mappingObject.getSource().addAll(mappingSourceList);
    if (expression != null) {
        if (mappingObject.getExpression() == null) {
            mappingObject.setExpression(new ExpressionType());
        }
        ExpressionUtil.parseExpressionEvaluators(expression, mappingObject.getExpression(), prismContext);
    }
    if (condition != null) {
        if (mappingObject.getCondition() == null) {
            mappingObject.setCondition(new ExpressionType());
        }
        ExpressionUtil.parseExpressionEvaluators(condition, mappingObject.getCondition(), prismContext);
    }
    return mappingObject;
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ArrayList(java.util.ArrayList)

Aggregations

ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)114 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)58 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)27 Test (org.testng.annotations.Test)27 QName (javax.xml.namespace.QName)25 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)24 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)21 List (java.util.List)18 NotNull (org.jetbrains.annotations.NotNull)18 PrismObject (com.evolveum.midpoint.prism.PrismObject)15 ArrayList (java.util.ArrayList)15 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)13 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)13 Collectors (java.util.stream.Collectors)13 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)12 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)11 ObjectDeltaOperation (com.evolveum.midpoint.schema.ObjectDeltaOperation)11 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)11 OperationResultStatus (com.evolveum.midpoint.schema.result.OperationResultStatus)11 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)11