List of usage examples for com.google.gwt.gdata.client.finance TransactionEntryCallback TransactionEntryCallback
TransactionEntryCallback
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceCreateTransactionDemo.java
License:Apache License
/** * Create a transaction by inserting a transaction entry into * a transaction feed.//from w w w . jav a2s. c om * Set the transaction's notes to an arbitrary string. Here * we prefix the notes field with 'GWT-Finance-Client' so that * we can identify which transactions were created by this demo. * The new transaction is created with a set of transaction data * specifying the type and shares. * The transaction is inserted into the transactions feed for * the symbol "NASDAQ:GOOG". If no position exists for this symbol * the insert request will fail. * On success and failure, display a status message. * * @param portfolioEditUri The uri of the portfolio entry into which * to insert the transaction entry */ private void createTransaction(String portfolioEditUri) { showStatus("Creating transaction...", false); TransactionEntry entry = TransactionEntry.newInstance(); TransactionData data = TransactionData.newInstance(); data.setType("Buy"); data.setShares(141.42); data.setNotes("GWT-Finance-Client - inserted transaction"); entry.setTransactionData(data); String ticker = "NASDAQ:GOOG"; String transactionPostUri = portfolioEditUri + "/positions/" + ticker + "/transactions"; service.insertEntry(transactionPostUri, entry, new TransactionEntryCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while creating a transaction: " + caught.getMessage(), true); } public void onSuccess(TransactionEntry result) { showStatus("Created a transaction.", false); } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceDeleteTransactionDemo.java
License:Apache License
/** * Delete a transaction entry using the Finance service and * the transaction entry uri.//from w w w . ja v a 2 s .c o m * On success and failure, display a status message. * * @param transactionEntryUri The uri of the transaction entry to delete */ private void deleteTransaction(String transactionEntryUri) { showStatus("Deleting transaction...", false); service.deleteEntry(transactionEntryUri, new TransactionEntryCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while deleting a transaction: " + caught.getMessage(), true); } public void onSuccess(TransactionEntry result) { showStatus("Deleted a transaction.", false); } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceDeleteTransactionDemo.java
License:Apache License
/** * Retrieves the transaction entry corresponding to the given URI. * On failure display a status message. On success call * deleteTransaction to delete the transaction. Alternatively, * we could also have used result.deleteEntry, but the effect * is the same./* w w w . ja v a 2s.c o m*/ * * @param transactionEntryUri The transaction entry uri */ private void getTransaction(String transactionEntryUri) { showStatus("Retrieving transaction...", false); service.getTransactionEntry(transactionEntryUri, new TransactionEntryCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving a transaction: " + caught.getMessage(), true); } public void onSuccess(TransactionEntry result) { if (result == null) { showStatus("No transaction found.", false); } else { String transactionEntryUri = result.getSelfLink().getHref(); deleteTransaction(transactionEntryUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceUpdateTransactionDemo.java
License:Apache License
/** * Retrieves the transaction entry corresponding to the given URI. * On failure display a status message. On success call * updateTransaction to update the transaction. * /*w w w . j a va 2 s .co m*/ * @param transactionEntryUri The transaction entry uri */ private void getTransaction(String transactionEntryUri) { showStatus("Retrieving transaction...", false); service.getTransactionEntry(transactionEntryUri, new TransactionEntryCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving a transaction: " + caught.getMessage(), true); } public void onSuccess(TransactionEntry result) { if (result == null) { showStatus("No transaction found.", false); } else { updateTransaction(result); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceUpdateTransactionDemo.java
License:Apache License
/** * Update a transaction by making use of the updateEntry * method of the Entry class./*from ww w .ja v a 2 s .c o m*/ * Set the transaction notes to an arbitrary string. Here * we prefix the notes with 'GWT-Finance-Client' so that * we can identify which transactions were updated by this demo. * On success and failure, display a status message. * * @param transactionEntry The transaction entry which to update */ private void updateTransaction(TransactionEntry transactionEntry) { showStatus("Updating transaction...", false); transactionEntry.getTransactionData().setNotes("GWT-Finance-Client - updated transaction"); transactionEntry.getTransactionData().setShares(271.82); transactionEntry.updateEntry(new TransactionEntryCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while updating a transaction: " + caught.getMessage(), true); } public void onSuccess(TransactionEntry result) { showStatus("Updated a transaction.", false); } }); }