Skip to content

Commit 7279cd3

Browse files
authored
Upgrade Cloudbank to SB 32 (#800)
* springboot 3.2 initial commit * spingboot 3.2 initial commit * minimal changes * minimal changes * springboot 3.2 initial commit * spingboot 3.2 initial commit * minimal changes * minimal changes
1 parent 56cdbc9 commit 7279cd3

File tree

89 files changed

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

89 files changed

+6039
-0
lines changed

cloudbank-v32/README.md

Lines changed: 575 additions & 0 deletions
Large diffs are not rendered by default.

cloudbank-v32/account/checkstyle/checkstyle.xml

Lines changed: 329 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC
4+
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
5+
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
6+
7+
<suppressions>
8+
<!-- There's nothing wrong with these - ignore them b/c they generate noise -->
9+
<suppress checks="AbbreviationAsWordInName" files=".*"/>
10+
<suppress checks="MemberNameCheck" files=".*"/>
11+
<suppress checks="VariableDeclarationUsageDistanceCheck" files=".*"/>
12+
<suppress checks="AbbreviationAsWordInNameCheck" files=".*"/>
13+
</suppressions>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<suppressions xmlns="https://jeremylong.github.io/DependencyCheck/dependency-suppression.1.3.xsd">
3+
</suppressions>

cloudbank-v32/account/pom.xml

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+
<!-- Copyright (c) 2023, Oracle and/or its affiliates. -->
3+
<!-- Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ -->
4+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<parent>
9+
<groupId>com.example</groupId>
10+
<artifactId>sample-spring-apps</artifactId>
11+
<version>0.0.1-SNAPSHOT</version>
12+
</parent>
13+
14+
<artifactId>account</artifactId>
15+
<version>0.0.1-SNAPSHOT</version>
16+
<name>account</name>
17+
<description>Account Application</description>
18+
19+
<properties>
20+
<oracle-springboot-starter.version>23.4.0</oracle-springboot-starter.version>
21+
<liquibase.version>4.24.0</liquibase.version>
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-data-jpa</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>com.oracle.database.spring</groupId>
31+
<artifactId>oracle-spring-boot-starter-ucp</artifactId>
32+
<version>${oracle-springboot-starter.version}</version>
33+
<type>pom</type>
34+
</dependency>
35+
<dependency>
36+
<groupId>com.oracle.database.spring</groupId>
37+
<artifactId>oracle-spring-boot-starter-wallet</artifactId>
38+
<version>${oracle-springboot-starter.version}</version>
39+
<type>pom</type>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.liquibase</groupId>
43+
<artifactId>liquibase-core</artifactId>
44+
<version>${liquibase.version}</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>com.oracle.microtx.lra</groupId>
48+
<artifactId>microtx-lra-spring-boot-starter</artifactId>
49+
<version>23.4.1</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>jakarta.inject</groupId>
53+
<artifactId>jakarta.inject-api</artifactId>
54+
<version>2.0.1</version>
55+
</dependency>
56+
</dependencies>
57+
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.springframework.boot</groupId>
62+
<artifactId>spring-boot-maven-plugin</artifactId>
63+
</plugin>
64+
<plugin>
65+
<groupId>org.graalvm.buildtools</groupId>
66+
<artifactId>native-maven-plugin</artifactId>
67+
</plugin>
68+
<plugin>
69+
<groupId>org.liquibase</groupId>
70+
<artifactId>liquibase-maven-plugin</artifactId>
71+
<version>${liquibase.version}</version>
72+
</plugin>
73+
</plugins>
74+
</build>
75+
76+
</project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
package com.example.accounts;
5+
6+
import org.springframework.boot.SpringApplication;
7+
import org.springframework.boot.autoconfigure.SpringBootApplication;
8+
9+
@SpringBootApplication
10+
public class AccountsApplication {
11+
12+
public static void main(String[] args) {
13+
SpringApplication.run(AccountsApplication.class, args);
14+
}
15+
}
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
package com.example.accounts.controller;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
import java.util.Optional;
9+
10+
import com.example.accounts.model.Account;
11+
import com.example.accounts.model.Journal;
12+
import com.example.accounts.repository.AccountRepository;
13+
import com.example.accounts.repository.JournalRepository;
14+
import org.springframework.http.HttpStatus;
15+
import org.springframework.http.ResponseEntity;
16+
import org.springframework.web.bind.annotation.DeleteMapping;
17+
import org.springframework.web.bind.annotation.GetMapping;
18+
import org.springframework.web.bind.annotation.PathVariable;
19+
import org.springframework.web.bind.annotation.PostMapping;
20+
import org.springframework.web.bind.annotation.RequestBody;
21+
import org.springframework.web.bind.annotation.RequestMapping;
22+
import org.springframework.web.bind.annotation.RestController;
23+
24+
@RestController
25+
@RequestMapping("/api/v1")
26+
public class AccountController {
27+
28+
final AccountRepository accountRepository;
29+
final JournalRepository journalRepository;
30+
31+
public AccountController(AccountRepository accountRepository, JournalRepository journalRepository) {
32+
this.accountRepository = accountRepository;
33+
this.journalRepository = journalRepository;
34+
}
35+
36+
/**
37+
* Get all Accounts.
38+
* @return List off accounts
39+
*/
40+
@GetMapping("/accounts")
41+
public List<Account> getAllAccounts() {
42+
return accountRepository.findAll();
43+
}
44+
45+
/**
46+
* Create an account.
47+
* @param account Account object
48+
* @return Http Status Code
49+
*/
50+
@PostMapping("/account")
51+
public ResponseEntity<Account> createAccount(@RequestBody Account account) {
52+
try {
53+
Account newAccount = accountRepository.saveAndFlush(account);
54+
return new ResponseEntity<>(newAccount, HttpStatus.CREATED);
55+
} catch (Exception e) {
56+
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
57+
}
58+
}
59+
60+
/**
61+
* Find an account by Account Id.
62+
* @param accountId Account Id
63+
* @return An account
64+
*/
65+
@GetMapping("/account/{accountId}")
66+
public ResponseEntity<Account> getAccountById(@PathVariable("accountId") long accountId) {
67+
Optional<Account> accountData = accountRepository.findById(accountId);
68+
try {
69+
return accountData.map(account -> new ResponseEntity<>(account, HttpStatus.OK))
70+
.orElseGet(() -> new ResponseEntity<>(HttpStatus.NOT_FOUND));
71+
} catch (Exception e) {
72+
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
73+
}
74+
}
75+
76+
/**
77+
* Find an account by customer Id.
78+
* @param customerId Customer Id
79+
* @return A list opf Account(s)
80+
*/
81+
@GetMapping("/account/getAccounts/{customerId}")
82+
public ResponseEntity<List<Account>> getAccountsByCustomerId(@PathVariable("customerId") String customerId) {
83+
try {
84+
List<Account> accountData = new ArrayList<Account>();
85+
accountData.addAll(accountRepository.findByAccountCustomerId(customerId));
86+
if (accountData.isEmpty()) {
87+
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
88+
}
89+
return new ResponseEntity<>(accountData, HttpStatus.OK);
90+
} catch (Exception e) {
91+
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
92+
}
93+
}
94+
95+
/**
96+
* Delete an Account with specific Id.
97+
* @param accountId Account ID
98+
* @return HTTP Status Code
99+
*/
100+
@DeleteMapping("/account/{accountId}")
101+
public ResponseEntity<HttpStatus> deleteAccount(@PathVariable("accountId") long accountId) {
102+
try {
103+
accountRepository.deleteById(accountId);
104+
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
105+
} catch (Exception e) {
106+
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
107+
}
108+
}
109+
110+
/**
111+
* Get transactions (Journal) for an Account Id.
112+
* @param accountId Account Id
113+
* @return List of Journal object(s)
114+
*/
115+
@GetMapping("/account/{accountId}/transactions")
116+
public ResponseEntity<List<Journal>> getTransactions(@PathVariable("accountId") long accountId) {
117+
try {
118+
List<Journal> transactions = new ArrayList<Journal>();
119+
transactions.addAll(journalRepository.findByAccountId(accountId));
120+
if (transactions.isEmpty()) {
121+
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
122+
}
123+
return new ResponseEntity<>(transactions, HttpStatus.OK);
124+
} catch (Exception e) {
125+
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
126+
}
127+
}
128+
129+
/**
130+
* Create a Journal entry.
131+
* @param journalEntry Journal object
132+
* @return HTTP Status Code
133+
*/
134+
@PostMapping("/account/journal")
135+
public ResponseEntity<Journal> postSimpleJournalEntry(@RequestBody Journal journalEntry) {
136+
try {
137+
Journal newJournalEntry = journalRepository.saveAndFlush(journalEntry);
138+
return new ResponseEntity<>(newJournalEntry, HttpStatus.CREATED);
139+
} catch (Exception e) {
140+
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
141+
}
142+
}
143+
144+
/**
145+
* Find Journal entries by Account Id.
146+
* @param accountId Account Id
147+
* @return Journal object(s)
148+
*/
149+
@GetMapping("/account/{accountId}/journal")
150+
public List<Journal> getJournalEntriesForAccount(@PathVariable("accountId") long accountId) {
151+
return journalRepository.findJournalByAccountId(accountId);
152+
}
153+
154+
/**
155+
* Clears the Journal Entry.
156+
* @param journalId Journal Id
157+
* @return HTTP Status Code
158+
*/
159+
@PostMapping("/account/journal/{journalId}/clear")
160+
public ResponseEntity<Journal> clearJournalEntry(@PathVariable long journalId) {
161+
try {
162+
Optional<Journal> data = journalRepository.findById(journalId);
163+
if (data.isPresent()) {
164+
Journal newJournalEntry = data.get();
165+
newJournalEntry.setJournalType("DEPOSIT");
166+
journalRepository.saveAndFlush(newJournalEntry);
167+
return new ResponseEntity<Journal>(newJournalEntry, HttpStatus.OK);
168+
} else {
169+
return new ResponseEntity<Journal>(new Journal(), HttpStatus.ACCEPTED);
170+
}
171+
} catch (Exception e) {
172+
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
173+
}
174+
}
175+
176+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
package com.example.accounts.model;
5+
6+
import java.util.Date;
7+
8+
import jakarta.persistence.Column;
9+
import jakarta.persistence.Entity;
10+
import jakarta.persistence.GeneratedValue;
11+
import jakarta.persistence.GenerationType;
12+
import jakarta.persistence.Id;
13+
import jakarta.persistence.Table;
14+
import lombok.Data;
15+
import lombok.NoArgsConstructor;
16+
import org.hibernate.annotations.Generated;
17+
import org.hibernate.annotations.GenerationTime;
18+
19+
@SuppressWarnings("deprecation") // TODO: Needs to be removed
20+
@Data
21+
@NoArgsConstructor
22+
@Entity
23+
@Table(name = "ACCOUNTS")
24+
public class Account {
25+
26+
@Id
27+
@GeneratedValue(strategy = GenerationType.IDENTITY)
28+
@Column(name = "ACCOUNT_ID")
29+
private long accountId;
30+
31+
@Column(name = "ACCOUNT_NAME")
32+
private String accountName;
33+
34+
@Column(name = "ACCOUNT_TYPE")
35+
private String accountType;
36+
37+
@Column(name = "CUSTOMER_ID")
38+
private String accountCustomerId;
39+
40+
@Generated(GenerationTime.INSERT)
41+
@Column(name = "ACCOUNT_OPENED_DATE", updatable = false, insertable = false)
42+
private Date accountOpenedDate;
43+
44+
@Column(name = "ACCOUNT_OTHER_DETAILS")
45+
private String accountOtherDetails;
46+
47+
@Column(name = "ACCOUNT_BALANCE")
48+
private long accountBalance;
49+
50+
/**
51+
* Create Account object.
52+
* @param accountName Account name
53+
* @param accountType Account Type
54+
* @param accountOtherDetails Other details about account
55+
* @param accountCustomerId Account Customer ID
56+
*/
57+
public Account(String accountName, String accountType, String accountOtherDetails, String accountCustomerId) {
58+
this.accountName = accountName;
59+
this.accountType = accountType;
60+
this.accountOtherDetails = accountOtherDetails;
61+
this.accountCustomerId = accountCustomerId;
62+
}
63+
}

0 commit comments

Comments
 (0)