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

Java V2 FSA #5362

Merged
merged 68 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1c91d0d
new pr for FSA
scmacdon Sep 6, 2023
a4a7ee0
new pr for FSA
scmacdon Sep 6, 2023
d08e623
added term to 40 char
scmacdon Sep 6, 2023
8178a98
added term to 40 char
scmacdon Sep 6, 2023
9b45042
modified application readme to include Java
scmacdon Sep 6, 2023
9f9daea
rolled in edits
scmacdon Sep 7, 2023
595da88
rolled in edits
scmacdon Sep 7, 2023
fab4dd1
rolled in edits
scmacdon Sep 7, 2023
fa80b8d
rolled in edits
scmacdon Sep 7, 2023
a908715
rolled in edits
scmacdon Sep 7, 2023
449c6eb
rolled in edits
scmacdon Sep 7, 2023
31beebf
added support for Java and CDK
scmacdon Sep 8, 2023
b07446f
added support for Java and CDK
scmacdon Sep 8, 2023
7ee5718
update the Readme
scmacdon Sep 8, 2023
e3e6ecf
update the Readme
scmacdon Sep 8, 2023
dc77bf3
update the Readme
scmacdon Sep 8, 2023
82a98f6
update Java code
scmacdon Sep 8, 2023
27ecf42
update Readme
scmacdon Sep 8, 2023
2467337
update Readme
scmacdon Sep 8, 2023
faba61a
update Readme
scmacdon Sep 8, 2023
64a6548
update Readme
scmacdon Sep 8, 2023
6da7c35
update Readme
scmacdon Sep 11, 2023
84e55ad
update handlers
scmacdon Sep 11, 2023
8b1b94d
rolled in edits
scmacdon Sep 11, 2023
ac9e682
rolled in edits
scmacdon Sep 11, 2023
53f14c4
rolled in edits
scmacdon Sep 12, 2023
3faa2f7
rolled in edits
scmacdon Sep 12, 2023
7914aa0
rolled in edits
scmacdon Sep 12, 2023
ecaebd9
rolled in edits
scmacdon Sep 12, 2023
c8d6201
rolled in edits
scmacdon Sep 12, 2023
d19a526
rolled in edits
scmacdon Sep 12, 2023
8525cc5
changed Handler names
scmacdon Sep 12, 2023
4c0298f
changes exception logic based on edits
scmacdon Sep 12, 2023
f7edb70
lintered TS with Prettier
scmacdon Sep 12, 2023
4fec6e2
lintered TS with Prettier
scmacdon Sep 12, 2023
f562409
added javascript
scmacdon Sep 12, 2023
4fc3990
added transfer manager API
scmacdon Sep 12, 2023
f5ddf52
added transfer manager API
scmacdon Sep 12, 2023
e083ed7
added transfer manager API
scmacdon Sep 12, 2023
1c9eeec
added transfer manager API
scmacdon Sep 12, 2023
54ba8a7
modified java to use async clients
scmacdon Sep 12, 2023
67560be
modified java to use async clients
scmacdon Sep 12, 2023
93bd574
modified java to use async clients
scmacdon Sep 12, 2023
3adbb06
modified java to use async clients
scmacdon Sep 12, 2023
8ab73f0
modified java to use async clients
scmacdon Sep 12, 2023
00bdbb6
updated the Readme
scmacdon Sep 12, 2023
27e4462
updated the Readme
scmacdon Sep 12, 2023
26ffb77
updated the Readme
scmacdon Sep 12, 2023
0ad7ddd
updated the Readme
scmacdon Sep 12, 2023
ce023a6
updated the Readme
scmacdon Sep 12, 2023
d4ac9c5
updated the Readme
scmacdon Sep 12, 2023
50942fa
updated transfer manager logic
scmacdon Sep 12, 2023
bf316a8
updated transfer manager logic
scmacdon Sep 13, 2023
a785b82
updated transfer manager logic
scmacdon Sep 13, 2023
680f3ba
add tests
scmacdon Sep 13, 2023
0d0ae96
updated POM
scmacdon Sep 13, 2023
558545b
modified TM API code based on SDK team suggestion
scmacdon Sep 14, 2023
e0d40da
modified tests to test the Service Classes code and make sure they al…
scmacdon Sep 14, 2023
f8fa366
modified pom
scmacdon Sep 14, 2023
6d74aab
updated the upload logic using transfer manager
scmacdon Sep 14, 2023
cb1b89b
updated the POM in Readme
scmacdon Sep 14, 2023
5c48b4f
updated the POM in Readme
scmacdon Sep 14, 2023
1bbb175
updated headings in Readme
scmacdon Sep 14, 2023
7110e00
updated headings in Readme
scmacdon Sep 14, 2023
f59c87c
rolled in comments
scmacdon Sep 25, 2023
63ab0e8
rolled in comments
scmacdon Sep 25, 2023
0c0ffa4
rolled in comments
scmacdon Sep 25, 2023
7c221cb
rolled in comments
scmacdon Sep 25, 2023
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
33 changes: 33 additions & 0 deletions .doc_gen/cross-content/cross_FSA_Java_block.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "file://zonbook/docbookx.dtd" [
<!ENTITY % phrases-shared SYSTEM "file://AWSShared/common/phrases-shared.ent">
%phrases-shared;
]>
<block>
<para>
This example application analyzes and stores customer feedback cards. Specifically,
it fulfills the need of a fictitious hotel in New York City. The hotel receives feedback
from guests in various languages in the form of physical comment cards. That feedback
is uploaded into the app through a web client.

