OWL ITS + 탐지시스템(인터넷 진흥원)
src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java
@@ -81,6 +81,8 @@
    // 업체 추가
    @Override
    public CompanyField addCompany(CompanyFieldForm companyFieldForm) {
        //  업체명 중복 체크
        this.verifyTitle(companyFieldForm.getName(), null);
        //  url 유효성 체크
        this.verifyUrl(companyFieldForm.getUrl(), null);
@@ -109,7 +111,7 @@
    private void verifyUrl(String url, Long id) {
        if (StringUtils.isEmpty(url)) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.COMPANYFIELD_NOT_URL));
                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NOT_URL));
        }
        CompanyField companyField;
@@ -121,7 +123,7 @@
        if (companyField != null) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.COMPANYFIELD_USED_URL));
                    this.messageAccessor.getMessage(MsgConstants.COMPANY_USED_URL));
        }
    }
@@ -218,6 +220,8 @@
    // 업체 정로를 수정한다.
    @Override
    public void modifyCompany(CompanyFieldForm companyFieldForm) {
        //  업체명 유효성 체크
        this.verifyTitle(companyFieldForm.getName(), companyFieldForm.getId());
        //  url 유효성 체크
        this.verifyUrl(companyFieldForm.getUrl(), companyFieldForm.getId());
@@ -236,10 +240,12 @@
            companyFieldForm.setEmail(emails.trim());
        }
        CompanyFieldCategory companyFieldCategory = this.companyFieldCategoryService.find(companyFieldForm.getChildSectorId());
        if (!companyFieldCategory.getParentId().equals(companyFieldForm.getParentSectorId())) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.PARENT_SECTOR_NOT_EQUAL));
        if (companyFieldForm.getChildSectorId() != null) {
            CompanyFieldCategory companyFieldCategory = this.companyFieldCategoryService.find(companyFieldForm.getChildSectorId());
            if (!companyFieldCategory.getParentId().equals(companyFieldForm.getParentSectorId())) {
                throw new OwlRuntimeException(
                        this.messageAccessor.getMessage(MsgConstants.PARENT_SECTOR_NOT_EQUAL));
            }
        }
        CompanyField companyField = ConvertUtil.copyProperties(companyFieldForm, CompanyField.class);
@@ -382,7 +388,7 @@
            for (int rowIndex = 0; rowIndex < lastRowNum; rowIndex++) {
                //  0번은 헤더는 무시한다.
                Row row = sheet.getRow(rowIndex);
                //  헤더 정보를 추출한다 - 사용자 정의 필드 정보를 가져오기 위해
                //  헤더 정보를 추출한다
                if (rowIndex == 1) {
                    for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) {
                        Cell cell = row.getCell(cellIndex);
@@ -443,7 +449,6 @@
        CompanyFieldForm companyFieldForm = new CompanyFieldForm();
        companyFieldForm.setRegisterId(this.webAppUtil.getLoginId());
        //  제목, 내용, 프로젝트 키, 이슈 타입, 우선순위, 중요도, 담당자, 시작일, 종료일, 사용자 정의 필드
        for (int cellIndex = 0; cellIndex < headers.size(); cellIndex++) {
            Cell cell = row.getCell(cellIndex);
            switch (cellIndex) {
@@ -525,6 +530,7 @@
                    if (cellNullCheck(cell)) {
                        this.setCompanyFormStatus(cell, statusMaps, companyFieldForm, rowIndex);
                    }
                    break;
                case 12:
                    // 비고
@@ -568,10 +574,19 @@
    private void setCompanyFormChildSector(Cell cell, Map<String, Map<String, Object>> childSectorMaps, CompanyFieldForm companyFieldForm, int rowIndex) {
        if (cell != null) {
            Map<String, Object> childSectorMap = childSectorMaps.get(CommonUtil.convertExcelStringToCell(cell));
            //  대분류 없이 중분류만 입력했을경우
            if (companyFieldForm.getParentSectorId() == null) {
                throw new OwlRuntimeException(
                        this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PARENT_SECTOR_IS_NULL, rowIndex));
            }
            //  중분류가 대분류에 속해있지 않는 경우
            if (!companyFieldForm.getParentSectorId().equals(MapUtil.getLong(childSectorMap, "parentId"))) {
                throw new OwlRuntimeException(
                        this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PARENT_SECTOR_NOT_EQUAL, rowIndex));
            }
            companyFieldForm.setChildSectorId(MapUtil.getLong(childSectorMap, "id"));
        }
    }
@@ -658,7 +673,7 @@
        String title = CommonUtil.convertExcelStringToCell(cell);
        //  업체명 유효성 체크
        this.verifyTitle(title);
        this.verifyTitle(title, null);
        companyFieldForm.setName(title);
    }
@@ -677,15 +692,31 @@
    }
    //  업체명 유효성 체크
    private void verifyTitle(String title) {
        if (StringUtils.isEmpty(title)) {
    private void verifyTitle(String title, Long id) {
        List<CompanyField> companyFields = new ArrayList<>();
        //  업체명 중복 체크
        if (id != null) { //수정 일 경우
            companyFields = this.companyFieldRepository.findByNameAndIdNot(title, id);
        } else { // 추가 일 경우
            companyFields = this.companyFieldRepository.findByName(title);
        }
        if (companyFields != null && companyFields.size() > 0) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.ISSUE_NO_TITLE));
                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NAME_ALREADY_IN_USE));
        }
        //  업체명 빈값 체크
        if (StringUtils.isEmpty(title)) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NO_TITLE));
        }
        //  업체명 길이 체크
        if (title.length() > 300) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.ISSUE_TITLE_MAX_LENGTH_OUT));
                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NAME_MAX_LENGTH_OUT));
        }
    }
@@ -817,13 +848,13 @@
    public CompanyField getCompany(Long id) {
        if (id == null) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.COMPANYFIELD_NOT_EXIST));
                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NOT_EXIST));
        }
        CompanyField companyField = this.findOne(id);
        if (companyField == null) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.COMPANYFIELD_NOT_EXIST));
                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NOT_EXIST));
        }
        return companyField;
    }