Package org.enhydra.shark.api.client.wfservice

Examples of org.enhydra.shark.api.client.wfservice.AdminMisc


            WfProcessMgr wfProcessMgr = wfProcess.manager();
            String processInstanceId = wfProcess.key();
            String processDefId = wfProcessMgr.name();

            //get limit
            AdminMisc admin = shark.getAdminMisc();
            WMEntity actEnt = admin.getActivityDefinitionInfo(sessionHandle, processInstanceId, activityInstanceId);

            WMFilter filter = new WMFilter();
            filter.setFilterType(XPDLBrowser.SIMPLE_TYPE_XPDL);
            filter.setAttributeName("Name");
            filter.setFilterString("Limit");

            WMAttributeIterator actAttributeIterator = xpdl.listAttributes(sessionHandle, actEnt, filter, true);
            WMAttribute[] actAttributeList = null;
            if (actAttributeIterator != null) {
                actAttributeList = actAttributeIterator.getArray();
            }

            // retrieve the user who accepted the particular activity
            String username = admin.getActivityResourceUsername(sessionHandle, processInstanceId, activityInstanceId);
            wfAct.setNameOfAcceptedUser(username);

            double limit = -1;
            if (actAttributeList != null) {
                if (actAttributeList[0].getValue() != null && !actAttributeList[0].getValue().equals("")) {
                    try {
                        limit = Double.parseDouble((String) actAttributeList[0].getValue());
                    } catch (Exception e) {}
                }
            }

            filter = new WMFilter();
            filter.setFilterType(XPDLBrowser.SIMPLE_TYPE_XPDL);
            filter.setAttributeName("Name");
            filter.setFilterString("Performer");

            actAttributeIterator = xpdl.listAttributes(sessionHandle, actEnt, filter, true);
            actAttributeList = null;
            if (actAttributeIterator != null) {
                actAttributeList = actAttributeIterator.getArray();
            }

            if (actAttributeList != null) {
                String state = wfActivity.state();
                if (state.equals(SharkConstants.STATE_OPEN_NOT_RUNNING_NOT_STARTED)) {
                    wfAct.setStatus("Pending");
                } else if (state.equals(SharkConstants.STATE_CLOSED_COMPLETED)) {
                    wfAct.setStatus("Completed");
                } else if (state.equals(SharkConstants.STATE_CLOSED_ABORTED)) {
                    wfAct.setStatus("Aborted");
                } else {
                    wfAct.setStatus("Accepted");
                }

                wfAct.setPerformer((String) actAttributeList[0].getValue());
            }

            if (includeAssignees) {
                List<String> users = getAssignmentResourceIds(processDefId, processInstanceId, activityInstanceId);
                Collections.sort(users);
                if (users != null) {
                    wfAct.setAssignmentUsers(users.toArray(new String[users.size()]));
                }
            }

            String durationUnit = "";
            if (limit != -1) {
                //get duration unit
                filter = new WMFilter();
                filter.setFilterType(XPDLBrowser.SIMPLE_TYPE_XPDL);
                filter.setAttributeName("Type");
                filter.setFilterString("ProcessHeader");

                WMEntity procEnt = admin.getProcessDefinitionInfo(sessionHandle, processInstanceId);
                WMEntityIterator procEntityIterator = xpdl.listEntities(sessionHandle, procEnt, filter, true);
                WMEntity[] procEntityList = null;
                if (procEntityIterator != null) {
                    procEntityList = procEntityIterator.getArray();
                }

                if (procEntityList != null) {
                    WMEntity ent = procEntityList[0];

                    filter = new WMFilter();
                    filter.setFilterType(XPDLBrowser.SIMPLE_TYPE_XPDL);
                    filter.setAttributeName("Name");
                    filter.setFilterString("DurationUnit");

                    WMAttributeIterator procAttributeIterator = xpdl.listAttributes(sessionHandle, ent, filter, true);
                    WMAttribute[] procAttributeList = null;
                    if (procAttributeIterator != null) {
                        procAttributeList = procAttributeIterator.getArray();
                    }

                    if (procAttributeList != null) {
                        durationUnit = (String) procAttributeList[0].getValue();
                    }
                }
            }

            Calendar calendar = Calendar.getInstance();

            long createdTime = admin.getActivityCreatedTime(sessionHandle, processInstanceId, activityInstanceId);
            long startedTime = admin.getActivityStartedTime(sessionHandle, processInstanceId, activityInstanceId);

            if (startedTime != SharkConstants.UNDEFINED_TIME) {
                calendar.setTimeInMillis(startedTime);
                wfAct.setStartedTime(calendar.getTime());
            }

            calendar.setTimeInMillis(createdTime);
            wfAct.setCreatedTime(calendar.getTime());

            if (limit != -1) {
                if (!durationUnit.equals("")) {
                    if (durationUnit.equals("D")) {
                        wfAct.setLimitInSeconds(Math.round(limit * 24 * 60 * 60));
                        wfAct.setLimit(limit + " day");
                    } else if (durationUnit.equals("h")) {
                        wfAct.setLimitInSeconds(Math.round(limit * 60 * 60));
                        wfAct.setLimit(limit + " hour(s)");
                    } else if (durationUnit.equals("m")) {
                        wfAct.setLimitInSeconds(Math.round(limit * 60));
                        wfAct.setLimit(limit + " minute(s)");
                    } else if (durationUnit.equals("s")) {
                        wfAct.setLimitInSeconds(Math.round(limit));
                        wfAct.setLimit(limit + " second(s)");
                    }
                    wfAct.setDue(getDueDateProceedByPlugin(processInstanceId, activityInstanceId, wfAct.getLimitInSeconds(), wfAct.getCreatedTime(), wfAct.getStartedTime()));
                }
            }

            Date currentDate = new Date();

            if (wfActivity.state().equals(SharkConstants.STATE_CLOSED_COMPLETED)) {
                Calendar completionCal = Calendar.getInstance();
                Calendar dueCal = Calendar.getInstance();

                long finishTime = admin.getActivityFinishTime(sessionHandle, processInstanceId, activityInstanceId);

                completionCal.setTimeInMillis(finishTime);
                wfAct.setFinishTime(completionCal.getTime());
                //completion minus due if completion date is after due date, vice versa otherwise
                if (wfAct.getDue() != null && wfAct.getFinishTime().after(wfAct.getDue())) {
View Full Code Here


            result.setProcess(processStarted);

            //redirect to assignment view accordingly
            if (wfProcess != null && !startManually) {
                Shark shark = Shark.getInstance();
                AdminMisc admin = shark.getAdminMisc();
                WMSessionHandle sessionHandle = sc.getSessionHandle();

                XPDLBrowser xpdl = shark.getXPDLBrowser();
                WfActivity[] activityList = wfProcess.get_sequence_step(0);
                WorkflowActivity activity = getNextActivity(sessionHandle, mgr, admin, xpdl, wfProcess.key(), activityList);
View Full Code Here

                    //process activity name variable
                    ass.setActivityName(WorkflowUtil.processVariable(ass.getActivityName(), null, ass));
                }

                Shark shark = Shark.getInstance();
                AdminMisc admin = shark.getAdminMisc();
                WMSessionHandle sessionHandle = sc.getSessionHandle();
                WMEntity ent = admin.getActivityDefinitionInfo(sessionHandle, process.key(), activity.key());
                ass.setActivityDefId(ent.getId());
                ass.setProcessRequesterId(getUserByProcessIdAndActivityDefId(ass.getProcessDefId(), ass.getProcessId(), WorkflowUtil.ACTIVITY_DEF_ID_RUN_PROCESS));

                WfRequester requester = process.requester();
                if (requester != null) {
View Full Code Here

                sc = connect();

                WfProcess wfProcess = sc.getProcess(processId);
                if (wfProcess != null) {
                    Shark shark = Shark.getInstance();
                    AdminMisc admin = shark.getAdminMisc();
                    WMSessionHandle sessionHandle = sc.getSessionHandle();
                    XPDLBrowser xpdl = shark.getXPDLBrowser();

                    WfActivity[] activityList = wfProcess.get_sequence_step(0);
                    WorkflowActivity activity = getNextActivity(sessionHandle, wfProcess.manager(), admin, xpdl, wfProcess.key(), activityList);
View Full Code Here

            WMSessionHandle sessionHandle = sc.getSessionHandle();
            Shark shark = Shark.getInstance();

            // get required activity def to start
            AdminMisc admin = shark.getAdminMisc();
            WMEntity procEntity = admin.getProcessDefinitionInfo(sessionHandle, processId);
            XPDLBrowser xpdlBrowser = shark.getXPDLBrowser();
            WMEntity[] entities = WMEntityUtilities.getOverallActivities(sessionHandle, xpdlBrowser, procEntity);
            WMEntity activityDef = null;
            for (WMEntity ent : entities) {
                if (ent.getId().equals(activityDefId) && "Activity".equals(ent.getType())) {
View Full Code Here

        try {

            sc = connect();

            Shark shark = Shark.getInstance();
            AdminMisc admin = shark.getAdminMisc();
            WMSessionHandle sessionHandle = sc.getSessionHandle();

            WfProcess process = sc.getProcess(processId);

            if (process != null) {
                if (activityDefId.equals(WorkflowUtil.ACTIVITY_DEF_ID_RUN_PROCESS)) {
                    return admin.getProcessRequesterUsername(sessionHandle, processId);
                } else {
                    WfActivityIterator iter = process.get_iterator_step();

                    for (int i = 0; i < iter.how_many(); i++) {
                        WfActivity activity = iter.get_next_object();

                        if (activity != null) {
                            WMEntity entity = admin.getActivityDefinitionInfo(sessionHandle, activity.container().key(), activity.key());

                            if (entity.getId().equals(activityDefId)) {
                                return admin.getActivityResourceUsername(sessionHandle, activity.container().key(), activity.key());
                            }
                        }
                    }
                }
            }
View Full Code Here

        try {
            sc = connect();

            Shark shark = Shark.getInstance();
            AdminMisc admin = shark.getAdminMisc();
            XPDLBrowser xpdlBrowser = shark.getXPDLBrowser();
            for (Iterator<WorkflowAssignment> i = assignmentList.iterator(); i.hasNext();) {
                WorkflowAssignment assignment = (WorkflowAssignment) i.next();


                // get activity and process
                WMSessionHandle sessionHandle = sc.getSessionHandle();
                WMEntity activityEntity = admin.getActivityDefinitionInfo(sessionHandle, assignment.getProcessId(), assignment.getActivityId());

                // get performer
                WMFilter filter = new WMFilter("Name", WMFilter.EQ, "Performer");
                filter.setFilterType(XPDLBrowser.SIMPLE_TYPE_XPDL);
                WMAttribute[] performers = xpdlBrowser.listAttributes(sessionHandle, activityEntity, filter, true).getArray();
View Full Code Here

TOP

Related Classes of org.enhydra.shark.api.client.wfservice.AdminMisc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.