Skip to content

Commit 10c3f60

Browse files
committed
Kotlin fix on insurance app
1 parent c07bf1c commit 10c3f60

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/schema/InsuranceSchemaV1.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.corda.samples.carinsurance.schema
22

33
//4.6 changes
4+
import jdk.nashorn.internal.objects.annotations.Constructor
45
import net.corda.core.schemas.MappedSchema
56
import net.corda.core.schemas.PersistentState
67
import org.hibernate.annotations.Type
@@ -41,6 +42,9 @@ object InsuranceSchemaV1 : MappedSchema(
4142
var claimAmount: Int
4243
) {
4344
// Default constructor required by hibernate.
45+
constructor(claimNumber: String,claimDescription: String,claimAmount: Int) : this(
46+
UUID.randomUUID(), claimNumber,claimDescription,claimAmount)
47+
4448
constructor() : this(UUID.randomUUID(), "", "", 0)
4549
}
4650

@@ -98,6 +102,6 @@ object InsuranceSchemaV1 : MappedSchema(
98102
@JoinColumns(JoinColumn(name = "output_index", referencedColumnName = "output_index"), JoinColumn(name = "transaction_id", referencedColumnName = "transaction_id"))
99103
val claims: List<PersistentClaim>
100104
) : PersistentState(), Serializable {
101-
constructor() : this("", 0, 0, 0, PersistentVehicle(), listOf())
105+
constructor() : this("", 0, 0, 0, PersistentVehicle(), listOf(PersistentClaim()))
102106
}
103107
}

Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/states/Claim.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ package net.corda.samples.carinsurance.states
33
import net.corda.core.serialization.CordaSerializable
44

55
@CordaSerializable
6-
data class Claim(val claimNumber: String, val claimDescription: String, val claimAmount: Int)
6+
data class Claim(val claimNumber: String,
7+
val claimDescription: String,
8+
val claimAmount: Int)

Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/states/InsuranceState.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ data class InsuranceState(val policyNumber: String,
2727
override val participants: List<AbstractParty> = listOf(insuree, insurer)) : QueryableState {
2828
override fun generateMappedObject(schema: MappedSchema): PersistentState {
2929
if (schema is InsuranceSchemaV1) {
30-
var persistentClaims = ArrayList<InsuranceSchemaV1.PersistentClaim>()
30+
// var persistentClaims = listOf<InsuranceSchemaV1.PersistentClaim>()
31+
val persistentClaims : MutableList<InsuranceSchemaV1.PersistentClaim> = mutableListOf()
3132
if (claims.isNotEmpty()) {
3233
for (item in claims) {
33-
persistentClaims.add(InsuranceSchemaV1.PersistentClaim(
34-
UUID.randomUUID(),
34+
persistentClaims += (InsuranceSchemaV1.PersistentClaim(
3535
item.claimNumber,
3636
item.claimDescription,
3737
item.claimAmount))
3838
}
3939
}
40+
4041
var vDetail = InsuranceSchemaV1.PersistentVehicle(vehicleDetail.registrationNumber,
4142
vehicleDetail.chasisNumber,
4243
vehicleDetail.make,

Features/queryableState-carinsurance/workflows/src/main/resources/migration/claim-detail.changelog-v1.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@
55
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
66
<changeSet author="R3.Corda" id="create_claim_detail_state">
77
<createTable tableName="claim_detail">
8-
<column name="output_index" type="INT">
9-
<constraints nullable="false"/>
10-
</column>
11-
<column name="transaction_id" type="NVARCHAR(64)">
12-
<constraints nullable="false"/>
13-
</column>
8+
<column name="output_index" type="INT"/>
9+
<column name="transaction_id" type="NVARCHAR(64)"/>
1410
<column name="claimAmount" type="int"/>
1511
<column name="claimNumber" type="NVARCHAR(64)"/>
1612
<column name="claimDescription" type="NVARCHAR(64)"/>
1713
<column name="id" type="NVARCHAR(64)"/>
18-
1914
</createTable>
2015
</changeSet>
2116
</databaseChangeLog>

Features/queryableState-carinsurance/workflows/src/main/resources/migration/insurance-detail.changelog-v1.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<column name="insuredvalue" type="BIGINT"/>
1818
<column name="id" type="NVARCHAR(64)"/>
1919
<column name="registrationnumber" type="NVARCHAR(64)"/>
20-
2120
</createTable>
2221
</changeSet>
2322
</databaseChangeLog>

Features/queryableState-carinsurance/workflows/src/main/resources/migration/vehicle-detail.changelog-v1.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
66
<changeSet author="R3.Corda" id="create_vehicle_detail_state">
77
<createTable tableName="vehicle_detail">
8-
98
<column name="id" type="NVARCHAR(64)"/>
109
<column name="registrationNumber" type="NVARCHAR(64)"/>
1110
<column name="chasisNumber" type="NVARCHAR(64)"/>
@@ -14,7 +13,6 @@
1413
<column name="variant" type="NVARCHAR(64)"/>
1514
<column name="color" type="NVARCHAR(64)"/>
1615
<column name="fuelType" type="NVARCHAR(64)"/>
17-
1816
</createTable>
1917
</changeSet>
2018
</databaseChangeLog>

0 commit comments

Comments
 (0)