Database / Land & assets

farmerassets

A farmer's asset, mainly land parcels (owned or leased), with area, classification, lease details and geofence pointer.

Table factsheetagri_db
Written by
  • Data down-sync (DataSetupViewModel, UnitDataSetupViewModel, SetupForUser, SetupForUnitInChargeLogin)
  • Farmer option screen pull-to-refresh (OptionViewModel)
  • FarmerDataUpdateWorker / LandDataUpdateWorker
  • Land add/edit/lease dialogs (view/landasset/*, AddUpdateAssetNewDialog)
  • Response handlers FarmerAssetsPost/PatchRH, AssetDeleteRH
Read by
  • Land list and lease (LandAssetViewModel)
  • PLI land picker (IePortfolioViewModel)
  • Geofencing
  • ATM
  • FarmerAssetsMapper (copies into legacy ie_asset)
Filled from
POST api/setupdata/v2 (AssetDTO)
GET /gateway/asset-service/api/v1/assets/ownerEntities
GET /gateway/asset-service/api/v1/assets/{assetid}
GET /gateway/asset-service/api/v1/asset/attachment/bulk (geofence attachments)
Sync
appId is a client UUID primary key. syncStatus starts at SYNC_DONE for downloaded rows, becomes SYNC_NOT_INITIALIZED when the row is created or edited on the device, and goes back to SYNC_DONE when the response handler writes the server id. opId holds the id of the last queued library operation. Sync entity FARMER_ASSETS (POST, PATCH, DELETE).
Source
data/src/main/java/org/mindtree/app/agricultor/data/entity/FarmerAssets.kt

Columns

ColumnTypeNullKeyMeaning
owningEntityIdTEXTYesFK → ie_flat_entity.iEOLTPIdFarmer server id (= ie_flat_entity.iEOLTPId), stored as text. Link by convention only, no FK constraint.
assetCodeTEXTYesHuman code, usually the survey number.
dateOfPurchaseTEXTYesNo description in code.
idINTEGERYesServer id. Null or 0 until the row is synced.
assetCheckSumTEXTYesContent hash of a land asset. Links this row to the land before the land has a server id.
authenticatedINTEGERYes1 = land verified. Only authenticated owned land can be leased out.
notesTEXTYesFree-text description typed on the add/edit asset form.
leasedFromOwningEntityIdTEXTYesFarmer who leased the land out.
leasedToOwningEntityIdTEXTYesFarmer who leased the land in.
isLeasedINTEGERYes1 if this land is leased.
leaseStatusTEXTYesLease state.
leaseTypeTEXTYesLease type (leased in / out).
leasedFromAssetIdTEXTYesFK → farmerassets.idServer id of the owned land this lease comes from. Link by convention only, no FK constraint.
leasedFromWorknodeCodeTEXTYesCode of the SHG (or VO when no SHG was chosen) used to pick the lessor farmer for leased-in land.
leasedFromWorknodeTypeTEXTYesType of node used to pick the lessor farmer for leased-in land: "SHG" when an SHG was chosen, else "VO".
isActiveINTEGERNoSoft-delete flag (default 1).
inactiveReasonTEXTYesReason given when the row was deactivated.
inactiveAtINTEGERYesWhen the row was deactivated (epoch millis).
createdAtTEXTYesCreated time from the server.
lastModifiedAtTEXTYesLast modified time from the server.
appCreatedAtTEXTYesCreated on device (epoch millis). Type differs between tables (TEXT vs INTEGER).
appLastModifiedAtTEXTYesLast modified on device (epoch millis).
createdByAppINTEGERYesAudit: app that created/last changed the row.
lastModifiedByAppINTEGERYesAudit: app that created/last changed the row.
createdFromDeviceTEXTYesAudit: device id that created/last changed the row.
lastUpdatedFromDeviceTEXTYesAudit: device id that created/last changed the row.
geoFencingFileNameTEXTYesFile name of the geofence polygon (KML/GeoJSON).
geoFencingCreatedOnTEXTYesWhen the geofence was captured.
geoFencingFilePathTEXTYesLocal path of the polygon file under filesDir/geofencing/.
geoFencingIdINTEGERYesServer attachment id of the geofence file.
appIdTEXTNoPKClient-side UUID. Defaults to a random UUID when the object is built, including when server JSON is parsed.
opIdTEXTYesId of the last queued operation in the library queue (SYNC_QUEUE_DB).
syncStatusTEXTNoSYNC_NOT_INITIALIZED | IN_SYNC_QUEUE | SYNC_DONE (default).
assetsubcategory_codeTEXTYese.g. ASSET_SUBCATEGORY.LAND_OWNED.
assetsubcategory_refclass_codeTEXTYesReference class of the code (flattened embedded DTO).
ownerentitytype_codeTEXTYesReference data code.
ownerentitytype_refclass_codeTEXTYesReference class of the code (flattened embedded DTO).
totalquantity_idINTEGERYesServer id of the embedded object.
totalquantity_valueREALYesArea of the land.
totalquantity_uom_symbolTEXTYesUnit of measure detail (flattened embedded DTO).
totalquantity_uom_codeTEXTYesUnit of measure detail (flattened embedded DTO).
totalquantity_uom_nameTEXTYesUnit of measure detail (flattened embedded DTO).
totalquantity_uom_descriptionTEXTYesUnit of measure detail (flattened embedded DTO).
totalquantity_uom_measurementtype_codeTEXTYesUnit of measure detail (flattened embedded DTO).
totalquantity_uom_measurementtype_nameTEXTYesUnit of measure detail (flattened embedded DTO).
totalquantity_uom_measurementtype_descriptionTEXTYesUnit of measure detail (flattened embedded DTO).
totalquantity_uom_measurementtype_globalrefclass_codeTEXTYesUnit of measure detail (flattened embedded DTO).
totalquantity_uom_measurementtype_globalrefclass_nameTEXTYesUnit of measure detail (flattened embedded DTO).
totalquantity_uom_measurementtype_globalrefclass_descriptionTEXTYesUnit of measure detail (flattened embedded DTO).
assetcategory_codeTEXTYesASSET_CATEGORY.LAND, livestock, ...
assetcategory_refclass_codeTEXTYesReference class of the code (flattened embedded DTO).
assetfunctionality_codeTEXTYesReference data code.
assetfunctionality_refclass_codeTEXTYesReference class of the code (flattened embedded DTO).
quality_codeTEXTYesReference data code.
quality_refclass_codeTEXTYesReference class of the code (flattened embedded DTO).
appmill_metadata_ie_appIdTEXTYesFK → ie.appIdLocal appId of the owning farmer (ie.appId). Used to link rows before the farmer has a server id. Link by convention only, no FK constraint.

Notes

  • getOwnedLand: active, authenticated LAND_OWNED assets with a server id. Only these can be leased out.
  • fetchFarmerLandDataFromIEIDs returns all LAND assets including inactive ones.
  • saveFarmerAssetsList reuses an existing appId by server id to avoid duplicates.
  • disableLand is a soft delete; deleteLand is a hard delete by server id.
  • Possible bug · unverified getFarmerAssestsId / getFarmerAssestsFromAssetCode use assetCode LIKE '%code%', so survey number 12 matches 112.
  • Possible bug · unverified hard delete (deleteLand) can orphan PLIs and compact block members.
  • Missing indexes on owningEntityId, assetCode and id.