@RequestMapping(value = "/transactionservice/transaction/{id}", method = RequestMethod.PUT) public ResponseEntity addTransaction(@PathVariable("id") Long id, @RequestBody String body) { Transaction aTransaction = gson.fromJson(body, Transaction.class); aTransaction.setId(id); long result = transactionService.addTransaction(aTransaction); if (result >= 0) { return new ResponseEntity<String>("{ \"status\": \"ok\" }", HttpStatus.OK); } else { return new ResponseEntity<String>( "Oops! You tried to feed me a duplicate transaction_id. Updating is not implemented, yet.", HttpStatus.UNPROCESSABLE_ENTITY); } }
public void submitTransaction(View view) { Calendar currentDate = Calendar.getInstance(); TransactionService TransactionService = new TransactionService(); TransactionService.getTransactions(); EditText item = (EditText) findViewById(R.id.Item); EditText amount = (EditText) findViewById(R.id.Amount); EditText employee = (EditText) findViewById(R.id.Employee); String product = item.getText().toString(); String amountPurchased = amount.getText().toString(); String employeeOnDuty = employee.getText().toString(); Transaction newTransaction = new Transaction(); newTransaction.setId(UUID.randomUUID()); newTransaction.setItem(product); newTransaction.setAmount(amountPurchased); newTransaction.setEmployee(employeeOnDuty); newTransaction.setDate(currentDate.toString()); TransactionService.setTransaction(newTransaction); Intent manageTransactionintent = new Intent(this, manageTrnasactions.class); startActivity(manageTransactionintent); }
@Test public void testHuobiBuyMatch() throws IOException { init(); List<NavigableMap<byte[], byte[]>> results = api.getRecordBySmallerTS("HuobiDepthInfo", "1450633999526", "Asks", 5); OrderInfo info = service.matchRecords(results, -1, 2917.15, 0.2555, "buy"); System.out.println("The traded amount is:" + info.getProcessed_amount()); System.out.println("The traded price is:" + info.getPrice()); info = service.matchRecords(results, -1, 2917.6, 1, "buy"); System.out.println("The traded amount is:" + info.getProcessed_amount()); System.out.println("The traded price is:" + info.getPrice()); info = service.matchRecords(results, -1, 2917.1, 1, "buy"); System.out.println("The traded amount is:" + info.getProcessed_amount()); System.out.println("The traded price is:" + info.getPrice()); info = service.matchRecords(results, -1, 2916.95, 2, "buy"); System.out.println("The traded amount is:" + info.getProcessed_amount()); System.out.println("The traded price is:" + info.getPrice()); results = api.getRecordBySmallerTS("HuobiDepthInfo", "1450633999526", "Bids", 5); info = service.matchRecords(results, -1, 2917.10, 0.2555, "ask"); System.out.println("The traded amount is:" + info.getProcessed_amount()); System.out.println("The traded price is:" + info.getPrice()); info = service.matchRecords(results, -1, 2917.10, 1, "ask"); System.out.println("The traded amount is:" + info.getProcessed_amount()); System.out.println("The traded price is:" + info.getPrice()); info = service.matchRecords(results, -1, 2916.45, 3, "ask"); System.out.println("The traded amount is:" + info.getProcessed_amount()); System.out.println("The traded price is:" + info.getPrice()); info = service.matchRecords(results, -1, 2918.00, 1, "ask"); System.out.println("The traded amount is:" + info.getProcessed_amount()); System.out.println("The traded price is:" + info.getPrice()); }
@RequestMapping(value = "/transactionservice/transaction/", method = RequestMethod.GET) public ResponseEntity getTransactionCount() { return new ResponseEntity<String>( "{ \"numberOfTransactions\": " + transactionService.getTransactionCount() + " }", HttpStatus.OK); }
@RequestMapping(value = "/transactionservice/sum/{id}", method = RequestMethod.GET) public ResponseEntity getSum(@PathVariable("id") Long id) { return new ResponseEntity<String>( "{ \"sum\": " + transactionService.getSum(id) + " }", HttpStatus.OK); }
@RequestMapping(value = "/transactionservice/types/{type}", method = RequestMethod.GET) public ResponseEntity getTransaction(@PathVariable("type") String type) { return new ResponseEntity<String>( gson.toJson(transactionService.getTransactionType(type)), HttpStatus.OK); }
@RequestMapping(value = "/transactionservice/transaction/{id}", method = RequestMethod.GET) public ResponseEntity getTransaction(@PathVariable("id") Long id) { return new ResponseEntity<String>( gson.toJson(transactionService.getTransaction(id)), HttpStatus.OK); }