After an image of a comment card is uploaded, the following steps occur:
</para>
<itemizedlist>
<listitem>
<para>Text is extracted from the image using &TEXTRACT;.</para>
</listitem>
<listitem>
<para>&CMP; determines the sentiment of the extracted text and its language.</para>
</listitem>
<listitem>
<para>The extracted text is translated to French using &TSL;.</para>
</listitem>
<listitem>
<para>&POL; synthesizes an audio file from the extracted text.</para>
</listitem>
</itemizedlist>
<para> The full app can be deployed with the &CDK;. For source code and deployment
instructions, see the project in <ulink
url="https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/usecases/creating_fsa_app">
GitHub</ulink>. </para>
</block>
4 changes: 4 additions & 0 deletions .doc_gen/metadata/cross_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ cross_FSA:
their original language, determines their sentiment, and generates an audio file
from the translated text.
languages:
Java:
versions:
- sdk_version: 2
block_content: cross_FSA_Java_block.xml
Ruby:
versions:
- sdk_version: 3
Expand Down
1 change: 1 addition & 0 deletions .github/pre_validate/pre_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
'AKIAIOSFODNN7EXAMPLE',
'APKAEIBAERJR2EXAMPLE',
'AppStreamUsageReportsCFNGlueAthenaAccess',
'examples/blob/main/applications/feedback',
'aws/acm/model/DescribeCertificateRequest',
'aws/cloudtrail/model/LookupEventsRequest',
'aws/codebuild/model/BatchGetBuildsResult',
Expand Down
1 change: 1 addition & 0 deletions applications/feedback_sentiment_analyzer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This application has been implemented with the following AWS SDKs.

- [Ruby](../../ruby/cross_service_examples/feedback_sentiment_analyzer/README.md)
- [JavaScript](../../javascriptv3/example_code/cross-services/feedback-sentiment-analyzer/README.md)
- [Java](../../javav2/usecases/creating_fsa_app/README.md)

