Pulling Master Data Directly

To allow for external systems to be able to access the master data in the Custodian database so they can synchronize their data stores with the data stored in the master data environment, there is an API and Command Line Interface which allows bulk reading of the data structures.

Command Line Scripting to Query Master Data

The CLI allows you to run a scripted query against the monsterDB database directly to pull information from the Custodian database and store it in a file.

java -jar monsterDB.jar --script script.grr --db custodia-demo --collection NODES -host localhost --port 27018 --quiet

XML

script.grr will contain valid monsterDB commands to produce output:

set output XML
db.NODES.find({'Table': 'LEI'})

Produces the following output:

<NODESs>
<NODES>
<Entity><RegistrationAuthority><RegistrationAuthorityID>RA000526</RegistrationAuthorityID><RegistrationAuthorityEntityID>36768171</RegistrationAuthorityEntityID><OtherRegistrationAuthorityID>Okresn sd Bansk Bystrica - 12967/S</OtherRegistrationAuthorityID></RegistrationAuthority><LegalName>HTS BB s.r.o.</LegalName><HeadquartersAddress><FirstAddressLine>Matu?kova 48</FirstAddressLine><PostalCode>97631</PostalCode><Country>SK</Country><City>Vlkanov</City></HeadquartersAddress><EntityStatus>ACTIVE</EntityStatus><LegalAddress><FirstAddressLine>Matu?kova 48</FirstAddressLine><PostalCode>97631</PostalCode><Country>SK</Country><City>Vlkanov</City></LegalAddress><LegalJurisdiction>SK</LegalJurisdiction><LegalForm><OtherLegalForm>Spolocnost s rucenim obmedzenym</OtherLegalForm><EntityLegalFormCode>8888</EntityLegalFormCode></LegalForm></Entity><LEI>097900BFGQ0000028579</LEI><EID>393</EID><lastUpdated>Dec 9, 2019 2:01:58 PM</lastUpdated><Table>lei</Table><systemName>lei</systemName><Registration><ValidationAuthority><ValidationAuthorityEntityID>36768171</ValidationAuthorityEntityID><OtherValidationAuthorityID>Okresn sd Bansk Bystrica - 12967/S</OtherValidationAuthorityID><ValidationAuthorityID>RA000526</ValidationAuthorityID></ValidationAuthority><ValidationSources>FULLY_CORROBORATED</ValidationSources><ManagingLOU>097900BEFH0000000217</ManagingLOU><RegistrationStatus>ISSUED</RegistrationStatus><InitialRegistrationDate>Jun 16, 2015 12:00:00 AM</InitialRegistrationDate><LastUpdateDate>Jul 11, 2017 12:00:00 AM</LastUpdateDate><NextRenewalDate>Jun 16, 2018 12:00:00 AM</NextRenewalDate></Registration><action>LOADED</action><_id>99ab284d-f177-43de-948a-9d839a0ca2bd</_id> </NODES>
......
</NODESs> 

JSON

Similarly:

set output pretty
db.NODES.find({'Table': 'LEI', LEI: {pattern: "097900.*"})  

Would produce:

{
  "systemName": "lei",
  "Table": "lei",
  "Entity": {
    "LegalForm": {
      "OtherLegalForm": "Spolocnost s rucenim obmedzenym",
      "EntityLegalFormCode": "8888"
    },
    "RegistrationAuthority": {
      "RegistrationAuthorityEntityID": "36768171",
      "RegistrationAuthorityID": "RA000526",
      "OtherRegistrationAuthorityID": "Okresn sd Bansk Bystrica - 12967/S"
    },
    "LegalAddress": {
      "PostalCode": "97631",
      "FirstAddressLine": "Matu?kova 48",
      "City": "Vlkanov",
      "Country": "SK"
    },
    "TransliteratedOtherEntityNames": [],
    "HeadquartersAddress": {
      "City": "Vlkanov",
      "PostalCode": "97631",
      "FirstAddressLine": "Matu?kova 48",
      "Country": "SK"
    },
    "LegalName": "HTS BB s.r.o.",
    "EntityStatus": "ACTIVE",
    "LegalJurisdiction": "SK"
  },
  "Registration": {
    "ValidationAuthority": {
      "ValidationAuthorityEntityID": "36768171",
      "ValidationAuthorityID": "RA000526",
      "OtherValidationAuthorityID": "Okresn sd Bansk Bystrica - 12967/S"
    },
    "InitialRegistrationDate": "Jun 16, 2015 12:00:00 AM",
    "ManagingLOU": "097900BEFH0000000217",
    "LastUpdateDate": "Jul 11, 2017 12:00:00 AM",
    "ValidationSources": "FULLY_CORROBORATED",
    "NextRenewalDate": "Jun 16, 2018 12:00:00 AM",
    "RegistrationStatus": "ISSUED"
  },
  "LEI": "097900BFGQ0000028579",
  "action": "LOADED",
  "EID": 393,
  "lastUpdated": "Dec 9, 2019 2:01:58 PM",
  "_id": "99ab284d-f177-43de-948a-9d839a0ca2bd"
},
.....

Above example includes a regular expression which is denoted by a simple object containing a property “pattern” and optional “flags” which is used to indicate case sensitivity (0 or 1). The example looks for LEI’s with and LEI ID starting with 097900.

CSV

Also the output type can be CSV – which will attempt to flatten the output to a 2 dimensional form, but this will only be useful if the document in the database only has lower level attributes.

Output to a file

The following example demonstrates exporting the results to a local file:

java -jar monsterDB.jar --script script.grr --db custodia-demo --collection NODES -host localhost --port 27018 --quiet > myfile.json

API to query master data:

The API can be used to extract master data from Custodian, the following is an example that queries the database and outputs to a file.

private String databaseName="custodia-demo";
private String collectionName="NODES";
private String tableName="Company"; 

public void run() {
      PrintWriter out = null;
      MonsterClient client = null;
      try {
              out =  new PrintWriter(new File("output.json"));  
              client = new MonsterClient("localhost:27018");
              client.useDatabase(databaseName);
              client.useCollection(collectionName);
              Document filter =  new Document("Table": tableName)
                                 .append("LegalName", "Entitystream");
              for (Document i : client.find(filter)) 
                  out.println(i.toJson());
         } catch (Exception e){
              e.printStackTrace();
         }
         if (client!=null)
             client.disconnect();
         if (out!=null)
             out.close();
}
...