Search in sources :

Example 6 with ProcessObjectResult

use of com.evolveum.midpoint.studio.action.transfer.ProcessObjectResult in project midpoint-studio by Evolveum.

the class TaskUpgradeTask method processObject.

@Override
public ProcessObjectResult processObject(MidPointObject object) throws Exception {
    String oldContent = object.getContent();
    String newContent = MidPointUtils.upgradeTaskToUseActivities(oldContent);
    MidPointObject newObject = MidPointObject.copy(object);
    newObject.setContent(newContent);
    return new ProcessObjectResult(null).object(newObject);
}
Also used : MidPointObject(com.evolveum.midpoint.studio.client.MidPointObject) ProcessObjectResult(com.evolveum.midpoint.studio.action.transfer.ProcessObjectResult)

Example 7 with ProcessObjectResult

use of com.evolveum.midpoint.studio.action.transfer.ProcessObjectResult in project midpoint-studio by Evolveum.

the class ObjectsBackgroundableTask method processObjects.

protected ProcessFileObjectsResult processObjects(ProgressIndicator indicator, List<MidPointObject> objects, VirtualFile file) {
    if (objects.isEmpty()) {
        state.incrementSkippedFile();
        midPointService.printToConsole(null, RefreshAction.class, "Skipped file " + (file != null ? file.getPath() : "<unknown>") + " no objects found (parsed).");
        return new ProcessFileObjectsResult();
    }
    List<String> newObjects = new ArrayList<>();
    boolean stop = false;
    int current = 0;
    for (MidPointObject object : objects) {
        ProgressManager.checkCanceled();
        current++;
        if (indicator != null) {
            indicator.setFraction((double) current / objects.size());
        }
        if (shouldSkipObjectProcessing(object)) {
            newObjects.add(object.getContent());
            state.incrementSkipped();
            continue;
        }
        ProcessObjectResult result = processObject(object, new ExtendedCallable<>() {

            @Override
            public String describe() {
                return object.getName() + "(" + object.getOid() + ")";
            }

            @Override
            public ProcessObjectResult call() throws Exception {
                return processObject(object);
            }
        });
        if (!result.shouldContinue()) {
            state.setStopOnError();
            stop = true;
            break;
        }
        MidPointObject newObject = result.object();
        if (newObject != null) {
            newObjects.add(newObject.getContent());
        }
    }
    return new ProcessFileObjectsResult(newObjects, stop);
}
Also used : MidPointObject(com.evolveum.midpoint.studio.client.MidPointObject) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ProcessObjectResult(com.evolveum.midpoint.studio.action.transfer.ProcessObjectResult)

Example 8 with ProcessObjectResult

use of com.evolveum.midpoint.studio.action.transfer.ProcessObjectResult in project midpoint-studio by Evolveum.

the class ObjectsBackgroundableTask method processObject.

private ProcessObjectResult processObject(MidPointObject object, ExtendedCallable<ProcessObjectResult> callable) {
    try {
        ProcessObjectResult processResult = callable.call();
        if (processResult.problem()) {
            state.incrementFailed();
        } else {
            state.incrementProcessed();
        }
        return processResult;
    } catch (Exception ex) {
        state.incrementFailed();
        publishException(midPointService, "Exception occurred during '" + getTitle() + "' of '" + callable.describe() + "'", ex);
    }
    ProcessObjectResult result = new ProcessObjectResult(null);
    result.object(object);
    result.shouldContinue(!isShouldStopOnError());
    return result;
}
Also used : IOException(java.io.IOException) ProcessObjectResult(com.evolveum.midpoint.studio.action.transfer.ProcessObjectResult)

Example 9 with ProcessObjectResult

use of com.evolveum.midpoint.studio.action.transfer.ProcessObjectResult in project midpoint-studio by Evolveum.

the class ObjectsBackgroundableTask method processOidsList.

private boolean processOidsList(ProgressIndicator indicator) {
    if (!confirmedOperation(oids.size(), ConfirmationUnit.OBJECT)) {
        return false;
    }
    int i = 0;
    for (Pair<String, ObjectTypes> pair : oids) {
        ProgressManager.checkCanceled();
        i++;
        indicator.setFraction((double) i / oids.size());
        ProcessObjectResult result = processObject(null, new ExtendedCallable<>() {

            @Override
            public String describe() {
                return pair.getFirst() + "(" + pair.getSecond() + ")";
            }

            @Override
            public ProcessObjectResult call() throws Exception {
                return processObjectOid(pair.getSecond(), pair.getFirst());
            }
        });
        if (!result.shouldContinue()) {
            state.setStopOnError();
            break;
        }
    }
    return true;
}
Also used : ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) IOException(java.io.IOException) ProcessObjectResult(com.evolveum.midpoint.studio.action.transfer.ProcessObjectResult)

Aggregations

ProcessObjectResult (com.evolveum.midpoint.studio.action.transfer.ProcessObjectResult)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 MidPointObject (com.evolveum.midpoint.studio.client.MidPointObject)3 IOException (java.io.IOException)3 ExecuteScriptResponseType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ExecuteScriptResponseType)2 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)2 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)1 DeleteOptions (com.evolveum.midpoint.studio.client.DeleteOptions)1 BulkActionGenerator (com.evolveum.midpoint.studio.impl.browse.BulkActionGenerator)1 GeneratorOptions (com.evolveum.midpoint.studio.impl.browse.GeneratorOptions)1 ArrayList (java.util.ArrayList)1