Skip to content

Commit 966f3d1

Browse files
committed
revamp working queryablestate
1 parent efac05c commit 966f3d1

File tree

32 files changed

+339
-83
lines changed

32 files changed

+339
-83
lines changed

Features/attachment-sendfile/contracts/src/test/java/net.corda.samples.sendfile/contracts/InvoiceContractTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class DummyCommand extends TypeOnlyCommandData implements Commands {
2727
Arrays.asList("net.corda.samples.sendfile.contracts")
2828
);
2929

30-
3130
private TestIdentity a = new TestIdentity(new CordaX500Name("Alice", "", "GB"));
3231
private TestIdentity b = new TestIdentity(new CordaX500Name("Bob", "", "GB"));
3332

@@ -45,7 +44,6 @@ public void InvoiceContractImplementsContract() {
4544
assert (new InvoiceContract() instanceof Contract);
4645
}
4746

48-
4947
@Test
5048
public void contractRequiresOneCommandInTheTransaction() {
5149
transaction(ledgerServices, tx -> {

Features/queryablestate-carinsurance/build.gradle

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ buildscript {
33
file("$projectDir/../constants.properties").withInputStream { constants.load(it) }
44

55
ext {
6-
76
corda_release_group = constants.getProperty("cordaReleaseGroup")
8-
corda_release_version = constants.getProperty("cordaVersion")
97
corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup")
8+
corda_release_version = constants.getProperty("cordaVersion")
109
corda_core_release_version = constants.getProperty("cordaCoreVersion")
1110
corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
11+
kotlin_version = constants.getProperty("kotlinVersion")
1212
junit_version = constants.getProperty("junitVersion")
1313
quasar_version = constants.getProperty("quasarVersion")
1414
log4j_version = constants.getProperty("log4jVersion")
1515
slf4j_version = constants.getProperty("slf4jVersion")
1616
corda_platform_version = constants.getProperty("platformVersion").toInteger()
17+
1718
//springboot
1819
spring_boot_version = '2.0.2.RELEASE'
1920
spring_boot_gradle_plugin_version = '2.0.2.RELEASE'
@@ -58,9 +59,6 @@ allprojects {
5859
}
5960
}
6061

61-
62-
63-
6462
apply plugin: 'net.corda.plugins.cordapp'
6563
apply plugin: 'net.corda.plugins.cordformation'
6664
apply plugin: 'net.corda.plugins.quasar-utils'
@@ -87,25 +85,28 @@ dependencies {
8785
cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}"
8886
cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version"
8987
}
88+
9089
cordapp {
9190
info {
92-
name "CorDapp carinsurance"
91+
name "Queryablestate Car Insurance"
9392
vendor "Corda Open Source"
9493
targetPlatformVersion corda_platform_version
9594
minimumPlatformVersion corda_platform_version
9695
}
9796
}
97+
9898
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
9999
nodeDefaults {
100100
projectCordapp {
101101
deploy = false
102102
}
103-
cordapp project(':contracts')
104-
cordapp project(':workflows')
103+
cordapp project(":workflows")
104+
cordapp project(":contracts")
105105
runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid
106106
//problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change
107107
//it to false for quicker project compiling time.
108108
}
109+
109110
node {
110111
name "O=Notary,L=London,C=GB"
111112
notary = [validating : false]
@@ -116,6 +117,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
116117
}
117118
cordapps.clear()
118119
}
120+
119121
node {
120122
name "O=Insurer,L=London,C=GB"
121123
p2pPort 10005
@@ -126,6 +128,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
126128
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
127129
extraConfig = ['h2Settings.address' : 'localhost:20041']
128130
}
131+
129132
node {
130133
name "O=Insuree,L=New York,C=US"
131134
p2pPort 10008
@@ -137,10 +140,3 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
137140
extraConfig = ['h2Settings.address' : 'localhost:20042']
138141
}
139142
}
140-
141-
task installQuasar(type: Copy) {
142-
destinationDir rootProject.file("lib")
143-
from(configurations.quasar) {
144-
rename 'quasar-core(.*).jar', 'quasar.jar'
145-
}
146-
}

Features/queryablestate-carinsurance/clients/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ dependencies {
2525
}
2626

2727
springBoot {
28-
mainClassName = "net.corda.examples.carinsurance.webserver.Starter"
28+
mainClassName = "net.corda.samples.carinsurance.webserver.Starter"
2929
}
30+
31+
// Note that the bootRun task is built into gradle so there is no webserver task defined here.

Features/queryablestate-carinsurance/clients/src/main/java/net/corda/examples/carinsurance/Client.java renamed to Features/queryablestate-carinsurance/clients/src/main/java/net/corda/samples/carinsurance/Client.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.corda.examples.carinsurance;
1+
package net.corda.samples.carinsurance;
22

33
import net.corda.client.rpc.CordaRPCClient;
44
import net.corda.core.messaging.CordaRPCOps;
@@ -33,4 +33,4 @@ public static void main(String[] args) {
3333
final List<NodeInfo> nodes = proxy.networkMapSnapshot();
3434
logger.info("{}", nodes);
3535
}
36-
}
36+
}

