Skip to content

Commit deb935c

Browse files
author
David Hasani
committed
skip getPlan for SQL conversions
1 parent b6efdf4 commit deb935c

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/CodeModernizerManager.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,12 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo
451451
private suspend fun handleJobResumedFromHil(
452452
jobId: JobId,
453453
session: CodeModernizerSession,
454-
transformationType: CodeTransformType,
454+
transformType: CodeTransformType,
455455
): CodeModernizerJobCompletedResult = session.pollUntilJobCompletion(
456+
transformType,
456457
jobId
457458
) { new, plan ->
458-
codeModernizerBottomWindowPanelManager.handleJobTransition(new, plan, session.sessionContext.sourceJavaVersion, transformationType)
459+
codeModernizerBottomWindowPanelManager.handleJobTransition(new, plan, session.sessionContext.sourceJavaVersion, transformType)
459460
}
460461

461462
private suspend fun handleJobStarted(jobId: JobId, session: CodeModernizerSession): CodeModernizerJobCompletedResult {
@@ -466,10 +467,10 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo
466467
codeModernizerBottomWindowPanelManager.setJobRunningUI()
467468
}
468469

469-
val transformationType = if (session.sessionContext.sqlMetadataZip != null) CodeTransformType.SQL_CONVERSION else CodeTransformType.LANGUAGE_UPGRADE
470+
val transformType = if (session.sessionContext.sqlMetadataZip != null) CodeTransformType.SQL_CONVERSION else CodeTransformType.LANGUAGE_UPGRADE
470471

471-
return session.pollUntilJobCompletion(jobId) { new, plan ->
472-
codeModernizerBottomWindowPanelManager.handleJobTransition(new, plan, session.sessionContext.sourceJavaVersion, transformationType)
472+
return session.pollUntilJobCompletion(transformType, jobId) { new, plan ->
473+
codeModernizerBottomWindowPanelManager.handleJobTransition(new, plan, session.sessionContext.sourceJavaVersion, transformType)
473474
}
474475
}
475476

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/CodeModernizerSession.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModerni
3232
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerSessionContext
3333
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerStartJobResult
3434
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeTransformHilDownloadArtifact
35+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeTransformType
3536
import software.aws.toolkits.jetbrains.services.codemodernizer.model.DownloadArtifactResult
3637
import software.aws.toolkits.jetbrains.services.codemodernizer.model.JobId
3738
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MavenCopyCommandsResult
@@ -319,11 +320,6 @@ class CodeModernizerSession(
319320
return clientAdaptor.getCodeModernizationJob(jobId.id).transformationJob()
320321
}
321322

322-
fun getTransformPlanDetails(jobId: JobId): TransformationPlan {
323-
LOG.info { "Getting transform plan details." }
324-
return clientAdaptor.getCodeModernizationPlan(jobId).transformationPlan()
325-
}
326-
327323
/**
328324
* This will resume the job, i.e. it will resume the main job loop kicked of by [createModernizationJob]
329325
*/
@@ -413,6 +409,7 @@ class CodeModernizerSession(
413409
}
414410

