use of com.evolveum.midpoint.util.annotation.Experimental in project midpoint by Evolveum.
the class ModelObjectResolver method resolveAllReferences.
@Experimental
@Override
public void resolveAllReferences(Collection<PrismContainerValue<?>> pcvs, Object taskObject, OperationResult result) {
Session session = openResolutionSession(null);
Task task = (Task) taskObject;
ConfigurableVisitor<?> visitor = new ConfigurableVisitor() {
@Override
public boolean shouldVisitEmbeddedObjects() {
// e.g. "resolveAllReferencesDeeply".
return false;
}
@Override
public void visit(Visitable visitable) {
if (visitable instanceof PrismReferenceValue) {
resolveReference((PrismReferenceValue) visitable, "resolving object reference", session, task, result);
}
}
};
pcvs.forEach(pcv -> pcv.accept(visitor));
}
use of com.evolveum.midpoint.util.annotation.Experimental in project midpoint by Evolveum.
the class MidpointFunctionsImpl method getFocusObjectReference.
@Experimental
@NotNull
public ObjectReferenceType getFocusObjectReference() {
ObjectType focusObject = getFocusObjectAny();
String oid = focusObject.getOid();
if (oid == null) {
throw new IllegalStateException("No OID in focus object");
}
return ObjectTypeUtil.createObjectRef(focusObject, prismContext);
}
use of com.evolveum.midpoint.util.annotation.Experimental in project midpoint by Evolveum.
the class LinkedObjectsFunctions method findLinkedTargets.
// Should be used after assignment evaluation!
@Experimental
@NotNull
<T extends AssignmentHolderType> List<T> findLinkedTargets(Class<T> type, String archetypeOid) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
Set<PrismReferenceValue> membership = getMembership();
List<PrismReferenceValue> assignedWithMemberRelation = membership.stream().filter(ref -> relationRegistry.isMember(ref.getRelation()) && objectTypeMatches(ref, type)).collect(Collectors.toList());
// TODO deduplicate w.r.t. member/manager
// TODO optimize matching
List<T> objects = new ArrayList<>(assignedWithMemberRelation.size());
for (PrismReferenceValue reference : assignedWithMemberRelation) {
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue(reference);
T object = midpointFunctions.resolveReferenceInternal(ort, true);
if (objectMatches(object, type, archetypeOid)) {
objects.add(object);
}
}
return objects;
}
use of com.evolveum.midpoint.util.annotation.Experimental in project midpoint by Evolveum.
the class SqlRepositoryServiceImpl method modifyObjectDynamically.
@NotNull
@Override
@Experimental
public <T extends ObjectType> ModifyObjectResult<T> modifyObjectDynamically(@NotNull Class<T> type, @NotNull String oid, @Nullable Collection<SelectorOptions<GetOperationOptions>> getOptions, @NotNull ModificationsSupplier<T> modificationsSupplier, RepoModifyOptions modifyOptions, @NotNull OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
Validate.notNull(type, "Object class in delta must not be null.");
Validate.notEmpty(oid, "Oid must not null or empty.");
Validate.notNull(modificationsSupplier, "Modifications supplier must not be null.");
Validate.notNull(parentResult, "Operation result must not be null.");
// TODO executeAttempts?
final String operation = "modifying";
int attempt = 1;
int restarts = 0;
boolean noFetchExtensionValueInsertionForbidden = false;
SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
long opHandle = pm.registerOperationStart(OP_MODIFY_OBJECT_DYNAMICALLY, type);
OperationResult result = parentResult.subresult(MODIFY_OBJECT_DYNAMICALLY).addQualifier(type.getSimpleName()).addParam("type", type.getName()).addParam("oid", oid).build();
ModifyObjectResult<T> rv = null;
try {
while (true) {
try {
ModificationsSupplier<T> innerModificationsSupplier = object -> {
Collection<? extends ItemDelta<?, ?>> modifications = modificationsSupplier.get(object);
checkModifications(modifications);
logNameChange(modifications);
return modifications;
};
rv = objectUpdater.modifyObjectDynamicallyAttempt(type, oid, getOptions, innerModificationsSupplier, modifyOptions, attempt, result, this, noFetchExtensionValueInsertionForbidden);
invokeConflictWatchers((w) -> w.afterModifyObject(oid));
rv.setPerformanceRecord(pm.registerOperationFinish(opHandle, attempt));
return rv;
} catch (RestartOperationRequestedException ex) {
// special case: we want to restart but we do not want to count these
LOGGER.trace("Restarting because of {}", ex.getMessage());
restarts++;
if (restarts > RESTART_LIMIT) {
throw new IllegalStateException("Too many operation restarts");
} else if (ex.isForbidNoFetchExtensionValueAddition()) {
noFetchExtensionValueInsertionForbidden = true;
}
} catch (RuntimeException ex) {
attempt = baseHelper.logOperationAttempt(oid, operation, attempt, ex, result);
pm.registerOperationNewAttempt(opHandle, attempt);
}
}
} catch (Throwable t) {
LOGGER.debug("Got exception while processing dynamic modifications on {}:{}", type.getSimpleName(), oid, t);
pm.registerOperationFinish(opHandle, attempt);
throw t;
} finally {
OperationLogger.logModifyDynamically(type, oid, rv, modifyOptions, result);
}
}
use of com.evolveum.midpoint.util.annotation.Experimental in project midpoint by Evolveum.
the class LocalActivityRun method setTaskObjectRef.
/**
* Updates task objectRef. This is e.g. to allow displaying of all tasks related to given resource.
* Conditions:
*
* 1. task.objectRef has no value yet,
* 2. the value provided by {@link #getDesiredTaskObjectRef()} is non-null.
*
* The method does this recursively towards the root of the task tree.
*/
@Experimental
final void setTaskObjectRef(OperationResult result) throws CommonException {
RunningTask task = getRunningTask();
if (task.getObjectOid() != null) {
LOGGER.trace("Task.objectRef is already set for the current task. We assume it is also set for parent tasks.");
return;
}
ObjectReferenceType desiredObjectRef = getDesiredTaskObjectRef();
LOGGER.trace("Desired task object ref: {}", desiredObjectRef);
if (desiredObjectRef == null) {
return;
}
setObjectRefRecursivelyUpwards(task, desiredObjectRef, result);
}
Aggregations