From 3d47c9ac30b3c79ec8909b89c3439f7d74cd488b Mon Sep 17 00:00:00 2001 From: MorkovkAs Date: Thu, 24 Nov 2022 00:23:10 +0300 Subject: [PATCH] Added externalJiraLink to model. Done some refactoring --- gradle/wrapper/gradle-wrapper.properties | 5 +- report-service-ui/build.gradle | 2 +- report-service/build.gradle | 4 +- .../ru/morkovka/report/entity/ReleaseNote.kt | 6 - .../kotlin/ru/morkovka/report/entity/Task.kt | 1 + .../ru/morkovka/report/entity/TaskFeature.kt | 3 +- .../morkovka/report/entity/dto/FieldsDto.kt | 1 + .../report/entity/mapper/TaskMapper.kt | 1 + .../report/service/impl/ReleaseServiceImpl.kt | 113 ++++++++++-------- .../report/service/impl/TaskServiceImpl.kt | 29 +++-- .../src/main/resources/application.yml | 37 +++--- 11 files changed, 109 insertions(+), 93 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d77a9da..be52383 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Tue Apr 21 18:23:58 MSK 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/report-service-ui/build.gradle b/report-service-ui/build.gradle index 8408e83..b16522f 100644 --- a/report-service-ui/build.gradle +++ b/report-service-ui/build.gradle @@ -16,7 +16,7 @@ group = "com.morkovka.jira-report-tools" version '0.0.1' java { - targetCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_11 } frontend { diff --git a/report-service/build.gradle b/report-service/build.gradle index cd35f4a..acd6641 100644 --- a/report-service/build.gradle +++ b/report-service/build.gradle @@ -37,10 +37,10 @@ dependencies { } compileKotlin { - kotlinOptions.jvmTarget = "1.8" + kotlinOptions.jvmTarget = "11" } compileTestKotlin { - kotlinOptions.jvmTarget = "1.8" + kotlinOptions.jvmTarget = "11" } // clean service and ui files diff --git a/report-service/src/main/kotlin/ru/morkovka/report/entity/ReleaseNote.kt b/report-service/src/main/kotlin/ru/morkovka/report/entity/ReleaseNote.kt index d7988f9..ae80fea 100644 --- a/report-service/src/main/kotlin/ru/morkovka/report/entity/ReleaseNote.kt +++ b/report-service/src/main/kotlin/ru/morkovka/report/entity/ReleaseNote.kt @@ -6,12 +6,6 @@ data class ReleaseNote( */ var taskInKey: String, - /** - * Map to store corresponded Jira keys of issues. - * The key in map is a key from our Jira, the value in map is a key of task in customer's Jira - */ - var jiraKeysMap: MutableMap, - /** * Исходные коды */ diff --git a/report-service/src/main/kotlin/ru/morkovka/report/entity/Task.kt b/report-service/src/main/kotlin/ru/morkovka/report/entity/Task.kt index f1b1e49..1dd4ac1 100644 --- a/report-service/src/main/kotlin/ru/morkovka/report/entity/Task.kt +++ b/report-service/src/main/kotlin/ru/morkovka/report/entity/Task.kt @@ -4,6 +4,7 @@ data class Task( val id: Long, val key: String, val link: String, + var externalJiraLink: String, var summary: String, var status: String, var description: String, diff --git a/report-service/src/main/kotlin/ru/morkovka/report/entity/TaskFeature.kt b/report-service/src/main/kotlin/ru/morkovka/report/entity/TaskFeature.kt index f7312a7..da75eb1 100644 --- a/report-service/src/main/kotlin/ru/morkovka/report/entity/TaskFeature.kt +++ b/report-service/src/main/kotlin/ru/morkovka/report/entity/TaskFeature.kt @@ -3,5 +3,6 @@ package ru.morkovka.report.entity data class TaskFeature( val key: String, val link: String, - var summary: String + var summary: String, + var externalJiraKey: String ) \ No newline at end of file diff --git a/report-service/src/main/kotlin/ru/morkovka/report/entity/dto/FieldsDto.kt b/report-service/src/main/kotlin/ru/morkovka/report/entity/dto/FieldsDto.kt index f96e17f..00c1d70 100644 --- a/report-service/src/main/kotlin/ru/morkovka/report/entity/dto/FieldsDto.kt +++ b/report-service/src/main/kotlin/ru/morkovka/report/entity/dto/FieldsDto.kt @@ -5,5 +5,6 @@ data class FieldsDto( val status: HashMap?, val description: String?, val fixVersions: ArrayList>?, + val customfield_13700: String?, //our custom field in Jira for external tasks val comment: CommentsDto? ) \ No newline at end of file diff --git a/report-service/src/main/kotlin/ru/morkovka/report/entity/mapper/TaskMapper.kt b/report-service/src/main/kotlin/ru/morkovka/report/entity/mapper/TaskMapper.kt index 17c6ab2..fbe3bbc 100644 --- a/report-service/src/main/kotlin/ru/morkovka/report/entity/mapper/TaskMapper.kt +++ b/report-service/src/main/kotlin/ru/morkovka/report/entity/mapper/TaskMapper.kt @@ -19,6 +19,7 @@ class TaskMapper { .map { it["name"] } .filter(Objects::nonNull) .collect(Collectors.toList()), + externalJiraLink = taskDto.fields.customfield_13700 ?: "", comments = (taskDto.fields.comment?.comments ?: arrayListOf>()).stream() .filter(Objects::nonNull) .map { it["body"] as String } diff --git a/report-service/src/main/kotlin/ru/morkovka/report/service/impl/ReleaseServiceImpl.kt b/report-service/src/main/kotlin/ru/morkovka/report/service/impl/ReleaseServiceImpl.kt index 6f64828..4c8c6fe 100644 --- a/report-service/src/main/kotlin/ru/morkovka/report/service/impl/ReleaseServiceImpl.kt +++ b/report-service/src/main/kotlin/ru/morkovka/report/service/impl/ReleaseServiceImpl.kt @@ -16,8 +16,8 @@ import java.util.stream.Collectors @Service class ReleaseServiceImpl( - @Value("\${jira.search.default.task.out.paragraph}") - val taskOutParagraph: String, + @Value("\${jira.search.default.task.paragraph}") + val tasksParagraph: String, @Value("\${jira.search.default.task.in.start}") val taskInStart: String, @@ -95,35 +95,59 @@ class ReleaseServiceImpl( if (note.taskInKey.isNotEmpty()) { taskIn = "{Jira:${note.taskInKey}}" } - val s = "$taskOutParagraph\n" + - "\n\n${taskInParagraph}\n$taskIn" + - "\n\n${commentProperties.sourceCode.paragraph}\n${stringFromMapWithoutTaskKeys( - note.sourceCode, commentProperties.sourceCode.default - )}" + - "\n\n${commentProperties.artifact.paragraph}\n${stringFromMapWithoutTaskKeys( - note.artifact, commentProperties.artifact.default - )}" + - "\n\n${commentProperties.newFeature.paragraph}\n${stringFromFeatures( - note.features, note.jiraKeysMap, commentProperties.newFeature.default - )}" + - "\n\n${commentProperties.databaseChange.paragraph}\n${stringFromMapWithoutTaskKeys( - note.dbChanges, commentProperties.databaseChange.default - )}" + - "\n\n${commentProperties.monitoringChange.paragraph}\n${stringFromMapWithoutTaskKeys( - note.monitoringChanges, commentProperties.monitoringChange.default - )}" + - "\n\n${commentProperties.config.paragraph}\n${stringFromMapWithoutTaskKeys( - note.configs, commentProperties.config.default - )}" + - "\n\n${commentProperties.deployInstruction.paragraph}\n${stringFromMapWithoutTaskKeys( - note.deploy, commentProperties.deployInstruction.default - )}" + - "\n\n${commentProperties.testCase.paragraph}\n${stringFromMapWithTaskKeys( - note.testCase, true, commentProperties.testCase.default - )}" + - "\n\n${commentProperties.rollbackAction.paragraph}\n${stringFromMapWithoutTaskKeys( - note.rollback, commentProperties.rollbackAction.default - )}" + val s = """ +{toc:printable=true|maxLevel=7|minLevel=1|type=list|separator=brackets} + +$tasksParagraph +$taskInParagraph +* $taskIn +* + +${commentProperties.sourceCode.paragraph} +${stringFromMapWithoutTaskKeys( + note.sourceCode, commentProperties.sourceCode.default +)} + +${commentProperties.artifact.paragraph} +${stringFromMapWithoutTaskKeys( + note.artifact, commentProperties.artifact.default +)} + +${commentProperties.newFeature.paragraph} +${stringFromFeatures( + note.features, commentProperties.newFeature.default +)} + +${commentProperties.databaseChange.paragraph} +${stringFromMapWithoutTaskKeys( + note.dbChanges, commentProperties.databaseChange.default +)} + +${commentProperties.monitoringChange.paragraph} +${stringFromMapWithoutTaskKeys( + note.monitoringChanges, commentProperties.monitoringChange.default +)} + +${commentProperties.config.paragraph} +${stringFromMapWithoutTaskKeys( + note.configs, commentProperties.config.default +)} + +${commentProperties.deployInstruction.paragraph} +${stringFromMapWithoutTaskKeys( + note.deploy, commentProperties.deployInstruction.default +)} + +${commentProperties.testCase.paragraph} +${stringFromMapWithTaskKeys( + note.testCase, true, commentProperties.testCase.default +)} + +${commentProperties.rollbackAction.paragraph} +${stringFromMapWithoutTaskKeys( + note.rollback, commentProperties.rollbackAction.default +)} +""" logger.info("releaseNoteToString [jiraFixVersion = $jiraFixVersion]: ReleaseNote to String convertation completed") @@ -140,30 +164,21 @@ class ReleaseServiceImpl( private fun getReleaseNoteFromTaskList(taskList: MutableList): ReleaseNote { val taskIn = taskList.filter { it.summary.startsWith(taskInStart) }.getOrNull(0) - val jiraKeys: MutableMap = mutableMapOf() val features: MutableMap = mutableMapOf() taskList .filter { !it.summary.startsWith((taskInStart)) } .forEach { - // Fill collection for mapping jira tasks - val regex = ("(\\[ссылка\\|https*://jcs\\.passport\\.local/(browse|projects/MDM/issues)/MDM-[0-9]+]" + - " на задачу в джире ДИТа)").toRegex(RegexOption.IGNORE_CASE) - val taskOutKey = regex.find(it.description) - if (taskOutKey != null) { - jiraKeys[it.key] = "MDM-[0-9]+".toRegex(RegexOption.IGNORE_CASE).find(taskOutKey.value)?.value ?: "" - } - // Fill release features features[it.key] = TaskFeature( key = it.key, link = it.link, - summary = it.summary + summary = it.summary, + externalJiraKey = "NMDM-[0-9]+".toRegex(RegexOption.IGNORE_CASE).find(it.externalJiraLink)?.value ?: "" ) } val note = ReleaseNote( taskInKey = taskIn?.key ?: "", - jiraKeysMap = jiraKeys, sourceCode = getCommentsFromTaskListByKeyword(taskList, commentProperties.sourceCode.start), artifact = getCommentsFromTaskListByKeyword(taskList, commentProperties.artifact.start), features = features, @@ -232,18 +247,20 @@ class ReleaseServiceImpl( * @return String consisted of features' info. */ - private fun stringFromFeatures(map: MutableMap, keyMap: MutableMap, defaultValue: String): String { + private fun stringFromFeatures(map: MutableMap, defaultValue: String): String { if (map.isEmpty()) { return defaultValue } - var s = "||Задача в jira||Задача в jira ТаскДата||Наименование задачи в jira ТаскДата||"; + var s = "||Задача ДИТ||Задача ЮД||Наименование||" map.forEach { (key, task) -> - var taskOutKey = keyMap.getOrDefault(key, " ") - if (taskOutKey != " ") { - taskOutKey = "{Jira:$taskOutKey}" + var externalJiraKey = task.externalJiraKey + if (externalJiraKey.trim().isNotEmpty()) { + externalJiraKey = "{Jira:${externalJiraKey}}" + } else { + externalJiraKey = " " } - s += "\n|$taskOutKey|{Jira:$key}|${task.summary}|" + s += "\n|$externalJiraKey|{Jira:$key}|${task.summary}|" } return s } diff --git a/report-service/src/main/kotlin/ru/morkovka/report/service/impl/TaskServiceImpl.kt b/report-service/src/main/kotlin/ru/morkovka/report/service/impl/TaskServiceImpl.kt index 0353705..6c6393d 100644 --- a/report-service/src/main/kotlin/ru/morkovka/report/service/impl/TaskServiceImpl.kt +++ b/report-service/src/main/kotlin/ru/morkovka/report/service/impl/TaskServiceImpl.kt @@ -93,18 +93,21 @@ class TaskServiceImpl( return taskList } - private fun getRequestJsonForJqlQuery(jqlString: String, maxResults: Int) = - "{\n" + - " \"jql\": \"$jqlString ORDER BY key ASC\",\n" + - " \"startAt\": 0,\n" + - " \"maxResults\": $maxResults,\n" + - " \"fields\": [\n" + - " \"summary\",\n" + - " \"status\",\n" + - " \"description\",\n" + - " \"fixVersions\",\n" + - " \"comment\"\n" + - " ]\n" + - "}" + /** + * Generates a JQL search string. customfield_13700 is our custom field for external tasks. + */ + private fun getRequestJsonForJqlQuery(jqlString: String, maxResults: Int) = """{ + "jql": "$jqlString ORDER BY key ASC", + "startAt": 0, + "maxResults": $maxResults, + "fields": [ + "summary", + "status", + "description", + "fixVersions", + "comment", + "customfield_13700" + ] +}""" } \ No newline at end of file diff --git a/report-service/src/main/resources/application.yml b/report-service/src/main/resources/application.yml index 6d4fbd6..106488f 100644 --- a/report-service/src/main/resources/application.yml +++ b/report-service/src/main/resources/application.yml @@ -10,7 +10,7 @@ jira: basic: ${JIRA_AUTH_BASIC:Basic TW9ya292a0E6bXlTdXBlclBhc3M} paragraph: font: - size: "h3." + size: "h1." start: font: size: "h2." @@ -19,45 +19,44 @@ jira: project: "DM" limit: 15 task: - out: - paragraph: "${jira.paragraph.font.size}Задача в Jira заказчика" + paragraph: "${jira.paragraph.font.size}*Ресурсы*" in: - start: "Релиз КСРД" - paragraph: "${jira.paragraph.font.size}Задача в Jira ТД" + start: "Релиз " + paragraph: "_Задача в Jira:_" comment: source-code: start: "${jira.start.font.size}Исходные коды:" - paragraph: "${jira.paragraph.font.size}Исходные коды" + paragraph: "_Исходные коды:_" default: ${SOURCE_CODE:*{color:#FF0000}Не заполнено.{color}*} artifact: start: "${jira.start.font.size}Артефакты:" - paragraph: "${jira.paragraph.font.size}Артефакты" + paragraph: "${jira.paragraph.font.size}*Артефакты*" default: ${STORAGE_LINK:*{color:#FF0000}Не заполнено.{color}*} new-feature: start: "${jira.start.font.size}Новые функции и исправления:" - paragraph: "${jira.paragraph.font.size}Новые функции и исправления" + paragraph: "${jira.paragraph.font.size}*Новые функции и исправления*" default: "*{color:#FF0000}Не заполнено.{color}*" database-change: start: "${jira.start.font.size}Настройки и изменения в структуре БД, атрибутах, справочниках:" - paragraph: "${jira.paragraph.font.size}Настройки и изменения в структуре БД, атрибутах, справочниках" - default: "Не применимо." + paragraph: "${jira.paragraph.font.size}*Настройки и изменения в структуре БД, атрибутах, справочниках*" + default: "Не требуется." monitoring-change: start: "${jira.start.font.size}Информация для подключений и мониторинга:" - paragraph: "${jira.paragraph.font.size}Информация для подключений и мониторинга" - default: "Не применимо." + paragraph: "${jira.paragraph.font.size}*Информация для подключений и мониторинга*" + default: "Не требуется." config: start: "${jira.start.font.size}Конфигурация:" - paragraph: "${jira.paragraph.font.size}Конфигурация" - default: "Не применимо." + paragraph: "${jira.paragraph.font.size}*Конфигурация*" + default: "Не требуется." deploy-instruction: start: "${jira.start.font.size}Порядок установки и изменения настроек:" - paragraph: "${jira.paragraph.font.size}Порядок установки и изменения настроек" - default: "Не применимо." + paragraph: "${jira.paragraph.font.size}*Порядок установки и изменения настроек*" + default: "Не требуется." test-case: start: "${jira.start.font.size}План тестирования у заказчика:" - paragraph: "${jira.paragraph.font.size}План тестирования" - default: "Выполнить соответствующие базовые сценарии для проверки функционала после деплоймента" + paragraph: "${jira.paragraph.font.size}*План тестирования*" + default: "Выполнить соответствующие быстрые тесты для релиза" rollback-action: start: "${jira.start.font.size}План отката:" - paragraph: "${jira.paragraph.font.size}План отката" + paragraph: "${jira.paragraph.font.size}*План отката*" default: "Откатить обновленные артефакты на предыдущие версии."