| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.text.ParseException; |
| | | import java.util.*; |
| | | |
| | | import static kr.wisestone.owl.domain.enumType.CustomFieldType.DATETIME; |
| | | import static kr.wisestone.owl.domain.enumType.CustomFieldType.INPUT; |
| | | import static kr.wisestone.owl.domain.enumType.CustomFieldType.*; |
| | | |
| | | @Service |
| | | public class IssueServiceImpl extends AbstractServiceImpl<Issue, Long, JpaRepository<Issue, Long>> implements IssueService { |
| | |
| | | issueApiForm.addUseIssueCustomFieldId(customFieldApiOverlap.getCustomField().getId()); |
| | | } |
| | | |
| | | // 종료상태가 아닌 중복된 상위 이슈검색 |
| | | // 중복된 상위 이슈검색 |
| | | List<Issue> issues = this.findIssue(issueApiForm, customFieldApiOverlaps, user.getId()); |
| | | int size = issues.size(); |
| | | if (size > 0) { |
| | |
| | | issueCustomFieldValueCondition.setUseValue(concatUseValue); |
| | | issueCustomFieldValueCondition.setUseValues(userValues); |
| | | issueCustomFieldValueCondition.setIssueTypeId(issueApiform.getIssueTypeId()); |
| | | issueCustomFieldValueCondition.setIssueStatusType("CLOSE"); |
| | | // issueCustomFieldValueCondition.setIssueStatusType("CLOSE"); |
| | | List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition); |
| | | if (results != null && results.size() > 0) { |
| | | for (Map<String, Object> result : results) { |
| | |
| | | if (issueForm.getParentIssueId() != null){ |
| | | Issue parentIssue = this.getIssue(issueForm.getParentIssueId()); |
| | | issue.setParentIssue(parentIssue); |
| | | |
| | | // 상위 이슈가 종료일경우 대기로 변경 |
| | | IssueStatus parentIssueStatus = parentIssue.getIssueStatus(); |
| | | if (parentIssueStatus.getIssueStatusType().equals(IssueStatusType.CLOSE)) { |
| | | parentIssue.setIssueStatus(issueStatus); |
| | | } |
| | | } |
| | | |
| | | issue.setIssueNumber(this.issueNumberGeneratorService.generateIssueNumber(project)); // 각 프로젝트의 고유 이슈 번호 생성 |
| | |
| | | } |
| | | } |
| | | |
| | | // 날짜 유효성 체크 |
| | | /** |
| | | * 날짜 유효성 체크 |
| | | * @param startDate 시작 일자(문자) |
| | | * @param completeDate 종료 일자(문자) |
| | | */ |
| | | private void checkStartCompleteDate(String startDate, String completeDate) { |
| | | if (!StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(completeDate)) { |
| | | Date start = DateUtil.convertStrToDate(startDate, "yy-MM-dd"); |
| | | Date end = DateUtil.convertStrToDate(completeDate, "yy-MM-dd"); |
| | | if (start.getTime() > end.getTime()) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.DATE_PICKER_NOT_AVAILABLE)); |
| | | } |
| | | checkStartCompleteDate(start, end); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 날짜 유효성 체크 |
| | | * @param start 시작 일자 |
| | | * @param end 종료 일자 |
| | | */ |
| | | private void checkStartCompleteDate(Date start, Date end) { |
| | | if (start.getTime() > end.getTime()) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.DATE_PICKER_NOT_AVAILABLE)); |
| | | } |
| | | } |
| | | |
| | |
| | | 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()); |
| | | |
| | | IssueDepartment issueDepartment = new IssueDepartment(); |
| | |
| | | // 이슈 담당자 벌크 등록 |
| | | this.bulkInsertIssueAssignee(issueForms, workspace); |
| | | // 0.361 - 0.705 |
| | | |
| | | |
| | | // 1.816 |
| | | /*StopWatch serviceStart = new StopWatch(); |
| | | serviceStart.start();*/ |
| | |
| | | issueCompany.setCompanyField(companyField); |
| | | issueCompany.setIssue(issue); |
| | | this.issueCompanyRepository.saveAndFlush(issueCompany); |
| | | |
| | | |
| | | // 사용자가 ISP를 직접 입력하지 않았을 경우 업체에 등록되어있는 ISP 설정 |
| | | if (issueForm.getIssueIspFields() == null || issueForm.getIssueIspFields().size() < 1) { |
| | | // 업체의 ISP가 있는 경우 issueISP 등록 |
| | |
| | | issueCustomField.put("registerId", this.webAppUtil.getLoginId()); |
| | | issueCustomFieldValueMaps.add(issueCustomField); |
| | | } |
| | | |
| | | |
| | | // 엑셀에 업체명을 입력하지 않았을 경우 같은 도메인 업체 찾기 |
| | | if (issueForm.getIssueCompanyFields() == null || issueForm.getIssueCompanyFields().size() < 1) { |
| | | // 같은 도메인 업체 찾기 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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 && cell.getStringCellValue() != null) { |
| | | cell.setCellValue(cell.getStringCellValue().trim());//셀 값 공백 제거 |
| | | 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 cell != null && cell.getStringCellValue() != null && !cell.getStringCellValue().equals("") && cell.getCellType() != Cell.CELL_TYPE_BLANK; |
| | | 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, |
| | | List<String> headers) { |
| | | 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); |
| | | |
| | | String cellStr = ""; |
| | | boolean isNull = true; |
| | | |
| | | if (cell != null) { |
| | | isNull = cellNullCheck(cell); |
| | | cellStr = stringToCell(cell, isNull); //cell을 String으로 변환 |
| | | } |
| | | |
| | | switch (cellIndex) { |
| | | case 0: |
| | | // 이슈 제목을 IssueForm 에 저장한다. |
| | | this.setIssueFormTitle(cell, issueForm, rowIndex); |
| | | if (isNull) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TITLE_IS_NULL, rowIndex)); |
| | | } |
| | | this.setIssueFormTitle(cellStr, issueForm, rowIndex); |
| | | break; |
| | | |
| | | case 1: // 내용 |
| | | if (cellNullCheck(cell)) { |
| | | issueForm.setDescription(CommonUtil.convertExcelStringToCell(cell)); |
| | | } else { |
| | | // null 입력 방지 |
| | | issueForm.setDescription(""); |
| | | } |
| | | |
| | | issueForm.setDescription(cellStr); |
| | | break; |
| | | |
| | | case 2: |
| | | // 우선순위를 IssueForm 에 저장한다. |
| | | this.setIssueFormPriority(cell, priorityMaps, issueForm, rowIndex); |
| | | if (isNull) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PRIORITY_IS_NULL, rowIndex)); |
| | | } |
| | | this.setIssueFormPriority(cellStr, priorityMaps, issueForm, rowIndex); |
| | | break; |
| | | |
| | | case 3: |
| | | // 중요도를 IssueForm 에 저장한다. |
| | | this.setIssueFormSeverity(cell, severityMaps, issueForm, rowIndex); |
| | | if (isNull) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_SEVERITY_IS_NULL, rowIndex)); |
| | | } |
| | | this.setIssueFormSeverity(cellStr, severityMaps, issueForm, rowIndex); |
| | | break; |
| | | /*case 6: |
| | | // 담당자를 IssueForm 에 저장한다. |
| | |
| | | break;*/ |
| | | case 4: |
| | | // 시작일을 IssueForm 에 저장한다. |
| | | if (cellNullCheck(cell)) { |
| | | this.setIssueFormPeriod(cell, issueForm, true, rowIndex); |
| | | } |
| | | this.setIssueFormPeriod(cellStr, issueForm, true, rowIndex, isNull); |
| | | break; |
| | | case 5: |
| | | // 종료일을 IssueForm 에 저장한다. |
| | | if (cellNullCheck(cell)) { |
| | | this.setIssueFormPeriod(cell, issueForm, false, rowIndex); |
| | | } |
| | | this.setIssueFormPeriod(cellStr, issueForm, false, rowIndex, isNull); |
| | | break; |
| | | case 6: |
| | | // 업체를 IssueForm 에 저장한다. |
| | | if (cellNullCheck(cell)) { |
| | | this.setIssueFormCompanyField(cell, companyFieldMaps, issueForm, rowIndex); |
| | | } |
| | | this.setIssueFormCompanyField(cellStr, companyFieldMaps, issueForm, rowIndex); |
| | | break; |
| | | case 7: |
| | | // ISP를 IssueForm 에 저장한다. |
| | | if (cellNullCheck(cell)) { |
| | | this.setIssueFormIspField(cell, ispFieldMaps, issueForm, rowIndex); |
| | | } |
| | | this.setIssueFormIspField(cellStr, ispFieldMaps, issueForm, rowIndex); |
| | | break; |
| | | case 8: |
| | | // 호스팅을 IssueForm 에 저장한다. |
| | | if (cellNullCheck(cell)) { |
| | | this.setIssueFormHostingField(cell, hostingFieldMaps, issueForm, rowIndex); |
| | | } |
| | | this.setIssueFormHostingField(cellStr, hostingFieldMaps, issueForm, rowIndex); |
| | | break; |
| | | default: |
| | | // 9번 부터는 사용자 정의 필드. 사용자 정의 필드 정보를 IssueForm 에 저장한다. |
| | | this.setIssueFormCustomFieldValue(cell, customFieldMaps, issueForm, headers.get(cellIndex), rowIndex); |
| | | this.setIssueFormCustomFieldValue(cellStr, customFieldMaps, issueForm, headers.get(cellIndex), rowIndex); |
| | | } |
| | | } |
| | | |
| | | return issueForm; |
| | | } |
| | | |
| | | private void setIssueFormHostingField(Cell cell, Map<String, HostingField> hostingFieldMaps, IssueForm issueForm, int rowIndex) { |
| | | if (cell != null) { |
| | | private void setIssueFormHostingField(String cell, Map<String, HostingField> hostingFieldMaps, IssueForm issueForm, int rowIndex) { |
| | | if (cell.length() > 0) { |
| | | Map<String, Object> issueHostingFields = new HashMap<>(); |
| | | HostingField hostingFieldMap = hostingFieldMaps.get(CommonUtil.convertExcelStringToCell(cell)); |
| | | HostingField hostingFieldMap = hostingFieldMaps.get(cell); |
| | | if (hostingFieldMap == null) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HOSTING_NOT_EXIST, rowIndex)); |
| | |
| | | } |
| | | } |
| | | |
| | | private void setIssueFormIspField(Cell cell, Map<String, IspField> ispFieldMaps, IssueForm issueForm, int rowIndex) { |
| | | if (cell != null) { |
| | | private void setIssueFormIspField(String cell, Map<String, IspField> ispFieldMaps, IssueForm issueForm, int rowIndex) { |
| | | if (cell.length() > 0) { |
| | | Map<String, Object> issueIspFields = new HashMap<>(); |
| | | IspField ispFieldMap = ispFieldMaps.get(CommonUtil.convertExcelStringToCell(cell)); |
| | | IspField ispFieldMap = ispFieldMaps.get(cell); |
| | | if (ispFieldMap == null) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISP_NOT_EXIST, rowIndex)); |
| | |
| | | } |
| | | } |
| | | |
| | | private void setIssueFormCompanyField(Cell cell, Map<String, CompanyField> companyFieldMaps, IssueForm issueForm, int rowIndex) { |
| | | if (cell != null) { |
| | | private void setIssueFormCompanyField(String cell, Map<String, CompanyField> companyFieldMaps, IssueForm issueForm, int rowIndex) { |
| | | if (cell.length() > 0) { |
| | | Map<String, Object> issueCompanyFields = new HashMap<>(); |
| | | CompanyField companyFieldMap = companyFieldMaps.get(CommonUtil.convertExcelStringToCell(cell)); |
| | | CompanyField companyFieldMap = companyFieldMaps.get(cell); |
| | | if (companyFieldMap == null) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_COMPANY_NOT_EXIST, rowIndex)); |
| | |
| | | } |
| | | |
| | | // 이슈 제목을 IssueForm 에 저장한다. |
| | | private void setIssueFormTitle(Cell cell, IssueForm issueForm, int rowIndex) { |
| | | if (!cellNullCheck(cell)) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TITLE_IS_NULL, rowIndex)); |
| | | } |
| | | |
| | | String title = CommonUtil.convertExcelStringToCell(cell); |
| | | |
| | | private void setIssueFormTitle(String title, IssueForm issueForm, int rowIndex) { |
| | | // 제목 유효성 체크 |
| | | this.verifyTitle(title); |
| | | issueForm.setTitle(title); |
| | |
| | | |
| | | |
| | | // 우선순위를 IssueForm 에 저장한다. |
| | | private void setIssueFormPriority(Cell cell, Map<String, Priority> priorityMaps, IssueForm issueForm, int rowIndex) { |
| | | if (!cellNullCheck(cell)) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PRIORITY_IS_NULL, rowIndex)); |
| | | } |
| | | |
| | | Priority priority = priorityMaps.get(CommonUtil.convertExcelStringToCell(cell)); |
| | | private void setIssueFormPriority(String priorityStr, Map<String, Priority> priorityMaps, IssueForm issueForm, int rowIndex) { |
| | | Priority priority = priorityMaps.get(priorityStr); |
| | | |
| | | if (priority == null) { |
| | | throw new OwlRuntimeException( |
| | |
| | | } |
| | | |
| | | // 중요도를 IssueForm 에 저장한다. |
| | | private void setIssueFormSeverity(Cell cell, Map<String, Severity> severityMaps, IssueForm issueForm, int rowIndex) { |
| | | if (!cellNullCheck(cell)) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_SEVERITY_IS_NULL, rowIndex)); |
| | | } |
| | | |
| | | Severity severity = severityMaps.get(CommonUtil.convertExcelStringToCell(cell)); |
| | | private void setIssueFormSeverity(String strSeverity, Map<String, Severity> severityMaps, IssueForm issueForm, int rowIndex) { |
| | | Severity severity = severityMaps.get(strSeverity); |
| | | |
| | | if (severity == null) { |
| | | throw new OwlRuntimeException( |
| | |
| | | } |
| | | } |
| | | // 시작일, 종료일을 IssueForm 에 저장한다. |
| | | private void setIssueFormPeriod(Cell cell, IssueForm issueForm, Boolean checkStartDate, int rowIndex) { |
| | | if (cell != null && !cell.toString().equals("")) { |
| | | private void setIssueFormPeriod(String periodDate, IssueForm issueForm, Boolean checkStartDate, int rowIndex, boolean isNull) throws ParseException { |
| | | if (!isNull) { |
| | | |
| | | // 값이 공백이면 중지 |
| | | String cellValue = CommonUtil.convertExcelStringToCell(cell); |
| | | if (StringUtils.isEmpty(cellValue) || !cell.toString().equals("null")) { |
| | | return; |
| | | } |
| | | |
| | | Date startDate; |
| | | |
| | | try { |
| | | startDate = cell.getDateCellValue(); |
| | | } catch (Exception e) { |
| | | Date startDate = DateUtil.convertStrToDateOnly(periodDate); |
| | | if (startDate == null) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_VALIDITY_EMPTY, rowIndex)); |
| | | } |
| | |
| | | } else { |
| | | issueForm.setCompleteDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd")); |
| | | |
| | | // 종료일만 입력 했을 경우 |
| | | if (issueForm.getCompleteDate() != null && issueForm.getStartDate() == null) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_VALIDITY_EMPTY_START, rowIndex)); |
| | | } |
| | | |
| | | try { |
| | | // 날짜 유효성 체크 |
| | | this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate()); |
| | | } catch (OwlRuntimeException e) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_VALIDITY, rowIndex)); |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_VALID, rowIndex)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 사용자 정의 필드 정보를 IssueForm 에 저장한다.- |
| | | private void setIssueFormCustomFieldValue(Cell cell, Map<String, CustomField> customFieldMaps, IssueForm issueForm, String customFieldName, int rowIndex) { |
| | | if (!cellNullCheck(cell)) { |
| | | String cellValue = CommonUtil.convertExcelStringToCell(cell); |
| | | Map<String, Object> issueCustomFieldMap = new HashMap<>(); |
| | | CustomField customField = customFieldMaps.get(customFieldName); |
| | | private void setIssueFormCustomFieldValue(String cellValue, Map<String, CustomField> customFieldMaps, IssueForm issueForm, String customFieldName, int rowIndex) { |
| | | Map<String, Object> issueCustomFieldMap = new HashMap<>(); |
| | | CustomField customField = customFieldMaps.get(customFieldName); |
| | | |
| | | if (customField == null) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HEADER_CUSTOM_FIELD_NOT_EXIST, rowIndex)); |
| | | } |
| | | // 사용자 정의 필드 값이 공백이면 중지 |
| | | if (StringUtils.isEmpty(cellValue)) { |
| | | return; |
| | | } |
| | | if (customField == null) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HEADER_CUSTOM_FIELD_NOT_EXIST, rowIndex)); |
| | | } |
| | | // 사용자 정의 필드 값이 공백이면 중지 |
| | | if (StringUtils.isEmpty(cellValue)) { |
| | | return; |
| | | } |
| | | |
| | | boolean validity = false; |
| | | boolean validity = false; |
| | | |
| | | switch (customField.getCustomFieldType()) { |
| | | case INPUT: |
| | | case NUMBER: |
| | | case DATETIME: |
| | | case IP_ADDRESS: |
| | | case EMAIL: |
| | | case SITE: |
| | | case TEL: |
| | | if (customField.getCustomFieldType() != INPUT && cellValue.length() > 100) { //INPUT 타입은 100자 제한 없음 |
| | | switch (customField.getCustomFieldType()) { |
| | | case INPUT: |
| | | case NUMBER: |
| | | case DATETIME: |
| | | case IP_ADDRESS: |
| | | case EMAIL: |
| | | case SITE: |
| | | case TEL: |
| | | if (customField.getCustomFieldType() != INPUT && cellValue.length() > 100) { //INPUT 타입은 100자 제한 없음 |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_TEXT_TYPE_MAX_LENGTH_OUT)); |
| | | } |
| | | |
| | | //DATETIME일 경우 format 변경 |
| | | if (customField.getCustomFieldType() == DATETIME) { |
| | | Date date = DateUtil.convertStrToDate(cellValue); |
| | | if (date == null) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_TEXT_TYPE_MAX_LENGTH_OUT)); |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_DATETIME_NOT_DASH, rowIndex)); |
| | | } |
| | | } |
| | | |
| | | if (customField.getCustomFieldType() == DATETIME) { //DATETIME일 경우 format 변경 |
| | | Date date = cell.getDateCellValue(); |
| | | cellValue = new SimpleDateFormat("yyyy-MM-dd H:mm:ss").format(date); |
| | | //IP_ADDRESS일 경우 정규표현식 체크 |
| | | if (customField.getCustomFieldType() == IP_ADDRESS) { |
| | | String regExp = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." |
| | | + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." |
| | | + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." |
| | | + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; |
| | | |
| | | if (!cellValue.matches(regExp)) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_IP_ADDRESS_NOT_VALIDITY, rowIndex)); |
| | | } |
| | | } |
| | | |
| | | issueCustomFieldMap.put("customFieldId", customField.getId()); |
| | | issueCustomFieldMap.put("useValue", cellValue); |
| | | issueForm.addIssueCustomFields(issueCustomFieldMap); |
| | | break; |
| | | case SINGLE_SELECT: |
| | | // 값 유효성 체크 |
| | | issueCustomFieldMap.put("customFieldId", customField.getId()); |
| | | issueCustomFieldMap.put("useValue", cellValue); |
| | | issueForm.addIssueCustomFields(issueCustomFieldMap); |
| | | break; |
| | | case SINGLE_SELECT: |
| | | // 값 유효성 체크 |
| | | for (CustomFieldValue customFieldValue : customField.getCustomFieldValues()) { |
| | | if (customFieldValue.getValue().equals(cellValue)) { |
| | | validity = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (!validity) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex)); |
| | | } |
| | | |
| | | issueCustomFieldMap.put("customFieldId", customField.getId()); |
| | | issueCustomFieldMap.put("useValue", cellValue); |
| | | issueForm.addIssueCustomFields(issueCustomFieldMap); |
| | | |
| | | break; |
| | | case MULTI_SELECT: |
| | | // 값 유효성 체크 |
| | | String[] useValues = cellValue.split("#"); |
| | | // 해, 달 |
| | | for (String useValue : useValues) { |
| | | for (CustomFieldValue customFieldValue : customField.getCustomFieldValues()) { |
| | | if (customFieldValue.getValue().equals(cellValue)) { |
| | | |
| | | if (customFieldValue.getValue().equals(useValue)) { |
| | | validity = true; |
| | | break; |
| | | Map<String, Object> multiValueMap = new HashMap<>(); |
| | | multiValueMap.put("customFieldId", customField.getId()); |
| | | multiValueMap.put("useValue", useValue); |
| | | issueForm.addIssueCustomFields(multiValueMap); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | if (!validity) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex)); |
| | | } |
| | | if (!validity) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex)); |
| | | } |
| | | |
| | | issueCustomFieldMap.put("customFieldId", customField.getId()); |
| | | issueCustomFieldMap.put("useValue", cellValue); |
| | | issueForm.addIssueCustomFields(issueCustomFieldMap); |
| | | |
| | | break; |
| | | case MULTI_SELECT: |
| | | // 값 유효성 체크 |
| | | String[] useValues = cellValue.split("#"); |
| | | // 해, 달 |
| | | for (String useValue : useValues) { |
| | | for (CustomFieldValue customFieldValue : customField.getCustomFieldValues()) { |
| | | |
| | | if (customFieldValue.getValue().equals(useValue)) { |
| | | validity = true; |
| | | Map<String, Object> multiValueMap = new HashMap<>(); |
| | | multiValueMap.put("customFieldId", customField.getId()); |
| | | multiValueMap.put("useValue", useValue); |
| | | issueForm.addIssueCustomFields(multiValueMap); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | if (!validity) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex)); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | |
| | | 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"); |