To deploy one of these implementations, follow the [Deployment instructions](#deployment-instructions).

Expand Down
58 changes: 53 additions & 5 deletions applications/feedback_sentiment_analyzer/cdk/lib/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {resolve} from "path";
import {BundlingOutput, Duration} from "aws-cdk-lib";
import {Code, Runtime} from "aws-cdk-lib/aws-lambda";

import {AppFunctionConfig} from "./constructs/app-lambdas";

const BASE_APP_FUNCTION: AppFunctionConfig = {
Expand Down Expand Up @@ -55,7 +54,7 @@ const EXAMPLE_LANG_FUNCTIONS: AppFunctionConfig[] = [
return Code.fromInline(`
exports.handler = async (event) => {
console.log("AnalyzeSentiment", event);
return { translated_text: "Bonjour", source_language: "en" }
return { translated_text: "Bonjour", source_language: "en"}
}
`);
},
Expand Down Expand Up @@ -164,14 +163,63 @@ const JAVASCRIPT_FUNCTIONS = [
},
];

const JAVA_BUNDLING_CONFIG = {
command: [
"bash",
"-c",
"mvn install -DskipTests && cp target/creating_fsa_app-1.0-SNAPSHOT.jar /asset-output/",
],
output: BundlingOutput.ARCHIVED,
user: "root",
image: Runtime.JAVA_11.bundlingImage,
volumes: [
{
hostPath: `${process.env.HOME}/.m2/`,
containerPath: "/root/.m2",
},
],
};

const COMMON_JAVA_FUNCTION_CONFIG = {
...BASE_APP_FUNCTION,
runtime: Runtime.JAVA_11,
codeAsset: () => {
const source = resolve("../../../javav2/usecases/creating_fsa_app");
return Code.fromAsset(source, {
bundling: JAVA_BUNDLING_CONFIG,
});
},
};

const JAVA_FUNCTIONS: AppFunctionConfig[] = [
{
...COMMON_JAVA_FUNCTION_CONFIG,
name: "ExtractText",
handler: "com.example.fsa.handlers.ExtractTextHandler::handleRequest",
},
{
...COMMON_JAVA_FUNCTION_CONFIG,
name: "AnalyzeSentiment",
handler: "com.example.fsa.handlers.AnalyzeSentimentHandler::handleRequest",
},
{
...COMMON_JAVA_FUNCTION_CONFIG,
name: "TranslateText",
handler: "com.example.fsa.handlers.TranslateTextHandler::handleRequest",
},
{
...COMMON_JAVA_FUNCTION_CONFIG,
name: "SynthesizeAudio",
handler: "com.example.fsa.handlers.SynthesizeAudioHandler::handleRequest",
},
];

const FUNCTIONS: Record<string, AppFunctionConfig[]> = {
examplelang: EXAMPLE_LANG_FUNCTIONS,
// Add more languages here. For example
// javascript: JAVASCRIPT_FUNCTIONS,
ruby: RUBY_FUNCTIONS,
java: JAVA_FUNCTIONS,
javascript: JAVASCRIPT_FUNCTIONS,
cpyle0819 marked this conversation as resolved.
Show resolved Hide resolved
};

export function getFunctions(language: string = ""): AppFunctionConfig[] {
return FUNCTIONS[language] ?? FUNCTIONS.examplelang;
}
4 changes: 3 additions & 1 deletion javav2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ The **javav2** folder in this repository contains examples of complete use cases

In the **use_cases** folder, find step-by-step development tutorials that use multiple AWS services. By following these tutorials, you will gain a deeper understanding of how to create Java-based applications that use the AWS SDK for Java. Most of these AWS SDK for Java tutorials use the Synchronous Java client.

If you are interested in using the Asynchronous Java client, see one of these tutorials:
If you are interested in using Asynchronous Java service clients, see one of these tutorials:

+ [Creating a Feedback Sentiment Analyzer application using the SDK for Java](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/usecases/creating_fsa_app) - Discusses how to develop a Feedback Sentiment Analyzer application using Machine Learning AWS services. The application solves a fictitious use case of a hotel that receives guest feedback on comment cards in a variety of languages. The application is developed by using the AWS SDK for Java (v2) and asynchronous Java clients.

+ [Creating a dynamic web application that asynchronously analyzes photos using the AWS SDK for Java](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/usecases/creating_photo_analyzer_async) - Discusses using the AWS SDK for Java (asynchronous client) and various AWS services, such as the Amazon Rekognition service, to analyze images. This web MVC application can analyze many images and generate a report that breaks down each image into a series of labels.

Expand Down
Loading
Loading