From 6806bad8f7e6132c9ba74d7e815ab7d64ecebe9c Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 화, 08 2월 2022 14:11:58 +0900
Subject: [PATCH] - 이슈 임포트 시 공백 오류 수정

---
 src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java |   60 ++++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 42 insertions(+), 18 deletions(-)

diff --git a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
index 45418f0..144a7d1 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -49,9 +49,9 @@
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.regex.Pattern;
 
-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 {
@@ -311,7 +311,7 @@
                     issueApiForm.addUseIssueCustomFieldId(customFieldApiOverlap.getCustomField().getId());
                 }
 
-                // 醫낅즺�긽�깭媛� �븘�땶 以묐났�맂 �긽�쐞 �씠�뒋寃��깋
+                // 以묐났�맂 �긽�쐞 �씠�뒋寃��깋
                 List<Issue> issues = this.findIssue(issueApiForm, customFieldApiOverlaps, user.getId());
                 int size = issues.size();
                 if (size > 0) {
@@ -468,7 +468,7 @@
             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) {
@@ -523,6 +523,12 @@
         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));    //  媛� �봽濡쒖젥�듃�쓽 怨좎쑀 �씠�뒋 踰덊샇 �깮�꽦
@@ -3191,7 +3197,7 @@
             //  �씠�뒋 �떞�떦�옄 踰뚰겕 �벑濡�
             this.bulkInsertIssueAssignee(issueForms, workspace);
             //  0.361 - 0.705
-            
+
             //  1.816
             /*StopWatch serviceStart = new StopWatch();
             serviceStart.start();*/
@@ -3229,7 +3235,7 @@
                 issueCompany.setCompanyField(companyField);
                 issueCompany.setIssue(issue);
                 this.issueCompanyRepository.saveAndFlush(issueCompany);
-                
+
                 //  �궗�슜�옄媛� ISP瑜� 吏곸젒 �엯�젰�븯吏� �븡�븯�쓣 寃쎌슦 �뾽泥댁뿉 �벑濡앸릺�뼱�엳�뒗 ISP �꽕�젙 
                 if (issueForm.getIssueIspFields() == null || issueForm.getIssueIspFields().size() < 1) {
                     //  �뾽泥댁쓽 ISP媛� �엳�뒗 寃쎌슦 issueISP �벑濡�
@@ -3373,7 +3379,7 @@
                 issueCustomField.put("registerId", this.webAppUtil.getLoginId());
                 issueCustomFieldValueMaps.add(issueCustomField);
             }
-            
+
             //  �뿊���뿉 �뾽泥대챸�쓣 �엯�젰�븯吏� �븡�븯�쓣 寃쎌슦 媛숈� �룄硫붿씤 �뾽泥� 李얘린
             if (issueForm.getIssueCompanyFields() == null || issueForm.getIssueCompanyFields().size() < 1) {
                 // 媛숈� �룄硫붿씤 �뾽泥� 李얘린
@@ -3465,23 +3471,26 @@
 
     /**
      * cell NULL 泥댄겕 �븿�닔
-     * 臾몄옄�삎�떇 cell 泥댄겕
+     * 鍮� 媛믪씠 �븘�땶 cell 泥댄겕
      * @param cell Cell
      * @return boolean
      */
     private Boolean cellNullCheck (Cell cell) {
         if (cell != null ) {
-            if (cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                if (cell.getCellType() == Cell.CELL_TYPE_STRING && cell.getStringCellValue() != 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 {
                     return false;
                 }
             }
         }
         return true;
     }
-
-
-
 
     //  �뿊�� �븘�뱶�뿉 �엳�뒗 �젙蹂대�� �씠�뒋 form �쑝濡� �삷湲대떎.
     private IssueForm setIssueFormToExcelField(Row row, int rowIndex, Map<String, Priority> priorityMaps,
@@ -3499,6 +3508,7 @@
             boolean isNull = cellNullCheck(cell);
 
             String cellStr = "";
+
             if (!isNull) {
                 cellStr = CommonUtil.convertExcelStringToCell(cell);
 
@@ -3702,10 +3712,10 @@
             }
 
             if (checkStartDate) {
-                issueForm.setStartDate(periodDate);
+                issueForm.setStartDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd"));
             } else {
-                issueForm.setCompleteDate(periodDate);
-                
+                issueForm.setCompleteDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd"));
+
                 //  醫낅즺�씪留� �엯�젰 �뻽�쓣 寃쎌슦
                 if (issueForm.getCompleteDate() != null && issueForm.getStartDate() == null) {
                     throw new OwlRuntimeException(
@@ -3717,7 +3727,7 @@
                     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));
                 }
             }
         }
@@ -3752,7 +3762,8 @@
                             this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_TEXT_TYPE_MAX_LENGTH_OUT));
                 }
 
-                if (customField.getCustomFieldType() == DATETIME) { //DATETIME�씪 寃쎌슦 format 蹂�寃�
+                //DATETIME�씪 寃쎌슦 format 蹂�寃�
+                if (customField.getCustomFieldType() == DATETIME) {
                     Date date = DateUtil.convertStrToDate(cellValue);
                     if (date == null) {
                         throw new OwlRuntimeException(
@@ -3760,6 +3771,19 @@
                     }
                 }
 
+                //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);

--
Gitblit v1.8.0