public interface LateIdResolver
Component used to handle late-stage primary key resolution. While importing files, it is sometimes necessary to
back-reference primary keys of lines that have already been processed but have not yet been persisted. Consider the case
of assigning a defaultParentCategory to a Category
. The import CSV might look like:
externalId,name,defaultParentCategory,url
cat-home,Home,,/home
cat-merch,Merchandise,cat-home,/merchandise
cat-clearance,Clearance,cat-home,/clearance
The cat-merch and cat-clearance categories both back-reference the cat-home row. However, since this entire set will be processed and persisted as a batch, at the time of processing the cat-merch and cat-clearance rows the cat-home row will not have been persisted and thus there is no way to properly handle the lookup. This allows us to process those rows and then actually fill in the IDs later (specifically, once cat-home has actually been persisted).
If we were not processing multiple lines in a batch this problem would not exist since each row would be processed and persisted one-by-one.
ImportPersisterImpl}
Modifier and Type | Field and Description |
---|---|
static String |
LATE_RESOLUTION_VALUE
Used to indicate that the property value should be resolved later.
|
Modifier and Type | Method and Description |
---|---|
String |
buildLateResolutionKey(String ceilingClass,
String externalId)
This should be invoked by any of the
BroadleafCellProcessor s that want to resolve an ID late in the game. |
String |
getPrimaryKey(String key)
Attempts to retrieve the primary key from the cache.
|
void |
populatePrimaryKey(String key,
String primaryKey)
Populates the cache with a primary key
|
static final String LATE_RESOLUTION_VALUE
DefaultParentCategoryCellProcessor}, {@link CategoryRelationshipCellProcessor}
,
Constant Field Valuesvoid populatePrimaryKey(String key, String primaryKey)
key
- a valid key built from buildLateResolutionKey(String, String)
primaryKey
- the primary key to put in the mapString getPrimaryKey(String key)
key
- a valid key built from buildLateResolutionKey(String, String)
populatePrimaryKey(String, String)
or null if none existsString buildLateResolutionKey(String ceilingClass, String externalId)
BroadleafCellProcessor
s that want to resolve an ID late in the game.
This will automatically build something that takes the ceilingClass, externalId and
LATE_RESOLUTION_VALUE
to build a placeholder keyceilingClass
- the class that the primary key should come fromexternalId
- the external ID that should uniquely identify the given ceilingClassCopyright © 2020. All rights reserved.