Skip to content

Commit 088ad39

Browse files
authored
Merge pull request #21 from Backbase/release-14.0.0
copy samples for 14.0.0 release
2 parents 78fbf72 + 42c359a commit 088ad39

File tree

221 files changed

+5932
-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.

221 files changed

+5932
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
service-sdk/12.1.0/.idea/
2+
.DS_Store
3+
target/
4+
.idea/
5+
*.iml
6+
.classpath
7+
.project
8+
.factorypath
9+
.settings
10+
.mvn/.m2
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)
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
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-service-1.0.0-SNAPSHOT.war`
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 Gateway after authenticating with the authentication 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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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>14.0.0</version>
13+
<relativePath />
14+
</parent>
15+
16+
<groupId>com.backbase.example</groupId>
17+
<artifactId>example-service</artifactId>
18+
<version>1.0.0-SNAPSHOT</version>
19+
<packaging>war</packaging>
20+
<name>Backbase :: Digital Banking Services :: example-service</name>
21+
22+
<properties>
23+
<java.version>11</java.version>
24+
</properties>
25+
26+
<dependencies>
27+
<!-- tag::persistence-dependencies[] -->
28+
<!--Added for persistence -->
29+
<dependency>
30+
<groupId>com.backbase.buildingblocks</groupId>
31+
<artifactId>persistence</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>com.backbase.buildingblocks</groupId>
35+
<artifactId>service-sdk-starter-mapping</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-cache</artifactId>
40+
</dependency>
41+
<!-- Required for Local testing -->
42+
<dependency>
43+
<groupId>com.h2database</groupId>
44+
<artifactId>h2</artifactId>
45+
<version>1.4.200</version>
46+
<scope>runtime</scope>
47+
</dependency>
48+
<!-- Required for MySql -->
49+
<dependency>
50+
<groupId>mysql</groupId>
51+
<artifactId>mysql-connector-java</artifactId>
52+
<scope>runtime</scope>
53+
</dependency>
54+
<!-- end::persistence-dependencies[] -->
55+
56+
<dependency>
57+
<groupId>com.backbase.buildingblocks</groupId>
58+
<artifactId>service-sdk-starter-test</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
62+
<!-- Add dependencies for your services, e.g. BB raml specifications, integration clients -->
63+
64+
<!-- Uncomment the following dependencies if DBS inter-service communication is needed -->
65+
<!--
66+
<dependency>
67+
<groupId>com.backbase.buildingblocks</groupId>
68+
<artifactId>communication</artifactId>
69+
</dependency>
70+
<dependency>
71+
<groupId>com.backbase.buildingblocks</groupId>
72+
<artifactId>auth-security</artifactId>
73+
</dependency>
74+
-->
75+
</dependencies>
76+
77+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.backbase.example;
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
4+
import org.springframework.boot.SpringApplication;
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,47 @@
1+
package com.backbase.example;
2+
3+
import com.backbase.example.domain.Greeting;
4+
import com.backbase.example.mapper.GreetingsMapper;
5+
import com.backbase.example.service.GreetingsService;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.http.HttpStatus;
8+
import org.springframework.web.bind.annotation.*;
9+
10+
import java.util.List;
11+
import java.util.UUID;
12+
13+
@RestController
14+
public class ExampleController {
15+
16+
@Autowired
17+
private GreetingsService greetingsService;
18+
19+
@RequestMapping(method = RequestMethod.GET, value = "/message/{id}", produces = {
20+
"application/json"
21+
})
22+
@ResponseStatus(HttpStatus.OK)
23+
public Message getMessage(@PathVariable(name = "id") String id) {
24+
Greeting greeting = greetingsService.getGreetingById(id);
25+
return GreetingsMapper.INSTANCE.greetingToMessage(greeting);
26+
}
27+
28+
@RequestMapping(method = RequestMethod.GET, value = "/messages", produces = {
29+
"application/json"
30+
})
31+
@ResponseStatus(HttpStatus.OK)
32+
public List<Message> getMessages() {
33+
List<Greeting> greetings = greetingsService.getGreetings();
34+
return GreetingsMapper.INSTANCE.greetingsToMessages(greetings);
35+
}
36+
// tag::addMessage[]
37+
@RequestMapping(method = RequestMethod.POST, value = "/message")
38+
@ResponseStatus(HttpStatus.CREATED)
39+
public String addMessage(@RequestBody Message message) {
40+
Greeting greeting = GreetingsMapper.INSTANCE.messageToGreeting(message);
41+
String id = UUID.randomUUID().toString();
42+
greeting.setId(id);
43+
greetingsService.addNewGreeting(greeting);
44+
return id;
45+
}
46+
// end::addMessage[]
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
8+
import javax.annotation.Generated;
9+
import javax.validation.constraints.NotNull;
10+
import javax.validation.constraints.Size;
11+
12+
@JsonInclude(JsonInclude.Include.NON_NULL)
13+
@Generated("org.jsonschema2pojo")
14+
@JsonPropertyOrder({
15+
"message"
16+
})
17+
@JsonIgnoreProperties(ignoreUnknown = true)
18+
public class Message {
19+
20+
/**
21+
*
22+
* (Required)
23+
*
24+
*/
25+
@JsonProperty("id")
26+
@NotNull
27+
private String id;
28+
29+
/**
30+
* Greetings message
31+
*/
32+
@JsonProperty("message")
33+
@Size(max = 255)
34+
@NotNull
35+
private String message;
36+
37+
public Message() {
38+
}
39+
40+
public Message(String id, String message) {
41+
this.id = id;
42+
this.message = message;
43+
}
44+
45+
public String getId() {
46+
return id;
47+
}
48+
49+
public void setId(String id) {
50+
this.id = id;
51+
}
52+
53+
public String getMessage() {
54+
return message;
55+
}
56+
57+
public void setMessage(String message) {
58+
this.message = message;
59+
}
60+
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.backbase.example.domain;
2+
3+
import javax.persistence.*;
4+
5+
@Entity
6+
@Table(name = "greetings")
7+
public class Greeting {
8+
9+
@Id
10+
@Column(name = "id")
11+
private String id;
12+
13+
@Column(name = "message")
14+
private String message;
15+
16+
public String getId() {
17+
return id;
18+
}
19+
20+
public void setId(String id) {
21+
this.id = id;
22+
}
23+
24+
public String getMessage() {
25+
return message;
26+
}
27+
28+
public void setMessage(String message) {
29+
this.message = message;
30+
}
31+
}
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 org.mapstruct.Mapper;
6+
import org.mapstruct.factory.Mappers;
7+
8+
import java.util.List;
9+
10+
@Mapper
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,14 @@
1+
package com.backbase.example.repository;
2+
3+
import com.backbase.example.domain.Greeting;
4+
import org.springframework.data.repository.CrudRepository;
5+
import org.springframework.stereotype.Repository;
6+
7+
import java.util.List;
8+
9+
@Repository
10+
public interface GreetingsRepository extends CrudRepository<Greeting, String> {
11+
12+
@Override
13+
List<Greeting> findAll();
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.backbase.example.service;
2+
3+
import com.backbase.example.domain.Greeting;
4+
5+
import java.util.List;
6+
7+
public interface GreetingsService {
8+
9+
List<Greeting> getGreetings();
10+
11+
Greeting getGreetingById(String id);
12+
13+
void addNewGreeting(Greeting greeting);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.backbase.example.service;
2+
3+
import com.backbase.example.domain.Greeting;
4+
import com.backbase.example.repository.GreetingsRepository;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.stereotype.Service;
7+
8+
import java.util.List;
9+
10+
@Service
11+
public class GreetingsServiceImpl implements GreetingsService {
12+
13+
@Autowired
14+
private GreetingsRepository greetingsRepository;
15+
16+
@Override
17+
public List<Greeting> getGreetings() {
18+
return greetingsRepository.findAll();
19+
}
20+
21+
@Override
22+
public Greeting getGreetingById(String id) {
23+
return greetingsRepository.findById(id).get();
24+
}
25+
26+
@Override
27+
public void addNewGreeting(Greeting greeting) {
28+
greetingsRepository.save(greeting);
29+
}
30+
}

0 commit comments

Comments
 (0)