Skip to content

Commit 1736ea0

Browse files
Fixed naming issues with progress tracker steps.
1 parent 6c406c2 commit 1736ea0

17 files changed

+86
-83
lines changed

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/accounts/AmendAccountFlowHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class AmendAccountFlowHandler(
6464
private class Handler(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
6565

6666
private companion object {
67-
object HandleAmendedAccountStep : Step("Handling amended account.") {
67+
object HandleAmendedAccountStep : Step("Handling account amendment.") {
6868
override fun childProgressTracker(): ProgressTracker = tracker()
6969
}
7070
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/accounts/GetAccountStateRefsByClaimFlow.kt

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,30 @@ class GetAccountStateRefsByClaimFlow(
4040
) : FlowLogic<List<StateRef>>() {
4141

4242
private companion object {
43+
44+
/**
45+
* The name of the transaction ID column.
46+
*/
4347
const val TRANSACTION_ID = "transaction_id"
48+
49+
/**
50+
* The name of the transaction output index column.
51+
*/
4452
const val OUTPUT_INDEX = "output_index"
4553
}
4654

4755
@Suspendable
4856
override fun call(): List<StateRef> {
49-
return if (property == null && value == null && hash == null) emptyList() else executeQuery(buildString {
57+
return if (property == null && value == null && hash == null) emptyList() else executeQuery()
58+
}
59+
60+
/**
61+
* Builds the SQL query.
62+
*
63+
* @return Returns a [String] representing the SQL query to be executed.
64+
*/
65+
private fun buildQuery(): String {
66+
return buildString {
5067
val criteria = mutableListOf<String>()
5168

5269
property?.let { criteria.add("property = '$it'") }
@@ -56,29 +73,37 @@ class GetAccountStateRefsByClaimFlow(
5673
appendln("select $TRANSACTION_ID, $OUTPUT_INDEX")
5774
appendln("from onixlabs_account_claims")
5875
appendln("where ${criteria.joinToString("\nand ")}")
59-
})
76+
}
6077
}
6178

79+
/**
80+
* Executes the SQL query.
81+
*
82+
* @return Returns a [List] of [StateRef] representing the recorded accounts.
83+
*/
6284
@Suspendable
63-
private fun executeQuery(query: String): List<StateRef> {
85+
private fun executeQuery(): List<StateRef> {
6486
return with(serviceHub.jdbcSession()) {
65-
val nativeQuery = nativeSQL(query)
66-
prepareStatement(nativeQuery).use {
87+
prepareStatement(nativeSQL(buildQuery())).use {
6788
it.executeQuery().use(::getStateRefsFromResults)
6889
}
6990
}
7091
}
7192

93+
/**
94+
* Gets a [List] of [StateRef] representing the recorded accounts.
95+
*
96+
* @param results The [ResultSet] from the executed SQL query containing the table query data.
97+
* @return Returns a [List] of [StateRef] representing the recorded accounts.
98+
*/
7299
@Suspendable
73100
private fun getStateRefsFromResults(results: ResultSet): List<StateRef> {
74-
val stateRefs = mutableListOf<StateRef>()
75-
76-
while (results.next()) {
77-
val txHash = SecureHash.parse(results.getString(TRANSACTION_ID))
78-
val index = results.getInt(OUTPUT_INDEX)
79-
stateRefs.add(StateRef(txHash, index))
101+
return mutableListOf<StateRef>().apply {
102+
while (results.next()) {
103+
val txHash = SecureHash.parse(results.getString(TRANSACTION_ID))
104+
val index = results.getInt(OUTPUT_INDEX)
105+
add(StateRef(txHash, index))
106+
}
80107
}
81-
82-
return stateRefs
83108
}
84109
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/accounts/IssueAccountFlowHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class IssueAccountFlowHandler(
6464
private class Handler(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
6565

6666
private companion object {
67-
object HandleIssuedAccountStep : Step("Handling issued account.") {
67+
object HandleIssuedAccountStep : Step("Handling account issuance.") {
6868
override fun childProgressTracker(): ProgressTracker = tracker()
6969
}
7070
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/accounts/PublishAccountFlow.kt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
package io.onixlabs.corda.identityframework.workflow.accounts
1818

1919
import co.paralleluniverse.fibers.Suspendable
20-
import io.onixlabs.corda.core.workflow.InitializeFlowStep
21-
import io.onixlabs.corda.core.workflow.currentStep
22-
import io.onixlabs.corda.core.workflow.findTransaction
23-
import io.onixlabs.corda.core.workflow.initiateFlows
20+
import io.onixlabs.corda.core.workflow.*
2421
import io.onixlabs.corda.identityframework.contract.accounts.Account
2522
import io.onixlabs.corda.identityframework.workflow.SendAccountTransactionStep
2623
import net.corda.core.contracts.StateAndRef
@@ -45,7 +42,10 @@ class PublishAccountFlow(
4542

4643
companion object {
4744
@JvmStatic
48-
fun tracker() = ProgressTracker(InitializeFlowStep, SendAccountTransactionStep)
45+
fun tracker() = ProgressTracker(
46+
InitializeFlowStep,
47+
SendAccountTransactionStep
48+
)
4949

5050
private const val FLOW_VERSION_1 = 1
5151
}
@@ -54,11 +54,7 @@ class PublishAccountFlow(
5454
override fun call(): SignedTransaction {
5555
currentStep(InitializeFlowStep)
5656
val transaction = findTransaction(account)
57-
58-
currentStep(SendAccountTransactionStep)
59-
sessions.forEach { subFlow(SendTransactionFlow(it, transaction)) }
60-
61-
return transaction
57+
return publishTransaction(transaction, sessions, SendAccountTransactionStep)
6258
}
6359

6460
/**
@@ -76,21 +72,21 @@ class PublishAccountFlow(
7672
) : FlowLogic<SignedTransaction>() {
7773

7874
private companion object {
79-
object PublishAccountTransactionStep : Step("Publishing account transaction.") {
75+
object PublishAccountStep : Step("Publishing account.") {
8076
override fun childProgressTracker() = tracker()
8177
}
8278
}
8379

84-
override val progressTracker = ProgressTracker(PublishAccountTransactionStep)
80+
override val progressTracker = ProgressTracker(PublishAccountStep)
8581

8682
@Suspendable
8783
override fun call(): SignedTransaction {
88-
currentStep(PublishAccountTransactionStep)
84+
currentStep(PublishAccountStep)
8985
return subFlow(
9086
PublishAccountFlow(
9187
account,
9288
initiateFlows(observers),
93-
PublishAccountTransactionStep.childProgressTracker()
89+
PublishAccountStep.childProgressTracker()
9490
)
9591
)
9692
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/accounts/PublishAccountFlowHandler.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ package io.onixlabs.corda.identityframework.workflow.accounts
1818

1919
import co.paralleluniverse.fibers.Suspendable
2020
import io.onixlabs.corda.core.workflow.currentStep
21+
import io.onixlabs.corda.core.workflow.publishTransactionHandler
2122
import io.onixlabs.corda.identityframework.workflow.ReceiveAccountTransactionStep
2223
import net.corda.core.flows.FlowLogic
2324
import net.corda.core.flows.FlowSession
2425
import net.corda.core.flows.InitiatedBy
25-
import net.corda.core.flows.ReceiveTransactionFlow
26-
import net.corda.core.node.StatesToRecord
2726
import net.corda.core.transactions.SignedTransaction
2827
import net.corda.core.utilities.ProgressTracker
2928
import net.corda.core.utilities.ProgressTracker.Step
@@ -46,8 +45,7 @@ class PublishAccountFlowHandler(
4645

4746
@Suspendable
4847
override fun call(): SignedTransaction {
49-
currentStep(ReceiveAccountTransactionStep)
50-
return subFlow(ReceiveTransactionFlow(session, statesToRecord = StatesToRecord.ALL_VISIBLE))
48+
return publishTransactionHandler(session, progressTrackerStep = ReceiveAccountTransactionStep)
5149
}
5250

5351
/**
@@ -59,20 +57,20 @@ class PublishAccountFlowHandler(
5957
private class Handler(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
6058

6159
private companion object {
62-
object HandlePublishedAccountTransactionStep : Step("Receiving account transaction.") {
60+
object HandlePublishedAccountStep : Step("Handling account publication.") {
6361
override fun childProgressTracker() = tracker()
6462
}
6563
}
6664

67-
override val progressTracker = ProgressTracker(HandlePublishedAccountTransactionStep)
65+
override val progressTracker = ProgressTracker(HandlePublishedAccountStep)
6866

6967
@Suspendable
7068
override fun call(): SignedTransaction {
71-
currentStep(HandlePublishedAccountTransactionStep)
69+
currentStep(HandlePublishedAccountStep)
7270
return subFlow(
7371
PublishAccountFlowHandler(
7472
session,
75-
HandlePublishedAccountTransactionStep.childProgressTracker()
73+
HandlePublishedAccountStep.childProgressTracker()
7674
)
7775
)
7876
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/accounts/RevokeAccountFlowHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class RevokeAccountFlowHandler(
6464
private class Handler(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
6565

6666
private companion object {
67-
object HandleRevokedAccountStep : Step("Handling revoked account.") {
67+
object HandleRevokedAccountStep : Step("Handling account revocation.") {
6868
override fun childProgressTracker(): ProgressTracker = tracker()
6969
}
7070
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/attestations/AmendAttestationFlowHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class AmendAttestationFlowHandler(
6565
private class Handler(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
6666

6767
private companion object {
68-
object HandleAmendedAttestationStep : Step("Handling amended attestation.") {
68+
object HandleAmendedAttestationStep : Step("Handling attestation amendment.") {
6969
override fun childProgressTracker(): ProgressTracker = tracker()
7070
}
7171
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/attestations/IssueAttestationFlowHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class IssueAttestationFlowHandler(
6565
private class Handler(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
6666

6767
private companion object {
68-
object HandleIssuedAttestationStep : Step("Handling issued attestation.") {
68+
object HandleIssuedAttestationStep : Step("Handling attestation issuance.") {
6969
override fun childProgressTracker(): ProgressTracker = tracker()
7070
}
7171
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/attestations/PublishAttestationFlow.kt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
package io.onixlabs.corda.identityframework.workflow.attestations
1818

1919
import co.paralleluniverse.fibers.Suspendable
20-
import io.onixlabs.corda.core.workflow.InitializeFlowStep
21-
import io.onixlabs.corda.core.workflow.currentStep
22-
import io.onixlabs.corda.core.workflow.findTransaction
23-
import io.onixlabs.corda.core.workflow.initiateFlows
20+
import io.onixlabs.corda.core.workflow.*
2421
import io.onixlabs.corda.identityframework.contract.attestations.Attestation
2522
import io.onixlabs.corda.identityframework.workflow.SendAttestationTransactionStep
2623
import net.corda.core.contracts.StateAndRef
@@ -45,7 +42,10 @@ class PublishAttestationFlow(
4542

4643
companion object {
4744
@JvmStatic
48-
fun tracker() = ProgressTracker(InitializeFlowStep, SendAttestationTransactionStep)
45+
fun tracker() = ProgressTracker(
46+
InitializeFlowStep,
47+
SendAttestationTransactionStep
48+
)
4949

5050
private const val FLOW_VERSION_1 = 1
5151
}
@@ -54,11 +54,7 @@ class PublishAttestationFlow(
5454
override fun call(): SignedTransaction {
5555
currentStep(InitializeFlowStep)
5656
val transaction = findTransaction(attestation)
57-
58-
currentStep(SendAttestationTransactionStep)
59-
sessions.forEach { subFlow(SendTransactionFlow(it, transaction)) }
60-
61-
return transaction
57+
return publishTransaction(transaction, sessions, SendAttestationTransactionStep)
6258
}
6359

6460
/**
@@ -76,21 +72,21 @@ class PublishAttestationFlow(
7672
) : FlowLogic<SignedTransaction>() {
7773

7874
private companion object {
79-
object PublishAttestationTransactionStep : Step("Publishing attestation transaction.") {
75+
object PublishAttestationStep : Step("Publishing attestation.") {
8076
override fun childProgressTracker() = tracker()
8177
}
8278
}
8379

84-
override val progressTracker = ProgressTracker(PublishAttestationTransactionStep)
80+
override val progressTracker = ProgressTracker(PublishAttestationStep)
8581

8682
@Suspendable
8783
override fun call(): SignedTransaction {
88-
currentStep(PublishAttestationTransactionStep)
84+
currentStep(PublishAttestationStep)
8985
return subFlow(
9086
PublishAttestationFlow(
9187
attestation,
9288
initiateFlows(observers),
93-
PublishAttestationTransactionStep.childProgressTracker()
89+
PublishAttestationStep.childProgressTracker()
9490
)
9591
)
9692
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/attestations/PublishAttestationFlowHandler.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ package io.onixlabs.corda.identityframework.workflow.attestations
1818

1919
import co.paralleluniverse.fibers.Suspendable
2020
import io.onixlabs.corda.core.workflow.currentStep
21+
import io.onixlabs.corda.core.workflow.publishTransactionHandler
2122
import io.onixlabs.corda.identityframework.workflow.ReceiveAttestationTransactionStep
2223
import net.corda.core.flows.FlowLogic
2324
import net.corda.core.flows.FlowSession
2425
import net.corda.core.flows.InitiatedBy
25-
import net.corda.core.flows.ReceiveTransactionFlow
26-
import net.corda.core.node.StatesToRecord
2726
import net.corda.core.transactions.SignedTransaction
2827
import net.corda.core.utilities.ProgressTracker
2928
import net.corda.core.utilities.ProgressTracker.Step
@@ -46,8 +45,7 @@ class PublishAttestationFlowHandler(
4645

4746
@Suspendable
4847
override fun call(): SignedTransaction {
49-
currentStep(ReceiveAttestationTransactionStep)
50-
return subFlow(ReceiveTransactionFlow(session, statesToRecord = StatesToRecord.ALL_VISIBLE))
48+
return publishTransactionHandler(session, progressTrackerStep = ReceiveAttestationTransactionStep)
5149
}
5250

5351
/**
@@ -59,7 +57,7 @@ class PublishAttestationFlowHandler(
5957
private class Handler(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
6058

6159
private companion object {
62-
object HandlePublishedAttestationStep : Step("Handling published attestation.") {
60+
object HandlePublishedAttestationStep : Step("Handling attestation publication.") {
6361
override fun childProgressTracker() = tracker()
6462
}
6563
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/attestations/RevokeAttestationFlowHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class RevokeAttestationFlowHandler(
6565
private class Handler(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
6666

6767
private companion object {
68-
object HandleRevokedAttestationStep : Step("Handling revoked attestation.") {
68+
object HandleRevokedAttestationStep : Step("Handling attestation revocation.") {
6969
override fun childProgressTracker(): ProgressTracker = tracker()
7070
}
7171
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/claims/AmendClaimFlowHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class AmendClaimFlowHandler(
6565
private class Handler(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
6666

6767
private companion object {
68-
object HandleAmendedClaimStep : Step("Handling amended claim.") {
68+
object HandleAmendedClaimStep : Step("Handling claim amendment.") {
6969
override fun childProgressTracker(): ProgressTracker = tracker()
7070
}
7171
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/claims/IssueClaimFlowHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class IssueClaimFlowHandler(
6565
private class Handler(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
6666

6767
private companion object {
68-
object HandleIssuedClaimStep : Step("Handling issued claim.") {
68+
object HandleIssuedClaimStep : Step("Handling claim issuance.") {
6969
override fun childProgressTracker(): ProgressTracker = tracker()
7070
}
7171
}

0 commit comments

Comments
 (0)