From 849d5921d3527f298f4e637720b749eee8ad7359 Mon Sep 17 00:00:00 2001 From: Joel Dudley Date: Fri, 23 Jun 2017 13:31:04 +0100 Subject: [PATCH] Updates the cookbook to reflect vault API changes. --- .../java/net/corda/docs/FlowCookbookJava.java | 16 ++++------------ .../main/kotlin/net/corda/docs/FlowCookbook.kt | 14 +++++++++----- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/docs/source/example-code/src/main/java/net/corda/docs/FlowCookbookJava.java b/docs/source/example-code/src/main/java/net/corda/docs/FlowCookbookJava.java index 5ac2bff1ce..b50156b057 100644 --- a/docs/source/example-code/src/main/java/net/corda/docs/FlowCookbookJava.java +++ b/docs/source/example-code/src/main/java/net/corda/docs/FlowCookbookJava.java @@ -12,7 +12,8 @@ import net.corda.core.flows.*; import net.corda.core.identity.Party; import net.corda.core.node.services.ServiceType; import net.corda.core.node.services.Vault; -import net.corda.core.node.services.vault.QueryCriteria; +import net.corda.core.node.services.Vault.Page; +import net.corda.core.node.services.vault.QueryCriteria.VaultQueryCriteria; import net.corda.core.transactions.LedgerTransaction; import net.corda.core.transactions.SignedTransaction; import net.corda.core.transactions.TransactionBuilder; @@ -26,13 +27,8 @@ import net.corda.flows.ResolveTransactionsFlow; import net.corda.flows.SignTransactionFlow; import org.bouncycastle.asn1.x500.X500Name; -import net.corda.core.node.services.vault.QueryCriteria.VaultQueryCriteria; -import rx.Observable; - import java.security.PublicKey; import java.time.Instant; -import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -227,12 +223,8 @@ public class FlowCookbookJava { // For example, we would extract any unconsumed ``DummyState``s // from our vault as follows: - Vault.StateStatus status = Vault.StateStatus.UNCONSUMED; - Set> dummyStateTypes = new HashSet<>(ImmutableList.of(DummyState.class)); - - VaultQueryCriteria criteria = new VaultQueryCriteria(status, null, dummyStateTypes); - Vault.Page results = getServiceHub().getVaultService().queryBy(criteria); - + VaultQueryCriteria criteria = new VaultQueryCriteria(Vault.StateStatus.UNCONSUMED); + Page results = getServiceHub().getVaultQueryService().queryBy(DummyState.class, criteria); List> dummyStates = results.getStates(); // For a full list of the available ways of extracting states from diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/FlowCookbook.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/FlowCookbook.kt index edc75fbb0e..e906651f32 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/FlowCookbook.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/FlowCookbook.kt @@ -9,14 +9,18 @@ import net.corda.core.crypto.SecureHash import net.corda.core.flows.* import net.corda.core.identity.Party import net.corda.core.node.services.ServiceType -import net.corda.core.node.services.Vault -import net.corda.core.node.services.vault.QueryCriteria +import net.corda.core.node.services.Vault.Page +import net.corda.core.node.services.queryBy +import net.corda.core.node.services.vault.QueryCriteria.VaultQueryCriteria import net.corda.core.transactions.LedgerTransaction import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.TransactionBuilder import net.corda.core.transactions.WireTransaction -import net.corda.core.utilities.* +import net.corda.core.utilities.DUMMY_PUBKEY_1 +import net.corda.core.utilities.ProgressTracker import net.corda.core.utilities.ProgressTracker.Step +import net.corda.core.utilities.UntrustworthyData +import net.corda.core.utilities.unwrap import net.corda.flows.CollectSignaturesFlow import net.corda.flows.FinalityFlow import net.corda.flows.ResolveTransactionsFlow @@ -202,8 +206,8 @@ object FlowCookbook { // For example, we would extract any unconsumed ``DummyState``s // from our vault as follows: - val criteria = QueryCriteria.VaultQueryCriteria() // default is UNCONSUMED - val results: Vault.Page = serviceHub.vaultService.queryBy(criteria) + val criteria: VaultQueryCriteria = VaultQueryCriteria() // default is UNCONSUMED + val results: Page = serviceHub.vaultQueryService.queryBy(criteria) val dummyStates: List> = results.states // For a full list of the available ways of extracting states from