contractpendev / contractpen-work-client

NodeJS Client for ContractPen
https://contractpen.com/
Apache License 2.0
2 stars 1 forks source link

Extracting json data from the existing Cicero projects #4

Open contractpendev opened 6 years ago

contractpendev commented 6 years ago

Hi ! Please read and understand what this file does before starting any task https://github.com/contractpendev/contractpen_node_client/blob/master/src/services/SetupClient.coffee and also better to read and understand the existing code base. Refer to Accord Project https://www.accordproject.org/ Ergo API https://docs.accordproject.org/docs/ergo-api.html Cicero API https://docs.accordproject.org/docs/cicero-api.html


At https://github.com/accordproject/cicero-template-library/tree/master/src there are many projects which also contain CTO models.

For example here is a CTO model https://github.com/accordproject/cicero-template-library/blob/master/src/payment-upon-delivery/models/model.cto

Assume that all the files have been git cloned to a directory, we want to extract data from these projects by using the Javascript API provided by Accord Project, firstly we want to convert the CTO model files to JSON.

Here is the Javascript API for Accord Cicero https://docs.accordproject.org/docs/cicero-api.html and here is the API for Accord Ergo https://docs.accordproject.org/docs/ergo-api.html

In the Ergo API we can see there is Commands.parseCTOtoFile(ctoPath) which can parse a CTO file and output JSON data, a CTO file is a model definition file for data models. There are many CTO files such as https://github.com/accordproject/cicero-template-library/blob/master/src/payment-upon-delivery/models/model.cto

Template can be loaded from directory https://docs.accordproject.org/docs/cicero-api.html#templatefromdirectorypath-options-code-promise-code


The task here is to write code to iterate over all the projects and extract data from each folder in the form of JSON data.

Assume that https://github.com/accordproject/cicero-template-library has been downloaded and extracted to a directory.

[ 
  { 
    "project_path": "./src/helloworld", 
    "ctopaths": ["./src/helloworld/models/model.cto"] 
  },
  {
    "project_path": "./src/online-payment-contract-tr",
    "cto_paths": ["./src/online-payment-contract-tr/models/model.cto"]
  }
]
contractpendev commented 6 years ago

Good enough but last task not done