Index: web-module/pom.xml =================================================================== diff -u -r738af0e5b46a03630e8a4b1bd16e017ba2faf6e6 -r0d46135d0035bbcc5f203ebaba7023acb37ba83f --- web-module/pom.xml (.../pom.xml) (revision 738af0e5b46a03630e8a4b1bd16e017ba2faf6e6) +++ web-module/pom.xml (.../pom.xml) (revision 0d46135d0035bbcc5f203ebaba7023acb37ba83f) @@ -93,8 +93,9 @@ <dependency> <groupId>com.atlassian.jira</groupId> <artifactId>jira-rest-java-client-core</artifactId> - <version>2.0.0-m15</version> + <version>3.0.0</version> </dependency> + <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> Index: web-module/src/main/java/egovframework/api/arms/module_reqadd/controller/UserReqAddController.java =================================================================== diff -u -r738af0e5b46a03630e8a4b1bd16e017ba2faf6e6 -r0d46135d0035bbcc5f203ebaba7023acb37ba83f --- web-module/src/main/java/egovframework/api/arms/module_reqadd/controller/UserReqAddController.java (.../UserReqAddController.java) (revision 738af0e5b46a03630e8a4b1bd16e017ba2faf6e6) +++ web-module/src/main/java/egovframework/api/arms/module_reqadd/controller/UserReqAddController.java (.../UserReqAddController.java) (revision 0d46135d0035bbcc5f203ebaba7023acb37ba83f) @@ -11,12 +11,6 @@ */ package egovframework.api.arms.module_reqadd.controller; -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_filerepository.service.FileRepository; import egovframework.api.arms.module_filerepositorylog.model.FileRepositoryLogDTO; import egovframework.api.arms.module_filerepositorylog.service.FileRepositoryLog; @@ -56,7 +50,6 @@ 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.beans.factory.annotation.Autowired; @@ -77,7 +70,6 @@ import javax.annotation.PostConstruct; import javax.servlet.http.HttpServletRequest; -import java.net.URI; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.*; @@ -568,6 +560,7 @@ ReqStatusDTO statusDTO = reqStatus.addNode(reqStatusDTO); SessionUtil.removeAttribute("updateNode"); + updateReqStatusIDs.add(statusDTO.getC_id().toString()); } }else { @@ -638,12 +631,13 @@ ReqStatusDTO checkAddDTO = reqStatus.addNode(reqStatusAddDTO); + updateReqStatusIDs.add(checkAddDTO.getC_id().toString()); - }else{ //있으면 enable statusDTO.setC_title("enable"); reqStatus.updateNode(statusDTO); + updateReqStatusIDs.add(statusDTO.getC_id().toString()); } SessionUtil.removeAttribute("updateNode"); @@ -661,7 +655,15 @@ } + String issueLinkResult = updateReqStatusIDs.stream().collect(Collectors.joining(",")); + addDTO.setC_issue_link(issueLinkResult); + SessionUtil.setAttribute("updateNode",changeReqTableName); + + reqAdd.updateNode(addDTO); + + SessionUtil.removeAttribute("updateNode"); + ModelAndView modelAndView = new ModelAndView("jsonView"); modelAndView.addObject("result", "god"); Index: web-module/src/main/java/egovframework/api/arms/module_reqstatus/service/ReqStatusImpl.java =================================================================== diff -u -r738af0e5b46a03630e8a4b1bd16e017ba2faf6e6 -r0d46135d0035bbcc5f203ebaba7023acb37ba83f --- web-module/src/main/java/egovframework/api/arms/module_reqstatus/service/ReqStatusImpl.java (.../ReqStatusImpl.java) (revision 738af0e5b46a03630e8a4b1bd16e017ba2faf6e6) +++ web-module/src/main/java/egovframework/api/arms/module_reqstatus/service/ReqStatusImpl.java (.../ReqStatusImpl.java) (revision 0d46135d0035bbcc5f203ebaba7023acb37ba83f) @@ -11,10 +11,11 @@ */ package egovframework.api.arms.module_reqstatus.service; +import com.atlassian.jira.rest.client.api.IssueRestClient; 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.jira.rest.client.api.domain.input.*; +import com.atlassian.util.concurrent.Effect; import com.atlassian.util.concurrent.Promise; import egovframework.api.arms.module_armsscheduler.component.ArmsSchedulerUtil; import egovframework.api.arms.module_pdserviceconnect.model.PdServiceConnectDTO; @@ -31,12 +32,13 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import java.io.IOException; import java.net.URI; -import java.util.Collections; -import java.util.List; +import java.net.URISyntaxException; +import java.util.*; @Service("reqStatus") -public class ReqStatusImpl extends JsTreeHibernateServiceImpl implements ReqStatus{ +public class ReqStatusImpl extends JsTreeHibernateServiceImpl implements ReqStatus { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -47,21 +49,21 @@ 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}) + Restrictions.in("c_id", new Object[]{1L, 2L}) ); - searchStatusDTO.setWhere("c_title","enable"); + searchStatusDTO.setWhere("c_title", "enable"); searchStatusDTO.getCriterions().add(criterion); List<ReqStatusDTO> allList = this.getChildNode(searchStatusDTO); String reqaddTableName = StringUtility.replace(reqStatusTableName, "T_ARMS_REQSTATUS", "T_ARMS_REQADD"); - for ( ReqStatusDTO statusDTO: allList ) { + 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)){ + if (StringUtility.isEmpty(jiraIssueLink)) { //이슈가 없다는 뜻이니까. //이슈 등록 final JiraRestClient restClient = ArmsSchedulerUtil.getJiraRestClient(); @@ -83,15 +85,15 @@ 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"+ - "관련한 이슈를 연결 하세요"); + "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<BasicIssue> promise = restClient.getIssueClient().createIssue(issueInput); @@ -119,23 +121,24 @@ 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}) + Restrictions.in("c_id", new Object[]{1L, 2L}) ); searchStatusDTO.getCriterions().add(criterion); List<ReqStatusDTO> allList = this.getChildNode(searchStatusDTO); - for ( ReqStatusDTO statusDTO: allList ) { + 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)){ + if (StringUtility.isNotEmpty(jiraIssueLink)) { //이슈가 있다는 뜻이니까. //이슈와 연관된 데이터 수집 및 업데이트 + final JiraRestClient restClient = ArmsSchedulerUtil.getJiraRestClient(); - logger.info("statusDTO.getC_jira_req_issue_key() => " + statusDTO.getC_jira_req_issue_key() ); + 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()); @@ -156,27 +159,80 @@ 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}) + Restrictions.in("c_id", new Object[]{1L, 2L}) ); - searchStatusDTO.setWhere("c_title","disable"); + searchStatusDTO.setWhere("c_title", "disable"); searchStatusDTO.getCriterions().add(criterion); List<ReqStatusDTO> disableList = this.getChildNode(searchStatusDTO); - for ( ReqStatusDTO statusDTO: disableList ) { + for (ReqStatusDTO statusDTO : disableList) { 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)){ - //이슈가 없다는 뜻이니까. + if (StringUtility.isNotEmpty(jiraIssueLink)) { + //이슈가 있다는 뜻이니까. //이슈 업데이트 - final JiraRestClient restClient = ArmsSchedulerUtil.getJiraRestClient(); - URI issueLink = new URI(jiraIssueLink); - Comment comment = Comment.valueOf("본 이슈는 더이상 관리되지 않습니다."); - restClient.getIssueClient().addComment(issueLink, comment); +// final JiraRestClient restClient = ArmsSchedulerUtil.getJiraRestClient(); +// +// IssueInput input = new IssueInputBuilder() +// .setDescription("본 요구사항 이슈는 더이상 관리되지 않습니다.") +// .setFieldValue(IssueFieldId.LABELS_FIELD.id, Collections.singleton(new String("DISABLE 된 요구사항"))) +// .build(); +// restClient.getIssueClient() +// .updateIssue(statusDTO.getC_jira_req_issue_key(), input) +// .claim(); + + Issue issue = getIssue(statusDTO.getC_jira_req_issue_key()); + Iterable<Transition> transitions = ArmsSchedulerUtil.getJiraRestClient().getIssueClient().getTransitions(issue).claim(); + logger.info("============" + issue.getStatus().getName()); + + + String status = "Close Issue"; + updateIssueStatus(issue, status); + +// +// Issue issue = restClient.getIssueClient().getIssue(statusDTO.getC_jira_req_issue_key()).claim(); +// Iterable<Transition> transitions = restClient.getIssueClient().getTransitions(issue.getTransitionsUri()).get(); +// final Transition closedTransition = getTransitionByName(transitions, "Resolve Issue"); +// +// Collection<FieldInput> fieldInputs = Arrays.asList(new FieldInput("resolution", "Incomplete")); +// final TransitionInput transitionInput = new TransitionInput(closedTransition.getId(), fieldInputs, Comment.valueOf("My comment")); +// +// restClient.getIssueClient().transition(issue.getTransitionsUri(), transitionInput); } } } + + public void updateIssueStatus(Issue issue, String status) throws IOException, URISyntaxException { + IssueRestClient issueClient = ArmsSchedulerUtil.getJiraRestClient().getIssueClient(); + + + Iterable<Transition> transitions = issueClient.getTransitions(issue).claim(); + + for(Transition t : transitions){ + if(t.getName().equals(status)) { + TransitionInput input = new TransitionInput(t.getId()); + issueClient.transition(issue, input).claim(); + + return; + } + } + } + + public Issue getIssue(String issueKey) throws IOException, URISyntaxException { + IssueRestClient client = ArmsSchedulerUtil.getJiraRestClient().getIssueClient(); + return client.getIssue(issueKey).claim(); + } + + private static Transition getTransitionByName(Iterable<Transition> transitions, String transitionName) { + for (Transition transition : transitions) { + if (transition.getName().equals(transitionName)) { + return transition; + } + } + return null; + } } \ No newline at end of file