Skip to content

Commit a428a06

Browse files
authored
Adding checkstyle files & code fixes (#767)
* Adding checkstyle files * adding TODO * Code cleanup * import fixes * pom update * checkstyle files * Checkstyle stuff * moving checkstyle to main project * pom.xml update * customer checkstyle * Typo in customer * account checkstyle * checkstyle on checks * testrunner checkstyle * transfer checkstyle * account checkstyle * account checkstyle * checkstyle * Checkstyle UPL and Copyright
1 parent 5fa601e commit a428a06

File tree

58 files changed

+2917
-247
lines changed

Some content is hidden

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

58 files changed

+2917
-247
lines changed

cloudbank-v3/spring-apps-spring3/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>
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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/
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/
33

44
package com.example.accounts;
55

@@ -9,8 +9,7 @@
99
@SpringBootApplication
1010
public class AccountsApplication {
1111

12-
public static void main(String[] args) {
13-
SpringApplication.run(AccountsApplication.class, args);
14-
}
15-
12+
public static void main(String[] args) {
13+
SpringApplication.run(AccountsApplication.class, args);
14+
}
1615
}

cloudbank-v3/spring-apps-spring3/account/src/main/java/com/example/accounts/controller/AccountController.java

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
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/
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/
33

44
package com.example.accounts.controller;
55

6-
import org.springframework.web.bind.annotation.GetMapping;
7-
import org.springframework.web.bind.annotation.RequestMapping;
8-
import org.springframework.web.bind.annotation.RestController;
9-
import com.example.accounts.repository.AccountRepository;
10-
import com.example.accounts.repository.JournalRepository;
6+
import java.util.ArrayList;
117
import java.util.List;
8+
import java.util.Optional;
9+
1210
import com.example.accounts.model.Account;
1311
import com.example.accounts.model.Journal;
14-
import org.springframework.web.bind.annotation.PostMapping;
15-
import org.springframework.web.bind.annotation.RequestBody;
12+
import com.example.accounts.repository.AccountRepository;
13+
import com.example.accounts.repository.JournalRepository;
1614
import org.springframework.http.HttpStatus;
1715
import org.springframework.http.ResponseEntity;
18-
import org.springframework.web.bind.annotation.PathVariable;
19-
import java.util.ArrayList;
20-
import java.util.Optional;
2116
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;
2223

2324
@RestController
2425
@RequestMapping("/api/v1")
@@ -32,21 +33,35 @@ public AccountController(AccountRepository accountRepository, JournalRepository
3233
this.journalRepository = journalRepository;
3334
}
3435

36+
/**
37+
* Get all Accounts.
38+
* @return List off accounts
39+
*/
3540
@GetMapping("/accounts")
3641
public List<Account> getAllAccounts() {
3742
return accountRepository.findAll();
3843
}
3944

45+
/**
46+
* Create an account.
47+
* @param account Account object
48+
* @return Http Status Code
49+
*/
4050
@PostMapping("/account")
4151
public ResponseEntity<Account> createAccount(@RequestBody Account account) {
4252
try {
43-
Account _account = accountRepository.saveAndFlush(account);
44-
return new ResponseEntity<>(_account, HttpStatus.CREATED);
53+
Account newAccount = accountRepository.saveAndFlush(account);
54+
return new ResponseEntity<>(newAccount, HttpStatus.CREATED);
4555
} catch (Exception e) {
4656
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
4757
}
4858
}
4959

60+
/**
61+
* Find an account by Account Id.
62+
* @param accountId Account Id
63+
* @return An account
64+
*/
5065
@GetMapping("/account/{accountId}")
5166
public ResponseEntity<Account> getAccountById(@PathVariable("accountId") long accountId) {
5267
Optional<Account> accountData = accountRepository.findById(accountId);
@@ -58,6 +73,11 @@ public ResponseEntity<Account> getAccountById(@PathVariable("accountId") long ac
5873
}
5974
}
6075

76+
/**
77+
* Find an account by customer Id.
78+
* @param customerId Customer Id
79+
* @return A list opf Account(s)
80+
*/
6181
@GetMapping("/account/getAccounts/{customerId}")
6282
public ResponseEntity<List<Account>> getAccountsByCustomerId(@PathVariable("customerId") String customerId) {
6383
try {
@@ -72,6 +92,11 @@ public ResponseEntity<List<Account>> getAccountsByCustomerId(@PathVariable("cust
7292
}
7393
}
7494

95+
/**
96+
* Delete an Account with specific Id.
97+
* @param accountId Account ID
98+
* @return HTTP Status Code
99+
*/
75100
@DeleteMapping("/account/{accountId}")
76101
public ResponseEntity<HttpStatus> deleteAccount(@PathVariable("accountId") long accountId) {
77102
try {
@@ -82,6 +107,11 @@ public ResponseEntity<HttpStatus> deleteAccount(@PathVariable("accountId") long
82107
}
83108
}
84109

110+
/**
111+
* Get transactions (Journal) for an Account Id.
112+
* @param accountId Account Id
113+
* @return List of Journal object(s)
114+
*/
85115
@GetMapping("/account/{accountId}/transactions")
86116
public ResponseEntity<List<Journal>> getTransactions(@PathVariable("accountId") long accountId) {
87117
try {
@@ -96,30 +126,45 @@ public ResponseEntity<List<Journal>> getTransactions(@PathVariable("accountId")
96126
}
97127
}
98128

129+
/**
130+
* Create a Journal entry.
131+
* @param journalEntry Journal object
132+
* @return HTTP Status Code
133+
*/
99134
@PostMapping("/account/journal")
100135
public ResponseEntity<Journal> postSimpleJournalEntry(@RequestBody Journal journalEntry) {
101136
try {
102-
Journal _journalEntry = journalRepository.saveAndFlush(journalEntry);
103-
return new ResponseEntity<>(_journalEntry, HttpStatus.CREATED);
137+
Journal newJournalEntry = journalRepository.saveAndFlush(journalEntry);
138+
return new ResponseEntity<>(newJournalEntry, HttpStatus.CREATED);
104139
} catch (Exception e) {
105140
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
106141
}
107142
}
108143

144+
/**
145+
* Find Journal entries by Account Id.
146+
* @param accountId Account Id
147+
* @return Journal object(s)
148+
*/
109149
@GetMapping("/account/{accountId}/journal")
110150
public List<Journal> getJournalEntriesForAccount(@PathVariable("accountId") long accountId) {
111151
return journalRepository.findJournalByAccountId(accountId);
112152
}
113153

154+
/**
155+
* Clears the Journal Entry.
156+
* @param journalId Journal Id
157+
* @return HTTP Status Code
158+
*/
114159
@PostMapping("/account/journal/{journalId}/clear")
115160
public ResponseEntity<Journal> clearJournalEntry(@PathVariable long journalId) {
116161
try {
117162
Optional<Journal> data = journalRepository.findById(journalId);
118163
if (data.isPresent()) {
119-
Journal _journalEntry = data.get();
120-
_journalEntry.setJournalType("DEPOSIT");
121-
journalRepository.saveAndFlush(_journalEntry);
122-
return new ResponseEntity<Journal>(_journalEntry, HttpStatus.OK);
164+
Journal newJournalEntry = data.get();
165+
newJournalEntry.setJournalType("DEPOSIT");
166+
journalRepository.saveAndFlush(newJournalEntry);
167+
return new ResponseEntity<Journal>(newJournalEntry, HttpStatus.OK);
123168
} else {
124169
return new ResponseEntity<Journal>(new Journal(), HttpStatus.ACCEPTED);
125170
}

cloudbank-v3/spring-apps-spring3/account/src/main/java/com/example/accounts/model/Account.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
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/
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/
33

44
package com.example.accounts.model;
55

66
import java.util.Date;
7+
8+
import jakarta.persistence.Column;
79
import jakarta.persistence.Entity;
10+
import jakarta.persistence.GeneratedValue;
11+
import jakarta.persistence.GenerationType;
12+
import jakarta.persistence.Id;
813
import jakarta.persistence.Table;
914
import lombok.Data;
1015
import lombok.NoArgsConstructor;
11-
import jakarta.persistence.Column;
12-
import jakarta.persistence.GeneratedValue;
13-
import jakarta.persistence.GenerationType;
1416
import org.hibernate.annotations.Generated;
1517
import org.hibernate.annotations.GenerationTime;
16-
import jakarta.persistence.Id;
1718

19+
@SuppressWarnings("deprecation") // TODO: Needs to be removed
1820
@Data
1921
@NoArgsConstructor
2022
@Entity
@@ -45,6 +47,13 @@ public class Account {
4547
@Column(name = "ACCOUNT_BALANCE")
4648
private long accountBalance;
4749

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+
*/
4857
public Account(String accountName, String accountType, String accountOtherDetails, String accountCustomerId) {
4958
this.accountName = accountName;
5059
this.accountType = accountType;

cloudbank-v3/spring-apps-spring3/account/src/main/java/com/example/accounts/model/Journal.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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/
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/
33

44
package com.example.accounts.model;
55

@@ -9,7 +9,6 @@
99
import jakarta.persistence.GenerationType;
1010
import jakarta.persistence.Id;
1111
import jakarta.persistence.Table;
12-
1312
import lombok.Data;
1413
import lombok.NoArgsConstructor;
1514

@@ -40,6 +39,14 @@ public class Journal {
4039
@Column(name = "JOURNAL_AMOUNT")
4140
private long journalAmount;
4241

42+
/**
43+
* Create Journal Object.
44+
* @param journalType Journal Type
45+
* @param accountId Account Id
46+
* @param journalAmount Amount
47+
* @param lraId LRA Id
48+
* @param lraState State
49+
*/
4350
public Journal(String journalType, long accountId, long journalAmount, String lraId, String lraState) {
4451
this.journalType = journalType;
4552
this.accountId = accountId;
@@ -48,6 +55,12 @@ public Journal(String journalType, long accountId, long journalAmount, String lr
4855
this.journalAmount = journalAmount;
4956
}
5057

58+
/**
59+
* Create Journal object.
60+
* @param journalType Journal Type
61+
* @param accountId Account Id
62+
* @param journalAmount Amount
63+
*/
5164
public Journal(String journalType, long accountId, long journalAmount) {
5265
this.journalType = journalType;
5366
this.accountId = accountId;
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
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/
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/
33

44
package com.example.accounts.repository;
55

66
import java.util.List;
77

8+
import com.example.accounts.model.Account;
89
import org.springframework.data.jpa.repository.JpaRepository;
910

10-
import com.example.accounts.model.Account;
11+
public interface AccountRepository extends JpaRepository<Account, Long> {
12+
13+
List<Account> findByAccountCustomerId(String customerId);
14+
15+
List<Account> findAccountsByAccountNameContains(String accountName);
1116

12-
public interface AccountRepository extends JpaRepository<Account, Long> {
13-
List<Account> findByAccountCustomerId(String customerId);
14-
List<Account> findAccountsByAccountNameContains (String accountName);
1517
Account findByAccountId(long accountId);
1618
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
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/
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/
33

44
package com.example.accounts.repository;
55

6+
import java.util.List;
7+
68
import com.example.accounts.model.Journal;
79
import org.springframework.data.jpa.repository.JpaRepository;
810

9-
import java.util.List;
10-
1111
public interface JournalRepository extends JpaRepository<Journal, Long> {
12+
1213
Journal findJournalByLraIdAndJournalType(String lraId, String journalType);
14+
1315
List<Journal> findByAccountId(long accountId);
16+
1417
List<Journal> findJournalByAccountId(long accountId);
1518
}

0 commit comments

Comments
 (0)