Index: web-module/pom.xml =================================================================== diff -u -r668413b38f5dc118f409ac4dd6f8f20be2b4e2aa -rb7429348b97fd89d41aaa97521e08ca41cf0c2f6 --- web-module/pom.xml (.../pom.xml) (revision 668413b38f5dc118f409ac4dd6f8f20be2b4e2aa) +++ web-module/pom.xml (.../pom.xml) (revision b7429348b97fd89d41aaa97521e08ca41cf0c2f6) @@ -17,7 +17,7 @@ Web Project by 313 DEV GRP - 23.01.17 + 23.01.18 Index: web-module/src/main/java/egovframework/api/arms/module_armsscheduler/component/ArmsSchedulerUtil.java =================================================================== diff -u -r2e055ae035a195f71c6fc5194c10831d56ab48e8 -rb7429348b97fd89d41aaa97521e08ca41cf0c2f6 --- web-module/src/main/java/egovframework/api/arms/module_armsscheduler/component/ArmsSchedulerUtil.java (.../ArmsSchedulerUtil.java) (revision 2e055ae035a195f71c6fc5194c10831d56ab48e8) +++ web-module/src/main/java/egovframework/api/arms/module_armsscheduler/component/ArmsSchedulerUtil.java (.../ArmsSchedulerUtil.java) (revision b7429348b97fd89d41aaa97521e08ca41cf0c2f6) @@ -63,7 +63,7 @@ } - @Scheduled(initialDelay = 1 * 60 * 1000, fixedDelay = 3 * 60 * 100) //10m 딜레이, 5m 단위 + @Scheduled(initialDelay = 1 * 60 * 1000, fixedDelay = 60 * 60 * 1000) //10m 딜레이, 60m 단위 public void set_jiraServerInfo_toStatic() throws IOException, URISyntaxException { final JiraRestClient restClient = ArmsSchedulerUtil.getJiraRestClient(); ServerInfo serverInfo = restClient.getMetadataClient().getServerInfo().claim(); @@ -75,7 +75,7 @@ ArmsSchedulerUtil.serverInfo_BaseURI = serverInfo.getBaseUri().toString(); } - @Scheduled(initialDelay = 1 * 60 * 1000, fixedDelay = 3 * 60 * 100) //10m 딜레이, 5m 단위 + @Scheduled(initialDelay = 1 * 60 * 1000, fixedDelay = 60 * 60 * 1000) //10m 딜레이, 5m 단위 public void set_jiraIssueType_toStatic() throws IOException, URISyntaxException { final JiraRestClient restClient = ArmsSchedulerUtil.getJiraRestClient(); Iterable issueTypes = restClient.getMetadataClient().getIssueTypes().claim(); Index: web-module/src/main/java/egovframework/api/arms/module_reqadd/controller/UserReqAddController.java =================================================================== diff -u -r74dab7d35944906f087b65f1c59368270bf6b41e -rb7429348b97fd89d41aaa97521e08ca41cf0c2f6 --- web-module/src/main/java/egovframework/api/arms/module_reqadd/controller/UserReqAddController.java (.../UserReqAddController.java) (revision 74dab7d35944906f087b65f1c59368270bf6b41e) +++ web-module/src/main/java/egovframework/api/arms/module_reqadd/controller/UserReqAddController.java (.../UserReqAddController.java) (revision b7429348b97fd89d41aaa97521e08ca41cf0c2f6) @@ -351,6 +351,7 @@ reqStatusDTO.setC_jira_version_link(jiraVerDTOInfo.getC_id()); reqStatusDTO.setC_jira_version_name(jiraVerDTOInfo.getC_jiraversion_name()); reqStatusDTO.setC_jira_version_url(jiraVerDTOInfo.getC_jiraversion_link()); + reqStatusDTO.setC_jira_version_title(jiraVerDTOInfo.getC_title()); //REQADD 의 요구사항 아이디, 타이틀 reqStatusDTO.setC_req_link(returnNode.getC_id().toString()); Index: web-module/src/main/java/egovframework/api/arms/module_reqstatus/controller/AnonReqStatusController.java =================================================================== diff -u -rd7698afe04b9bc7fdcca30f52ccc39a8f9b1b2c1 -rb7429348b97fd89d41aaa97521e08ca41cf0c2f6 --- web-module/src/main/java/egovframework/api/arms/module_reqstatus/controller/AnonReqStatusController.java (.../AnonReqStatusController.java) (revision d7698afe04b9bc7fdcca30f52ccc39a8f9b1b2c1) +++ web-module/src/main/java/egovframework/api/arms/module_reqstatus/controller/AnonReqStatusController.java (.../AnonReqStatusController.java) (revision b7429348b97fd89d41aaa97521e08ca41cf0c2f6) @@ -11,14 +11,19 @@ */ package egovframework.api.arms.module_reqstatus.controller; +import egovframework.api.arms.module_reqadd.model.ReqAddDTO; +import egovframework.com.ext.jstree.springHibernate.core.interceptor.SessionUtil; import lombok.extern.slf4j.Slf4j; +import org.hibernate.criterion.Order; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.ui.ModelMap; import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @@ -48,4 +53,38 @@ setJsTreeHibernateService(reqStatus); } + @ResponseBody + @RequestMapping( + value = {"/{reqStatusTableName}/updateStatusNode.do"}, + method = {RequestMethod.GET} + ) + public ModelAndView putJiraIssue( + @PathVariable(value ="reqStatusTableName") String reqStatusTableName, + ModelMap model, HttpServletRequest request) throws Exception { + + SessionUtil.setAttribute("updateStatusNode",reqStatusTableName); + reqStatus.putJiraIssue(reqStatusTableName); + SessionUtil.removeAttribute("updateStatusNode"); + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", "AnonReqStatusController :: putJiraIssue"); + return modelAndView; + } + + @ResponseBody + @RequestMapping( + value = {"/{reqStatusTableName}/issueCrawler/updateStatusNode.do"}, + method = {RequestMethod.GET} + ) + public ModelAndView updateJiraIssueCrawler( + @PathVariable(value ="reqStatusTableName") String reqStatusTableName, + ModelMap model, HttpServletRequest request) throws Exception { + + SessionUtil.setAttribute("updateStatusNode",reqStatusTableName); + reqStatus.updateJiraIssueCrawl(reqStatusTableName); + SessionUtil.removeAttribute("updateStatusNode"); + ModelAndView modelAndView = new ModelAndView("jsonView"); + modelAndView.addObject("result", "AnonReqStatusController :: updateJiraIssueCrawler"); + return modelAndView; + } + } Index: web-module/src/main/java/egovframework/api/arms/module_reqstatus/model/ReqStatusDTO.java =================================================================== diff -u -r668413b38f5dc118f409ac4dd6f8f20be2b4e2aa -rb7429348b97fd89d41aaa97521e08ca41cf0c2f6 --- web-module/src/main/java/egovframework/api/arms/module_reqstatus/model/ReqStatusDTO.java (.../ReqStatusDTO.java) (revision 668413b38f5dc118f409ac4dd6f8f20be2b4e2aa) +++ web-module/src/main/java/egovframework/api/arms/module_reqstatus/model/ReqStatusDTO.java (.../ReqStatusDTO.java) (revision b7429348b97fd89d41aaa97521e08ca41cf0c2f6) @@ -204,6 +204,14 @@ this.c_jira_version_name = c_jira_version_name; } + public String getC_jira_version_title() { + return c_jira_version_title; + } + + public void setC_jira_version_title(String c_jira_version_title) { + this.c_jira_version_title = c_jira_version_title; + } + public String getC_jira_version_url() { return c_jira_version_url; } Index: web-module/src/main/java/egovframework/api/arms/module_reqstatus/service/ReqStatus.java =================================================================== diff -u -rd7698afe04b9bc7fdcca30f52ccc39a8f9b1b2c1 -rb7429348b97fd89d41aaa97521e08ca41cf0c2f6 --- web-module/src/main/java/egovframework/api/arms/module_reqstatus/service/ReqStatus.java (.../ReqStatus.java) (revision d7698afe04b9bc7fdcca30f52ccc39a8f9b1b2c1) +++ web-module/src/main/java/egovframework/api/arms/module_reqstatus/service/ReqStatus.java (.../ReqStatus.java) (revision b7429348b97fd89d41aaa97521e08ca41cf0c2f6) @@ -15,6 +15,7 @@ public interface ReqStatus extends JsTreeHibernateService { + public void putJiraIssue(String reqStatusTableName) throws Exception; + public void updateJiraIssueCrawl(String reqStatusTableName) throws Exception; - } \ No newline at end of file Index: web-module/src/main/java/egovframework/api/arms/module_reqstatus/service/ReqStatusImpl.java =================================================================== diff -u -rd7698afe04b9bc7fdcca30f52ccc39a8f9b1b2c1 -rb7429348b97fd89d41aaa97521e08ca41cf0c2f6 --- web-module/src/main/java/egovframework/api/arms/module_reqstatus/service/ReqStatusImpl.java (.../ReqStatusImpl.java) (revision d7698afe04b9bc7fdcca30f52ccc39a8f9b1b2c1) +++ web-module/src/main/java/egovframework/api/arms/module_reqstatus/service/ReqStatusImpl.java (.../ReqStatusImpl.java) (revision b7429348b97fd89d41aaa97521e08ca41cf0c2f6) @@ -11,14 +11,141 @@ */ package egovframework.api.arms.module_reqstatus.service; +import com.atlassian.jira.rest.client.api.JiraRestClient; +import com.atlassian.jira.rest.client.api.domain.*; +import com.atlassian.jira.rest.client.api.domain.input.IssueInput; +import com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder; +import com.atlassian.util.concurrent.Promise; +import egovframework.api.arms.module_armsscheduler.component.ArmsSchedulerUtil; +import egovframework.api.arms.module_pdserviceconnect.model.PdServiceConnectDTO; +import egovframework.api.arms.module_reqstatus.model.ReqStatusDTO; +import egovframework.api.arms.util.StringUtility; +import egovframework.com.ext.jstree.springHibernate.core.interceptor.SessionUtil; import egovframework.com.ext.jstree.springHibernate.core.service.JsTreeHibernateServiceImpl; +import egovframework.com.ext.jstree.support.util.StringUtils; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import java.net.URI; +import java.util.Collections; +import java.util.List; + @Service("reqStatus") public class ReqStatusImpl extends JsTreeHibernateServiceImpl implements ReqStatus{ private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Override + public void putJiraIssue(String reqStatusTableName) throws Exception { + + ReqStatusDTO searchStatusDTO = new ReqStatusDTO(); + searchStatusDTO.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}) + ); + searchStatusDTO.getCriterions().add(criterion); + + List allList = this.getChildNode(searchStatusDTO); + + String reqaddTableName = StringUtility.replace(reqStatusTableName, "T_ARMS_REQSTATUS", "T_ARMS_REQADD"); + + for ( ReqStatusDTO statusDTO: allList ) { + logger.info("statusDTO = " + statusDTO.getC_id()); + logger.info("statusDTO = " + statusDTO.getC_req_name()); + + String jiraIssueLink = statusDTO.getC_jira_req_issue_link(); + if(StringUtility.isEmpty(jiraIssueLink)){ + //이슈가 없다는 뜻이니까. + //이슈 등록 + final JiraRestClient restClient = ArmsSchedulerUtil.getJiraRestClient(); + + Promise projectPromise = restClient.getProjectClient().getProject(statusDTO.getC_jira_project_key()); + Project project = projectPromise.claim(); + + Promise issueTypePromise = restClient.getMetadataClient().getIssueType(new URI(ArmsSchedulerUtil.issueType_link)); + IssueType issueType = issueTypePromise.claim(); + + Promise versionPromise = restClient.getVersionRestClient().getVersion(new URI(statusDTO.getC_jira_version_url())); + Version version = versionPromise.claim(); + + String summary = statusDTO.getC_req_name(); + IssueInputBuilder issueInputBuilder = new IssueInputBuilder(project, issueType, summary); + issueInputBuilder.setFixVersions(Collections.singleton(version)); + issueInputBuilder.setPriorityId(6L); + DateTime dueDate = new DateTime("2022-12-30"); + issueInputBuilder.setDueDate(dueDate); + issueInputBuilder.setFieldValue(IssueFieldId.LABELS_FIELD.id, Collections.singleton(new String("a-RMS_요구사항"))); + issueInputBuilder.setDescription( + "a-RMS 에서 제공하는 요구사항 이슈 타입입니다.\n" + + "자동으로 관리되므로 이슈를 강제로 삭제하지 마세요\n"+ + "아래 링크에서 요구사항을 확인 할 수 있습니다.\n" + + "=========================================\n" + + //BaseURL + /auth-anon/api/arms/reqAdd/테이블명/요구사항아이디 + "http://www.a-rms.net/auth-user/api/arms/reqSearch/" + reqaddTableName + "/" + statusDTO.getC_req_link() +"\n" + + "=========================================\n" + + "본 이슈 하위로 Sub-Task를 만들어서 개발을 하시거나\n"+ + "관련한 이슈를 연결 하세요"); + IssueInput issueInput = issueInputBuilder.build(); + + Promise promise = restClient.getIssueClient().createIssue(issueInput); + BasicIssue issue = promise.claim(); + logger.info("issue = " + issue.getKey()); + logger.info("issue = " + issue.getId()); + logger.info("issue = " + issue.getSelf()); + + + logger.info("reqStatusTableName ====> " + reqStatusTableName); + statusDTO.setC_jira_req_issue_key(issue.getKey()); + statusDTO.setC_jira_req_issue_id(issue.getId().toString()); + statusDTO.setC_jira_req_issue_link(issue.getSelf().toString()); + this.updateNode(statusDTO); + + } + } + + } + + @Override + public void updateJiraIssueCrawl(String reqStatusTableName) throws Exception { + + ReqStatusDTO searchStatusDTO = new ReqStatusDTO(); + searchStatusDTO.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}) + ); + searchStatusDTO.getCriterions().add(criterion); + + List allList = this.getChildNode(searchStatusDTO); + + for ( ReqStatusDTO statusDTO: allList ) { + logger.info("statusDTO = " + statusDTO.getC_id()); + logger.info("statusDTO = " + statusDTO.getC_req_name()); + + String jiraIssueLink = statusDTO.getC_jira_req_issue_link(); + if(StringUtility.isNotEmpty(jiraIssueLink)){ + //이슈가 있다는 뜻이니까. + //이슈와 연관된 데이터 수집 및 업데이트 + final JiraRestClient restClient = ArmsSchedulerUtil.getJiraRestClient(); + + logger.info("statusDTO.getC_jira_req_issue_key() => " + statusDTO.getC_jira_req_issue_key() ); + Issue issue = restClient.getIssueClient().getIssue(statusDTO.getC_jira_req_issue_key()).claim(); + logger.info("issue = " + issue.getSubtasks()); + logger.info("issue = " + issue.getIssueLinks()); + + statusDTO.setC_jira_req_subtaskissue(issue.getSubtasks().toString()); + statusDTO.setC_jira_req_linkingissue(issue.getIssueLinks().toString()); + + this.updateNode(statusDTO); + + } + } + + } } \ No newline at end of file