List of usage examples for org.apache.commons.lang.mutable MutableBoolean getValue
public Object getValue()
From source file:com.evolveum.midpoint.model.impl.lens.projector.ActivationProcessor.java
private <F extends FocusType> boolean evaluateExistenceMapping(final LensContext<F> context, final LensProjectionContext accCtx, final XMLGregorianCalendar now, final boolean current, Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { final String accCtxDesc = accCtx.toHumanReadableString(); final Boolean legal = accCtx.isLegal(); if (legal == null) { throw new IllegalStateException("Null 'legal' for " + accCtxDesc); }//from w w w. ja v a 2 s . c om ResourceObjectTypeDefinitionType resourceAccountDefType = accCtx.getResourceObjectTypeDefinitionType(); if (resourceAccountDefType == null) { return legal; } ResourceActivationDefinitionType activationType = resourceAccountDefType.getActivation(); if (activationType == null) { return legal; } ResourceBidirectionalMappingType existenceType = activationType.getExistence(); if (existenceType == null) { return legal; } List<MappingType> outbound = existenceType.getOutbound(); if (outbound == null || outbound.isEmpty()) { // "default mapping" return legal; } MappingInitializer<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> initializer = new MappingInitializer<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>>() { @Override public void initialize( Mapping<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> existenceMapping) throws SchemaException { // Source: legal ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> legalSourceIdi = getLegalIdi( accCtx); Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> legalSource = new Source<>( legalSourceIdi, ExpressionConstants.VAR_LEGAL); existenceMapping.setDefaultSource(legalSource); // Source: assigned ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> assignedIdi = getAssignedIdi( accCtx); Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> assignedSource = new Source<>( assignedIdi, ExpressionConstants.VAR_ASSIGNED); existenceMapping.addSource(assignedSource); // Source: focusExists ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> focusExistsSourceIdi = getFocusExistsIdi( context.getFocusContext()); Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> focusExistsSource = new Source<>( focusExistsSourceIdi, ExpressionConstants.VAR_FOCUS_EXISTS); existenceMapping.addSource(focusExistsSource); // Variable: focus existenceMapping.addVariableDefinition(ExpressionConstants.VAR_FOCUS, context.getFocusContext().getObjectDeltaObject()); // Variable: user (for convenience, same as "focus") existenceMapping.addVariableDefinition(ExpressionConstants.VAR_USER, context.getFocusContext().getObjectDeltaObject()); // Variable: shadow existenceMapping.addVariableDefinition(ExpressionConstants.VAR_SHADOW, accCtx.getObjectDeltaObject()); // Variable: resource existenceMapping.addVariableDefinition(ExpressionConstants.VAR_RESOURCE, accCtx.getResource()); existenceMapping.setOriginType(OriginType.OUTBOUND); existenceMapping.setOriginObject(accCtx.getResource()); } }; final MutableBoolean output = new MutableBoolean(false); MappingOutputProcessor<PrismPropertyValue<Boolean>> processor = new MappingOutputProcessor<PrismPropertyValue<Boolean>>() { @Override public void process(ItemPath mappingOutputPath, PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple) throws ExpressionEvaluationException { if (outputTriple == null) { // The "default existence mapping" output.setValue(legal); return; } Collection<PrismPropertyValue<Boolean>> nonNegativeValues = outputTriple.getNonNegativeValues(); if (nonNegativeValues == null || nonNegativeValues.isEmpty()) { throw new ExpressionEvaluationException( "Activation existence expression resulted in null or empty value for projection " + accCtxDesc); } if (nonNegativeValues.size() > 1) { throw new ExpressionEvaluationException( "Activation existence expression resulted in too many values (" + nonNegativeValues.size() + ") for projection " + accCtxDesc); } output.setValue(nonNegativeValues.iterator().next().getValue()); } }; MappingEvaluatorParams<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>, ShadowType, F> params = new MappingEvaluatorParams<>(); params.setMappingTypes(outbound); params.setMappingDesc("outbound existence mapping in projection " + accCtxDesc); params.setNow(now); params.setInitializer(initializer); params.setProcessor(processor); params.setAPrioriTargetObject(accCtx.getObjectOld()); params.setEvaluateCurrent(current); params.setTargetContext(accCtx); params.setFixTarget(true); params.setContext(context); PrismPropertyDefinition<Boolean> shadowExistsDef = new PrismPropertyDefinition<Boolean>( SHADOW_EXISTS_PROPERTY_NAME, DOMUtil.XSD_BOOLEAN, prismContext); shadowExistsDef.setMinOccurs(1); shadowExistsDef.setMaxOccurs(1); params.setTargetItemDefinition(shadowExistsDef); mappingHelper.evaluateMappingSetProjection(params, task, result); // PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = mappingHelper.evaluateMappingSetProjection( // outbound, "outbound existence mapping in projection " + accCtxDesc, // now, initializer, null, null, accCtx.getObjectOld(), current, null, context, accCtx, task, result); return (boolean) output.getValue(); }