415411
suspend fun pollUntilJobCompletion(
412+
transformType: CodeTransformType,
416413
jobId: JobId,
417414
jobTransitionHandler: (currentStatus: TransformationStatus, migrationPlan: TransformationPlan?) -> Unit,
418415
): CodeModernizerJobCompletedResult {
@@ -427,6 +424,7 @@ class CodeModernizerSession(
427424
var passedStart = false
428425

429426
val result = jobId.pollTransformationStatusAndPlan(
427+
transformType,
430428
succeedOn = setOf(
431429
TransformationStatus.COMPLETED,
432430
TransformationStatus.PAUSED,
@@ -459,7 +457,7 @@ class CodeModernizerSession(
459457
}
460458

461459
// Open the transformation plan detail panel once transformation plan is available (no plan for SQL conversions)
462-
if (sessionContext.sqlMetadataZip == null && state.transformationPlan != null && !isTransformationPlanEditorOpened) {
460+
if (transformType != CodeTransformType.SQL_CONVERSION && state.transformationPlan != null && !isTransformationPlanEditorOpened) {
463461
tryOpenTransformationPlanEditor()
464462
isTransformationPlanEditorOpened = true
465463
}

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/CodeTransformApiUtils.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import software.aws.toolkits.core.utils.Waiters.waitUntil
2323
import software.aws.toolkits.jetbrains.services.codemodernizer.CodeTransformTelemetryManager
2424
import software.aws.toolkits.jetbrains.services.codemodernizer.client.GumbyClient
2525
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.BILLING_RATE
26+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeTransformType
2627
import software.aws.toolkits.jetbrains.services.codemodernizer.model.JobId
2728
import software.aws.toolkits.resources.message
2829
import java.time.Duration
@@ -40,6 +41,7 @@ data class PollingResult(
4041
* Wrapper around [waitUntil] that polls the API DescribeMigrationJob to check the migration job status.
4142
*/
4243
suspend fun JobId.pollTransformationStatusAndPlan(
44+
transformType: CodeTransformType,
4345
succeedOn: Set<TransformationStatus>,
4446
failOn: Set<TransformationStatus>,
4547
clientAdaptor: GumbyClient,
@@ -85,7 +87,7 @@ suspend fun JobId.pollTransformationStatusAndPlan(
8587
transformationResponse = clientAdaptor.getCodeModernizationJob(this.id)
8688
val newStatus = transformationResponse?.transformationJob()?.status() ?: throw RuntimeException("Unable to get job status")
8789
var newPlan: TransformationPlan? = null
88-
if (newStatus in STATES_WHERE_PLAN_EXIST) {
90+
if (newStatus in STATES_WHERE_PLAN_EXIST && transformType != CodeTransformType.SQL_CONVERSION) { // no plan for SQL conversions
8991
delay(sleepDurationMillis)
9092
newPlan = clientAdaptor.getCodeModernizationPlan(this).transformationPlan()
9193
}

plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ codemodernizer.toolwindow.problems_window_not_found=Unable to display Code Trans
756756
codemodernizer.toolwindow.progress.building=Build uploaded code in secure build environment
757757
codemodernizer.toolwindow.progress.parent=Transformation progress
758758
codemodernizer.toolwindow.progress.planning=Generate transformation plan
759-
codemodernizer.toolwindow.progress.transforming=Transform your code to Java 17 using transformation plan
759+
codemodernizer.toolwindow.progress.transforming=Transform your code
760760
codemodernizer.toolwindow.progress.uploading=Uploading your code
761761
codemodernizer.toolwindow.scan_display=Transformation details
762762
codemodernizer.toolwindow.scan_in_progress=Amazon Q is scanning the project files and getting ready to start the job. To start the job, Amazon Q needs to upload the project artifacts. Once that's done, Q can start the transformation job. The estimated time for this operation ranges from a few seconds to several minutes.
@@ -765,7 +765,7 @@ codemodernizer.toolwindow.scan_in_progress.building=Amazon Q is building your co
765765
codemodernizer.toolwindow.scan_in_progress.failed=The step failed, fetching additional details...
766766
codemodernizer.toolwindow.scan_in_progress.planning=Amazon Q is analyzing your code in order to generate a transformation plan.
767767
codemodernizer.toolwindow.scan_in_progress.stopping=Stopping the job...
768-
codemodernizer.toolwindow.scan_in_progress.transforming=Amazon Q is transforming your code. Details will appear soon.
768+
codemodernizer.toolwindow.scan_in_progress.transforming=Amazon Q is transforming your code.
769769
codemodernizer.toolwindow.stop_scan=Stop job
770770
codemodernizer.toolwindow.table.header.date=Date
771771
codemodernizer.toolwindow.table.header.job_id=Job Id

0 commit comments

Comments
 (0)