* @param packageId
* @param version
*/
public void processDeleteAndUnloadVersion(String packageId, String version) {
SharkConnection sc = null;
try {
sc = connect();
// delete process instances
LogUtil.info(getClass().getName(), "Deleting running processes for " + packageId + " version " + version);
Shark shark = Shark.getInstance();
ExecutionAdministration ea = shark.getExecutionAdministration();
WAPI wapi = shark.getWAPIConnection();
WfProcessIterator wpi = sc.get_iterator_process();
ProcessFilterBuilder fb = shark.getProcessFilterBuilder();
WMSessionHandle sessionHandle = sc.getSessionHandle();
WMFilter filter1 = fb.addPackageIdEquals(sessionHandle, packageId);
WMFilter filter2 = fb.addVersionEquals(sessionHandle, version);
WMFilter filter = fb.and(sessionHandle, filter1, filter2);
wpi.set_query_expression(fb.toIteratorExpression(sessionHandle, filter));
WfProcess[] procs = wpi.get_next_n_sequence(0);