GetDotStringDAO { public List<String> getDotString(Integer processId) { List<String> dotStringList = new ArrayList<String>(); Session session = sessionFactory.openSession(); try { session.beginTransaction(); List<String> srcTargetNodeIdList = new ArrayList<String>(); Criteria fetchListOfSubProcess = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.Process.class).add(Restrictions.eq("process.processId", processId)).setProjection(Projections.property(PROCESSID)); LOGGER.info("Number of sub processes:" + fetchListOfSubProcess.list().size()); List<Integer> subProcessList = fetchListOfSubProcess.list(); if (!fetchListOfSubProcess.list().isEmpty()) { Criteria fetchMaxIeId = session.createCriteria(LineageQuery.class).setProjection(Projections.groupProperty(PROCESSID)).add(Restrictions.in(PROCESSID, subProcessList)).setProjection(Projections.max("instanceExecId")); List<Long> maxIeIdList = fetchMaxIeId.list(); LOGGER.info("max instance exec Id list size:" + fetchMaxIeId.list().size()); if (!fetchMaxIeId.list().isEmpty()) { Criteria fetchQueryId = session.createCriteria(LineageQuery.class).add(Restrictions.in("instanceExecId", maxIeIdList)).setProjection(Projections.property("queryId")); LOGGER.info("Number of query ids fetched:" + fetchQueryId.list().size()); List<String> queryIdList = fetchQueryId.list(); if (!fetchQueryId.list().isEmpty()) { Criteria fetchSrcNodeId = session.createCriteria(LineageRelation.class).add(Restrictions.in(LINEAGEQUARYID, queryIdList)).setProjection(Projections.property("lineageNodeBySrcNodeId.nodeId")); LOGGER.info("Source node id list size:" + fetchSrcNodeId.list().size()); List<String> srcNodeIdList = fetchSrcNodeId.list(); Criteria fetchTargetNodeId = session.createCriteria(LineageRelation.class).add(Restrictions.in(LINEAGEQUARYID, queryIdList)).setProjection(Projections.property("lineageNodeByTargetNodeId.nodeId")); LOGGER.info("Target node id list size:" + fetchTargetNodeId.list().size()); List<String> targetNodeIdList = fetchTargetNodeId.list(); for (String srcNodeId : srcNodeIdList) { srcTargetNodeIdList.add(srcNodeId); } for (String targetNodeId : targetNodeIdList) { srcTargetNodeIdList.add(targetNodeId); } if (!srcTargetNodeIdList.isEmpty()) { Criteria fetchSpecificNodeTypeIdDotString = session.createCriteria(LineageNode.class).add(Restrictions.in("lineageNodeType.nodeTypeId", new Integer[]{3, 4, 5, 6})).add(Restrictions.in(NODEID, srcTargetNodeIdList)).setProjection(Projections.property(DOTSTRING)); List<String> specificNodeTypeIdDotString = fetchSpecificNodeTypeIdDotString.list(); for (String dotString : specificNodeTypeIdDotString) { dotStringList.add(dotString); } Criteria fetchContainerNodeId = session.createCriteria(LineageNode.class).add(Restrictions.eq("lineageNodeType.nodeTypeId", 2)).add(Restrictions.in(NODEID, srcTargetNodeIdList)).setProjection(Projections.property("lineageNode.nodeId")); List<String> containerNodeIdList = fetchContainerNodeId.list(); if (!fetchContainerNodeId.list().isEmpty()) { Criteria fetchContainerNodeIdDotString = session.createCriteria(LineageNode.class).add(Restrictions.in(NODEID, containerNodeIdList)).setProjection(Projections.property(DOTSTRING)); List<String> containerNodeDotStringList = fetchContainerNodeIdDotString.list(); for (String dotString : containerNodeDotStringList) { dotStringList.add(dotString); } } } Criteria fetchLineageRelationDotString = session.createCriteria(LineageRelation.class).add(Restrictions.in(LINEAGEQUARYID, queryIdList)).setProjection(Projections.property(DOTSTRING)); List<String> lineageRelationDotStringList = fetchLineageRelationDotString.list(); for (String dotString : lineageRelationDotStringList) { dotStringList.add(dotString); } } } } session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.error(e); throw new MetadataException(e); } finally { session.close(); } return dotStringList; }  List<String> getDotString(Integer processId);  }
@Test public void testGetDotString() throws Exception { List<String> dotStringList = getDotStringDAO.getDotString(165); for (String dot : dotStringList) { LOGGER.info(dot); } }