Features/queryablestate-carinsurance/clients/src/main/java/net/corda/examples/carinsurance/webserver/Controller.java renamed to Features/queryablestate-carinsurance/clients/src/main/java/net/corda/samples/carinsurance/webserver/Controller.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package net.corda.examples.carinsurance.webserver;
1+
package net.corda.samples.carinsurance.webserver;
22

33
import net.corda.core.identity.Party;
44
import net.corda.core.messaging.CordaRPCOps;
5-
import net.corda.examples.carinsurance.flows.ClaimInfo;
6-
import net.corda.examples.carinsurance.flows.InsuranceClaimFlow;
7-
import net.corda.examples.carinsurance.flows.InsuranceInfo;
8-
import net.corda.examples.carinsurance.flows.IssueInsuranceFlow;
5+
import net.corda.samples.carinsurance.flows.ClaimInfo;
6+
import net.corda.samples.carinsurance.flows.InsuranceClaimFlow;
7+
import net.corda.samples.carinsurance.flows.InsuranceInfo;
8+
import net.corda.samples.carinsurance.flows.IssueInsuranceFlow;
99
import org.slf4j.Logger;
1010
import org.slf4j.LoggerFactory;
1111
import org.springframework.web.bind.annotation.*;
@@ -51,4 +51,4 @@ private String claim(@RequestBody ClaimInfo claimInfo, @PathVariable String poli
5151
proxy.startFlowDynamic(InsuranceClaimFlow.InsuranceClaimInitiator.class, claimInfo, policyNumber);
5252
return "Insurance Claim Completed";
5353
}
54-
}
54+
}

Features/queryablestate-carinsurance/clients/src/main/java/net/corda/examples/carinsurance/webserver/NodeRPCConnection.java renamed to Features/queryablestate-carinsurance/clients/src/main/java/net/corda/samples/carinsurance/webserver/NodeRPCConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.corda.examples.carinsurance.webserver;
1+
package net.corda.samples.carinsurance.webserver;
22

33
import net.corda.client.rpc.CordaRPCClient;
44
import net.corda.client.rpc.CordaRPCConnection;
@@ -45,4 +45,4 @@ public void initialiseNodeRPCConnection() {
4545
public void close() {
4646
rpcConnection.notifyServerAndClose();
4747
}
48-
}
48+
}

Features/queryablestate-carinsurance/clients/src/main/java/net/corda/examples/carinsurance/webserver/Starter.java renamed to Features/queryablestate-carinsurance/clients/src/main/java/net/corda/samples/carinsurance/webserver/Starter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.corda.examples.carinsurance.webserver;
1+
package net.corda.samples.carinsurance.webserver;
22

