Skip to content

Commit cdc408b

Browse files
committed
BEFOUND-1854: SSDK 19.0.0
1 parent d3b76ff commit cdc408b

File tree

130 files changed

+4195
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+4195
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This project contains code samples documented in the following section in [Backbase Community](https://community.backbase.com/documentation/ServiceSDK/latest/index):
2+
3+
* [Add persistence to your capability](https://community.backbase.com/documentation/ServiceSDK/latest/add_persistence_to_core_service)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
target
2+
.idea
3+
*.iml
4+
blackduck-scan-wars/hub-detect.sh
5+
*.springBeans
6+
/flaws.json
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# example-service
2+
3+
_Fill out this file with some information about your Service._
4+
5+
## Dependencies
6+
7+
Requires a running Eureka registry, by default on port 8080.
8+
9+
## Configuration
10+
11+
Service configuration is under `src/main/resources/application.yaml`.
12+
13+
## Running
14+
15+
To run the service in development mode, use:
16+
- `mvn spring-boot:run`
17+
18+
To run the service from the built binaries, use:
19+
- `java -jar target/example-persistence-service-1.0.0-SNAPSHOT.jar`
20+
21+
## Authorization
22+
23+
Requests to this service are authorized with a Backbase Internal JWT, therefore you must access this service via the Backbase Edge after authenticating with identity service.
24+
25+
For local development, an internal JWT can be created from http://jwt.io, entering ```JWTSecretKeyDontUseInProduction!``` as the secret in the signature to generate a valid signed JWT.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<!-- The simplest way to build a service with service-sdk-starter-core
6+
is to use it as a parent in your project’s POM file, and alternative If you
7+
don’t want to use service-sdk-starter-core as your project’s parent, you
8+
can declare it as a dependency instead, see pom-as-dependency.xml -->
9+
<parent>
10+
<artifactId>service-sdk-starter-core</artifactId>
11+
<groupId>com.backbase.buildingblocks</groupId>
12+
<version>19.0.1</version>
13+
<relativePath />
14+
</parent>
15+
16+
<groupId>com.backbase.example</groupId>
17+
<artifactId>example-persistence-service</artifactId>
18+
<version>1.0.0-SNAPSHOT</version>
19+
<name>Backbase :: Digital Banking Services :: example-persistence-service</name>
20+
21+
<properties>
22+
<java.version>21</java.version>
23+
</properties>
24+
25+
<dependencies>
26+
<!-- tag::persistence-dependencies[] -->
27+
<!--Added for persistence -->
28+
<dependency>
29+
<groupId>com.backbase.buildingblocks</groupId>
30+
<artifactId>persistence</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.backbase.buildingblocks</groupId>
34+
<artifactId>service-sdk-starter-mapping</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-cache</artifactId>
39+
</dependency>
40+
<!-- Required for Local testing -->
41+
<dependency>
42+
<groupId>com.h2database</groupId>
43+
<artifactId>h2</artifactId>
44+
<version>2.1.214</version>
45+
<scope>test</scope>
46+
</dependency>
47+
<!-- Required for MySql -->
48+
<dependency>
49+
<groupId>com.mysql</groupId>
50+
<artifactId>mysql-connector-j</artifactId>
51+
<scope>test</scope>
52+
</dependency>
53+
<!-- end::persistence-dependencies[] -->
54+
55+
<dependency>
56+
<groupId>com.backbase.buildingblocks</groupId>
57+
<artifactId>service-sdk-starter-test</artifactId>
58+
<scope>test</scope>
59+
</dependency>
60+
61+
<!-- Add dependencies for your services, e.g. BB specifications, integration clients -->
62+
63+
<!-- Uncomment the following dependencies if DBS inter-service communication is needed -->
64+
<!--
65+
<dependency>
66+
<groupId>com.backbase.buildingblocks</groupId>
67+
<artifactId>communication</artifactId>
68+
</dependency>
69+
<dependency>
70+
<groupId>com.backbase.buildingblocks</groupId>
71+
<artifactId>auth-security</artifactId>
72+
</dependency>
73+
-->
74+
</dependencies>
75+
76+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.backbase.example;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.autoconfigure.domain.EntityScan;
6+
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
7+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
8+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
9+
10+
// tag::application-annotations[]
11+
@SpringBootApplication
12+
@EnableDiscoveryClient
13+
@EnableJpaRepositories
14+
@EntityScan
15+
public class Application extends SpringBootServletInitializer {
16+
// end::application-annotations[]
17+
public static void main(final String[] args) {
18+
SpringApplication.run(Application.class, args);
19+
}
20+
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.backbase.example;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
7+
import jakarta.annotation.Generated;
8+
import jakarta.validation.constraints.NotNull;
9+
import jakarta.validation.constraints.Size;
10+
11+
@JsonInclude(JsonInclude.Include.NON_NULL)
12+
@Generated("org.jsonschema2pojo")
13+
@JsonPropertyOrder({
14+
"message"
15+
})
16+
@JsonIgnoreProperties(ignoreUnknown = true)
17+
public class Message {
18+
19+
/**
20+
*
21+
* (Required)
22+
*
23+
*/
24+
@JsonProperty("id")
25+
@NotNull
26+
private String id;
27+
28+
/**
29+
* Greetings message
30+
*/
31+
@JsonProperty("message")
32+
@Size(max = 255)
33+
@NotNull
34+
private String message;
35+
36+
public Message() {
37+
}
38+
39+
public Message(String id, String message) {
40+
this.id = id;
41+
this.message = message;
42+
}
43+
44+
public String getId() {
45+
return id;
46+
}
47+
48+
public void setId(String id) {
49+
this.id = id;
50+
}
51+
52+
public String getMessage() {
53+
return message;
54+
}
55+
56+
public void setMessage(String message) {
57+
this.message = message;
58+
}
59+
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.backbase.example.api;
2+
3+
import com.backbase.example.Message;
4+
import com.backbase.example.domain.Greeting;
5+
import com.backbase.example.mapper.GreetingsMapper;
6+
import com.backbase.example.service.GreetingsService;
7+
import java.util.List;
8+
import java.util.UUID;
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.http.HttpStatus;
11+
import org.springframework.web.bind.annotation.PathVariable;
12+
import org.springframework.web.bind.annotation.RequestBody;
13+
import org.springframework.web.bind.annotation.RequestMapping;
14+
import org.springframework.web.bind.annotation.RequestMethod;
15+
import org.springframework.web.bind.annotation.ResponseStatus;
16+
import org.springframework.web.bind.annotation.RestController;
17+
18+
@RestController
19+
public class ExampleController {
20+
21+
@Autowired
22+
private GreetingsService greetingsService;
23+
24+
@RequestMapping(method = RequestMethod.GET, value = "/message/{id}", produces = {
25+
"application/json"
26+
})
27+
@ResponseStatus(HttpStatus.OK)
28+
public Message getMessage(@PathVariable(name = "id") String id) {
29+
Greeting greeting = greetingsService.getGreetingById(id);
30+
return GreetingsMapper.INSTANCE.greetingToMessage(greeting);
31+
}
32+
33+
@RequestMapping(method = RequestMethod.GET, value = "/messages", produces = {
34+
"application/json"
35+
})
36+
@ResponseStatus(HttpStatus.OK)
37+
public List<Message> getMessages() {
38+
List<Greeting> greetings = greetingsService.getGreetings();
39+
return GreetingsMapper.INSTANCE.greetingsToMessages(greetings);
40+
}
41+
// tag::addMessage[]
42+
@RequestMapping(method = RequestMethod.POST, value = "/message")
43+
@ResponseStatus(HttpStatus.CREATED)
44+
public String addMessage(@RequestBody Message message) {
45+
Greeting greeting = GreetingsMapper.INSTANCE.messageToGreeting(message);
46+
String id = UUID.randomUUID().toString();
47+
greeting.setId(id);
48+
greetingsService.addNewGreeting(greeting);
49+
return id;
50+
}
51+
// end::addMessage[]
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.backbase.example.domain;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.Id;
6+
import jakarta.persistence.Table;
7+
8+
@Entity
9+
@Table(name = "greetings")
10+
public class Greeting {
11+
12+
@Id
13+
@Column(name = "id")
14+
private String id;
15+
16+
@Column(name = "message")
17+
private String message;
18+
19+
public String getId() {
20+
return id;
21+
}
22+
23+
public void setId(String id) {
24+
this.id = id;
25+
}
26+
27+
public String getMessage() {
28+
return message;
29+
}
30+
31+
public void setMessage(String message) {
32+
this.message = message;
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.backbase.example.mapper;
2+
3+
import com.backbase.example.Message;
4+
import com.backbase.example.domain.Greeting;
5+
import java.util.List;
6+
import org.mapstruct.Mapper;
7+
import org.mapstruct.ReportingPolicy;
8+
import org.mapstruct.factory.Mappers;
9+
10+
@Mapper(unmappedTargetPolicy= ReportingPolicy.ERROR)
11+
public interface GreetingsMapper {
12+
13+
GreetingsMapper INSTANCE = Mappers.getMapper( GreetingsMapper.class);
14+
15+
Message greetingToMessage(Greeting greeting);
16+
List<Message> greetingsToMessages(List<Greeting> greetings);
17+
Greeting messageToGreeting(Message message);
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.backbase.example.repository;
2+
3+
import com.backbase.example.domain.Greeting;
4+
import java.util.List;
5+
import org.springframework.data.repository.CrudRepository;
6+
import org.springframework.stereotype.Repository;
7+
8+
@Repository
9+
public interface GreetingsRepository extends CrudRepository<Greeting, String> {
10+
11+
@Override
12+
List<Greeting> findAll();
13+
}

0 commit comments

Comments
 (0)