Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete PersistentMembershipState mappings #33

Open
wants to merge 4 commits into
base: release/1.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ only know about those in their group).

In a business network, there is at least one *authorised member*. This member has sufficient permissions to execute management operations over the network and its members.

## Installation

Add the `business-networks-contracts` dependency in your "contracts" (and states) cordapp module:

```groovy
dependencies {
//...
cordapp("net.corda.bn:business-networks-contracts:$corda_bn_extension_version")
//...
}
```

... and the `business-networks-workflows` dependency in your "workflows" cordapp module:

```groovy
dependencies {
//...
cordapp("net.corda.bn:business-networks-workflows:$corda_bn_extension_version")
//...
}
```

Remember to add both dependencies in your Cordform (i.e. `deployNodes`) task.

## Creating and managing a business network

BNE provides a set of workflows that allows a user to start a business network, on-board members and assign them to membership lists or groups. The flows can also be used to update the information
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package net.corda.bn.schemas

import net.corda.bn.states.BNIdentity
import net.corda.bn.states.MembershipState
import net.corda.bn.states.MembershipStatus
import net.corda.core.identity.Party
import net.corda.core.schemas.MappedSchema
import net.corda.core.schemas.PersistentState
import net.corda.core.serialization.CordaSerializable
import java.time.Instant
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.Table
Expand All @@ -26,11 +28,20 @@ object MembershipStateSchemaV1 : MappedSchema(schemaFamily = MembershipState::cl
@Entity
@Table(name = "membership_state")
class PersistentMembershipState(
@Column(name = "corda_identity")
@Column(name = "corda_identity", nullable = false)
val cordaIdentity: Party,
@Column(name = "network_id")
/** String representation of custom [BNIdentity] */
@Column(name = "business_identity")
val businessIdentity: String?,
@Column(name = "network_id", nullable = false)
val networkId: String,
@Column(name = "status")
val status: MembershipStatus
@Column(name = "status", nullable = false)
val status: MembershipStatus,
@Column(name = "issuer_identity", nullable = false)
val issuer: Party,
@Column(name = "issued", nullable = false)
val issued: Instant,
@Column(name = "modified", nullable = false)
val modified: Instant
) : PersistentState()
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ data class MembershipState(
override fun generateMappedObject(schema: MappedSchema) = when (schema) {
is MembershipStateSchemaV1 -> MembershipStateSchemaV1.PersistentMembershipState(
cordaIdentity = identity.cordaIdentity,
businessIdentity = identity.businessIdentity?.toString(),
networkId = networkId,
status = status
status = status,
issuer = issuer,
issued = issued,
modified = modified

)
else -> throw IllegalArgumentException("Unrecognised schema $schema")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<changeSet author="R3 Corda" id="complete_initial_membership_state_columns_and_constraints">
<addNotNullConstraint tableName="membership_state" columnName="corda_identity" columnDataType="varchar(255)"/>
<addNotNullConstraint tableName="membership_state" columnName="network_id" columnDataType="varchar(255)"/>
<addNotNullConstraint tableName="membership_state" columnName="status" columnDataType="integer"/>
<addColumn tableName="membership_state">
<column name="business_identity" type="varchar(64)" />
<column name="issuer_identity" type="varchar(255)">
<constraints nullable="false"/>
</column>
<column name="issued" type="TIMESTAMP">
<constraints nullable="false"/>
</column>
<column name="modified" type="TIMESTAMP">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<include relativeToChangelogFile="true" file="membership-state-schema-v1.changelog-init.xml"/>
<include relativeToChangelogFile="true" file="membership-state-schema-v1.changelog-additional-fields.xml"/>
</databaseChangeLog>