Skip to content

Commit 637ba0f

Browse files
author
David Hasani
committed
address comments
1 parent e3d8067 commit 637ba0f

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ const val MAVEN_DEFAULT_BUILD_DIRECTORY_NAME = "target"
5353
const val IDEA_DIRECTORY_NAME = ".idea"
5454
const val INVALID_SUFFIX_SHA = "sha1"
5555
const val INVALID_SUFFIX_REPOSITORIES = "repositories"
56+
const val ORACLE_DB = "ORACLE"
5657
data class CodeModernizerSessionContext(
5758
val project: Project,
5859
var configurationFile: VirtualFile? = null, // used to ZIP module
5960
val sourceJavaVersion: JavaSdkVersion, // always needed for startJob API
6061
val targetJavaVersion: JavaSdkVersion = JavaSdkVersion.JDK_17, // only one supported
6162
var customBuildCommand: String = MAVEN_BUILD_RUN_UNIT_TESTS, // run unit tests by default
62-
val sourceVendor: String = "ORACLE", // only one supported
63+
val sourceVendor: String = ORACLE_DB, // only one supported
6364
val targetVendor: String? = null,
6465
val sourceServerName: String? = null,
6566
var schema: String? = null,

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/panels/managers/BuildProgressSplitterPanelManager.kt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class BuildProgressSplitterPanelManager(private val project: Project) :
123123
haveProgressUpdates(plan)
124124
)
125125

