use of com.evolveum.midpoint.prism.ItemDefinition in project midpoint by Evolveum.
the class ItemWrapperComparator method compare.
@Override
public int compare(ItemWrapper p1, ItemWrapper p2) {
ItemDefinition def1 = p1.getItemDefinition();
ItemDefinition def2 = p2.getItemDefinition();
if (isMainContainer(p1)) {
return -1;
}
if (isMainContainer(p2)) {
return 1;
}
Integer index1 = def1.getDisplayOrder();
Integer index2 = def2.getDisplayOrder();
if (index1 != null && index2 != null) {
return index1 - index2;
} else if (index1 != null && index2 == null) {
return -1;
} else if (index1 == null && index2 != null) {
return 1;
}
return String.CASE_INSENSITIVE_ORDER.compare(getDisplayName(def1), getDisplayName(def2));
}
use of com.evolveum.midpoint.prism.ItemDefinition in project midpoint by Evolveum.
the class DynamicFieldGroupPanel method createItemWrapper.
private ItemWrapper createItemWrapper(AbstractFormItemType formField, ObjectWrapper objectWrapper) {
ItemPathType itemPathType = GuiImplUtil.getPathType(formField);
if (itemPathType == null) {
getSession().error("Bad form item definition. It has to contain reference to the real attribute");
LOGGER.error("Bad form item definition. It has to contain reference to the real attribute");
throw new RestartResponseException(getPageBase());
}
ItemPath path = itemPathType.getItemPath();
ItemDefinition itemDef = objectWrapper.getObject().getDefinition().findItemDefinition(path);
ItemWrapper itemWrapper = null;
if (itemDef instanceof PrismContainerDefinition) {
itemWrapper = objectWrapper.findContainerWrapper(path);
} else {
itemWrapper = objectWrapper.findPropertyWrapper(path);
}
if (itemWrapper == null) {
getSession().error("Bad form item definition. No attribute with path: " + path + " was found");
LOGGER.error("Bad form item definition. No attribute with path: " + path + " was found");
throw new RestartResponseException(getPageBase());
}
applyFormDefinition(itemWrapper, formField);
return itemWrapper;
}
use of com.evolveum.midpoint.prism.ItemDefinition in project midpoint by Evolveum.
the class OutboundProcessor method evaluateMapping.
private <F extends FocusType, V extends PrismValue, D extends ItemDefinition> Mapping<V, D> evaluateMapping(final Mapping.Builder<V, D> mappingBuilder, QName mappingQName, D targetDefinition, ObjectDeltaObject<F> focusOdo, ObjectDeltaObject<ShadowType> projectionOdo, String operation, RefinedObjectClassDefinition rOcDef, RefinedObjectClassDefinition assocTargetObjectClassDefinition, LensContext<F> context, LensProjectionContext projCtx, final Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
if (!mappingBuilder.isApplicableToChannel(context.getChannel())) {
LOGGER.trace("Skipping outbound mapping for {} because the channel does not match", mappingQName);
return null;
}
// TODO: check access
// This is just supposed to be an optimization. The consolidation should deal with the weak mapping
// even if it is there. But in that case we do not need to evaluate it at all.
// Edit 2017-02-16 pmed: It's not quite true. If the attribute is non-tolerant, it will get removed if we would
// skip evaluation of this mapping. So we really need to do this.
// if (mappingBuilder.getStrength() == MappingStrengthType.WEAK && projCtx.hasValueForAttribute(mappingQName)) {
// LOGGER.trace("Skipping outbound mapping for {} because it is weak", mappingQName);
// return null;
// }
mappingBuilder.setDefaultTargetDefinition(targetDefinition);
mappingBuilder.setSourceContext(focusOdo);
mappingBuilder.setMappingQName(mappingQName);
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_USER, focusOdo);
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_FOCUS, focusOdo);
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_ACCOUNT, projectionOdo);
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_SHADOW, projectionOdo);
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_PROJECTION, projectionOdo);
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_CONFIGURATION, context.getSystemConfiguration());
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_ITERATION, LensUtil.getIterationVariableValue(projCtx));
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_ITERATION_TOKEN, LensUtil.getIterationTokenVariableValue(projCtx));
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_RESOURCE, projCtx.getResource());
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_OPERATION, operation);
if (assocTargetObjectClassDefinition != null) {
mappingBuilder.addVariableDefinition(ExpressionConstants.VAR_ASSOCIATION_TARGET_OBJECT_CLASS_DEFINITION, assocTargetObjectClassDefinition);
}
mappingBuilder.setRootNode(focusOdo);
mappingBuilder.setOriginType(OriginType.OUTBOUND);
mappingBuilder.setRefinedObjectClassDefinition(rOcDef);
StringPolicyResolver stringPolicyResolver = new StringPolicyResolver() {
private ItemPath outputPath;
private ItemDefinition outputDefinition;
@Override
public void setOutputPath(ItemPath outputPath) {
this.outputPath = outputPath;
}
@Override
public void setOutputDefinition(ItemDefinition outputDefinition) {
this.outputDefinition = outputDefinition;
}
@Override
public StringPolicyType resolve() {
if (mappingBuilder.getMappingType().getExpression() != null) {
List<JAXBElement<?>> evaluators = mappingBuilder.getMappingType().getExpression().getExpressionEvaluator();
for (JAXBElement jaxbEvaluator : evaluators) {
Object object = jaxbEvaluator.getValue();
if (object instanceof GenerateExpressionEvaluatorType && ((GenerateExpressionEvaluatorType) object).getValuePolicyRef() != null) {
ObjectReferenceType ref = ((GenerateExpressionEvaluatorType) object).getValuePolicyRef();
try {
ValuePolicyType valuePolicyType = mappingBuilder.getObjectResolver().resolve(ref, ValuePolicyType.class, null, "resolving value policy for generate attribute " + outputDefinition.getName() + "value", task, new OperationResult("Resolving value policy"));
if (valuePolicyType != null) {
return valuePolicyType.getStringPolicy();
}
} catch (CommonException ex) {
throw new SystemException(ex.getMessage(), ex);
}
}
}
}
return null;
}
};
mappingBuilder.setStringPolicyResolver(stringPolicyResolver);
// (e.g. in old values in ADD situations and new values in DELETE situations).
if (focusOdo.getOldObject() == null) {
mappingBuilder.setConditionMaskOld(false);
}
if (focusOdo.getNewObject() == null) {
mappingBuilder.setConditionMaskNew(false);
}
Mapping<V, D> mapping = mappingBuilder.build();
mappingEvaluator.evaluateMapping(mapping, context, projCtx, task, result);
return mapping;
}
use of com.evolveum.midpoint.prism.ItemDefinition in project midpoint by Evolveum.
the class SearchPanel method createPropertiesList.
private List<Property> createPropertiesList() {
List<Property> list = new ArrayList<>();
Search search = getModelObject();
List<ItemDefinition> defs = search.getAllDefinitions();
for (ItemDefinition def : defs) {
list.add(new Property(def));
}
Collections.sort(list);
return list;
}
use of com.evolveum.midpoint.prism.ItemDefinition in project midpoint by Evolveum.
the class PrismAsserts method assertDefinition.
public static void assertDefinition(Item item, QName type, int minOccurs, int maxOccurs) {
ItemDefinition definition = item.getDefinition();
assertDefinition(definition, item.getElementName(), type, minOccurs, maxOccurs);
}
Aggregations