| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import static kr.wisestone.owl.domain.enumType.CustomFieldType.*; |
| | | |
| | |
| | | private void setMapToIssueVo(List<Map<String, Object>> results, List<IssueVo> issueVos, IssueCondition issueCondition, User user) { |
| | | for (Map<String, Object> result : results) { |
| | | IssueVo issueVo = ConvertUtil.convertMapToClass(result, IssueVo.class); |
| | | if (MapUtil.getString(result, "inheritPartners") != null && MapUtil.getString(result, "inheritPartners").equals("1")) { |
| | | issueVo.setInheritPartners(true); |
| | | } |
| | | issueVos.add(issueVo); |
| | | issueCondition.addIssueIds(String.valueOf(issueVo.getId())); |
| | | } |
| | |
| | | // HOSTING 정보 저장 |
| | | this.issueHostingService.modifyIssueHostingField(issue, issueForm, detectIssueChange); |
| | | |
| | | // 파트너정보 하위이슈 상속 |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId(issue.getId()); |
| | | if (issueForm.getInheritYn() != null && issueForm.getInheritYn() |
| | | && downIssues != null && downIssues.size() > 0) { |
| | | for (Issue downIssue : downIssues) { |
| | | this.inheritPartners(downIssue, issue); |
| | | } |
| | | } |
| | | |
| | | // 이슈 이력 등록 |
| | | if (!StringUtils.isEmpty(detectIssueChange.toString())) { |
| | | this.issueHistoryService.addIssueHistory(issue, user, IssueHistoryType.MODIFY, detectIssueChange.toString()); |
| | |
| | | |
| | | for (IssueVo issueVo : issueVos) { |
| | | for (Map<String, Object> issueCustomFieldValue : issueCustomFieldValues) { |
| | | int count = 0; |
| | | Map<String, Object> useValues = new HashMap<>(); |
| | | |
| | | if (issueVo.getId().equals(MapUtil.getLong(issueCustomFieldValue, "issueId"))) { |
| | | IssueCustomFieldValueVo issueCustomFieldValueVo = new IssueCustomFieldValueVo(); |
| | | |
| | | useValues.put("useValue"+count, MapUtil.getString(issueCustomFieldValue, "useValue")); |
| | | useValues.put("customFieldId", MapUtil.getLong(issueCustomFieldValue, "customFieldId")); |
| | | issueCustomFieldValueVo.setUseValues(useValues); |
| | | |
| | | issueCustomFieldValueVo.setUseValue(MapUtil.getString(issueCustomFieldValue, "useValue")); |
| | | |
| | | CustomFieldVo customFieldVo = new CustomFieldVo(); |
| | |
| | | // 1번 헤더부터 데이터 영역 |
| | | if (rowIndex > 1) { |
| | | // 이슈로 등록하기 위해 IssueForm 에 데이터를 셋팅한다. |
| | | IssueForm newIssueForm = this.setIssueFormToExcelField(row, (rowIndex + 1), priorityMaps, severityMaps, departmentMaps, customFieldMaps, |
| | | IssueForm newIssueForm = this.setIssueFormToExcelField(row, (rowIndex + 1), priorityMaps, severityMaps, customFieldMaps, |
| | | companyFieldMaps, ispFieldMaps, hostingFieldMaps, headers); |
| | | ConvertUtil.copyProperties(issueForm, newIssueForm); |
| | | |
| | |
| | | } |
| | | |
| | | issue = this.issueRepository.saveAndFlush(issue); |
| | | |
| | | if (issueForm.getInheritYn() != null && issueForm.getInheritYn() && issue.getParentIssue() != null) { |
| | | // 상위이슈의 파트너 정보 상속 |
| | | this.inheritPartners(issue, issue.getParentIssue()); |
| | | } |
| | | |
| | | saveIssueForm.setId(issue.getId()); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * cell String으로 변환 함수 |
| | | * @param cell Cell |
| | | * @param isNull boolean |
| | | * @return String |
| | | */ |
| | | private String stringToCell (Cell cell, boolean isNull) { |
| | | String cellStr = ""; |
| | | if (!isNull) { |
| | | cellStr = CommonUtil.convertExcelStringToCell(cell); |
| | | // 공백 제거 |
| | | cell.setCellValue(cellStr.trim()); |
| | | } else { |
| | | cell.setCellValue(cellStr); |
| | | } |
| | | return cellStr; |
| | | } |
| | | |
| | | /** |
| | | * cell NULL 체크 함수 |
| | | * 빈 값이 아닌 cell 체크 |
| | | * @param cell Cell |
| | | * @return boolean |
| | | */ |
| | | private Boolean cellNullCheck (Cell cell) { |
| | | if (cell != null ) { |
| | | int cellType = cell.getCellType(); |
| | | if (cellType < Cell.CELL_TYPE_BLANK) { |
| | | if (cellType == Cell.CELL_TYPE_STRING) |
| | | { |
| | | if (cell.getStringCellValue() != null && !cell.getStringCellValue().equals("")) { |
| | | return false; |
| | | } |
| | | } else { |
| | | int cellType = cell.getCellType(); |
| | | if (cellType < Cell.CELL_TYPE_BLANK) { |
| | | if (cellType == Cell.CELL_TYPE_STRING) { |
| | | if (cell.getStringCellValue() != null && !cell.getStringCellValue().equals("")) { |
| | | return false; |
| | | } |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | |
| | | |
| | | // 엑셀 필드에 있는 정보를 이슈 form 으로 옮긴다. |
| | | private IssueForm setIssueFormToExcelField(Row row, int rowIndex, Map<String, Priority> priorityMaps, |
| | | Map<String, Severity> severityMaps, Map<String, DepartmentVo> departmentMaps, |
| | | Map<String, CustomField> customFieldMaps, Map<String, CompanyField> companyFieldMaps, |
| | | Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps, |
| | | Map<String, Severity> severityMaps, Map<String, CustomField> customFieldMaps, |
| | | Map<String, CompanyField> companyFieldMaps, Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps, |
| | | List<String> headers) throws ParseException { |
| | | IssueForm issueForm = new IssueForm(); |
| | | issueForm.setRegisterId(this.webAppUtil.getLoginId()); |
| | | Project project = null; |
| | | |
| | | // 제목, 내용, 프로젝트 키, 이슈 타입, 우선순위, 중요도, 담당자, 시작일, 종료일, 사용자 정의 필드 |
| | | for (int cellIndex = 0; cellIndex < headers.size(); cellIndex++) { |
| | | Cell cell = row.getCell(cellIndex); |
| | | |
| | | boolean isNull = true; |
| | | String cellStr = ""; |
| | | boolean isNull = true; |
| | | |
| | | if (cell != null) { |
| | | isNull = cellNullCheck(cell); |
| | | |
| | | if (!isNull) { |
| | | cellStr = CommonUtil.convertExcelStringToCell(cell); |
| | | |
| | | // 공백 제거 |
| | | cell.setCellValue(cellStr.trim()); |
| | | } else { |
| | | cell.setCellValue(cellStr); |
| | | } |
| | | cellStr = stringToCell(cell, isNull); //cell을 String으로 변환 |
| | | } |
| | | |
| | | switch (cellIndex) { |
| | |
| | | this.issueHistoryService.detectDownIssues(IssueHistoryType.DELETE, issue, sb); |
| | | issue.setParentIssue(null); |
| | | } |
| | | |
| | | if (issueDownForm.getInheritYn() != null && issueDownForm.getInheritYn() && issue.getParentIssue() != null) { |
| | | // 상위이슈의 파트너 정보 상속받기 |
| | | issue = this.inheritPartners(issue, parentIssue); |
| | | } |
| | | |
| | | this.issueHistoryService.addIssueHistory(parentIssue, IssueHistoryType.MODIFY, sb.toString()); //parentIssue = myIssue(기록은 현재 상세페이지에 해야하니까) |
| | | this.issueRepository.saveAndFlush(issue); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 상위이슈의 파트너 정보 상속받기 |
| | | * @param issue Issue |
| | | * @param parentIssue Issue |
| | | * @return Issue |
| | | */ |
| | | private Issue inheritPartners(Issue issue, Issue parentIssue) { |
| | | if (parentIssue != null) { |
| | | if (parentIssue.getIssueType().getInheritPartners()) { |
| | | IssueCompany issueCompany = new IssueCompany(); |
| | | IssueIsp issueIsp = new IssueIsp(); |
| | | IssueHosting issueHosting = new IssueHosting(); |
| | | |
| | | if (parentIssue.getIssueCompanies() != null && parentIssue.getIssueCompanies().size() > 0) { |
| | | issue.getIssueCompanies().clear(); |
| | | issue.getIssueCompanies().addAll(parentIssue.getIssueCompanies()); |
| | | Iterator<IssueCompany> itrCompany = issue.getIssueCompanies().iterator(); |
| | | ConvertUtil.copyProperties(itrCompany.next(), issueCompany, "id"); |
| | | issueCompany.setIssue(issue); |
| | | issueCompany.setCompanyField(parentIssue.getIssueCompanies().iterator().next().getCompanyField()); |
| | | this.issueCompanyRepository.saveAndFlush(issueCompany); |
| | | } else { |
| | | this.issueCompanyRepository.deleteByIssueId(issue.getId()); |
| | | this.issueCompanyRepository.flush(); |
| | | } |
| | | if (parentIssue.getIssueIspFields() != null && parentIssue.getIssueIspFields().size() > 0) { |
| | | issue.getIssueIspFields().clear(); |
| | | issue.getIssueIspFields().addAll(parentIssue.getIssueIspFields()); |
| | | Iterator<IssueIsp> itrIsp = issue.getIssueIspFields().iterator(); |
| | | ConvertUtil.copyProperties(itrIsp.next(), issueIsp, "id"); |
| | | issueIsp.setIssue(issue); |
| | | issueIsp.setIspField(parentIssue.getIssueIspFields().iterator().next().getIspField()); |
| | | this.issueIspRepository.saveAndFlush(issueIsp); |
| | | } else { |
| | | this.issueIspRepository.deleteByIssueId(issue.getId()); |
| | | this.issueIspRepository.flush(); |
| | | } |
| | | if (parentIssue.getIssueHostingFields() != null && parentIssue.getIssueHostingFields().size() > 0) { |
| | | issue.getIssueHostingFields().clear(); |
| | | issue.getIssueHostingFields().addAll(parentIssue.getIssueHostingFields()); |
| | | Iterator<IssueHosting> itrHosting = issue.getIssueHostingFields().iterator(); |
| | | ConvertUtil.copyProperties(itrHosting.next(), issueHosting, "id"); |
| | | issueHosting.setIssue(issue); |
| | | issueHosting.setHostingField(parentIssue.getIssueHostingFields().iterator().next().getHostingField()); |
| | | this.issueHostingRepository.saveAndFlush(issueHosting); |
| | | } else { |
| | | this.issueHostingRepository.deleteByIssueId(issue.getId()); |
| | | this.issueHostingRepository.flush(); |
| | | } |
| | | } |
| | | } |
| | | return issue; |
| | | } |
| | | |
| | | @Override |
| | | public void findPartner(Map<String, Object> resJsonData, Map<String, Object> params) { |
| | | Long issueTypeId = MapUtil.getLong(params, "issueTypeId"); |