Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

The persister configuration is written in a YAML format. The INSERT and UPDATE queries for each table is added in prepared Statement format, followed by the jsonPaths of values which has to be inserted/updated.

For example, for a table named studentinfo with id, name, age, marks fields, the following configuration will get the persister ready to insert data into studentinfo table -

serviceMaps:
 serviceName: student-management-service
 mappings:
 - version: 1.0
   description: Persists student details in studentinfo table
   fromTopic: save-student-info
   isTransaction: true
   queryMaps:
       - query: INSERT INTO studentinfo( id, name, age, marks) VALUES (?, ?, ?, ?);
         basePath: Students.*
         jsonMaps:
          - jsonPath: $.Students.*.id

          - jsonPath: $.Students.*.name

          - jsonPath: $.Students.*.age

          - jsonPath: $.Students.*.marks


For our guide, for adding persister config, the following steps need to be followed -

i) Clone configs repo locally.

git clone -o upstream https://github.com/egovernments/configs

ii) Create a file by the name of digit-developer-guide.yml under persister configs folder.

iii) Add the following content into it -

serviceMaps:
  serviceName: vtr-services
  mappings:
    - version: 1.0
      description: Persists voter details in tables
      fromTopic: save-vt-application
      isTransaction: true
      queryMaps:

        - query: INSERT INTO eg_vt_registration(id,tenantid,assemblyconstituency,applicationnumber,applicantid,datesinceresidence,createdby, lastmodifiedby, createdtime, lastmodifiedtime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
          basePath: VoterRegistrationApplications.*
          jsonMaps:
            - jsonPath: $.VoterRegistrationApplications.*.id

            - jsonPath: $.VoterRegistrationApplications.*.tenantId

            - jsonPath: $.VoterRegistrationApplications.*.assemblyConstituency

            - jsonPath: $.VoterRegistrationApplications.*.applicationNumber

            - jsonPath: $.VoterRegistrationApplications.*.applicantId

            - jsonPath: $.VoterRegistrationApplications.*.dateSinceResidence

            - jsonPath: $.VoterRegistrationApplications.*.auditDetails.createdBy

            - jsonPath: $.VoterRegistrationApplications.*.auditDetails.lastModifiedBy

            - jsonPath: $.VoterRegistrationApplications.*.auditDetails.createdTime

            - jsonPath: $.VoterRegistrationApplications.*.auditDetails.lastModifiedTime

        - query: INSERT INTO eg_vt_address(id, tenantid, doorno, latitude, longitude, buildingname, addressid, addressnumber, type, addressline1, addressline2, landmark, street, city, locality, pincode, detail, registrationid, createdby, lastmodifiedby, createdtime, lastmodifiedtime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
          basePath: VoterRegistrationApplications.*
          jsonMaps:
            - jsonPath: $.VoterRegistrationApplications.*.address.id

            - jsonPath: $.VoterRegistrationApplications.*.address.tenantId

            - jsonPath: $.VoterRegistrationApplications.*.address.doorNo

            - jsonPath: $.VoterRegistrationApplications.*.address.latitude

            - jsonPath: $.VoterRegistrationApplications.*.address.longitude

            - jsonPath: $.VoterRegistrationApplications.*.address.buildingName

            - jsonPath: $.VoterRegistrationApplications.*.address.addressId

            - jsonPath: $.VoterRegistrationApplications.*.address.addressNumber

            - jsonPath: $.VoterRegistrationApplications.*.address.type

            - jsonPath: $.VoterRegistrationApplications.*.address.addressLine1

            - jsonPath: $.VoterRegistrationApplications.*.address.addressLine2

            - jsonPath: $.VoterRegistrationApplications.*.address.landmark

            - jsonPath: $.VoterRegistrationApplications.*.address.street

            - jsonPath: $.VoterRegistrationApplications.*.address.city

            - jsonPath: $.VoterRegistrationApplications.*.address.locality.name

            - jsonPath: $.VoterRegistrationApplications.*.address.pincode

            - jsonPath: $.VoterRegistrationApplications.*.address.detail

            - jsonPath: $.VoterRegistrationApplications.*.address.registrationId

            - jsonPath: $.VoterRegistrationApplications.*.address.createdBy

            - jsonPath: $.VoterRegistrationApplications.*.address.lastModifiedBy

            - jsonPath: $.VoterRegistrationApplications.*.address.createdTime

            - jsonPath: $.VoterRegistrationApplications.*.address.lastModifiedTime

    - version: 1.0
      description: Update voter registration applications in table
      fromTopic: update-vt-application
      isTransaction: true
      queryMaps:
        - query: UPDATE eg_vt_registration SET tenantid = ?,assemblyconstituency = ?, datesinceresidence = ? WHERE id=?;
          basePath: VoterRegistrationApplications.*
          jsonMaps:
            - jsonPath: $.VoterRegistrationApplications.*.tenantId

            - jsonPath: $.VoterRegistrationApplications.*.assemblyConstituency

            - jsonPath: $.VoterRegistrationApplications.*.dateSinceResidence

            - jsonPath: $.VoterRegistrationApplications.*.id
  • No labels