portfolio_portfoliolineitem
Portfolio line item (PLI): the crop plan for one land in one season, with practices, photo, geofence and compact block link.
Table factsheetagri_db
- Written by
- Portfolio save (
Repo.savePortfolioList) - Add/Edit crop plan (view/portfolio/*:
savePortfolioLineItem,updatePortfolioLineItem) - Season rollover relabel
- Response handlers
PortfolioLineItemPutRH,PutWithCropChangeRH,DeleteRH,PicRH,GeofencingPostRH
- Portfolio save (
- Read by
- Portfolio screens
- Compact block crop pickers
- Harvest
- A-grade adapter
- IEPortfolioMapper (legacy
ie_portfolio)
- Filled from
GET /gateway/portfolio-service/api/v1/portfolios/ownerEntitiesGET /gateway/portfolio-service/api/v1/portfolios/line-items/portfoliosForLineItemIdsGET /gateway/portfolio-service/api/v1/portfolios/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_PORTFOLIO_LINE_ITEM (PUT, DELETE, picture, geofence). hasSyncError/syncErrorId record the last failure.
- Source
- data/src/main/java/org/mindtree/app/agricultor/data/entity/PortfolioLineItem.kt
Columns
| Column | Type | Null | Key | Meaning |
|---|---|---|---|---|
portfolioId | TEXT | Yes | FK → portfolio.appId | Portfolio id. Link by convention only, no FK constraint. |
id | INTEGER | Yes | Server id. Null or 0 until the row is synced. | |
asset | TEXT | Yes | FK → farmerassets.id | Land server id stored as TEXT. Link by convention only, no FK constraint. |
uuid | TEXT | Yes | Index | Stable business UUID, also sent to the server. Index: unique. |
practiceMasterCodes | TEXT | Yes | JSON list of practice codes. | |
portfolioLineItemType | TEXT | Yes | PORTFOLIO_LINE_ITEM.PLANNED | PORTFOLIO_LINE_ITEM.SEASON_ACTUAL. | |
imageUrl | TEXT | Yes | Crop photo URL/path. | |
isActive | INTEGER | Yes | Soft-delete flag (1 = active). | |
currentSeason | TEXT | Yes | Season label currently applied. | |
appCreatedAt | TEXT | Yes | Created on device. Stored as TEXT millis. | |
appLastModifiedAt | TEXT | Yes | Last modified on device (epoch millis). | |
createdAt | TEXT | Yes | Created time from the server. | |
lastModifiedAt | TEXT | Yes | Last modified time from the server. | |
titleId | TEXT | Yes | Stable business key shared by all versions of the record. | |
assetId | INTEGER | Yes | FK → farmerassets.id | Land server id as INTEGER (parallel copy). 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. |
compactBlockId | INTEGER | Yes | FK → compact_block.id | Compact block id. Link by convention only, no FK constraint. |
isLinkedToCompactBlock | INTEGER | Yes | 1 when enrolled in a compact block. | |
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/. | |
geoFenceAttachments | TEXT | Yes | JSON list of server attachment ids for geofence files (LongListConverter). | |
isEditable | INTEGER | Yes | 1 when the user may edit. | |
imageAttachmentId | INTEGER | Yes | Server attachment id of the photo. | |
imageCreatedAt | TEXT | Yes | When the crop photo was taken (epoch millis as text), or the attachment's appCreatedAt from the server. | |
changeLog | TEXT | Yes | JSON list of crop changes (PortfolioProductLineItemChange). | |
cropSeason | TEXT | Yes | Season of the crop (Kharif, Rabi...). | |
isAttachmentFetched | INTEGER | Yes | 1 when images are downloaded. | |
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). | |
methodmaster_id | INTEGER | Yes | Server id of the embedded object. | |
methodmaster_uuid | TEXT | Yes | Embedded method: uuid. | |
methodmaster_methodCode | TEXT | Yes | Reference data code. | |
methodmaster_appId | TEXT | Yes | Embedded copy of the nested object's local appId. | |
methodmaster_opId | TEXT | Yes | Embedded copy of the nested object's opId. | |
methodmaster_syncStatus | TEXT | Yes | Embedded copy of the nested object's sync status. | |
practicemaster_practiceCode | TEXT | Yes | Reference data code. | |
practicemaster_id | INTEGER | Yes | Server id of the embedded object. | |
practicemaster_uuid | TEXT | Yes | Embedded practice: uuid. | |
practicemaster_appId | TEXT | Yes | Embedded copy of the nested object's local appId. | |
practicemaster_opId | TEXT | Yes | Embedded copy of the nested object's opId. | |
practicemaster_syncStatus | TEXT | Yes | Embedded copy of the nested object's sync status. |
Notes
- Season rollover: getPortfolioLineItemsWithOlderSeasonValue finds PLIs that started after the new season start but still carry an old season label, then relabels them.
- getUnFetchedAttachmentPLIIdListByFarmerIds selects synced PLIs whose images are not downloaded.
- inActiveLineItem is a soft delete; deletePortfolioLineItem is a hard delete.
- Possible bug · unverified PortfolioLineItemDao.updatePortfolio sets currentSeason on every PLI in the table.
- Possible bug · unverified getLatestPortfolioItemByTitleId orders by appCreatedAt, a TEXT column, so the order is lexicographic.
- Possible bug · unverified multi-relation reads (getPLIWithAllDataByTitleId) lack @Transaction.
- Missing indexes on portfolioId, titleId, asset and id.