APIs & services / Common TLD (ctld)

Download farmer role maps for a chunk of farmers.

Endpointtoday's app
Call
GET /ctld/api/ierolemap/v1?criteria=isActive=true AND iE.id in (...)
Service
Common TLD (ctld)
Features
Data download (Cadre), Add/Edit farmer (IE profile)
When
Data download
Auth
X-SESSIONID header (AuthInterceptor adds it; re-auth on 401/400)
In the App Service

Use case

Online read during cadre data download (DataSetupViewModel.syncIERoleMap, and SetupForUser in the background user-data worker). Farmer IE ids from ie_flat_entity are sent in chunks of 30 inside a criteria string; returned role maps are saved to the ierolemap table so farmer roles show on the profile. Any chunk failure throws and marks the data-download step failed.

Headers

HeaderValueNotes
X-SESSIONID<session token>Added by AuthInterceptor (data/net/AuthInterceptor.kt) when the call does not set it; on HTTP 401 or 400 the interceptor invalidates the token, fetches a new one and retries the request once.

Parameters

ParamInRequiredExampleNotes
criteriaqueryYesisActive=true AND iE.id in (40001,40002)Client-built; up to 30 ids per call.

Request

No body. client-built criteria with IE ids (chunk 30)

Response

Example response body (synthetic data)
[
  {
    "id": 801,
    "isActive": true,
    "role": {
      "code": "ROLE.FARMER",
      "roleName": "Farmer",
      "description": "Farmer role",
      "roleType": "ROLE_TYPE.IE"
    },
    "iE": {
      "id": "40001",
      "isActive": true,
      "person": {
        "id": 50001,
        "personProfile": {
          "firstName": "Farmer",
          "id": 60001
        }
      },
      "caretakerTenant": {
        "loginName": "tenant_a",
        "id": 11
      }
    }
  }
]
FieldTypeRequiredNotes
[].id / isActivemixedierolemap.id / isActive.
[].role.code / roleName / description / roleTypestringEmbedded role_* columns.
[].iE.id / person.id / person.personProfile.id / firstName / caretakerTenantmixedEmbedded ie_* columns linking to the farmer.

Errors

StatusWhenWhat the app does
401 / 400Session token expiredAuthInterceptor invalidates the token, gets a fresh session id and retries the request once.
any non-2xxOther failuresThrows 'Failed to fetch IE roles: <code>' -> step error; user retries data download.

Source

  • data/src/main/java/org/mindtree/app/agricultor/data/setup/SetupService.kt
  • app/src/main/java/org/platformcommons/urvi/view/datasetup/DataSetupViewModel.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/setup/SetupForUser.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/entity/IERoleMap.kt