Как передать объект в CLI в проектах Corda - PullRequest
0 голосов
/ 19 февраля 2020

Я пытался запустить проект автострахования в Корда, но я не могу знать, как передать данные ClaimInfo в типе объекта, может ли кто-нибудь мне помочь

https://github.com/corda/samples/tree/release-V4/carinsurance-QueryableState

я пытаюсь передать данные, подобные этим

start InsuranceClaimInitiator claimInfo: {claimNumber: "aa",claimDescription: "rrrr", claimAmount: 9}, policyNumber: "aaa" 

это право или нам нужно передать по-другому ????

это показывает мне эту ошибку

Wed Feb 19 16:34:55 IST 2020>>> flow start InsuranceClaimFlow$InsuranceClaimInitiator claimInfo: {claimNmuber: "c001",claimDescription: "hello",claimAmount: 123}, policyNumber: "hello"
No matching constructor found:
- [class net.corda.examples.carinsurance.flows.ClaimInfo, class java.lang.String]: Could not parse as a command: Cannot construct instance of `net.corda.examples.carinsurance.flows.ClaimInfo` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: UNKNOWN; line: -1, column: -1]





Wed Feb 19 16:35:16 IST 2020>>> flow start InsuranceClaimFlow$InsuranceClaimInitiator {claimInfo: {claimNmuber: "c001",claimDescription: "hello",claimAmount: 123}}, policyNumber: "hello"
flow start InsuranceClaimFlow$InsuranceClaimInitiator {claimInfo: {claimNmuber: "c001",claimDescription: "hello",claimAmount: 123}}, policyNumber: "hello": exception: Expected a field name (Scalar value in YAML), got this instead: <org.yaml.snakeyaml.events.MappingStartEvent(anchor=null, tag=null, implicit=true)>
 at [Source: (StringReader); line: 1, column: 4]
Wed Feb 19 16:36:00 IST 2020>>> [ERROR] 16:36:00+0530 [pool-8-thread-5] command.CRaSHSession. - Error while evaluating request 'flow start InsuranceClaimFlow$InsuranceClaimInitiator {claimInfo: {claimNmuber: "c001",claimDescription: "hello",claimAmount: 123}}, policyNumber: "hello"' flow start InsuranceClaimFlow$InsuranceClaimInitiator {claimInfo: {claimNmuber: "c001",claimDescription: "hello",claimAmount: 123}}, policyNumber: "hello": exception: Expected a field name (Scalar value in YAML), got this instead: <org.yaml.snakeyaml.events.MappingStartEvent(anchor=null, tag=null, implicit=true)>
 at [Source: (StringReader); line: 1, column: 4] [errorCode=rc1dem, moreInformationAt=https://errors.corda.net/OS/4.3/rc1dem]

1 Ответ

0 голосов
/ 19 февраля 2020

Добавьте конструктор по умолчанию в ClaimInfo, и он должен работать нормально. Также пометьте параметризованный конструктор с помощью @ConstructorForDeserialization. Для десериализации требуется конструктор по умолчанию.

public ClaimInfo(){
    this.claimNumber = null;
    this.claimDescription = null;
    this.claimAmount = 0;
}

@ConstructorForDeserialization
public ClaimInfo(String claimNumber, String claimDescription, int claimAmount) {
    this.claimNumber = claimNumber;
    this.claimDescription = claimDescription;
    this.claimAmount = claimAmount;
}

Я думаю, что мы должны обновить это в образце, или лучше сделать PR, если вы будете sh.

...