ProcessDAO { public List<ProcessInfo> selectProcessListWithExec(Integer processId, Long instanceExecId) { Session session = sessionFactory.openSession(); session.beginTransaction(); List<ProcessInfo> returnProcessList = new ArrayList<ProcessInfo>(); Date vStartTs, vEndTs; try { Criteria checkProcessIdWithIEId = session.createCriteria(InstanceExec.class).add(Restrictions.eq("instanceExecId", instanceExecId)); InstanceExec instanceExec = (InstanceExec) checkProcessIdWithIEId.uniqueResult(); Integer processIdWithIEId = null; if (instanceExec!=null) { processIdWithIEId = instanceExec.getProcess().getProcessId(); LOGGER.info("processIdWithIEId:" + processIdWithIEId); } if (processId.equals(processIdWithIEId)) { vStartTs = instanceExec.getStartTs(); vEndTs = instanceExec.getEndTs(); if (vEndTs == null) { vEndTs = new Date(); } Criteria fetchProcessList = session.createCriteria(Process.class).add(Restrictions.or(Restrictions.eq(PARENTPROCESSID, processId), Restrictions.eq(PROCESSID, processId))).add(Restrictions.eq(DELETE_FLAG, false)); List<Process> processList = fetchProcessList.list(); LOGGER.info("Process list size:" + fetchProcessList.list().size()); fetchProcessList.setProjection(Projections.property(PROCESSID)); List<Integer> processIdList = fetchProcessList.list(); LOGGER.info("process id list size:" + fetchProcessList.list().size()); if (!processIdList.isEmpty()) { Criteria fetchInstanceExecList = session.createCriteria(InstanceExec.class).add(Restrictions.ge("instanceExecId", instanceExecId)).add(Restrictions.in(PARENTPROCESSID, processIdList)).add(Restrictions.between("startTs", vStartTs, vEndTs)); List<InstanceExec> instanceExecList = fetchInstanceExecList.list(); LOGGER.info("instance exec list size:" + fetchInstanceExecList.list().size()); for (InstanceExec ieId : instanceExecList) { LOGGER.info(ieId.getInstanceExecId() + " , " + ieId.getProcess().getProcessId()); } for (Process process : processList) { ProcessInfo processInfo = new ProcessInfo(); processInfo.setProcessId(process.getProcessId()); processInfo.setBusDomainId(process.getBusDomain().getBusDomainId()); processInfo.setProcessTypeId(process.getProcessType().getProcessTypeId()); processInfo.setCanRecover(process.getCanRecover()); processInfo.setDescription(process.getDescription()); if (process.getProcess() != null) { processInfo.setParentProcessId(process.getProcess().getProcessId()); } processInfo.setProcessName(process.getProcessName()); processInfo.setEnqProcessId(process.getEnqueuingProcessId()); processInfo.setNextProcessIds(process.getNextProcessId()); processInfo.setWorkflowId(process.getWorkflowType().getWorkflowId()); processInfo.setBatchCutPattern(process.getBatchCutPattern()); processInfo.setDeleteFlag(process.getDeleteFlag()); for (InstanceExec instanceExec1 : instanceExecList) { if (process.getProcessId().equals(instanceExec1.getProcess().getProcessId())){ processInfo.setInstanceExecId(instanceExec1.getInstanceExecId()); processInfo.setStartTs(instanceExec1.getStartTs()); processInfo.setEndTs(instanceExec1.getEndTs()); if (instanceExec1.getExecStatus() != null) processInfo.setExecState(instanceExec1.getExecStatus().getExecStateId()); } } returnProcessList.add(processInfo); } } for (ProcessInfo processInfo : returnProcessList) { processInfo.setCounter(returnProcessList.size()); } if (!returnProcessList.isEmpty()) { LOGGER.info("processInfo bean:" + returnProcessList.get(0).getCounter()); } } else { Criteria fetchProcessList = session.createCriteria(Process.class).add(Restrictions.or(Restrictions.eq(PARENTPROCESSID, processId), Restrictions.eq(PROCESSID, processId))).add(Restrictions.eq(DELETE_FLAG, false)); List<Process> processList = fetchProcessList.list(); Integer sizeOfProcessList = fetchProcessList.list().size(); LOGGER.info("Process list size:" + sizeOfProcessList); for (Process process : processList) { ProcessInfo processInfo = new ProcessInfo(); processInfo.setProcessId(process.getProcessId()); processInfo.setBusDomainId(process.getBusDomain().getBusDomainId()); processInfo.setProcessTypeId(process.getProcessType().getProcessTypeId()); processInfo.setCanRecover(process.getCanRecover()); processInfo.setDescription(process.getDescription()); if (process.getProcess() != null) { processInfo.setParentProcessId(process.getProcess().getProcessId()); } processInfo.setProcessName(process.getProcessName()); processInfo.setEnqProcessId(process.getEnqueuingProcessId()); processInfo.setNextProcessIds(process.getNextProcessId()); processInfo.setWorkflowId(process.getWorkflowType().getWorkflowId()); processInfo.setBatchCutPattern(process.getBatchCutPattern()); processInfo.setDeleteFlag(process.getDeleteFlag()); processInfo.setCounter(sizeOfProcessList); returnProcessList.add(processInfo); } } session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); throw new MetadataException(e); } finally { session.close(); } return returnProcessList; }  List<com.wipro.ats.bdre.md.dao.jpa.Process> list(Integer pid, Integer processTypeId,Integer pageNum, Integer numResults,String userName); List<com.wipro.ats.bdre.md.dao.jpa.Process> processList(); Integer totalRecordCount(Integer pid,Integer processTypeId); Integer totalCount(); Process get(Integer id); Process getParent(Integer id); Integer insert(Process process); Process update(Process process); void delete(Integer id); void testDelete(Integer id); List<com.wipro.ats.bdre.md.dao.jpa.Process> subProcesslist(Integer processId); String getParentProcessTypeId(Integer pid); String getProcessTypeName(Integer pid); List<Process> selectProcessList(Integer processId); List<Process> selectProcessList(String processCode,String username); Process returnProcess(String processCode,String username); List<Process> returnProcesses(String processCode); void updateProcessId(Integer oldProcessId, Integer newProcessId); Process cloneProcess(Integer processId); List<ProcessInfo> selectProcessListWithExec(Integer processId, Long instanceExecId); List<Process> createOneChildJob(Process parentProcess, Process childProcess, List<Properties> parentProps, List<Properties> childProps ); List<Process> createHiveMigrationJob(Process parentProcess, List<Process> childProcesses, List<Properties> parentProperties); List<Process> createAnalyticsAppJob(Process parentProcess, List<Process> childProcesses, List<Properties> appProperties); List<Process> createDataloadJob(Process parentProcess, List<Process> childProcesses, List<Properties> parentProps, Map<Process,List<Properties>> childProps ); String securityCheck(Integer processId,String username,String action); List<com.wipro.ats.bdre.md.dao.jpa.Process> listByName(String processName); List<Process> getDownStreamProcess(Integer pid);  }
@Test @Ignore public void testSelectProcessListWithExec() throws Exception { List<ProcessInfo> processInfoList = processDAO.selectProcessListWithExec(10802 ,196l); for (ProcessInfo processInfo : processInfoList) { LOGGER.info(processInfo + "\n"); } }