Search in sources :

Example 6 with TaskInstanceVO

use of com.centurylink.mdw.model.value.task.TaskInstanceVO in project mdw-designer by CenturyLinkCloud.

the class TaskInstancesSection method createContextMenu.

private Menu createContextMenu(Shell shell) {
    Menu menu = new Menu(shell, SWT.POP_UP);
    StructuredSelection selection = (StructuredSelection) tableEditor.getTableViewer().getSelection();
    if (selection.size() == 1 && selection.getFirstElement() instanceof TaskInstanceVO) {
        final TaskInstanceVO taskInstanceVO = (TaskInstanceVO) selection.getFirstElement();
        // view
        MenuItem taskMgrItem = new MenuItem(menu, SWT.PUSH);
        taskMgrItem.setText("View in Task Manager");
        ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/taskmgr.gif");
        taskMgrItem.setImage(imageDesc.createImage());
        taskMgrItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                openTaskInstance(taskInstanceVO);
            }
        });
    }
    return menu;
}
Also used : TaskInstanceVO(com.centurylink.mdw.model.value.task.TaskInstanceVO) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Menu(org.eclipse.swt.widgets.Menu)

Example 7 with TaskInstanceVO

use of com.centurylink.mdw.model.value.task.TaskInstanceVO in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getTaskInstances.

private List<TaskInstanceVO> getTaskInstances(ProcessVO process, ProcessInstanceVO processInstance, Long activityId, List<TaskInstanceVO> allTaskInstances) throws DataAccessException {
    List<TaskInstanceVO> taskInstances = new ArrayList<>();
    for (TaskInstanceVO taskInstance : allTaskInstances) {
        String secondaryOwner = taskInstance.getSecondaryOwnerType();
        if (OwnerType.DOCUMENT.equals(secondaryOwner) || "EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner)) {
            String formDataString = null;
            if (OwnerType.DOCUMENT.equals(secondaryOwner))
                formDataString = rtinfo.getDocument(taskInstance.getSecondaryOwnerId()).getContent();
            else if ("EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner))
                formDataString = rtinfo.getExternalEventDetails(taskInstance.getSecondaryOwnerId());
            FormDataDocument formDataDoc = new FormDataDocument();
            try {
                formDataDoc.load(formDataString);
                for (ActivityInstanceVO activityInstance : processInstance.getActivityInstances(activityId)) {
                    if (activityInstance.getId().equals(formDataDoc.getActivityInstanceId()))
                        taskInstances.add(taskInstance);
                }
            } catch (MbengException ex) {
                throw new DataAccessException(-1, ex.getMessage(), ex);
            }
        } else {
            // task instance secondary owner is work transition instance
            Long workTransInstId = taskInstance.getSecondaryOwnerId();
            for (WorkTransitionInstanceVO transitionInstance : processInstance.getTransitions()) {
                if (transitionInstance.getTransitionInstanceID().equals(workTransInstId)) {
                    Long transitionId = transitionInstance.getTransitionID();
                    WorkTransitionVO workTrans = process.getWorkTransition(transitionId);
                    if (workTrans == null && process.getSubProcesses() != null) {
                        for (ProcessVO subproc : process.getSubProcesses()) {
                            workTrans = subproc.getWorkTransition(transitionId);
                            if (workTrans != null)
                                break;
                        }
                    }
                    if (workTrans != null && workTrans.getToWorkId().equals(activityId))
                        taskInstances.add(taskInstance);
                }
            }
        }
    }
    return taskInstances;
}
Also used : MbengException(com.qwest.mbeng.MbengException) WorkTransitionInstanceVO(com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO) WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) TaskInstanceVO(com.centurylink.mdw.model.value.task.TaskInstanceVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) FormDataDocument(com.centurylink.mdw.model.FormDataDocument) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 8 with TaskInstanceVO

use of com.centurylink.mdw.model.value.task.TaskInstanceVO in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getTaskInstances.

/**
 * Returns a map relating activityId to taskInstances for a processInstance.
 * Requires a list of task activities which have instances as a parameter.
 */
public Map<Long, List<TaskInstanceVO>> getTaskInstances(ProcessVO process, ProcessInstanceVO processInstance, List<Long> taskActivityIds) throws DataAccessException {
    Map<Long, List<TaskInstanceVO>> taskInstances = new HashMap<>();
    List<TaskInstanceVO> allTaskInstances = getTaskInstancesForProcessInstance(processInstance.getId());
    for (Long actId : taskActivityIds) {
        List<TaskInstanceVO> actTaskInstances = getTaskInstances(process, processInstance, actId, allTaskInstances);
        if (!actTaskInstances.isEmpty()) {
            List<TaskInstanceVO> subTaskInstances = new ArrayList<>();
            for (TaskInstanceVO taskInstance : allTaskInstances) {
                String secondaryOwner = taskInstance.getSecondaryOwnerType();
                if (OwnerType.TASK_INSTANCE.equals(secondaryOwner)) {
                    for (TaskInstanceVO masterInstance : actTaskInstances) {
                        if (masterInstance.getTaskInstanceId().equals(taskInstance.getSecondaryOwnerId()))
                            subTaskInstances.add(taskInstance);
                    }
                }
            }
            actTaskInstances.addAll(subTaskInstances);
            taskInstances.put(actId, actTaskInstances);
        }
    }
    return taskInstances;
}
Also used : HashMap(java.util.HashMap) TaskInstanceVO(com.centurylink.mdw.model.value.task.TaskInstanceVO) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ProcessList(com.centurylink.mdw.model.value.process.ProcessList)

Aggregations

TaskInstanceVO (com.centurylink.mdw.model.value.task.TaskInstanceVO)8 ArrayList (java.util.ArrayList)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)2 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)2 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)2 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)2 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)2 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 Menu (org.eclipse.swt.widgets.Menu)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)1 TranslationException (com.centurylink.mdw.common.exception.TranslationException)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)1 FormDataDocument (com.centurylink.mdw.model.FormDataDocument)1