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
- Data down-sync (
- Read by
- Land list and lease (
LandAssetViewModel) - PLI land picker (
IePortfolioViewModel) - Geofencing
- ATM
FarmerAssetsMapper(copies into legacyie_asset)
- Land list and lease (
- Filled from
POST api/setupdata/v2 (AssetDTO)GET /gateway/asset-service/api/v1/assets/ownerEntitiesGET /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
| Column | Type | Null | Key | Meaning |
|---|---|---|---|---|
owningEntityId | TEXT | Yes | FK → ie_flat_entity.iEOLTPId | Farmer server id (= ie_flat_entity.iEOLTPId), stored as text. Link by convention only, no FK constraint. |
assetCode | TEXT | Yes | Human code, usually the survey number. | |
dateOfPurchase | TEXT | Yes | No description in code. | |
id | INTEGER | Yes | Server id. Null or 0 until the row is synced. | |
assetCheckSum | TEXT | Yes | Content hash of a land asset. Links this row to the land before the land has a server id. | |
authenticated | INTEGER | Yes | 1 = land verified. Only authenticated owned land can be leased out. | |
notes | TEXT | Yes | Free-text description typed on the add/edit asset form. | |
leasedFromOwningEntityId | TEXT | Yes | Farmer who leased the land out. | |
leasedToOwningEntityId | TEXT | Yes | Farmer who leased the land in. | |
isLeased | INTEGER | Yes | 1 if this land is leased. | |
leaseStatus | TEXT | Yes | Lease state. | |
leaseType | TEXT | Yes | Lease type (leased in / out). | |
leasedFromAssetId | TEXT | Yes | FK → farmerassets.id | Server id of the owned land this lease comes from. Link by convention only, no FK constraint. |
leasedFromWorknodeCode | TEXT | Yes | Code of the SHG (or VO when no SHG was chosen) used to pick the lessor farmer for leased-in land. | |
leasedFromWorknodeType | TEXT | Yes | Type of node used to pick the lessor farmer for leased-in land: "SHG" when an SHG was chosen, else "VO". | |
isActive | INTEGER | No | Soft-delete flag (default 1). | |
inactiveReason | TEXT | Yes | Reason given when the row was deactivated. | |
inactiveAt | INTEGER | Yes | When the row was deactivated (epoch millis). | |
createdAt | TEXT | Yes | Created time from the server. | |
lastModifiedAt | TEXT | Yes | Last modified time from the server. | |
appCreatedAt | TEXT | Yes | Created on device (epoch millis). Type differs between tables (TEXT vs INTEGER). | |
appLastModifiedAt | TEXT | Yes | Last modified on device (epoch millis). | |
createdByApp | INTEGER | Yes | Audit: app that created/last changed the row. | |
lastModifiedByApp | INTEGER | Yes | Audit: app that created/last changed the row. | |
createdFromDevice | TEXT | Yes | Audit: device id that created/last changed the row. | |
lastUpdatedFromDevice | TEXT | Yes | Audit: device id that created/last changed the row. | |
geoFencingFileName | TEXT | Yes | File name of the geofence polygon (KML/GeoJSON). | |
geoFencingCreatedOn | TEXT | Yes | When the geofence was captured. | |
geoFencingFilePath | TEXT | Yes | Local path of the polygon file under filesDir/geofencing/. | |
geoFencingId | INTEGER | Yes | Server attachment id of the geofence file. | |
appId | TEXT | No | PK | Client-side UUID. Defaults to a random UUID when the object is built, including when server JSON is parsed. |
opId | TEXT | Yes | Id of the last queued operation in the library queue (SYNC_QUEUE_DB). | |
syncStatus | TEXT | No | SYNC_NOT_INITIALIZED | IN_SYNC_QUEUE | SYNC_DONE (default). | |
assetsubcategory_code | TEXT | Yes | e.g. ASSET_SUBCATEGORY.LAND_OWNED. | |
assetsubcategory_refclass_code | TEXT | Yes | Reference class of the code (flattened embedded DTO). | |
ownerentitytype_code | TEXT | Yes | Reference data code. | |
ownerentitytype_refclass_code | TEXT | Yes | Reference class of the code (flattened embedded DTO). | |
totalquantity_id | INTEGER | Yes | Server id of the embedded object. | |
totalquantity_value | REAL | Yes | Area of the land. | |
totalquantity_uom_symbol | TEXT | Yes | Unit of measure detail (flattened embedded DTO). | |
totalquantity_uom_code | TEXT | Yes | Unit of measure detail (flattened embedded DTO). | |
totalquantity_uom_name | TEXT | Yes | Unit of measure detail (flattened embedded DTO). | |
totalquantity_uom_description | TEXT | Yes | Unit of measure detail (flattened embedded DTO). | |
totalquantity_uom_measurementtype_code | TEXT | Yes | Unit of measure detail (flattened embedded DTO). | |
totalquantity_uom_measurementtype_name | TEXT | Yes | Unit of measure detail (flattened embedded DTO). | |
totalquantity_uom_measurementtype_description | TEXT | Yes | Unit of measure detail (flattened embedded DTO). | |
totalquantity_uom_measurementtype_globalrefclass_code | TEXT | Yes | Unit of measure detail (flattened embedded DTO). | |
totalquantity_uom_measurementtype_globalrefclass_name | TEXT | Yes | Unit of measure detail (flattened embedded DTO). | |
totalquantity_uom_measurementtype_globalrefclass_description | TEXT | Yes | Unit of measure detail (flattened embedded DTO). | |
assetcategory_code | TEXT | Yes | ASSET_CATEGORY.LAND, livestock, ... | |
assetcategory_refclass_code | TEXT | Yes | Reference class of the code (flattened embedded DTO). | |
assetfunctionality_code | TEXT | Yes | Reference data code. | |
assetfunctionality_refclass_code | TEXT | Yes | Reference class of the code (flattened embedded DTO). | |
quality_code | TEXT | Yes | Reference data code. | |
quality_refclass_code | TEXT | Yes | Reference class of the code (flattened embedded DTO). | |
appmill_metadata_ie_appId | TEXT | Yes | FK → ie.appId | Local 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.