| | |
| | | import kr.wisestone.owl.exception.OwlRuntimeException; |
| | | import kr.wisestone.owl.mapper.CustomFieldMapper; |
| | | import kr.wisestone.owl.repository.CustomFieldRepository; |
| | | import kr.wisestone.owl.repository.IssueTypeCustomFieldRepository; |
| | | import kr.wisestone.owl.service.*; |
| | | import kr.wisestone.owl.util.ConvertUtil; |
| | | import kr.wisestone.owl.util.MapUtil; |
| | |
| | | |
| | | @Autowired |
| | | private CustomFieldRepository customFieldRepository; |
| | | |
| | | @Autowired |
| | | private IssueTypeCustomFieldRepository issueTypeCustomFieldRepository; |
| | | |
| | | @Autowired |
| | | private CustomFieldMapper customFieldMapper; |
| | |
| | | |
| | | // 옵션 값 유효 체크 |
| | | private void verifyOptions(CustomFieldForm customFieldForm) { |
| | | // 사용자 정의 필드 유형이 텍스트 일때는 옵션 값이 존재하면 안된다. |
| | | if (CustomFieldType.valueOf(customFieldForm.getCustomFieldType()).equals(CustomFieldType.INPUT)) { |
| | | // 사용자 정의 필드 유형이 텍스트 일때는 옵션 값이 존재하면 안된다. => 단일선택 또는 다중선택 필드가 아닐 경우 옵션 값 존재 하면 안되는 것으로 변경 |
| | | if (!CustomFieldType.valueOf(customFieldForm.getCustomFieldType()).equals(CustomFieldType.MULTI_SELECT) && !CustomFieldType.valueOf(customFieldForm.getCustomFieldType()).equals(CustomFieldType.SINGLE_SELECT)) { |
| | | if (customFieldForm.getOptions().size() > 0) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_OPTIONS_NOT_USE_INPUT_FIELD)); |
| | |
| | | } |
| | | // 기본 값으로 지정한 값이 옵션에 있는지 확인한다. |
| | | this.verifyOptionsDefaultValue(customFieldForm); |
| | | |
| | | break; |
| | | case MULTI_SELECT: |
| | | // 기본 값으로 지정한 값이 옵션에 있는지 확인한다. |
| | |
| | | |
| | | // 사용자 정의 필드 유형이 단일, 다중 선택에서 문자열로 변경될 경우 사용자 정의 필드 값을 초기화한다. |
| | | private void checkChangeCustomFieldType(CustomFieldForm customFieldForm, CustomField customField) { |
| | | if (!customField.getCustomFieldType().equals(CustomFieldType.INPUT)) { |
| | | if (customField.getCustomFieldType().equals(CustomFieldType.MULTI_SELECT) || customField.getCustomFieldType().equals(CustomFieldType.SINGLE_SELECT)) { |
| | | // 단일, 다중 선택에서 문자열 필드로 변경된 경우 |
| | | if (CustomFieldType.valueOf(customFieldForm.getCustomFieldType()).equals(CustomFieldType.INPUT)) { |
| | | if (!CustomFieldType.valueOf(customFieldForm.getCustomFieldType()).equals(CustomFieldType.MULTI_SELECT) && !CustomFieldType.valueOf(customFieldForm.getCustomFieldType()).equals(CustomFieldType.SINGLE_SELECT)) { |
| | | customField.getCustomFieldValues().clear(); |
| | | } |
| | | } |
| | |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_NOT_EXIST)); |
| | | } |
| | | |
| | | |
| | | CustomField customField = this.findOne(id); |
| | | |
| | |
| | | public void removeCustomFields(CustomFieldForm customFieldForm) { |
| | | // 사용하고 있는 업무 공간이 활성 상태인지 확인한다. 사용 공간에서 로그인한 사용자가 비활성인지 확인한다. |
| | | this.workspaceService.checkUseWorkspace(); |
| | | |
| | | if (customFieldForm.getRemoveIds().size() < 1) { |
| | | List<Long> removeIds = customFieldForm.getRemoveIds(); |
| | | if (removeIds.size() < 1) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_REMOVE_NOT_SELECT)); |
| | | }else { |
| | | for (Long id : removeIds) { |
| | | Long count = this.issueTypeCustomFieldRepository.countByCustomFieldId(id); |
| | | if (count > 0){ |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_USED_DATA_REMOVE)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (Long projectId : customFieldForm.getRemoveIds()) { |
| | |
| | | } |
| | | |
| | | // this.customFieldRepository.flush(); |
| | | this.customFieldRepository.flush(); |
| | | } |
| | | |
| | | private void removeCustomFields(Long customFieldId) { |
| | |
| | | customField.setUse(UseType.N.toString()); |
| | | this.customFieldRepository.saveAndFlush(customField); |
| | | // this.customFieldRepository.delete(customField); |
| | | this.customFieldRepository.delete(customField); |
| | | } |
| | | |
| | | // 이슈 엑셀 import 에서 사용한다. |
| | |
| | | case "MULTI_SELECT" : |
| | | customFieldTypeName = this.messageAccessor.message("common.multipleSelectionField"); // 다중 선택 필드 |
| | | break; |
| | | case "NUMBER" : |
| | | customFieldTypeName = this.messageAccessor.message("common.numberField"); // 숫자 필드 |
| | | break; |
| | | case "DATETIME" : |
| | | customFieldTypeName = this.messageAccessor.message("common.datetimeField"); // 날짜 필드 |
| | | break; |
| | | case "IP_ADDRESS" : |
| | | customFieldTypeName = this.messageAccessor.message("common.ipAddressField"); // IP 주소 필드 |
| | | break; |
| | | case "EMAIL" : |
| | | customFieldTypeName = this.messageAccessor.message("common.emailField"); // 이메일 필드 |
| | | break; |
| | | case "SITE" : |
| | | customFieldTypeName = this.messageAccessor.message("common.siteField"); // 홈페이지 주소 필드 |
| | | break; |
| | | case "TEL" : |
| | | customFieldTypeName = this.messageAccessor.message("common.telField"); // 전화번호 필드 |
| | | break; |
| | | } |
| | | } |
| | | |