Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Feb 20, 2019
2 parents 76fa7f5 + 6171c27 commit 0e12126
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
Expand Up @@ -29,6 +29,8 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.statistics.StatisticsUtil;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.task.api.RunningTask;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
Expand Down Expand Up @@ -134,19 +136,24 @@ public long recordStart(ExecutionContext context, ObjectType objectType) {

public void recordEnd(ExecutionContext context, ObjectType objectType, long started, Throwable ex) {
if (context.isRecordProgressAndIterationStatistics()) {
if (context.getTask() != null && objectType != null) {
context.getTask().recordIterativeOperationEnd(
Task task = context.getTask();
if (task != null && objectType != null) {
task.recordIterativeOperationEnd(
PolyString.getOrig(objectType.getName()),
StatisticsUtil.getDisplayName(objectType.asPrismObject()),
StatisticsUtil.getObjectType(objectType, prismContext),
objectType.getOid(),
started, ex);
} else {
LOGGER.warn("Couldn't record operation end in script execution; task = {}, objectType = {}",
context.getTask(), objectType);
task, objectType);
}
if (context.getTask() != null) {
context.getTask().setProgress(context.getTask().getProgress() + 1);
if (task != null) {
if (task instanceof RunningTask) {
((RunningTask) task).incrementProgressAndStoreStatsIfNeeded();
} else {
task.setProgress(task.getProgress() + 1);
}
}
}
}
Expand Down
54 changes: 54 additions & 0 deletions samples/tasks/bulk-actions/script-objects-delay.xml
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<objects xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<task>
<name>Waits on each object</name>
<extension>
<scext:executeScript xmlns:scext="http://midpoint.evolveum.com/xml/ns/public/model/scripting/extension-3">
<s:search xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3">
<s:type>ObjectType</s:type>
<s:action>
<s:type>execute-script</s:type>
<s:parameter>
<s:name>script</s:name>
<c:value xsi:type="c:ScriptExpressionEvaluatorType">
<c:code>
log.info('Waiting on: {}', input)
Thread.sleep(15000)
log.info('Done waiting on: {}', input)
</c:code>
</c:value>
</s:parameter>
</s:action>
</s:search>
</scext:executeScript>
</extension>
<ownerRef oid="00000000-0000-0000-0000-000000000002"/>
<executionStatus>runnable</executionStatus>

<category>BulkActions</category>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/scripting/handler-3</handlerUri>
<recurrence>single</recurrence>
</task>

</objects>

0 comments on commit 0e12126

Please sign in to comment.