Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch CCv2 deployments via Native integration #1073

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
- Migrated `SAP CCM` logic to Kotlin coroutines [#1069](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1069)
- Introduced `Native` integration via OpenAPI [#1070](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1070)
- Added possibility to change Integration Protocol and current subscription [#1071](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1071)
- Fetch CCv2 build via `Native` integration [#1072](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1072)
- Fetch CCv2 builds via `Native` integration [#1072](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1072)
- Fetch CCv2 deployments via `Native` integration [#1073](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1073)

### `Type System` enhancements
- Show Item line marker for jalo classes [#1067](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1067)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ object SAPCCMDeploymentCommands {
undeployedTime = row.substring(columns["UNDEPLOYED TIME"]!!..<columns["STATUS"]!!).trim(),
status = CCv2DeploymentStatusEnum.tryValueOf(
row.substring(columns["STATUS"]!!..<columns["CANCELED BY"]!!).trim()
),
cancelledBy = row.substring(columns["CANCELED BY"]!!..<columns["CANCELED TIME"]!!).trim(),
cancelledTime = row.substring(columns["CANCELED TIME"]!!..<columns["CANCEL FINISHED TIME"]!!).trim(),
cancelFinishedTime = row.substring(columns["CANCEL FINISHED TIME"]!!..<columns["CANCEL FAILED"]!!).trim(),
cancelFailed = row.substring(columns["CANCEL FAILED"]!!).trim(),
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.intellij.idea.plugin.hybris.tools.ccv2.dto

import com.intellij.idea.plugin.hybris.ccv2.model.DeploymentDetailDTO
import com.intellij.idea.plugin.hybris.common.utils.HybrisIcons
import com.intellij.idea.plugin.hybris.tools.ccm.SAPCCM
import javax.swing.Icon
Expand All @@ -35,10 +36,6 @@ data class CCv2Deployment(
val failedTime: String,
val undeployedTime: String,
val status: CCv2DeploymentStatusEnum,
val cancelledBy: String,
val cancelledTime: String,
val cancelFinishedTime: String,
val cancelFailed: String,
) : CCv2DTO {

val createdTimeFormatted
Expand All @@ -55,9 +52,13 @@ enum class CCv2DeploymentDatabaseUpdateModeEnum(val title: String, val icon: Ico
UNKNOWN("Unknown", HybrisIcons.CCV2_DEPLOYMENT_UPDATE_MODE_UNKNOWN);

companion object {
fun tryValueOf(name: String) = entries
fun tryValueOf(name: String?) = entries
.find { it.name == name }
?: UNKNOWN

fun tryValueOf(mode: DeploymentDetailDTO.DatabaseUpdateMode?) = entries
.find { it.name == mode?.name }
?: UNKNOWN
}
}

Expand All @@ -68,9 +69,13 @@ enum class CCv2DeploymentStrategyEnum(val title: String, val icon: Icon) {
UNKNOWN("Unknown", HybrisIcons.CCV2_DEPLOYMENT_STRATEGY_UNKNOWN);

companion object {
fun tryValueOf(name: String) = entries
fun tryValueOf(name: String?) = entries
.find { it.name == name }
?: UNKNOWN

fun tryValueOf(strategy: DeploymentDetailDTO.Strategy?) = entries
.find { it.name == strategy?.name }
?: UNKNOWN
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.intellij.idea.plugin.hybris.tools.ccv2.strategies

import com.intellij.idea.plugin.hybris.ccv2.api.BuildApi
import com.intellij.idea.plugin.hybris.ccv2.api.DeploymentApi
import com.intellij.idea.plugin.hybris.ccv2.api.EnvironmentApi
import com.intellij.idea.plugin.hybris.ccv2.invoker.infrastructure.ApiClient
import com.intellij.idea.plugin.hybris.settings.CCv2Subscription
Expand Down Expand Up @@ -123,7 +124,42 @@ class CCv2NativeStrategy : CCv2Strategy {
subscriptions: Collection<CCv2Subscription>
): SortedMap<CCv2Subscription, Collection<CCv2Deployment>> {
ApiClient.accessToken = ccv2Token
return sortedMapOf()
val client = createClient()
val result = sortedMapOf<CCv2Subscription, Collection<CCv2Deployment>>()

reportProgress(subscriptions.size) { progressReporter ->
coroutineScope {
subscriptions.forEach {
launch {
result[it] = progressReporter.sizedStep(1, "Fetching Deployments for subscription: $it") {
DeploymentApi(client = client)
.getDeployments(it.id!!, dollarTop = 20)
.value
?.map { deployment ->
CCv2Deployment(
code = deployment.code ?: "N/A",
createdBy = deployment.createdBy ?: "N/A",
createdTime = deployment.createdTimestamp
?.toString() ?: "N/A",
buildCode = deployment.buildCode ?: "N/A",
envCode = deployment.environmentCode ?: "N/A",
updateMode = CCv2DeploymentDatabaseUpdateModeEnum.tryValueOf(deployment.databaseUpdateMode),
strategy = CCv2DeploymentStrategyEnum.tryValueOf(deployment.strategy),
scheduledTime = deployment.scheduledTimestamp?.toString() ?: "N/A",
deployedTime = deployment.deployedTimestamp?.toString() ?: "N/A",
failedTime = deployment.failedTimestamp?.toString() ?: "N/A",
undeployedTime = deployment.undeployedTimestamp?.toString() ?: "N/A",
status = CCv2DeploymentStatusEnum.tryValueOf(deployment.status)
)
}
?: emptyList()
}
}
}
}
}

return result
}

override suspend fun createBuild(
Expand Down
Loading