33
import org.springframework.boot.Banner;
44
import org.springframework.boot.SpringApplication;
@@ -20,4 +20,4 @@ public static void main(String[] args) {
2020
app.setWebApplicationType(SERVLET);
2121
app.run(args);
2222
}
23-
}
23+
}

Features/queryablestate-carinsurance/contracts/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cordapp {
55
targetPlatformVersion corda_platform_version.toInteger()
66
minimumPlatformVersion corda_platform_version.toInteger()
77
contract {
8-
name "carinsurance Contract"
8+
name "Queryablestate Car Insurance"
99
vendor "Corda Open Source"
1010
licence "Apache License, Version 2.0"
1111
versionId 1
@@ -46,5 +46,4 @@ dependencies {
4646
cordaRuntime "$corda_release_group:corda:$corda_release_version"
4747
compileOnly "$corda_release_group:corda-testserver-impl:$corda_release_version"
4848
testCompile "$corda_release_group:corda-node-driver:$corda_release_version"
49-
50-
}
49+
}

Features/queryablestate-carinsurance/contracts/src/main/java/net/corda/examples/carinsurance/contracts/InsuranceContract.java renamed to Features/queryablestate-carinsurance/contracts/src/main/java/net/corda/samples/carinsurance/contracts/InsuranceContract.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.corda.examples.carinsurance.contracts;
1+
package net.corda.samples.carinsurance.contracts;
22

33
import net.corda.core.contracts.CommandData;
44
import net.corda.core.contracts.CommandWithParties;
@@ -16,20 +16,21 @@
1616
// ************
1717
public class InsuranceContract implements Contract {
1818
// This is used to identify our contract when building a transaction.
19-
public static final String ID = "net.corda.examples.carinsurance.contracts.InsuranceContract";
19+
public static final String ID = "net.corda.samples.carinsurance.contracts.InsuranceContract";
2020

2121
// A transaction is valid if the verify() function of the contract of all the transaction's input and output states
2222
// does not throw an exception.
2323
@Override
2424
public void verify(LedgerTransaction tx) {
2525
CommandWithParties<Commands> command = requireSingleCommand(tx.getCommands(), InsuranceContract.Commands.class);
2626
List<ContractState> inputs = tx.getInputStates();
27+
2728
if (command.getValue() instanceof InsuranceContract.Commands.IssueInsurance) {
2829
requireThat(req -> {
2930
req.using("Transaction must have no input states.", inputs.isEmpty());
3031
return null;
3132
});
32-
} else if(command.getValue() instanceof InsuranceContract.Commands.AddClaim){
33+
} else if (command.getValue() instanceof InsuranceContract.Commands.AddClaim) {
3334
requireThat(req -> {
3435
req.using("Insurance transaction must have input states, the insurance police", (!inputs.isEmpty()));
3536
return null;
@@ -41,7 +42,10 @@ public void verify(LedgerTransaction tx) {
4142

4243
// Used to indicate the transaction's intent.
4344
public interface Commands extends CommandData {
44-
class IssueInsurance implements Commands {}
45-
class AddClaim implements Commands {}
45+
class IssueInsurance implements Commands {
46+
}
47+
48+
class AddClaim implements Commands {
49+
}
4650
}
47-
}
51+
}

Features/queryablestate-carinsurance/contracts/src/main/java/net/corda/examples/carinsurance/schema/InsuranceSchemaFamily.java renamed to Features/queryablestate-carinsurance/contracts/src/main/java/net/corda/samples/carinsurance/schema/InsuranceSchemaFamily.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package net.corda.examples.carinsurance.schema;
1+
package net.corda.samples.carinsurance.schema;
22

33
/**
44
* Schema Family for Insurance Mapped Schema
55
*
66
* MappedSchema should be associated with a schema family which is consistent across versions of the schema.
77
* It allows the SchemaService to select the appropriate version of the schema if it has evolved over time.
88
*/
9-
public class InsuranceSchemaFamily { }
9+
public class InsuranceSchemaFamily { }

0 commit comments

Comments
 (0)