farming_model
Farming model on a land: ATM (Anytime Money) or 365 DKG. Holds crops, practices, size, photo and geofence; crops and harvests live in a JSON column.
Table factsheetagri_db
- Written by
- Data down-sync (
DataSetupViewModel) andOptionViewModel(Repo.insertFarmingModelList, also setsie_flat_entity.hasATM) - ATMRepositoryImp (
saveATM) - ATM create/edit (ATMViewModel:
createATM,updateFarmingModel= delete + insert) - Response handlers
FarmingModelPostRH,FarmingModelPatch,FarmingModelGeofencingPostRH,FarmingModelHarvestPostRH, ATMPicRH
- Data down-sync (
- Read by
- ATM and DKG screens
- Land delete guard (
getATMBYAsset)
- Filled from
GET /gateway/portfolio-service/api/v1/farming-model/ownerEntitiesGET /gateway/portfolio-service/api/v1/farming-model/attachment/bulk- 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 IE_ATM. hasSyncError/syncErrorId record the last failure.
- Source
- data/src/main/java/org/mindtree/app/agricultor/data/entity/FarmingModel.kt
Columns
| Column | Type | Null | Key | Meaning |
|---|---|---|---|---|
uuid | TEXT | Yes | Index | Stable business UUID, also sent to the server. Index: unique. |
appCreatedAt | INTEGER | Yes | Created on device. Stored as INTEGER here. | |
id | INTEGER | Yes | Server id. Null or 0 until the row is synced. | |
raisedBeds | INTEGER | Yes | 1 if raised beds used. | |
vegetableCrops | TEXT | Yes | JSON list of vegetable crops. | |
maizeCultivation | INTEGER | Yes | 1 if maize grown. | |
pulseCrops | TEXT | Yes | JSON list of pulse crops. | |
practices | TEXT | Yes | JSON list of practices. | |
relayCropping | INTEGER | Yes | 1 if relay cropping. | |
relayCroppingDetails | TEXT | Yes | Free text describing relay cropping, entered when relayCropping is yes. | |
incomeGeneration | INTEGER | Yes | 1 if income generation activity. | |
incomeGenerationDetails | TEXT | Yes | Free text describing the income generation activity, entered when incomeGeneration is yes. | |
titleId | TEXT | Yes | Stable business key shared by all versions of the record. | |
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. |
owningEntityType | TEXT | Yes | Owner type, normally the farmer (IE) entity type. | |
aliasId | TEXT | Yes | FK → ie.aliasId | Farmer alias, used for unsynced farmers. Link by convention only, no FK constraint. |
landSize | REAL | Yes | Land size used by the model. | |
isDKG | INTEGER | Yes | 1 for 365 DKG (renamed from dkg365). | |
modelType | TEXT | Yes | MODEL_TYPE.ATM | MODEL_TYPE.365_DKG. | |
assetId | INTEGER | Yes | FK → farmerassets.id | Land server id as INTEGER. Link by convention only, no FK constraint. |
asset | TEXT | Yes | FK → farmerassets.id | Land server id as TEXT. Link by convention only, no FK constraint. |
assetCheckSum | TEXT | Yes | Content hash of a land asset. Links this row to the land before the land has a server id. | |
hasSyncError | INTEGER | Yes | 1 when the last sync of this row failed. | |
syncErrorId | INTEGER | Yes | FK → sync_error_logs.id | Points to sync_error_logs.id for the last failure. Link by convention only, no FK constraint. |
lastModifiedAt | INTEGER | Yes | Last modified time from the server. | |
geoFencingFileId | INTEGER | Yes | Server attachment id of the geofence file. | |
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/. | |
geotaggingFileName | TEXT | Yes | Geotag photo/file pointer for the farming model. | |
geotaggingCreatedOn | TEXT | Yes | Geotag photo/file pointer for the farming model. | |
geotaggingFilePath | TEXT | Yes | Geotag photo/file pointer for the farming model. | |
farmingModelLineItemDTOs | TEXT | Yes | JSON list of crops including harvest details. | |
imageUrl | TEXT | Yes | Local file path of the farming model photo, or the server attachment URL after download. | |
imageAttachmentId | INTEGER | Yes | Server attachment id of the photo. | |
imageCreatedAt | TEXT | Yes | When the photo was taken (epoch millis as text), or the attachment's appCreatedAt from the server. | |
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). |
Notes
- Renamed from portfolio_service in migration 34 to 35.
- ATMs: owningEntityId or aliasId with modelType = MODEL_TYPE.ATM. DKG: (owningEntityId = id OR aliasId = id) AND modelType = MODEL_TYPE.365_DKG.
- getATMBYAsset blocks deleting a land that has an ATM.
- Possible bug · unverified harvest data lives in a JSON blob, so it cannot be queried.
- Missing indexes on owningEntityId, aliasId, titleId and asset.