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");