126-
fun maybeAdd(stepId: ProgressStepId, string: String) {
126+
fun maybeAddTransformationStep(stepId: ProgressStepId, string: String) {
127127
// don't show building or generate plan message for SQL conversions since we don't build or generate plan
128128
if (transformType == CodeTransformType.SQL_CONVERSION && (
129129
string == message("codemodernizer.toolwindow.progress.building") ||
@@ -143,48 +143,48 @@ class BuildProgressSplitterPanelManager(private val project: Project) :
143143
TransformationStatus.PREPARING,
144144
)
145145
) {
146-
maybeAdd(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
147-
maybeAdd(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
146+
maybeAddTransformationStep(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
147+
maybeAddTransformationStep(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
148148
}
149149
if (newState in setOf(TransformationStatus.PREPARED, newState == TransformationStatus.PLANNING)) {
150-
maybeAdd(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
151-
maybeAdd(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
152-
maybeAdd(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
150+
maybeAddTransformationStep(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
151+
maybeAddTransformationStep(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
152+
maybeAddTransformationStep(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
153153
}
154154
if (newState in setOf(
155155
TransformationStatus.PLANNED,
156156
TransformationStatus.TRANSFORMING,
157157
)
158158
) {
159-
maybeAdd(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
160-
maybeAdd(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
161-
maybeAdd(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
162-
maybeAdd(ProgressStepId.TRANSFORMING, message("codemodernizer.toolwindow.progress.transforming"))
159+
maybeAddTransformationStep(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
160+
maybeAddTransformationStep(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
161+
maybeAddTransformationStep(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
162+
maybeAddTransformationStep(ProgressStepId.TRANSFORMING, message("codemodernizer.toolwindow.progress.transforming"))
163163
}
164164

165165
if (newState == TransformationStatus.PAUSED) {
166-
maybeAdd(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
167-
maybeAdd(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
168-
maybeAdd(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
169-
maybeAdd(ProgressStepId.TRANSFORMING, message("codemodernizer.toolwindow.progress.transforming"))
166+
maybeAddTransformationStep(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
167+
maybeAddTransformationStep(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
168+
maybeAddTransformationStep(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
169+
maybeAddTransformationStep(ProgressStepId.TRANSFORMING, message("codemodernizer.toolwindow.progress.transforming"))
170170
}
171171

172172
if (newState == TransformationStatus.RESUMED) {
173-
maybeAdd(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
174-
maybeAdd(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
175-
maybeAdd(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
176-
maybeAdd(ProgressStepId.TRANSFORMING, message("codemodernizer.toolwindow.progress.transforming"))
173+
maybeAddTransformationStep(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
174+
maybeAddTransformationStep(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
175+
maybeAddTransformationStep(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
176+
maybeAddTransformationStep(ProgressStepId.TRANSFORMING, message("codemodernizer.toolwindow.progress.transforming"))
177177
}
178178

179179
if (newState in setOf(
180180
TransformationStatus.COMPLETED,
181181
TransformationStatus.PARTIALLY_COMPLETED,
182182
)
183183
) {
184-
maybeAdd(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
185-
maybeAdd(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
186-
maybeAdd(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
187-
maybeAdd(ProgressStepId.TRANSFORMING, message("codemodernizer.toolwindow.progress.transforming"))
184+
maybeAddTransformationStep(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
185+
maybeAddTransformationStep(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
186+
maybeAddTransformationStep(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
187+
maybeAddTransformationStep(ProgressStepId.TRANSFORMING, message("codemodernizer.toolwindow.progress.transforming"))
188188
}
189189

190190
// Figure out if we should add plan steps

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fun parseXmlDependenciesReport(pathToXmlDependency: Path): DependencyUpdatesRepo
135135

136136
fun validateSctMetadata(sctFile: File?): SqlMetadataValidationResult {
137137
if (sctFile == null) {
138-
return SqlMetadataValidationResult(false, "No .sct metadata file found in the provided ZIP.")
138+
return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.missing_sct_file"))
139139
}
140140
val fileContent = sctFile.readBytes().toString(Charsets.UTF_8)
141141
val xmlDeserializer = XmlMapper(JacksonXmlModule())
@@ -144,7 +144,7 @@ fun validateSctMetadata(sctFile: File?): SqlMetadataValidationResult {
144144
sctMetadata = xmlDeserializer.readValue(fileContent, Any::class.java) as Map<*, *>
145145
} catch (e: Exception) {
146146
getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file; invalid XML encountered." }
147-
return SqlMetadataValidationResult(false, "Invalid XML encountered.")
147+
return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.invalid_sct"))
148148
}
149149

150150
try {
@@ -190,7 +190,7 @@ fun validateSctMetadata(sctFile: File?): SqlMetadataValidationResult {
190190
return SqlMetadataValidationResult(true, "", sourceVendor, targetVendor, sourceServerName, schemaNames)
191191
} catch (e: Exception) {
192192
getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file: $e" }
193-
return SqlMetadataValidationResult(false, "Sorry, the .sct metadata file you provided appears to be invalid.")
193+
return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.invalid_sct"))
194194
}
195195
}
196196

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ code.aws.workspaces.short=Dev Environments
562562
codemodernizer.builderrordialog.description.title=Error occurred when building your project
563563
codemodernizer.chat.form.user_selection.item.choose_module=Choose a module to transform
564564
codemodernizer.chat.form.user_selection.item.choose_skip_tests_option=Choose to skip unit tests
565-
codemodernizer.chat.form.user_selection.item.choose_sql_metadata_file=Next, I need the .sct metadata file of your project. You can download the .sct file by going to AWS Console -> AWS DMS -> Migration Projects. Open the schema conversion project and navigate to the S3 bucket linked to it. You will find the ZIP containing the .sct file under the {schema-conversion-project}/ directory.
565+
codemodernizer.chat.form.user_selection.item.choose_sql_metadata_file=Next, I need the zipped metadata file from your schema conversion. You can download the metadata by going to your migration project in the AWS DMS console. Open the schema conversion and choose **Convert the embedded SQL in your application**. You can download the metadata from Amazon S3 in the {schema-conversion-project}/ directory.
566566
codemodernizer.chat.form.user_selection.item.choose_target_version=Choose the target code version
567567
codemodernizer.chat.form.user_selection.title=Q - Code transformation
568568
codemodernizer.chat.message.absolute_path_detected=I detected {0} potential absolute file path(s) in your {1} file: **{2}**. Absolute file paths might cause issues when I build your code. Any errors will show up in the build log.
@@ -631,8 +631,10 @@ codemodernizer.chat.message.upload_failed_ssl_error=Sorry, I was unable to uploa
631631
codemodernizer.chat.message.upload_failed_url_expired=Sorry, I couldn't upload your project to begin the transformation. The Amazon S3 pre-signed URL used to upload your code expired after 30 minutes. This might have been caused by delays introduced by intermediate services in your network infrastructure.\n\nCheck your network configuration for services that might be causing delays. If the issue persists, you might need to allow list the following Amazon S3 bucket: 'amazonq-code-transformation-us-east-1-c6160f047e0.s3.amazonaws.com'.
632632
codemodernizer.chat.message.validation.check_eligible_projects=I'm checking for open projects that are eligible for Code Transformation.
633633
codemodernizer.chat.message.validation.check_passed=I can upgrade your Java module. To start the transformation, I need some information from you. Choose the module you want to upgrade and the target code version to upgrade to. Then, choose **Confirm**.\n\nIf you do not see the module you want to transform, you might need to configure your project so that I can find it. Go to File and choose Project Structure. In the Projects tab, set the correct project JDK and language level. In the Modules tab, set the correct module JDK and language level.
634-
codemodernizer.chat.message.validation.error.invalid_source_db=Sorry, your .sct metadata file appears to be invalid; the source DB must be Oracle.
635-
codemodernizer.chat.message.validation.error.invalid_target_db=Sorry, your .sct metadata file appears to be invalid; the target DB must be Aurora PostgreSQL or Amazon RDS for PostgreSQL.
634+
codemodernizer.chat.message.validation.error.invalid_sct=It looks like the .sct file you provided isn't valid. Make sure that you've uploaded the .zip file you retrieved from your schema conversion in AWS DMS.
635+
codemodernizer.chat.message.validation.error.invalid_source_db=I can only convert SQL for migrations from an Oracle source database. The provided .sct file indicates another source database for this migration.
636+
codemodernizer.chat.message.validation.error.invalid_target_db=I can only convert SQL for migrations to Aurora PostgreSQL or Amazon RDS for PostgreSQL target databases. The provided .sct file indicates another target database for this migration.
637+
codemodernizer.chat.message.validation.error.missing_sct_file=An .sct file is required for transformation. Make sure that you've uploaded the .zip file you retrieved from your schema conversion in AWS DMS.
636638
codemodernizer.chat.message.validation.error.more_info=For more information, see the [Amazon Q documentation]({0}).
637639
codemodernizer.chat.message.validation.error.no_java_project=Sorry, I could not find an open Java module. Make sure you have a module open that has the JDK configured and has at least 1 content root.
638640
codemodernizer.chat.message.validation.error.no_pom=Sorry, I couldn't find a module that I can upgrade. I couldn't find a pom.xml file in any of your open projects. Currently, I can only upgrade Java 8 or Java 11 projects built on Maven.

0 commit comments

Comments
 (0)