Skip to content

Commit

Permalink
Merge pull request #10 from IBMStockTrader/jnosql
Browse files Browse the repository at this point in the history
Update schema for JNoSQL
  • Loading branch information
jwalcorn authored Apr 27, 2024
2 parents 1aeb2a7 + e820a0c commit ecf42d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ public Broker[] getBrokers(@Context HttpServletRequest request) {

// Match up the accounts and portfolios
// TODO: Pagination should reduce the amount of work to do here
Map<String, Account> mapOfAccounts = Arrays.stream(accounts).collect(Collectors.toMap(Account::get_id, account -> account));
Set<String> accountIds = Arrays.stream(accounts).map(Account::get_id).collect(Collectors.toSet());
Map<String, Account> mapOfAccounts = Arrays.stream(accounts).collect(Collectors.toMap(Account::getId, account -> account));
Set<String> accountIds = Arrays.stream(accounts).map(Account::getId).collect(Collectors.toSet());

brokersSet = Arrays.stream(portfolios)
.parallel()
Expand Down Expand Up @@ -237,7 +237,7 @@ public Broker createBroker(@PathParam("owner") String owner, @QueryParam("balanc
if (useAccount) try {
logger.fine("Calling AccountClient.createAccount()");
account = accountClient.createAccount(jwt, owner);
if (account != null) accountID = account.get_id();
if (account != null) accountID = account.getId();
} catch (Throwable t) {
logException(t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public interface AccountClient {
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Account[] getAccounts(@HeaderParam("Authorization") String jwt);
public Account[] getAccounts(@HeaderParam("Authorization") String jwt);

@GET
@Path("/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

/** JSON-B POJO class representing an Account JSON object */
public class Account {
private String _id;
private String _rev;
private String id;
private String owner;
private String loyalty;
private double balance;
Expand All @@ -47,20 +46,12 @@ public Account(String initialOwner, String initialLoyalty, double initialBalance
setNextCommission(initialNextCommission);
}

public String get_id() {
return _id;
public String getId() {
return id;
}

public void set_id(String new_id) {
_id = new_id;
}

public String get_rev() {
return _rev;
}

public void set_rev(String new_rev) {
_rev = new_rev;
public void setId(String new_id) {
id = new_id;
}

public String getOwner() {
Expand Down Expand Up @@ -126,7 +117,7 @@ public boolean equals(Object obj) {
}

public String toString() {
return "{\"_id\": \""+_id+"\", \"_rev\": \""+_rev+"\", \"owner\": \""+owner+"\", \"loyalty\": \""+loyalty
return "{\"_id\": \""+ id +"\", \"owner\": \""+owner+"\", \"loyalty\": \""+loyalty
+"\", \"balance\": "+balance+", \"commissions\": "+commissions+", \"free\": "+free
+", \"nextCommission\": "+nextCommission+", \"sentiment\": \""+sentiment+"\"}";
}
Expand Down

0 comments on commit ecf42d5

Please sign in to comment.