[midPoint] Access to assignhments in message generation

Алексей Ващенков a.vashchenkov at solarsecurity.ru
Wed May 20 10:12:38 CEST 2015


I need to get assignment name. I found next decision:
            <bodyExpression>
               <script>
                  <code>
            			import com.evolveum.midpoint.wf.impl.processes.common.*;
            			import com.evolveum.midpoint.prism.*;
            			import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
            			import com.evolveum.midpoint.xml.ns.model.workflow.process_instance_state_3.*;
            			import com.evolveum.midpoint.prism.path.*;
            			import com.evolveum.midpoint.model.impl.controller.ModelController;
            			import com.evolveum.midpoint.task.api.Task;
            			import com.evolveum.midpoint.task.api.TaskManager;
            			import com.evolveum.midpoint.schema.result.OperationResult;
            
            			List segments = new ArrayList();
            			segments.add(new NameItemPathSegment(ProcessInstanceState.F_PROCESS_SPECIFIC_STATE));
            			segments.add(new NameItemPathSegment(ItemApprovalProcessState.F_APPROVAL_REQUEST));
            			segments.add(new NameItemPathSegment(ItemApprovalRequestType.F_ITEM_TO_APPROVE));
            			PrismPropertyValue value = (PrismPropertyValue)((PrismProperty)event.getProcessInstanceState().find(new ItemPath(segments))).getValues().get(0);
            
            			PrismReferenceValue reference = ((PrismReference) ((AssignmentType) value.getValue()).asPrismContainerValue().getItems().get(0)).getValue();
            			String oid = reference.getOid();
            			Class clazz = reference.getTargetTypeCompileTimeClass();
            
            			TaskManager taskManager = SpringApplicationContextHolder.getBean(TaskManager.class);
            			Task task = taskManager.createTaskInstance();
            			OperationResult parentResult = task.getResult();

            			PrismObject obj = SpringApplicationContextHolder.getBean(ModelController.class).getObject(clazz, oid, null, task, parentResult);
            
            			body = "Выдаваемое полномочие \""+obj.asObjectable().getName() +"\"";
            		</code>
               </script>
            </bodyExpression>
Is it easier way to take it?
________________________________________
От: midPoint [midpoint-bounces at lists.evolveum.com] от имени Pavol Mederly [mederly at evolveum.com]
Отправлено: 19 мая 2015 г. 16:06
Кому: midPoint General Discussion
Тема: Re: [midPoint] Access to assignhments in message generation

It should be possible. Let event be an instance of WorkItemEvent. Then:

- event.getProcessInstanceState() is an instance of ProcessInstanceState (it maybe will be renamed to ProcessInstanceStateType in later versions of midPoint)
- in its "processorSpecificState" attribute there is an instance of PrimaryChangeProcessorState, which in turn has the attribute "delta"
- delta contains the delta that is being approved

In your case, the delta should contain the assignment that is to be added.

I'm not sure that I've actually tested this, but it should work. If not, just let me know.

Pavol

----- Original Message -----
From: "Алексей Ващенков" <a.vashchenkov at solarsecurity.ru>
To: midpoint at lists.evolveum.com
Sent: Tuesday, May 19, 2015 1:48:04 PM
Subject: [midPoint] Access to assignhments in message generation

Is it possible access to requested assignments while message generation?
_______________________________________________
midPoint mailing list
midPoint at lists.evolveum.com
http://lists.evolveum.com/mailman/listinfo/midpoint
_______________________________________________
midPoint mailing list
midPoint at lists.evolveum.com
http://lists.evolveum.com/mailman/listinfo/midpoint


More information about the midPoint mailing list