Index: web-module/src/main/java/egovframework/api/arms/module_pdservice/controller/UserPdServiceController.java =================================================================== diff -u -r0a6fce79a32e31b793201f88e32fe4f3f9f879a5 -r37a862ecf1704c1827cc213eb32f85e6ab95a63b --- web-module/src/main/java/egovframework/api/arms/module_pdservice/controller/UserPdServiceController.java (.../UserPdServiceController.java) (revision 0a6fce79a32e31b793201f88e32fe4f3f9f879a5) +++ web-module/src/main/java/egovframework/api/arms/module_pdservice/controller/UserPdServiceController.java (.../UserPdServiceController.java) (revision 37a862ecf1704c1827cc213eb32f85e6ab95a63b) @@ -68,57 +68,41 @@ @Qualifier("pdServiceVersion") private PdServiceVersion pdServiceVersion; - @Resource(name = "reqAddTemplateInstallDB") - ArmsInstallDB reqAddTemplateInstallDB; - - @Resource(name = "reqStatusTemplateInstallDB") - ArmsInstallDB reqStatusTemplateInstallDB; - @PostConstruct public void initialize() { setJsTreeHibernateService(pdService); } private final Logger logger = LoggerFactory.getLogger(this.getClass()); - private static final Long ROOT_NODE_ID = new Long(2); - private static final String NODE_TYPE = new String("default"); private static final String REQ_PREFIX_TABLENAME_BY_PDSERVICE = new String("T_ARMS_REQADD_"); - private static final String REQ_PREFIX_TABLENAME_BY_PDSERVICE_STATUS = new String("T_ARMS_REQSTATUS_"); @ResponseBody @RequestMapping( value = {"/addPdServiceNode.do"}, method = {RequestMethod.POST} ) - public ModelAndView addNode(@Validated({AddNode.class}) PdServiceDTO pdServiceDTO, + public ModelAndView addPdServiceNode(@Validated({AddNode.class}) PdServiceDTO pdServiceDTO, BindingResult bindingResult, ModelMap model) throws Exception { if (bindingResult.hasErrors()) { throw new RuntimeException(); } else { pdServiceDTO.setC_title(Util_TitleChecker.StringReplace(pdServiceDTO.getC_title())); + //제품(서비스) 데이터 등록 PdServiceDTO addedNode = pdService.addNode(pdServiceDTO); //제품(서비스) 생성시 - 요구사항 TABLE 생성 - ArmsInstallDB_SqlMaaperDTO armsInstallDB_sqlMaaperDTO = new ArmsInstallDB_SqlMaaperDTO(); - armsInstallDB_sqlMaaperDTO.setC_title(REQ_PREFIX_TABLENAME_BY_PDSERVICE + addedNode.getC_id().toString()); - armsInstallDB_sqlMaaperDTO.setSqlMapSelector("arms-reqadd-template"); + pdService.setDynamicReqAddDB(addedNode); - reqAddTemplateInstallDB.sqlMapExecute(armsInstallDB_sqlMaaperDTO); - //C_ETC 컬럼에 요구사항 테이블 이름 기입 addedNode.setC_etc(REQ_PREFIX_TABLENAME_BY_PDSERVICE + addedNode.getC_id().toString()); pdService.updateNode(addedNode); //제품(서비스) 생성시 - 요구사항 STATUS TABLE 생성 - ArmsInstallDB_SqlMaaperDTO armsInstall_statusDB_sqlMaaperDTO = new ArmsInstallDB_SqlMaaperDTO(); - armsInstall_statusDB_sqlMaaperDTO.setC_title(REQ_PREFIX_TABLENAME_BY_PDSERVICE_STATUS + addedNode.getC_id().toString()); - armsInstall_statusDB_sqlMaaperDTO.setSqlMapSelector("arms-reqstatus-template"); + pdService.setDynamicReqStatusDB(addedNode); - reqStatusTemplateInstallDB.sqlMapExecute(armsInstall_statusDB_sqlMaaperDTO); - //Default Version 생성 PdServiceVersionDTO pdServiceVersionDTO = new PdServiceVersionDTO(); pdServiceVersionDTO.setRef(2L); @@ -140,24 +124,8 @@ if (bindingResult.hasErrors()) throw new RuntimeException(); - //루트 노드를 기준으로 리스트를 검색 - PdServiceDTO paramPdServiceDTO = new PdServiceDTO(); - paramPdServiceDTO.setWhere("c_parentid", ROOT_NODE_ID); - List list = pdService.getChildNode(paramPdServiceDTO); - - //검색된 노드중 maxPosition을 찾는다. - PdServiceDTO maxPositionPdServiceDTO = list - .stream() - .max(Comparator.comparing(PdServiceDTO::getC_position)) - .orElseThrow(NoSuchElementException::new); - - //노드 값 셋팅 - pdServiceDTO.setRef(ROOT_NODE_ID); - pdServiceDTO.setC_position(maxPositionPdServiceDTO.getC_position() + 1); - pdServiceDTO.setC_type(NODE_TYPE); - ModelAndView modelAndView = new ModelAndView("jsonView"); - modelAndView.addObject("result", pdService.addNode(pdServiceDTO)); + modelAndView.addObject("result", pdService.addNodeToEndPosition(pdServiceDTO)); return modelAndView; } @@ -192,18 +160,10 @@ method = {RequestMethod.GET} ) public ModelAndView getPdServiceMonitor(PdServiceDTO pdServiceDTO, ModelMap model, HttpServletRequest request) throws Exception { - pdServiceDTO.setOrder(Order.asc("c_id")); - Criterion criterion = Restrictions.not( - // replace "id" below with property name, depending on what you're filtering against - Restrictions.in("c_id", new Object[] {1L, 2L}) - ); - pdServiceDTO.getCriterions().add(criterion); - List list = this.pdService.getChildNode(pdServiceDTO); - for (PdServiceDTO dto: list) { - dto.setC_contents("force empty"); - } + ModelAndView modelAndView = new ModelAndView("jsonView"); - modelAndView.addObject("result", list); + modelAndView.addObject("result", pdService.getNodesWithoutRoot(pdServiceDTO)); return modelAndView; + } } \ No newline at end of file Index: web-module/src/main/java/egovframework/api/arms/module_pdservice/service/PdService.java =================================================================== diff -u -r0a6fce79a32e31b793201f88e32fe4f3f9f879a5 -r37a862ecf1704c1827cc213eb32f85e6ab95a63b --- web-module/src/main/java/egovframework/api/arms/module_pdservice/service/PdService.java (.../PdService.java) (revision 0a6fce79a32e31b793201f88e32fe4f3f9f879a5) +++ web-module/src/main/java/egovframework/api/arms/module_pdservice/service/PdService.java (.../PdService.java) (revision 37a862ecf1704c1827cc213eb32f85e6ab95a63b) @@ -13,7 +13,18 @@ import egovframework.api.arms.module_pdservice.model.PdServiceDTO; import egovframework.com.ext.jstree.springHibernate.core.service.JsTreeHibernateService; +import egovframework.com.ext.jstree.springHibernate.core.vo.JsTreeHibernateSearchDTO; +import java.util.List; + public interface PdService extends JsTreeHibernateService { + public List getNodesWithoutRoot(PdServiceDTO pdServiceDTO) throws Exception; + + public void setDynamicReqAddDB(PdServiceDTO addedPdServiceDTO) throws Exception; + + public void setDynamicReqStatusDB(PdServiceDTO addedPdServiceDTO) throws Exception; + + public PdServiceDTO addNodeToEndPosition(PdServiceDTO pdServiceDTO) throws Exception; + } \ No newline at end of file Index: web-module/src/main/java/egovframework/api/arms/module_pdservice/service/PdServiceImpl.java =================================================================== diff -u -r0a6fce79a32e31b793201f88e32fe4f3f9f879a5 -r37a862ecf1704c1827cc213eb32f85e6ab95a63b --- web-module/src/main/java/egovframework/api/arms/module_pdservice/service/PdServiceImpl.java (.../PdServiceImpl.java) (revision 0a6fce79a32e31b793201f88e32fe4f3f9f879a5) +++ web-module/src/main/java/egovframework/api/arms/module_pdservice/service/PdServiceImpl.java (.../PdServiceImpl.java) (revision 37a862ecf1704c1827cc213eb32f85e6ab95a63b) @@ -11,15 +11,89 @@ */ package egovframework.api.arms.module_pdservice.service; +import egovframework.api.arms.module_armsmaker.model.ArmsInstallDB_SqlMaaperDTO; +import egovframework.api.arms.module_armsmaker.service.ArmsInstallDB; +import egovframework.api.arms.module_pdservice.model.PdServiceDTO; import egovframework.com.ext.jstree.springHibernate.core.service.JsTreeHibernateServiceImpl; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.Comparator; +import java.util.List; +import java.util.NoSuchElementException; + @Service("pdService") public class PdServiceImpl extends JsTreeHibernateServiceImpl implements PdService{ private final Logger logger = LoggerFactory.getLogger(this.getClass()); + private static final Long ROOT_NODE_ID = new Long(2); + private static final String NODE_TYPE = new String("default"); + private static final String REQ_PREFIX_TABLENAME_BY_PDSERVICE = new String("T_ARMS_REQADD_"); + private static final String REQ_PREFIX_TABLENAME_BY_PDSERVICE_STATUS = new String("T_ARMS_REQSTATUS_"); + @Resource(name = "reqAddTemplateInstallDB") + ArmsInstallDB reqAddTemplateInstallDB; + + @Resource(name = "reqStatusTemplateInstallDB") + ArmsInstallDB reqStatusTemplateInstallDB; + + @Override + public List getNodesWithoutRoot(PdServiceDTO pdServiceDTO) throws Exception { + pdServiceDTO.setOrder(Order.asc("c_id")); + Criterion criterion = Restrictions.not( + // replace "id" below with property name, depending on what you're filtering against + Restrictions.in("c_id", new Object[] {1L, 2L}) + ); + pdServiceDTO.getCriterions().add(criterion); + List list = this.getChildNode(pdServiceDTO); + for (PdServiceDTO dto: list) { + dto.setC_contents("force empty"); + } + return list; + } + + @Override + public void setDynamicReqAddDB(PdServiceDTO addedNode) throws Exception { + ArmsInstallDB_SqlMaaperDTO armsInstallDB_sqlMaaperDTO = new ArmsInstallDB_SqlMaaperDTO(); + armsInstallDB_sqlMaaperDTO.setC_title(REQ_PREFIX_TABLENAME_BY_PDSERVICE + addedNode.getC_id().toString()); + armsInstallDB_sqlMaaperDTO.setSqlMapSelector("arms-reqadd-template"); + + reqAddTemplateInstallDB.sqlMapExecute(armsInstallDB_sqlMaaperDTO); + } + + @Override + public void setDynamicReqStatusDB(PdServiceDTO addedNode) throws Exception { + ArmsInstallDB_SqlMaaperDTO armsInstall_statusDB_sqlMaaperDTO = new ArmsInstallDB_SqlMaaperDTO(); + armsInstall_statusDB_sqlMaaperDTO.setC_title(REQ_PREFIX_TABLENAME_BY_PDSERVICE_STATUS + addedNode.getC_id().toString()); + armsInstall_statusDB_sqlMaaperDTO.setSqlMapSelector("arms-reqstatus-template"); + + reqStatusTemplateInstallDB.sqlMapExecute(armsInstall_statusDB_sqlMaaperDTO); + } + + @Override + public PdServiceDTO addNodeToEndPosition(PdServiceDTO pdServiceDTO) throws Exception { + //루트 노드를 기준으로 리스트를 검색 + PdServiceDTO paramPdServiceDTO = new PdServiceDTO(); + paramPdServiceDTO.setWhere("c_parentid", ROOT_NODE_ID); + List list = this.getChildNode(paramPdServiceDTO); + + //검색된 노드중 maxPosition을 찾는다. + PdServiceDTO maxPositionPdServiceDTO = list + .stream() + .max(Comparator.comparing(PdServiceDTO::getC_position)) + .orElseThrow(NoSuchElementException::new); + + //노드 값 셋팅 + pdServiceDTO.setRef(ROOT_NODE_ID); + pdServiceDTO.setC_position(maxPositionPdServiceDTO.getC_position() + 1); + pdServiceDTO.setC_type(NODE_TYPE); + + return this.addNode(pdServiceDTO); + } } \ No newline at end of file