Skip to content

Commit 9309d64

Browse files
committed
added Entity Resolution files
1 parent 8d354d4 commit 9309d64

File tree

10 files changed

+2299
-0
lines changed

10 files changed

+2299
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# AWS Entity Resolution code examples for the SDK for Java 2.x
2+
3+
## Overview
4+
5+
Shows how to use the AWS SDK for Java 2.x to work with AWS Entity Resolution.
6+
7+
<!--custom.overview.start-->
8+
<!--custom.overview.end-->
9+
10+
_AWS Entity Resolution helps organizations extract, link, and organize information from multiple data sources._
11+
12+
## ⚠ Important
13+
14+
* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/).
15+
* Running the tests might result in charges to your AWS account.
16+
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
17+
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
18+
19+
<!--custom.important.start-->
20+
<!--custom.important.end-->
21+
22+
## Code examples
23+
24+
### Prerequisites
25+
26+
For prerequisites, see the [README](../../README.md#Prerequisites) in the `javav2` folder.
27+
28+
29+
<!--custom.prerequisites.start-->
30+
<!--custom.prerequisites.end-->
31+
32+
### Get started
33+
34+
- [Hello AWS Entity Resolution](src/main/java/com/example/entity/HelloEntityResoultion.java#L19) (`listMatchingWorkflows`)
35+
36+
37+
### Basics
38+
39+
Code examples that show you how to perform the essential operations within a service.
40+
41+
- [Learn the basics](src/main/java/com/example/entity/scenario/EntityResScenario.java)
42+
43+
44+
### Single actions
45+
46+
Code excerpts that show you how to call individual service functions.
47+
48+
- [CheckWorkflowStatus](src/main/java/com/example/entity/scenario/EntityResActions.java#L393)
49+
- [CreateMatchingWorkflow](src/main/java/com/example/entity/scenario/EntityResActions.java#L431)
50+
- [CreateSchemaMapping](src/main/java/com/example/entity/scenario/EntityResActions.java#L232)
51+
- [DeleteMatchingWorkflow](src/main/java/com/example/entity/scenario/EntityResActions.java#L198)
52+
- [DeleteSchemaMapping](src/main/java/com/example/entity/scenario/EntityResActions.java#L139)
53+
- [GetMatchingJob](src/main/java/com/example/entity/scenario/EntityResActions.java#L319)
54+
- [GetSchemaMapping](src/main/java/com/example/entity/scenario/EntityResActions.java#L282)
55+
- [ListSchemaMappings](src/main/java/com/example/entity/scenario/EntityResActions.java#L175)
56+
- [StartMatchingJob](src/main/java/com/example/entity/scenario/EntityResActions.java#L356)
57+
- [TagEntityResource](src/main/java/com/example/entity/scenario/EntityResActions.java#L518)
58+
59+
60+
<!--custom.examples.start-->
61+
<!--custom.examples.end-->
62+
63+
## Run the examples
64+
65+
### Instructions
66+
67+
68+
<!--custom.instructions.start-->
69+
<!--custom.instructions.end-->
70+
71+
#### Hello AWS Entity Resolution
72+
73+
This example shows you how to get started using AWS Entity Resolution.
74+
75+
76+
#### Learn the basics
77+
78+
This example shows you how to do the following:
79+
80+
- Create Schema Mapping.
81+
- Create an AWS Entity Resolution workflow.
82+
- Start the matching job for the workflow.
83+
- Get details for the matching job.
84+
- Get Schema Mapping.
85+
- List all Schema Mappings.
86+
- Tag the Schema Mapping resource.
87+
- Delete the AWS Entity Resolution Assets.
88+
89+
<!--custom.basic_prereqs.entityresolution_Scenario.start-->
90+
<!--custom.basic_prereqs.entityresolution_Scenario.end-->
91+
92+
93+
<!--custom.basics.entityresolution_Scenario.start-->
94+
<!--custom.basics.entityresolution_Scenario.end-->
95+
96+
97+
### Tests
98+
99+
⚠ Running tests might result in charges to your AWS account.
100+
101+
102+
To find instructions for running these tests, see the [README](../../README.md#Tests)
103+
in the `javav2` folder.
104+
105+
106+
107+
<!--custom.tests.start-->
108+
<!--custom.tests.end-->
109+
110+
## Additional resources
111+
112+
- [AWS Entity Resolution User Guide](https://docs.aws.amazon.com/entityresolution/latest/userguide/what-is-service.html)
113+
- [AWS Entity Resolution API Reference](https://docs.aws.amazon.com/entityresolution/latest/apireference/Welcome.html)
114+
- [SDK for Java 2.x AWS Entity Resolution reference](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/entityresolution/package-summary.html)
115+
116+
<!--custom.resources.start-->
117+
<!--custom.resources.end-->
118+
119+
---
120+
121+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
122+
123+
SPDX-License-Identifier: Apache-2.0
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.example</groupId>
8+
<artifactId>entityresolution</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
<java.version>17</java.version>
13+
<maven.compiler.target>17</maven.compiler.target>
14+
<maven.compiler.source>17</maven.compiler.source>
15+
</properties>
16+
<build>
17+
<plugins>
18+
<plugin>
19+
<groupId>org.apache.maven.plugins</groupId>
20+
<artifactId>maven-surefire-plugin</artifactId>
21+
<version>2.22.1</version>
22+
<configuration>
23+
<groups>IntegrationTest</groups>
24+
</configuration>
25+
</plugin>
26+
</plugins>
27+
</build>
28+
<dependencyManagement>
29+
<dependencies>
30+
<dependency>
31+
<groupId>software.amazon.awssdk</groupId>
32+
<artifactId>bom</artifactId>
33+
<version>2.29.45</version>
34+
<type>pom</type>
35+
<scope>import</scope>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.apache.logging.log4j</groupId>
39+
<artifactId>log4j-bom</artifactId>
40+
<version>2.23.1</version>
41+
<type>pom</type>
42+
<scope>import</scope>
43+
</dependency>
44+
</dependencies>
45+
</dependencyManagement>
46+
<dependencies>
47+
<dependency>
48+
<groupId>org.junit.jupiter</groupId>
49+
<artifactId>junit-jupiter-api</artifactId>
50+
<version>5.9.2</version>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.junit.jupiter</groupId>
55+
<artifactId>junit-jupiter-engine</artifactId>
56+
<version>5.9.2</version>
57+
<scope>test</scope>
58+
</dependency>
59+
<dependency>
60+
<groupId>software.amazon.awssdk</groupId>
61+
<artifactId>secretsmanager</artifactId>
62+
</dependency>
63+
<dependency>
64+
<groupId>com.google.code.gson</groupId>
65+
<artifactId>gson</artifactId>
66+
<version>2.10.1</version>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.junit.platform</groupId>
70+
<artifactId>junit-platform-commons</artifactId>
71+
<version>1.9.2</version>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.junit.platform</groupId>
75+
<artifactId>junit-platform-launcher</artifactId>
76+
<version>1.9.2</version>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>software.amazon.awssdk</groupId>
81+
<artifactId>entityresolution</artifactId>
82+
</dependency>
83+
<dependency>
84+
<groupId>com.opencsv</groupId>
85+
<artifactId>opencsv</artifactId>
86+
<version>5.7.1</version>
87+
</dependency>
88+
<dependency>
89+
<groupId>software.amazon.awssdk</groupId>
90+
<artifactId>s3</artifactId>
91+
</dependency>
92+
<!-- JAnsi for Console Table Formatting -->
93+
<dependency>
94+
<groupId>org.fusesource.jansi</groupId>
95+
<artifactId>jansi</artifactId>
96+
<version>2.4.0</version>
97+
</dependency>
98+
<dependency>
99+
<groupId>software.amazon.awssdk</groupId>
100+
<artifactId>netty-nio-client</artifactId>
101+
</dependency>
102+
<dependency>
103+
<groupId>software.amazon.awssdk</groupId>
104+
<artifactId>cloudformation</artifactId>
105+
</dependency>
106+
<dependency>
107+
<groupId>software.amazon.awssdk</groupId>
108+
<artifactId>sso</artifactId>
109+
</dependency>
110+
<dependency>
111+
<groupId>software.amazon.awssdk</groupId>
112+
<artifactId>ssooidc</artifactId>
113+
</dependency>
114+
<dependency>
115+
<groupId>org.apache.logging.log4j</groupId>
116+
<artifactId>log4j-core</artifactId>
117+
</dependency>
118+
<dependency>
119+
<groupId>org.slf4j</groupId>
120+
<artifactId>slf4j-api</artifactId>
121+
<version>2.0.13</version>
122+
</dependency>
123+
<dependency>
124+
<groupId>org.apache.logging.log4j</groupId>
125+
<artifactId>log4j-slf4j2-impl</artifactId>
126+
</dependency>
127+
<dependency>
128+
<groupId>org.apache.logging.log4j</groupId>
129+
<artifactId>log4j-1.2-api</artifactId>
130+
</dependency>
131+
</dependencies>
132+
</project>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package com.example.entity;
5+
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
8+
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
9+
import software.amazon.awssdk.core.retry.RetryMode;
10+
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
11+
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;
12+
import software.amazon.awssdk.regions.Region;
13+
import software.amazon.awssdk.services.entityresolution.EntityResolutionAsyncClient;
14+
import software.amazon.awssdk.services.entityresolution.model.ListMatchingWorkflowsRequest;
15+
import software.amazon.awssdk.services.entityresolution.paginators.ListMatchingWorkflowsPublisher;
16+
import java.time.Duration;
17+
import java.util.concurrent.CompletableFuture;
18+
19+
// snippet-start:[entityres.java2_hello.main]
20+
/**
21+
* Before running this Java V2 code example, set up your development
22+
* environment, including your credentials.
23+
*
24+
* For more information, see the following documentation topic:
25+
*
26+
* https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
27+
*/
28+
public class HelloEntityResoultion {
29+
30+
private static final Logger logger = LoggerFactory.getLogger(HelloEntityResoultion.class);
31+
32+
private static EntityResolutionAsyncClient entityResolutionAsyncClient;
33+
public static void main(String[] args) {
34+
listMatchingWorkflows();
35+
}
36+
37+
public static EntityResolutionAsyncClient getResolutionAsyncClient() {
38+
if (entityResolutionAsyncClient == null) {
39+
/*
40+
The `NettyNioAsyncHttpClient` class is part of the AWS SDK for Java, version 2,
41+
and it is designed to provide a high-performance, asynchronous HTTP client for interacting with AWS services.
42+
It uses the Netty framework to handle the underlying network communication and the Java NIO API to
43+
provide a non-blocking, event-driven approach to HTTP requests and responses.
44+
*/
45+
46+
SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder()
47+
.maxConcurrency(50) // Adjust as needed.
48+
.connectionTimeout(Duration.ofSeconds(60)) // Set the connection timeout.
49+
.readTimeout(Duration.ofSeconds(60)) // Set the read timeout.
50+
.writeTimeout(Duration.ofSeconds(60)) // Set the write timeout.
51+
.build();
52+
53+
ClientOverrideConfiguration overrideConfig = ClientOverrideConfiguration.builder()
54+
.apiCallTimeout(Duration.ofMinutes(2)) // Set the overall API call timeout.
55+
.apiCallAttemptTimeout(Duration.ofSeconds(90)) // Set the individual call attempt timeout.
56+
.retryStrategy(RetryMode.STANDARD)
57+
.build();
58+
59+
entityResolutionAsyncClient = EntityResolutionAsyncClient.builder()
60+
.region(Region.US_EAST_1)
61+
.httpClient(httpClient)
62+
.overrideConfiguration(overrideConfig)
63+
.build();
64+
}
65+
return entityResolutionAsyncClient;
66+
}
67+
68+
/**
69+
* Lists all matching workflows using an asynchronous paginator.
70+
* <p>
71+
* This method requests a paginated list of matching workflows from the
72+
* AWS Entity Resolution service and logs the names of the retrieved workflows.
73+
* It uses an asynchronous approach with a paginator and waits for the operation
74+
* to complete using {@code CompletableFuture#join()}.
75+
* </p>
76+
*/
77+
public static void listMatchingWorkflows() {
78+
ListMatchingWorkflowsRequest request = ListMatchingWorkflowsRequest.builder().build();
79+
80+
ListMatchingWorkflowsPublisher paginator =
81+
getResolutionAsyncClient().listMatchingWorkflowsPaginator(request);
82+
83+
// Iterate through the paginated results asynchronously
84+
CompletableFuture<Void> future = paginator.subscribe(response -> {
85+
response.workflowSummaries().forEach(workflow ->
86+
logger.info("Matching Workflow Name: " + workflow.workflowName())
87+
);
88+
});
89+
90+
// Wait for the asynchronous operation to complete
91+
future.join();
92+
}
93+
}
94+
// snippet-end:[entityres.java2_hello.main]

0 commit comments

Comments
 (0)