use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.
the class ShadowDiscriminatorObjectDelta method createModificationReplaceProperty.
/**
* Convenience method for quick creation of object deltas that replace a single object property. This is used quite often
* to justify a separate method.
*/
public static <O extends Objectable, X> ShadowDiscriminatorObjectDelta<O> createModificationReplaceProperty(Class<O> type, String resourceOid, ShadowKindType kind, String intent, ItemPath propertyPath, PrismContext prismContext, X... propertyValues) {
ShadowDiscriminatorObjectDelta<O> objectDelta = new ShadowDiscriminatorObjectDelta<O>(type, ChangeType.MODIFY, prismContext);
objectDelta.setDiscriminator(new ResourceShadowDiscriminator(resourceOid, kind, intent));
fillInModificationReplaceProperty(objectDelta, propertyPath, propertyValues);
return objectDelta;
}
use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.
the class ChangeExecutor method prepareScripts.
private <F extends ObjectType, T extends ObjectType> OperationProvisioningScriptsType prepareScripts(PrismObject<T> changedObject, LensContext<F> context, LensElementContext<T> objectContext, ProvisioningOperationTypeType operation, ResourceType resource, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
if (resource == null) {
LOGGER.warn("Resource does not exist. Skipping processing scripts.");
return null;
}
OperationProvisioningScriptsType resourceScripts = resource.getScripts();
PrismObject<? extends ShadowType> resourceObject = (PrismObject<? extends ShadowType>) changedObject;
PrismObject<F> user = null;
if (context.getFocusContext() != null) {
if (context.getFocusContext().getObjectNew() != null) {
user = context.getFocusContext().getObjectNew();
} else if (context.getFocusContext().getObjectOld() != null) {
user = context.getFocusContext().getObjectOld();
}
}
ResourceShadowDiscriminator discr = ((LensProjectionContext) objectContext).getResourceShadowDiscriminator();
ExpressionVariables variables = Utils.getDefaultExpressionVariables(user, resourceObject, discr, resource.asPrismObject(), context.getSystemConfiguration(), objectContext);
return evaluateScript(resourceScripts, discr, operation, null, variables, context, objectContext, task, result);
}
use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.
the class LensProjectionContext method getResourceObjectTypeDefinitionType.
public ResourceObjectTypeDefinitionType getResourceObjectTypeDefinitionType() {
if (synchronizationPolicyDecision == SynchronizationPolicyDecision.BROKEN) {
return null;
}
ResourceShadowDiscriminator discr = getResourceShadowDiscriminator();
if (discr == null) {
// maybe when an account is deleted
return null;
}
if (resource == null) {
return null;
}
ResourceObjectTypeDefinitionType def = ResourceTypeUtil.getResourceObjectTypeDefinitionType(resource, discr.getKind(), discr.getIntent());
return def;
}
use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.
the class LensProjectionContext method getHumanReadableName.
public String getHumanReadableName() {
if (humanReadableName == null) {
StringBuilder sb = new StringBuilder();
sb.append("account(");
String humanReadableAccountIdentifier = getHumanReadableIdentifier();
if (StringUtils.isEmpty(humanReadableAccountIdentifier)) {
sb.append("no ID");
} else {
sb.append("ID ");
sb.append(humanReadableAccountIdentifier);
}
ResourceShadowDiscriminator discr = getResourceShadowDiscriminator();
if (discr != null) {
sb.append(", type '");
sb.append(discr.getIntent());
sb.append("', ");
if (discr.getOrder() != 0) {
sb.append("order ").append(discr.getOrder()).append(", ");
}
} else {
sb.append(" (no discriminator) ");
}
sb.append(getResource());
sb.append(")");
humanReadableName = sb.toString();
}
return humanReadableName;
}
use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.
the class LensUtil method setContextOid.
public static <T extends ObjectType, F extends ObjectType> void setContextOid(LensContext<F> context, LensElementContext<T> objectContext, String oid) {
objectContext.setOid(oid);
// Check if we need to propagate this oid also to higher-order contexts
if (!(objectContext instanceof LensProjectionContext)) {
return;
}
LensProjectionContext refProjCtx = (LensProjectionContext) objectContext;
ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator();
if (refDiscr == null) {
return;
}
for (LensProjectionContext aProjCtx : context.getProjectionContexts()) {
ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator();
if (aDiscr != null && refDiscr.equivalent(aDiscr) && (refDiscr.getOrder() < aDiscr.getOrder())) {
aProjCtx.setOid(oid);
}
}
}
Aggregations