Skip to content

Instantly share code, notes, and snippets.

View jwmatthews's full-sized avatar

John Matthews jwmatthews

View GitHub Profile
@jwmatthews
jwmatthews / Prompt_ShippingService.txt
Created April 18, 2024 18:59
April 18 2024 - Example prompt for ShippingService
<s>[INST] <<SYS>>
You are an AI Assistant trained on migrating enterprise JavaEE code to Quarkus.
<</SYS>>
I will give you a JavaEE file for which I want to take one step towards migrating to Quarkus.
I will provide you with static source code analysis information highlighting an issue which needs to be addressed.
I will also provide you with an example of how a similar issue was solved in the past via a solved example.
#!/usr/bin/env bash
SOURCE_DIR="coolstore"
SOURCE_ONLY=""
# If you want to run with source only uncomment below
# SOURCE_ONLY="-m source-only"
# We are experimenting with modifying some of the default Kantra rules from:
# . https://github.com/konveyor/rulesets/tree/main/default/generated
- name: cloud-readiness
description: This ruleset detects logging configurations that may be problematic when migrating an application to a cloud environment.
violations:
session-00000:
description: HTTP session replication (distributable web.xml)
category: mandatory
labels:
- clustering
- konveyor.io/source=java
- konveyor.io/source=java-ee
+ cp -r /opt/input/source /tmp/source-code
+ sed -i 's|/opt/input/source|/tmp/source-code|g' /opt/input/config/settings.json
+ /usr/local/bin/konveyor-analyzer --provider-settings=/opt/input/config/settings.json --output-file=/opt/output/output.yaml --context-lines=100 --rules=/opt/input/rules/ '--dep-label-selector=(!konveyor.io/dep-source=open-source)' --verbose=4 '--label-selector=((konveyor.io/target=quarkus || konveyor.io/target=jakarta-ee || konveyor.io/target=jakarta-ee8+ || konveyor.io/target=jakarta-ee9+ || konveyor.io/target=cloud-readiness) && konveyor.io/source) || (discovery)' --dep-output-file=/opt/output/dependencies.yaml
time="2024-04-16T12:29:56Z" level=error msg="grpc unable to get info" error="rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing: dial tcp [::1]:42615: connect: connection refused\"" logger=java provider=grpc
time="2024-04-16T12:29:59Z" level=info msg="Caps found" caps="[{\"Name\":\"referenced\",\"Input\":{},\"Output\":{}},{\"Name\":\
interactions:
- request:
body: '{"messages": [{"role": "user", "content": "# Java EE to Quarkus Migration\n\nYou
are an AI Assistant trained on migrating enterprise JavaEE code to Quarkus.
I will give you an example of a JavaEE file and you will give me the Quarkus
equivalent.\n\nTo help you update this file to Quarkus I will provide you with
static source code analysis information highlighting an issue which needs to
be addressed, I will also provide you with an example of how a similar issue
was solved in the past via a solved example. You can refer to the solved example
for a pattern of how to update the input Java EE file to Quarkus.\n\nBe sure
interactions:
- request:
body: '{"messages": [{"role": "user", "content": "# Java EE to Quarkus Migration\n\nYou
are an AI Assistant trained on migrating enterprise JavaEE code to Quarkus.
I will give you an example of a JavaEE file and you will give me the Quarkus
equivalent.\n\nTo help you update this file to Quarkus I will provide you with
static source code analysis information highlighting an issue which needs to
be addressed, I will also provide you with an example of how a similar issue
was solved in the past via a solved example. You can refer to the solved example
for a pattern of how to update the input Java EE file to Quarkus.\n\nBe sure
interactions:
- request:
body: '{"messages": [{"role": "user", "content": "# Java EE to Quarkus Migration\n\nYou
are an AI Assistant trained on migrating enterprise JavaEE code to Quarkus.
I will give you an example of a JavaEE file and you will give me the Quarkus
equivalent.\n\nTo help you update this file to Quarkus I will provide you with
static source code analysis information highlighting an issue which needs to
be addressed, I will also provide you with an example of how a similar issue
was solved in the past via a solved example. You can refer to the solved example
for a pattern of how to update the input Java EE file to Quarkus.\n\nBe sure

Java EE to Quarkus Migration

You are an AI Assistant trained on migrating enterprise JavaEE code to Quarkus. I will give you an example of a JavaEE file and you will give me the Quarkus equivalent.

To help you update this file to Quarkus I will provide you with static source code analysis information highlighting an issue which needs to be addressed, I will also provide you with an example of how a similar issue was solved in the past via a solved example. You can refer to the solved example for a pattern of how to update the input Java EE file to Quarkus.

Be sure to pay attention to the issue found from static analysis and treat it as the primary issue you must address or explain why you are unable to.

Approach this code migration from Java EE to Quarkus as if you were an experienced enterprise Java EE developer. Before attempting to migrate the code to Quarkus, explain each step of your reasoning through what changes are required and why.

Model ID: ibm-mistralai/mixtral-8x7b-instruct-v01-q

Reasoning

  1. The first step is to address the issues found in the static source code analysis. We need to replace the javax.json import statements with jakarta.json as Quarkus uses the Jakarta EE API, which uses the jakarta package namespace instead of the javax package namespace. This change is required in lines 13, 14, 15, 16, 17, and 18.

  2. Next, we need to consider the external dependencies in the pom.xml file. Since we are migrating to Quarkus, we need to replace the Java EE dependencies with Quarkus-specific dependencies. For example, we need to replace the javaee-api dependency with the jakarta.platform dependency. Additionally, we need to add the quarkus-resteasy-json-provider-jakarta dependency to enable the Jakarta JSON-P API.

  3. We also need to update the imports to reflect the changes made in step 2. We need to replace the javax.json imports with jakarta.json imports.

package com.redhat.coolstore.utils;
import com.redhat.coolstore.model.CatalogItemEntity;
import com.redhat.coolstore.model.Order;
import com.redhat.coolstore.model.OrderItem;
import com.redhat.coolstore.model.Product;
import com.redhat.coolstore.model.ProductImpl;
import com.redhat.coolstore.model.ShoppingCart;
import java.io.StringReader;
import java.io.StringWriter;