Created
October 25, 2021 11:00
-
-
Save ashutoshmeher-r3/d2e93dca43fed362b379dad57c307402 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@InitiatingFlow | |
@StartableByRPC | |
public class TransferLandTitleFlow implements Flow<SignedTransactionDigest> { | |
// Constructor | |
@CordaInject | |
private PersistenceService persistenceService; | |
// Inject other services | |
@Suspendable | |
public SignedTransactionDigest call() { | |
// Fetch the parameters passed to the flow. | |
//Query the landState | |
Map <String, Object> namedParameters = new LinkedHashMap<>(); | |
namedParameters.put("stateStatus", StateStatus.UNCONSUMED); | |
Cursor<StateAndRef<LandTitleState>> cursor = persistenceService.query( | |
"VaultState.findByStateStatus", | |
namedParameters, | |
new SetBasedVaultQueryFilter.Builder() | |
.withContractStateClassNames(Set.of(LandTitleState.class.getName())) | |
.build(), | |
"Corda.IdentityStateAndRefPostProcessor" | |
); | |
List<StateAndRef<LandTitleState>> inputLandStateStateAndRefList = | |
cursor.poll(100, Duration.ofSeconds(20)).getValues(); | |
// Filter the states to find the state in question | |
StateAndRef<LandTitleState> inputLandStateStateAndRef = | |
inputLandStateStateAndRefList.stream().filter(stateAndRef -> { | |
LandTitleState landTitleState = stateAndRef.getState().getData(); | |
return landTitleState.getPlotNumber().equals(plotNumber); | |
}).findAny().orElseThrow(() -> new FlowException("Land Not Found")); | |
// Build, Verify, Collect Signature and Commit Transaction. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment